How can I confirm which changeset mercurial has invoked merge tool for?

19 Views Asked by At

I had edited a file in several changesets, lets say four for this example, and went back to make a change using hg histedit. Marked the initial changeset and then made the change that I wanted. When I then continued with hg histedit --continue I was presented with the merge tool, in my case emacs in the tty. What I lost sight of was which changeset am I merging with?

How might I know which changeset I am currently merging? Is there a command that makes that obvious other than hg log --graph?

I have merge tool configured to use emacs in .hgrc like so,

# 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" )'

I thought that it was possible that hg histedit printed something to the tty as it invoked the merge, but I didn't see it as emacs then cleared the screen and presented itself. By placing a shell script shim I can see that is not the case; unless I include --debug option:

$ 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

From emacs, in the C (combined) buffer, entering a shell (M-x shell) and running hg log -G the % symbol is displayed against the changeset as per hg help log:

With --graph the revisions are shown as an ASCII art DAG with the most
recent changeset at the top. 'o' is a changeset, '@' is a working
directory parent, '%' is a changeset involved in an unresolved merge
conflict, '_' closes a branch, 'x' is obsolete, '*' is unstable, and '+'
represents a fork where the changeset from the lines below is a parent of
the 'o' merge on the same line. Paths in the DAG are represented with '|',
'/' and so forth. ':' in place of a '|' indicates one or more revisions in
a path are omitted.

And the tip comment confirms the changeset being merged if only by the description (summary); confirmed with hg parent.

Example output

$ hg log -G 
@  changeset:   4:9558db15c42a
   tag:         tip
   parent:      -1:000000000000
   date:        Wed Aug 30 17:49:09 2023 +0100
   summary:     first

o  changeset:   3:0d19179257ec
|  date:        Wed Aug 30 17:55:16 2023 +0100
|  summary:     fourth
|
o  changeset:   2:7b3e7a45e14b
|  date:        Wed Aug 30 17:53:20 2023 +0100
|  summary:     third
|
%  changeset:   1:30b27c631a68
|  date:        Wed Aug 30 17:51:39 2023 +0100
|  summary:     second
|
o  changeset:   0:64a4f5d3c84c
   date:        Wed Aug 30 17:49:09 2023 +0100
   summary:     first

If someone want's to play along, here is how I created the example

$ cd hg
$ hg init
$ echo "smple file" > a
$ hg add a
$ hg commit -m 'first' a
$ printf "First line reserved\n$(cat a)\n last line\n" > a
$ hg commit -m 'second' a
$ printf "First line reserved.\n$(tail -2 a).\n" > a
$ hg commit -m 'third' a
$ gsed --in-place "s/smple/sample/" a     
$ hg commit -m 'fourth' a
$ hg histedit

Set edit on the first changeset. Insert the word "my " on the "smple file" line. Save and utter hg histedit --continue.

0

There are 0 best solutions below