Mercurial:这个变更集何时在稳定分支中生效?

时间:2016-08-02 12:56:05

标签: mercurial branching-and-merging

场景:一位同事告诉我,我制作的错误修复程序不在当前版本中。我说:“但我在两周前推了它!”

如何检查我的更改(提交到bug-fix-branch)是否已合并到stable-branch并且还被推送到服务器存储库?

所以这真的有三个部分:

1)它被承认了吗?什么时候?请参阅修订号:

hg blame FILENAME

使用日期查看日志,依此类推:

hg log REVISION

2)它合并了吗?

hg glog -r "(merge() and branch(2.5) and children(branch('BRANCHNAME')))" \
--template "{branches} [{rev}] ({date|shortdate}): {desc|firstline}\n"

这可能会更短吗?

3)被推了吗?

1 个答案:

答案 0 :(得分:1)

它可以更短更清洁(在某些条件下

任务1

如果您可以在任何文件中调用任何字符串补丁的任何部分 - hg help grep。 F.e(模式是regexp,因此 - 括号被转义以便“按原样”处理):

>hg grep "repo\[None\].parents()" test_hooks.py
tests/test_hooks.py:1417:        state = repo[None].parents()

输出中的第二个字段(易于自动处理可分析)是变更集,其中此变更是在此文件中

任务2

只需修复相当脏(和常见逻辑中的错误)revset:

使用merge() and branch(DST) and children(branch('SRC')),您将获得用于合并SRC的所有合并集 - > DST,甚至无关已知的错误修正版。上述存储库和revset的输出(请注意,稍微更改的命令 - hg glog已弃用)

>hg log -g -r "(merge() and branch(default) and children(branch('stable')))" --template "{branches} [{rev}] ({date|shortdate}): {desc|firstline}\n"
 [839] (2011-10-19): Merge with stable.
 [841] (2011-10-21): Merge with stable.
 [843] (2011-11-01): Merge with stable
 [982] (2012-11-11): Merge with stable.
 [1021] (2013-06-23): Merge with stable.
 [1108] (2014-02-11): Merge with stable.
 [1126] (2014-02-12): Merge with stable.
 [1171] (2014-04-04): Merge with stable.
 [1180] (2014-05-02): Merge with stable.
 [1228] (2014-08-01): Merge with stable.
 [1231] (2014-08-12): Merge with stable.
 [1257] (2014-11-05): Merge stable back into default.
 [1266] (2014-11-15): Merge with stable.
 [1280] (2014-12-10): Merge with stable.
 [1307] (2015-01-30): Merge with stable.
 [1326] (2015-05-08): Merge stable back into default.
 [1335] (2015-05-29): Merge with stable.
 [1338] (2015-07-08): Merge with stable.
 [1341] (2015-07-09): Merge with stable.
 [1346] (2015-08-11): Merge with stable.
 [1349] (2015-09-26): Merge with stable.
 [1358] (2015-09-30): Merge with stable.
 [1362] (2015-10-21): Merge with stable.
 [1367] (2015-12-31): Merge with stable.
 [1372] (2016-01-27): Merge with stable.
 [1378] (2016-03-04): Merge with stable.
 [1410] (2016-05-11): Merge with stable.
 [1418] (2016-05-23): Merge with stable.
 [1489] (2016-06-26): Merge with stable.

我从普通descendants(1417)开始(贪婪的革命,是的)

>hg log -r "descendants(1417)" -T "{rev}\n"
1417
1418
1419
1420
1421
...

因为我只对合并到default感兴趣(在我的情况下)可能更短的输出将是hg log -r "descendants(1417) and branch(default)"(但它也可能相当长 - 我确实消除了两个revsets)并且仅首先需要从列表中删除

>hg log -r "first(descendants(1417) and branch(default))" -T "{rev}\n"
1418

或者以一点点不同的方式(回想一下mergesets实体,也可以先() - ed)

>hg log -r "merge() and descendants(1417) and branch(default)" -T "{rev}\n"
1418
1489

注意:

  • 第3页的解决方案 - 在CENTRAL-REPO克隆上执行所有测试(已经是,是的)
  • “错误逻辑”评论 - branch(2.5) and children(branch('BRANCHNAME')按设计仅提取2.5中的合并集,merge()不应用任何其他有效过滤器

附录:

在一些(仍然未完成)头痛之后,我将上述命令作为别名使用两个参数:有问题的变更集和目标分支。这就像

[alias]
ismerged = log -r "first(descendants($1) and branch('$2'))" --template "{ifeq(branch, '$2', 'Merged in {rev}','Not merged')}\n"

在repo的.hgrc

合并变更集的输出

>hg ismerged 62 default
Merged in 63

但我无法获得其他部分工作,因为没有合并的变更集,并且在这种情况下仍然具有哑空输出

未来(更多装饰性而非功能性)改进可能包括:

  • 将revset定义从别名转移到`[revsetalias]
  • 获得好的其他 - 模板的一部分