evolvecmd: add comments and new lines in content-divergence handling logic
I have visited this logic three times in last 10 days and I have to re-read the
whole code to make sure I don't miss any part. Adding comments will help
understanding the code in better and fast way.
--- a/hgext3rd/evolve/evolvecmd.py Sun Apr 29 19:18:54 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py Sun Apr 22 20:14:42 2018 +0530
@@ -340,6 +340,8 @@
divergent = repo[divergent.rev()]
evolvestate['divergent'] = divergent.node()
base, others = divergentdata(divergent)
+
+ # we don't handle split in content-divergence yet
if len(others) > 1:
othersstr = "[%s]" % (','.join([str(i) for i in others]))
msg = _("skipping %d:%s with a changeset that got split"
@@ -357,6 +359,8 @@
return (False, '')
other = others[0]
evolvestate['other-divergent'] = other.node()
+
+ # we don't handle merge content-divergent changesets yet
if len(other.parents()) > 1:
msg = _("skipping %s: %s changeset can't be "
"a merge (yet)\n") % (divergent, TROUBLES['CONTENTDIVERGENT'])
@@ -366,6 +370,8 @@
"| `hg prune` to kill older version.\n")
ui.write_err(hint)
return (False, '')
+
+ # we don't handle content-divergent changesets with different parents yet
if other.p1() not in divergent.parents():
msg = _("skipping %s: have a different parent than %s "
"(not handled yet)\n") % (divergent, other)
@@ -405,6 +411,7 @@
repo.ui.status(_("updating to \"local\" side of the conflict: %s\n") %
divergent.hex()[:12])
hg.updaterepo(repo, divergent.node(), False)
+ # merging the two content-divergent changesets
repo.ui.status(_("merging \"other\" %s changeset '%s'\n") %
(TROUBLES['CONTENTDIVERGENT'], other.hex()[:12]))
if progresscb:
@@ -416,6 +423,8 @@
ancestor=base.node(),
mergeancestor=True)
hg._showstats(repo, stats)
+
+ # conflicts while merging content-divergent changesets
if compat.hasconflict(stats):
evolvestate.save()
raise error.Abort(_("fix conflicts and run 'hg evolve --continue' or"
@@ -427,6 +436,8 @@
def _completecontentdivergent(ui, repo, progresscb, divergent, other,
evolvestate):
"""completes the content-divergence resolution"""
+ # no conflicts were there in merging content divergent changesets, let's
+ # resume resolution
if progresscb:
progresscb()
emtpycommitallowed = repo.ui.backupconfig('ui', 'allowemptycommit')
@@ -440,12 +451,17 @@
# temporary hack because we can't use cmdrewrite.amend() during an
# interrupted evolve
evolvestate.delete()
+
+ # XXX: we should not use amend here, rather create a new commit
cmdrewrite.amend(ui, repo, message='', logfile='')
+ # XXX: we can get rid of this len() call also by creating a new commit
if oldlen == len(repo):
new = divergent
# no changes
else:
new = repo['.']
+
+ # creating markers and moving phases post-resolution
obsolete.createmarkers(repo, [(other, (new,))], operation='evolve')
phases.retractboundary(repo, tr, other.phase(), [new.node()])
return (True, new.node())