# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 1531064913 -19800 # Node ID dc2b53b3573f4be70df99eb2dfea7398a52b5cc3 # Parent 96bbea985b25002b40c9b44b8bf3f59f904515cc evolvecmd: move remaining logic to merge commit desc to existing utility fn This was a bit awful because we had a utility function and still we did some of merging outside of that fn. So let's move the remaining parts there. diff -r 96bbea985b25 -r dc2b53b3573f hgext3rd/evolve/evolvecmd.py --- a/hgext3rd/evolve/evolvecmd.py Sun Jul 08 22:52:33 2018 +0530 +++ b/hgext3rd/evolve/evolvecmd.py Sun Jul 08 21:18:33 2018 +0530 @@ -542,21 +542,9 @@ # merge the branches mergebranches(repo, divergent, other, base) # merge the commit messages - desc, conflicts = mergecommitmessages(base.description(), - divergent.description(), - other.description()) - if conflicts: - - 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 + desc = mergecommitmessages(ui, base.description(), + divergent.description(), + other.description()) # new node if any formed as the replacement newnode = None @@ -692,7 +680,7 @@ elif index == 2: repo.dirstate.setbranch(othbranch) -def mergecommitmessages(basedesc, divdesc, othdesc): +def mergecommitmessages(ui, basedesc, divdesc, othdesc): """merges the commit messages and return the new merged message and whether there were conflicts or not while merging the messages""" @@ -705,7 +693,21 @@ **kwargs): mdesc.append(line) - return ''.join(mdesc), merger.conflicts + desc = ''.join(mdesc) + if merger.conflicts: + + 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 + + return desc class MergeFailure(error.Abort): pass