evolve: pop up editor if conflicts occur while merging commit messages
Last patch added support for merging commit messages while resolving content
divergence. In case of conflicts we fallback to one of the divergent commit
messages.
After this patch, we will pop up an editor where user has to resolve the
conflicts in the commit messages and then continue.
Tests are added for this. We need to fix handling in test-sharing.t to use
HGEDITOR to fix conflicts and pass the new commit message.
Future improvement can be that we should respect HGMERGE while merging commit
descriptions too.
--- a/hgext3rd/evolve/evolvecmd.py Mon Jun 04 01:28:02 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py Wed Jun 06 03:26:47 2018 +0530
@@ -490,10 +490,17 @@
divergent.description(),
other.description())
if conflicts:
- # TODO: pop an editor when there are conflicts
- ui.status(_("conflicts while merging descriptions, using "
- "description of divergent changeset\n"))
- desc = divergent.description()
+
+ prefixes = ("HG: Conflicts while merging changeset description of"
+ " content-divergent changesets.\nHG: Resolve conflicts"
+ " in commit messages to continue.\n\n")
+
+ resolveddesc = ui.edit(prefixes + desc, ui.username(), action='desc')
+ # make sure we remove the prefixes part from final commit message
+ if prefixes in resolveddesc:
+ # hack, we should find something better
+ resolveddesc = resolveddesc[len(prefixes):]
+ desc = resolveddesc
# new node if any formed as the replacement
newnode = None
--- a/tests/test-evolve-content-divergence.t Mon Jun 04 01:28:02 2018 +0530
+++ b/tests/test-evolve-content-divergence.t Wed Jun 06 03:26:47 2018 +0530
@@ -241,12 +241,34 @@
$ hg resolve -m
(no more unresolved files)
continue: hg evolve --continue
- $ hg evolve --continue
- conflicts while merging descriptions, using description of divergent changeset
- working directory is now at 578f12701e5a
+
+ $ cat > editor.sh <<EOF
+ > #!/bin/sh
+ > printf "**showing editors text**\n\n"
+ > cat \$1
+ > printf "\n**done showing editors text**\n\n"
+ > cat > \$1 <<ENDOF
+ > watbar to d
+ > ENDOF
+ > EOF
+
+ $ HGEDITOR='sh ./editor.sh' hg evolve --continue
+ **showing editors text**
+
+ HG: Conflicts while merging changeset description of content-divergent changesets.
+ HG: Resolve conflicts in commit messages to continue.
+
+ <<<<<<< divergent
+ wat to d, wat?||||||| base
+ foo to d=======
+ bar to d, expect beers>>>>>>> other
+
+ **done showing editors text**
+
+ working directory is now at 00f8d08aea43
$ hg glog
- @ 16:578f12701e5a wat to d, wat?
+ @ 16:00f8d08aea43 watbar to d
| () [default] draft
o 3:ca1b80f7960a added c
| () [default] draft
--- a/tests/test-sharing.t Mon Jun 04 01:28:02 2018 +0530
+++ b/tests/test-sharing.t Wed Jun 06 03:26:47 2018 +0530
@@ -505,7 +505,14 @@
6:e3f99ce9d9cd draft fix bug 24 (v2 by alice)
Use evolve to fix the divergence.
- $ HGMERGE=internal:other hg evolve --content-divergent
+ $ cat > editor.sh <<EOF
+ > #!/bin/sh
+ > cat > \$1 <<ENDOF
+ > fix bug 24 (v2 by bob)
+ > ENDOF
+ > EOF
+
+ $ HGEDITOR='sh ./editor.sh' HGMERGE=internal:other hg evolve --content-divergent
merge:[5] fix bug 24 (v2 by bob)
with: [6] fix bug 24 (v2 by alice)
base: [4] fix bug 24 (v1)