当前在 perforce 中签出目录/文件的版本

发布于 2024-10-29 16:16:59 字数 299 浏览 2 评论 0原文

我正在尝试自动化保存在 perforce 中的项目的一些构建。我想提取当前的变更列表编号作为标记构建版本的一种方式。

此命令:

p4 changes -s submitted  ...  | head -1

非常接近于执行我需要的操作,除非我没有从 perforce 中签出最新版本。上面的命令(似乎)显示所有更改列表,而不仅仅是我签出的更改列表。

有没有办法获取最近同步到变更列表的变更列表编号?

注意:我有更多的 CVS / git 背景,所以我的术语可能不正确。

I'm trying to automate some builds for a project kept in perforce. I'd like to extract the current changelist number as a way of tagging the build version.

This command:

p4 changes -s submitted  ...  | head -1

goes very close to doing what I need, except in the case where I don't have the latest version checked out from perforce. The above command (appears to) display all the changelists, not just the ones in my check out.

Is there a way to get the changelist number of the most recently synced-to changelist?

Note: I come from more of a CVS / git background so my terminology may be off.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

云胡 2024-11-05 16:16:59

尝试运行“p4 cstat ...”。这会告诉您,对于影响“...”中文件集的每个变更列表,您是否拥有该变更列表、需要它​​还是部分同步。

Try running 'p4 cstat ...'. That'll tell you, for every changelist that affects the set of files in '...', whether you have that changelist, need it, or have it partially synced.

回忆追雨的时光 2024-11-05 16:16:59

我同意“p4 cstat”方法。

我使用它的方式如下: p4 cstat| p4-版本.awk
这是以下脚本:

 #! /usr/bin/awk -f

 # The input format is:
 # ... change 654056
 # ... status have|need|partial


 # So what we do:
 # find the first "need" or "partial"

 # and we might add +N as the number of other changes we have

 # Major is never 0. Hence End is set only once, to a non-zero.

 # Note: it's assumed that 0 is not a valid P4 changelist.
 # so  0+1-1 means: no entire changelist (i.e. the initial one)
 # has been (entirely) synced.

 # major is the last p4 CL processed
 # end   is the last CL, up to which _fully_ synced.
 # plus/minus  additional/missing CLs.

 BEGIN {end=0; contiguous=1; plus=0; minus=0}

 /^... change ([0-9])+/ {
         change=$3;
 };


 # we have 2 states: 1/ until now all have -- contiguous=1
 #                   2/ already something not "have"

 # (end=0) state 1

 /^... status have/ {
         if (!contiguous)
                  plus++;
         else
           end=change;
 };


 /^... status (partial|need)/ {
         minus++;
         if (contiguous) {
                 contiguous = 0;
         };
 }


 END {
         if (!contiguous)
                 printf "%d+%d-%d\n", end, plus, minus;
         else
                 printf "%d\n", end;
 }

I agree with the "p4 cstat" approach.

I use it like: p4 cstat| p4-version.awk
which is the following script:

 #! /usr/bin/awk -f

 # The input format is:
 # ... change 654056
 # ... status have|need|partial


 # So what we do:
 # find the first "need" or "partial"

 # and we might add +N as the number of other changes we have

 # Major is never 0. Hence End is set only once, to a non-zero.

 # Note: it's assumed that 0 is not a valid P4 changelist.
 # so  0+1-1 means: no entire changelist (i.e. the initial one)
 # has been (entirely) synced.

 # major is the last p4 CL processed
 # end   is the last CL, up to which _fully_ synced.
 # plus/minus  additional/missing CLs.

 BEGIN {end=0; contiguous=1; plus=0; minus=0}

 /^... change ([0-9])+/ {
         change=$3;
 };


 # we have 2 states: 1/ until now all have -- contiguous=1
 #                   2/ already something not "have"

 # (end=0) state 1

 /^... status have/ {
         if (!contiguous)
                  plus++;
         else
           end=change;
 };


 /^... status (partial|need)/ {
         minus++;
         if (contiguous) {
                 contiguous = 0;
         };
 }


 END {
         if (!contiguous)
                 printf "%d+%d-%d\n", end, plus, minus;
         else
                 printf "%d\n", end;
 }
一绘本一梦想 2024-11-05 16:16:59

虽然我不确定它是否适用于这个问题,但我想展示一种解决方案,可以让您获得最新的变更列表,直到您无缝同步的变更列表(即您可以在客户端上同步新的变更列表,而忽略一些旧的变更列表) ,例如,如果您自己提交了更改,而之前没有同步其他人提交的一些更改)。

使用以下命令列出未同步到客户端的所有更改:

p4 changes ..."#>have" 

如果提取该列表的最后一个更改列表并减去 1,您将获得已无缝同步所有内容的更改列表编号:

echo $((`p4 changes ..."#>have" | tail -1 | awk '{print $2}'`-1))

Though I am not sure if it is applicable for this question I want to show a solution that lets you get the latest changelist up to the one you have synced without gaps (i.e. you can have synced new changelists on your client leaving out some older ones, for example if you have submitted changes yourself without previously syncing a few changes that were submitted by other people).

With the following command you list all changes not synced to your client:

p4 changes ..."#>have" 

If you extract the last changelist of that list and subtract 1 you get the changelist number up to which you have synced everything without gaps:

echo $((`p4 changes ..."#>have" | tail -1 | awk '{print $2}'`-1))
半仙 2024-11-05 16:16:59

要查找客户端上的最新更改列表,请使用以下命令:

p4 changes -m 1 @name_of_your_client_here

客户端名称可以充当标签。

To find the latest changelist on your client, use this command:

p4 changes -m 1 @name_of_your_client_here

Client names can act like labels.

檐上三寸雪 2024-11-05 16:16:59

我认为以下内容将满足您的要求:

p4 fstat -T headChange ... | cut -d' ' -f3 | sort -nr | head -1

p4 fstat 非常好,因为它不仅需要一个过滤器(通过 -F 选项),还需要一个字段选择参数(使用 -T 选项)。

I think that the following will do what you want:

p4 fstat -T headChange ... | cut -d' ' -f3 | sort -nr | head -1

p4 fstat is really nice in that it takes not only a filter (via the -F option) but a field selection parameter (using the -T option).

茶花眉 2024-11-05 16:16:59

您想要的是文件的“haveRev”:

rev = `p4 fstat -T haveRev <filename>|cut -d' ' -f3`

然后您可以像这样查找更改号:

p4 filelog <filename>|grep $rev|cut -d' ' -f4

请注意,我使用了签出树的特定文件。

What you want is the 'haveRev' of your file:

rev = `p4 fstat -T haveRev <filename>|cut -d' ' -f3`

and then you can look up the changenumber like so:

p4 filelog <filename>|grep $rev|cut -d' ' -f4

Note that I used a specific file of the checked out tree.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文