修改列表

理想情况下,你任何时候都只做一件事,你的工作副本只包含一个逻辑修改集合。很好,回到现实。你经常会同时做几件不相关的事,当你察看提交对话框时,所有修改混到一起。修改列表特性帮助你分组,让你容易看到正在做什么。当然它只能在修改不重合的时候工作。如果两个不同的任务影响到同一个文件,没有办法隔离修改。

重要

The changelist feature in TortoiseSVN is only available in Windows XP and later, as it depends on a shell capability which is not present in Windows 2000. Sorry, but Win2K is really quite old now, so please don't complain.

You can see changelists in several places, but the most important ones are the commit dialog and the check-for-modifications dialog. Let's start in the check-for-modifications dialog after you have worked on several features and many files. When you first open the dialog, all the changed files are listed together. Suppose you now want to organise things and group those files according to feature.

Select one or more files and use Context MenuMove to changelist to add an item to a changelist. Initially there will be no changelists, so the first time you do this you will create a new changelist. Give it name which describes what you are using it for, and click OK. The dialog will now change to show groups of items.

Once you have created a changelist you can drag and drop items into it, either from another changelist, or from Windows Explorer. Dragging from Explorer can be useful as it allows you to add items to a changelist before the file is modified. You could do that from the check-for-modifications dialog, but only by displaying all unmodified files.

图 5.14. 带有修改列表的提交对话框

带有修改列表的提交对话框


In the commit dialog you can see those same files, grouped by changelist. Apart from giving an immediate visual indication of groupings, you can also use the group headings to select which files to commit.

On XP, there is a context menu when you right click on a group heading which gives you the choice to check or uncheck all group entries. On Vista however the context menu is not necessary. Click on the group header to select all entries, then check one of the selected entries to check all.

TortoiseSVN reserves one changelist name for its own use, namely ignore-on-commit. This is used to mark versioned files which you almost never want to commit even though they have local changes. This feature is described in “Excluding Items from the Commit List”一节.

When you commit files belonging to a changelist then normally you would expect that the changelist membership is no longer needed. So by default, files are removed from changelists automatically on commit. If you wish to retain the file in its changelist, use the Keep changelists checkbox at the bottom of the commit dialog.

提示

Changelists are purely a local client feature. Creating and removing changelists will not affect the repository, nor anyone else's working copy. They are simply a convenient way for you to organise your files.