我一直说我不喜欢回答自己的问题,但我要在这里这样做。我欢迎任何想要分享更好的解决方案和脚本的人。我特别欢迎有人向我表明这是不必要的,Perforce 实际上确实具有相当于svn/git/hg/bzr status
.
---+ A: git/hg/bzr/svn status
= p4 opened
+ p4 status
实际上,似乎至少需要两个单独的命令来近似其他 VCS 工具使用单个命令执行的操作,以提供有关软件仓库的工作区状态的快速摘要:
p4 opened
- 查看您在工作区中打开的文件列表
p4 status
- 未检入 Perforce 的文件列表。
**----+ 旧:p4 reconcile -n
代替p4 status
**
旧版本的 perforce 要么有p4 status
表现得像p4 reconcile
默认情况下对工作区进行更改,例如添加到工作区。或者说,当我写下这一页时,我已经崩溃了。
New: git/hg/bzr/svn status
= p4 opened
+ p4 status
**
New: git/hg/bzr/svn status
= p4 opened
+ p4 reconcile -n
**
p4 reconcile -n
- 获取未强制打开但已对其进行本地更改的文件列表。
(p4 reconcile -n
说“不做任何改变。”
-n 告诉 reconcile 不做任何改变。不再需要 - 现在p4 status
默认情况下是只读的。
老的:
p4 $P4OPTS 打开
p4 $P4OPTS 协调 -n | sed -e 's/ - / - 协调使:/'
---+ 适合别名或快速输入
我将它们组合如下:
p4 $P4OPTS opened
p4 $P4OPTS status | sed -e 's/ - / - RECONCILE TO MAKE: /'
sed 部分可以更好地区分 perforce 已打开的文件的状态与未在 perforce 下打开的文件的状态。但我注意到,当文件名称中可能包含字符串“-”时,这是不安全的。
----+ 幻想
因为我经常需要本地路径,所以我目前使用以下 shell 脚本my-p4-status
给我一些更像我习惯的其他VCS状态命令=的东西。
下面的脚本使用旧的reconcile -n
,并且尚未更新使用status
.
#!/bin/bash
# Perforce lacks a single command to tell you the status of a workspace,
# the equivalent of hg/bzr/git status.
# Warning: "p4 status" is not actually a read-only query!!!
# "p4 status" is more like "p4 reconcile" - it actually opens files to edit, add, or delete (-e -a -d)
# p4 opened only reports on the status of files currently opened by Perforce
# It is necessary to combine "p4 opened" and "p4 reconcile -n" to get a net overview.
# TBD: convert to local file path, rather than depot path.
# (Not a simple sed-xargs-p4_fstat pipeline)
P4OPTS=''
if [ "$1" == "-ztag" ] || [ "$1" == "-verbose" ]
then
shift
P4OPTS="-ztag"
fi
case $P4OPTS in
-ztag)
p4 $P4OPTS opened
p4 $P4OPTS reconcile -n
;;
*)
echo '#### p4 opened - Perforce files already opened ###'
p4 $P4OPTS opened
echo '#### p4 reconcile -n --- local edits, not opened in Perforce. Run p4 reconcile to actually open. ###'
p4 $P4OPTS reconcile -n | sed -e 's/ - / - RECONCILE TO MAKE: /'
esac
---+ 更好?请分享!
如果你有更好的,请分享。