What is a Perforce "shelved" file?



What is a Perforce "shelved" file?

收藏者: zzfy10010
转自: http://blog.csdn.net/Xsmile2012/article/details/6701538

Shelving is the process of temporarily storing work in progress on a Perforce Server without submitting a changelist. Shelving is useful when you need to perform multiple development tasks (such as interruptions from higher-priority work, testing across multiple platforms) on the same set of files, or share files for code review before committing your work to the depot.


The p4 shelve command creates, modifies, or discards shelved files in a pending changelist. Shelved files persist in the depot until they are discarded (by means of p4 shelve -d) or replaced by subsequent p4 shelve commands.


After shelving files, you can revert or modify them in your client workspace, and restore the shelved versions of those files to your workspace with the p4 unshelve command. While files are shelved, other users can unshelve the shelved files into their own workspaces, or into other client workspaces.
Files that have been shelved can also be accessed with the p4 diff, p4 diff2, p4 files, and p4 print commands, using the revision specifier @=change, where change is the pending changelist number.


If no arguments are specified, p4 shelve creates a new changelist, adds files from the user's default changelist, and (after the user completes a form similar to that used by p4 submit), shelves the specified files into the depot. If a file pattern is given, p4 shelve shelves only the files that match the pattern.

上面是对perforce shelve功能的介绍。下面自己对p4 shelve 应用做点简单的总结。

1、 创建shelved文件

         当我们从perforce里checkout文件后,一般做的操作时submit,这里告诉里其实还有一个操作你可以充分的应用它,那就是shelve操作。它可以将你修改好的文件存到库里,但是又不属于真正被提交的文件,它处于搁置状态。

         #p4 edit filename

         #p4 shelve filename

         如果你想覆盖一个存在的搁置文件,你可以使用参数-f, -c,即

         #p4 shelve -f -c changelist filename

         将文件搁置的同时会产生对应的pending changelist,建议记住这个changelist。

2、 Review shelved 文件

         如果你知道shelve文件的changelist,你可以使用下面的命令将shelve的文件restore工作区里。

         #p4 unshelve -s changelist

         如果不知道changelsit,你可以列出当前所有的pending changelist,然后确定哪个是你需要的。

         #p4 changes -s pending

         讲到这里,大家应该已经发现shelve好处了吧。一个程序员修改完代码,可以先不提交到库里,可以使用p4 shelve命令将文件搁置,它会在库中某个位置存起来。其他的程序员可以使用p4 diff命令比较文件做了哪些修改,或使用p4 unshelve 命令将文件restore到自己的工作去查看,这样code review的工作就简单的完成了。当代码通过review,就进入下一步提交了。

3、 Submit shelved 文件

         提交shelved文件,需要首先删除文件的shelve状态,然后才能提交。

         #p4 shelve -d -c changelist

         #p4 submit -c changelist

         shelve的操作名命令基本都是基于changelist,所以记住changelist确实很重要。

 

关于shelve命令和unshelve命令的详细介绍,可参考perforce命令手册。

          p4 shelve:    http://www.perforce.com/perforce/doc.current/manuals/cmdref/shelve.html

          p4 unshelve: http://www.perforce.com/perforce/doc.current/manuals/cmdref/unshelve.html

 

如内容有错误,欢迎指正。

http://www.programgo.com/article/98682027691/

你可能感兴趣的:(What is a Perforce "shelved" file?)