perforce-扩展p4交换输出,以包括集成到源代码的更改

perforce-扩展p4交换输出,以包括集成到源代码的更改,perforce,Perforce,我们有一条从主干->a->B流出的代码线,我们有人直接在主干中工作,或者在主干中工作,我们通过分支B将其合并以公开发布 现在我有一个需求,需要提供分支a中的变更列表,而分支B中还没有,以便我们可以传递给QA团队。为此,我运行以下命令: p4 interchanges -b integrate_branch_a_to_branch_b p4 changes -i -s submitted //myproject/branches/a/...@12345,12345 然而,我们已经在一个大的变更

我们有一条从主干->a->B流出的代码线,我们有人直接在主干中工作,或者在主干中工作,我们通过分支B将其合并以公开发布

现在我有一个需求,需要提供分支a中的变更列表,而分支B中还没有,以便我们可以传递给QA团队。为此,我运行以下命令:

p4 interchanges -b integrate_branch_a_to_branch_b
p4 changes -i -s submitted //myproject/branches/a/...@12345,12345
然而,我们已经在一个大的变更列表中集成了从主干到主干的变更(但实际上是由多个提交的变更列表组成)。我需要在我的变更通知中包含这些内容。根据Perforce文档(),如果我传递了-I标志,那么p4 changes命令应该这样做

所以我有一个编号为12345的变更列表,它被提交到分支a(作为主干的集成)。我想扩展它,列出提交到trunk的每个变更列表,就像p4 interchanges向我展示的那样,如果我运行它来预览CL#12345中发生的事情

我试过这个命令:

p4 interchanges -b integrate_branch_a_to_branch_b
p4 changes -i -s submitted //myproject/branches/a/...@12345,12345
我认为这应该奏效,给了我这样的东西:

Change 12345 on 2015/10/30 by user@host 'trunk -> a'
Change 12344 on 2015/10/29 by user@host 'fixed bug two'
Change 12343 on 2015/10/29 by user@host 'fixed bug one'
但它给了我成千上万的更改,其中大多数都超出了我所要求的更改列表范围,甚至可以追溯到本项目任何分支的第一次修订——从我们将//otherproject/中的一些共享库代码集成到//myproject/。如果我删除“-I”标志,它会像我预期的那样工作——它只列出变更列表12345

这只是这个命令中的一个错误,还是我的语法错误?我似乎想不出一个办法来得到我需要的东西。当然,我可以从trunk->A中挖掘并找到最后一个集成,并手动筛选脚本中较旧的变更列表——但如果不必这样做的话,这会更容易


P4服务器版本字符串为:P4D/LINUX26X86_64/2014.2/962050(2014/11/13)

因此,如果我理解正确,您希望从A->B集成所有更改,但对于从主干->A进行的任何集成,您希望看到单个更改而不是单个集成更改吗

虽然不能在单个表达式中执行此操作,但可以运行两个interchanges命令:

 p4 interchanges -b integrate_branch_a_to_branch_b  
 p4 interchanges -b integrate_trunk_to_branch_b
第二个命令将列出主干中尚未集成到分支B中的所有单个更改


这里会有一些重复项,因为第一个命令(A->B)也会显示仅集成的更改,但这应该很容易过滤掉。

这就是我的结论:

- p4 interchanges -b integrate_branch_a_to_branch_b
- for each change:
    - p4 describe -s change, and figure out if there were any "branch" 
    or "integrate" actions
    - if no, then it's a direct edit and we are interested in it
    - if yes, then it's an integration from our source branch (trunk) and 
    we need to find the original changelists
    - for each change where yes:
        - p4 integrate -n //myproject/branches/a/...@change,change //myproject/branches/b/....
        - if output (stderr) contains 'already integrated' then ignore
        because it has already been integrated
        - else run p4 changes -s submitted -i -l /myproject/branches/a/...
        (this will give us a list of all changelists that made up the
        single integrate changelist 12345 that I described above)
        - for each change there:
            - run p4 integrate -n //myproject/branches/trunk/...@change,change /myproject/branches/b/...
            - if output (stderr) contains 'already integrated' then ignore 
            because it has already been integrated
            - else run p4 describe -s change and check if standard output
            contains //myproject/branches/trunk - if not then it was an integrate
            *to* trunk from somewhere else and we don't care about it 
            (this is intended to fix the - issue where p4 changes goes
            beyond the first revision that I am interested in)
首先运行p4交换以获取要使用的未整合更改的列表。然后,对于那里的每一个变更,我们都会进行处理,要么发现#1)它确实是不整合的,要么#2)它对于我们的需求来说还不太旧

我还知道一个变更列表,我们最后一次运行一个完整的QA测试,所以当我们开始阅读比我感兴趣的变更更老的变更时,我们可以在底部循环的早期中断(处理p4变更-I问题)


似乎有效。但是非常麻烦。

您要查找的命令存在:

p4 interchanges -b integrate_trunk_to_branch_b @12345
文档有点复杂,我知道:

interchanges -- Report changes not yet integrated

p4 interchanges [options] fromFile[revRange] toFile
p4 interchanges [options] -b branch [toFile[revRange] ...]
p4 interchanges [options] -b branch -s fromFile[revRange] [toFile ...]
p4 interchanges [options] -S stream [-P parent] [file[revRange] ...]
toFile位指的是目标,而revRange指的是源,因此您只需在命令中指定上边界即可


您的脚本是否使用Python或Ruby之类的脚本语言?

是的,您对我想要的内容的总结是正确的。我遇到的问题是主干已经提交了更多的更改(这些更改尚未集成到,我对此不感兴趣)。因此,如果我在那里进行第二次p4交换,它将列出提交到trunk的更改,但我不打算将其集成到B。对吗?我真的需要能够运行这样的东西:
code
p4交换-b integrate\u trunk\u to\u branch\u b@12344。该命令以您想要的方式存在,请参阅我上面的最后一个答案。是的,我使用的是Python(虽然还不是P4Python)。我试过你的建议,但我不太明白它是怎么起作用的。由于字符限制,需要单独发布更多详细信息。更改740004刚刚进入主干,并且已合并到更改列表740005中的分支A,因为这是一个紧急修复。如果我运行p4交换集成分支a到分支b,它将给我变更列表740005,因为我还没有将其集成到分支b。当然,我希望这样。但在第二步中,我会运行p4交换-b integrate_trunk_to_branch_b@740005,但它会给我变更列表740004,但我没有任何合理的方法来过滤它,因为没有任何东西告诉我它是重复的。我遗漏了什么吗?也许我还没有得到你的要求。如果您对仅集成更改(740005)感到满意,并且只想在主干中添加尚未添加到A中的更改,那么将“interchanges trunk->A”添加到“interchanges A->B”。我以为您也想看到主干中的单个更改。是的,问题是我想要两者(因为有时在主干中有直接编辑,但有时是主干的集成,可以包含多个更改)。也许我解释得不太清楚。我可以将主干->C@12345分支,然后将p4交换与A->B和C->B结合起来。因为在A中进行的任何直接编辑都会被推回到主干中,这将消除该方向上的重复项,只在主干中保留更改,而不会在A中保留更改,进入C,比较A和B,然后C和B,应该可以得到两个来源的总变化。