如何确认Mercurial调用合并工具时对应的变更集?
如何在hg histedit合并时明确当前合并的变更集(除了hg log --graph)
当在多个变更集中编辑同一文件,使用hg histedit回溯修改初始变更集并执行hg histedit --continue触发合并时,若合并工具(如终端emacs)启动后清屏,无法直接查看合并的变更集信息,除了hg log --graph外,还可通过以下方法确认:
可用命令与方法
1. hg parent命令
在合并状态下,执行hg parent会显示当前工作目录的两个父变更集(对应合并的local和remote分支),结合变更集的描述信息,可直接确认正在合并的对象。
2. 带--debug参数执行histedit --continue
默认情况下hg histedit --continue不会输出合并的变更集详情,但添加--debug参数后,会打印出合并的关键信息,包括:
- 合并的祖先变更集(
ancestor) - 当前本地修改后的变更集(
local) - 需要合并的远程变更集(
remote) - 合并工具调用时关联的临时文件对应版本
示例输出:
$ hg --debug histedit --continue committing files: a committing manifest committing changelog updating the branch cache histedit: processing pick pick 7b3e7a45e14b 2 third resolving manifests branchmerge: True, force: True, partial: False ancestor: 30b27c631a68, local: ef552a34ed43+, remote: 7b3e7a45e14b preserving a for resolve of a a: versions differ -> m (premerge) couldn't find merge tool filemerge picked tool 'cemacs' for a (binary False symlink False changedelete False) merging a my a@ef552a34ed43+ other a@7b3e7a45e14b ancestor a@30b27c631a68 a: versions differ -> m (merge) couldn't find merge tool filemerge picked tool 'cemacs' for a (binary False symlink False changedelete False) my a@ef552a34ed43+ other a@7b3e7a45e14b ancestor a@30b27c631a68 launching merge tool: /home/sjm/tools/sh/hgemacs -q --no-desktop --no-splash --eval '(ediff-merge-with-ancestor "'/tmp/sjm/a~local.vgv2aasb'" "'/tmp/sjm/a~other.0skj2o6r'" "'/tmp/sjm/a~base.30iiaq_3'" nil "/home/sjm/tmp/hg/a" )' press return to continue
可提前将该输出保存到文件(如hg --debug histedit --continue > merge_log.txt 2>&1),避免被emacs清屏覆盖。
3. 在合并工具内查看版本关联信息
以终端emacs为例,启动的ediff合并窗口中,可通过M-x shell打开终端执行命令,除了hg log -G(其中%标记对应未解决冲突的变更集),也可直接查看临时文件的版本关联——合并工具的调用参数中已包含$local、$other、$base对应的文件,这些文件分别对应合并的两个分支版本及共同祖先版本,结合hg log -r <变更集ID>可查看具体版本内容。
我的合并工具配置(.hgrc)
# Merge tool selected by file name. [merge-patterns] **.[ch] = emacs Make** = emacs [merge-tools] # Disable preconfigured tools gvimdiff.disabled = yes vimdiff.disabled = yes emacs.priority=3 emacs.checkconflicts=True emacs.checkchanged=True emacs.executable=/usr/bin/emacs emacs.args= -q --no-desktop --no-splash --eval '(ediff-merge-with-ancestor "$local" "$other" "$base" nil "$output" )'
场景复现步骤
$ cd hg $ hg init $ echo "smple file" > a $ hg add a $ hg commit -m 'first' a $ printf "First line reserved $(cat a) last line " > a $ hg commit -m 'second' a $ printf "First line reserved. $(tail -2 a). " > a $ hg commit -m 'third' a $ gsed --in-place "s/smple/sample/" a $ hg commit -m 'fourth' a $ hg histedit
在hg histedit界面中标记初始变更集为edit,修改文件后执行hg histedit --continue即可触发合并场景。
内容的提问来源于stack exchange,提问作者alls0rts
相关产品推荐
相关产品推荐

