搁置中

经常会发生的一种情况是,你需要停下你正在做的事情然后做其他的。举例:一个严重的问题需要马上解决,你不得不停下新特性的工作。可能的话,你需要添加你目前所做的更改,然后开始处理紧急事项,但是通常这些更改会打断构建或者还没可以提交。

So if you can't commit your local changes yet, you have to put them aside while you're working on the urgent issue. The shelving feature helps you do exactly that: you can store your local changes on a shelve, get your working copy in a clean state again and work on the issue. After you're finished with the urgent issue and you've committed those changes, you can unshelve your shelved work and continue working on your previous task again.

两个新命令实现了这个功能。一个是搁置 ,另一个是取消搁置。

To shelve your local changes, select your working copy and use Context MenuShelve The following dialog allows you to select the files you want to shelve and give a name under which you want to store them.

图 4.16. 搁置对话框

搁置对话框


If you select an existing shelf, then a new version is created for that shelf. If you provide a new name, a new shelf is created for the selected files.

如果你单击折叠按钮,shelf被创建,并且你的工作副本文件被重置到一个干净的状态。如果你单击检查点按钮,shelf被创建,但是你的本地修改将被保留。

使用右键菜单Unshelve打开unshelve对话框来unshelve更改。这个对话框列出了所有shelved的项目。选择你想要的shelved 项目和回退到你工作副本的版本,然后单击应用

图 4.17. 取消贮藏对话框

取消贮藏对话框


提示

Shelves是本地客户端的一个特性。创建或者删除Shelves既不会影响版本库也不会影响其他工作副本

实验性

搁置特性仍被标记为实验性

That means that while shelving works as advertised, it is still in a stage where it's heavily improved and worked on. That also means that there's no guarantee that the shelves you create are upwards compatible and future versions might not be able to use them. And of course the UI might change as well in future versions to accommodate new features and behaviors.