1

我正在寻找一个命令,该命令将输出一个顺序补丁列表,如果存储库处于特定的已知早期状态,这些补丁将干净地应用。这是一个hg glog包含我遇到的一些问题的存储库(如果您想使用自己的克隆,也可以从https://bitbucket.org/dusty/funny_repo/获得):

@  changeset:   8:ffd749c92f3b
|  tag:         tip
|  summary:     h
|
o    changeset:   7:bc959885f6aa
|\   parent:      6:dfe021fa52a4
| |  parent:      5:4d8bc738f0ab
| |  summary:     MERGE
| |
| o  changeset:   6:dfe021fa52a4
| |  parent:      3:1374ea53e7b7
| |  summary:     e
| |
o |  changeset:   5:4d8bc738f0ab
| |  branch:      branch2
| |  summary:     g
| |
o |  changeset:   4:e46fa4632d36
|/   branch:      branch2
|    summary:     f
|
o  changeset:   3:1374ea53e7b7
|  summary:     d
|
o  changeset:   2:59712a781f0c
|  branch:      branch1
|  summary:     c
|
o  changeset:   1:ff7f8724ad17
|  branch:      branch1
|  summary:     b
|
o  changeset:   0:a3b3a87aa422
   summary:     a

本质上,我想知道要传递什么 revset 以hg export输出变更集 0、1、2、3、6、7 和 8。我不想要变更集 4 和 5,因为应用了这些变更集的“效果”在变更集 6 的合并提交中。

ancestors(default)输出所有变更集,但branch('default')忽略变更集 1 和 2,虽然它们在不同的分支上,但补丁需要干净地应用。

显然,对于这种情况,我可以使用hg log -r "0..default and not branch(branch2)",但我正在寻找一个更通用的命令 revset,它适用于所有情况。

为了测试,我使用命令hg export -r "0..default and not branch(branch2)" -o ../%R.patch和以下 for 循环来应用生成的补丁:

cd ../
mkdir patched
cd patched
for n in ../*.patch ; do
    patch -p1 <$n
done
4

1 回答 1

0

更一般的尝试:

  • 仍然需要一项初步的人工检查和配置操作;
  • 仅适用于相对较新的 Mercurial,其中 p(1|2) 函数添加到 revsets

预检查:对于带有合并集的存储库,您必须定义要使用合并集的哪个父行,p1(MERGESET) 和 p2(MERGESET) 将显示“谁是谁”;并记住合并集的修订。为您测试用例

hg log -r "p1(7)"
changeset:   6:dfe021fa52a4
parent:      3:1374ea53e7b7
user:        Dusty Phillips <dusty@buchuki.com>
date:        Mon Dec 17 17:54:01 2012 -0700
summary:     e

hg log -r "p2(7)"
changeset:   5:4d8bc738f0ab
branch:      branch2
user:        Dusty Phillips <dusty@buchuki.com>
date:        Mon Dec 17 17:53:55 2012 -0700
summary:     g

请注意:p1 线必须生存。

  • 排除某些东西是“x - y”(或“x and !y”,但第一种形式是可读的)

  • x 在我们的例子中是完整的历史

( 0:tip),

y - p1(7) 的所有间接亲属

! (ancestors(p1(7)) | descendants(p1(7)))

  • 最终修订成为"0:tip - ! (ancestors(p1(7)) | descendants(p1(7)))"

在您的存储库上试运行 revset

hg log -r "0:tip - ! (ancestors(p1(7)) | descendants(p1(7)))"
changeset:   0:a3b3a87aa422
user:        Dusty Phillips <dusty@buchuki.com>
date:        Mon Dec 17 17:51:43 2012 -0700
summary:     a

changeset:   1:ff7f8724ad17
branch:      branch1
user:        Dusty Phillips <dusty@buchuki.com>
date:        Mon Dec 17 17:52:25 2012 -0700
summary:     b

changeset:   2:59712a781f0c
branch:      branch1
user:        Dusty Phillips <dusty@buchuki.com>
date:        Mon Dec 17 17:52:27 2012 -0700
summary:     c

changeset:   3:1374ea53e7b7
user:        Dusty Phillips <dusty@buchuki.com>
date:        Mon Dec 17 17:52:36 2012 -0700
summary:     d

changeset:   6:dfe021fa52a4
parent:      3:1374ea53e7b7
user:        Dusty Phillips <dusty@buchuki.com>
date:        Mon Dec 17 17:54:01 2012 -0700
summary:     e

changeset:   7:bc959885f6aa
parent:      6:dfe021fa52a4
parent:      5:4d8bc738f0ab
user:        Dusty Phillips <dusty@buchuki.com>
date:        Mon Dec 17 17:54:20 2012 -0700
summary:     MERGE

changeset:   8:ffd749c92f3b
tag:         tip
user:        Dusty Phillips <dusty@buchuki.com>
date:        Mon Dec 17 17:54:25 2012 -0700
summary:     h

最终编辑

我记得形式逻辑的教训:我在表达式中双重否定 "x - ! SET" (在 x 但不是在未设置中)只是 SET。Purified revset 简洁明了

"ancestors(p1(7)) | descendants(p1(7))"

(它最初也是尾随| p1(7),但现在// Mercurial Distributed SCM (version 2.4.2),由于我不知道的原因,变更集是他自己的祖先和后代:hg log -r "ancestors(p1(7)) & descendants(p1(7))"返回变更集 6)

于 2013-01-11T23:01:15.757 回答