【问题标题】:How can I get the list of mercurial patches that would apply cleanly in a linear order?我怎样才能获得可以按线性顺序干净应用的 mercurial 补丁列表?
【发布时间】:2012-12-05 04:25:10
【问题描述】:

我正在寻找一个命令,该命令将输出一个顺序补丁列表,如果存储库处于特定的已知早期状态,这些补丁将干净地应用。这是一个存储库的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

本质上,我想知道为了输出变更集 0、1、2、3、6、7 和 8 将什么 revset 传递给 hg export。我不想要变更集 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

【问题讨论】:

  • 您需要单独应用补丁吗?或者你能导出一个补丁来显示第一个和最后一个变更集之间的累积差异吗?
  • 我希望将它们单独列出。我已经知道如何获得任何两个回购状态之间的差异。
  • 我已经玩过了,除了明确排除 branch2 之外,找不到其他可行的方法。我能看到的问题是,如果你能找到解决方案(总是选择default 分支),如果你有两个未命名的分支,它就行不通,这很有可能(可能比命名的分支更多,具体取决于在您的工作流程中?)。在这些情况下,您可能希望选择 default 分支,但也可以选择。

标签: version-control mercurial revision-history


【解决方案1】:

更一般的尝试:

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

预检查:对于带有mergeset 的存储库,您必须定义要使用的mergeset 的父行,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)) &amp; descendants(p1(7))" 返回变更集 6)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-01
    • 1970-01-01
    • 2021-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多