# HG changeset patch # User Siddharth Agarwal # Date 2015-10-08 04:22:16 # Node ID f18646cf0e936287237160f33289f065cf02eb7b # Parent 58880acd236989d0633ad978a9b96446e3e76fe5 filemerge: call premerge directly from main merge function The merge code currently does (in pseudocode): for f in tomerge: premerge f merge f We'd like to change this to look more like: for f in tomerge: premerge f for f in tomerge: merge f This makes sure as many files are resolved as possible before prompting for the others. This restructuring is also necessary for custom merge drivers. This function separates out the premerge step from the merge step. In future patches we'll actually turn these into separate steps in the merge driver. The 'if r:' occurrences will be cleaned up in subsequent patches. diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -247,7 +247,7 @@ def _merge(repo, mynode, orig, fcd, fco, files. It will fail if there are any conflicts and leave markers in the partially merged file. Markers will have two sections, one for each side of merge, unless mode equals 'union' which suppresses the markers.""" - r = _premerge(repo, toolconf, files, labels=labels) + r = 1 if r: a, b, c, back = files @@ -349,7 +349,7 @@ def _idump(repo, mynode, orig, fcd, fco, ``a.txt``, these files will accordingly be named ``a.txt.local``, ``a.txt.other`` and ``a.txt.base`` and they will be placed in the same directory as ``a.txt``.""" - r = _premerge(repo, toolconf, files, labels=labels) + r = 1 if r: a, b, c, back = files @@ -361,7 +361,7 @@ def _idump(repo, mynode, orig, fcd, fco, return False, r def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): - r = _premerge(repo, toolconf, files, labels=labels) + r = 1 if r: tool, toolpath, binary, symlink = toolconf a, b, c, back = files @@ -519,8 +519,15 @@ def filemerge(repo, mynode, orig, fcd, f if markerstyle != 'basic': labels = _formatlabels(repo, fcd, fco, fca, labels) - needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, files, - labels=labels) + r = 1 + if mergetype == fullmerge: + r = _premerge(repo, toolconf, files, labels=labels) + + if not r: # premerge successfully merged the file + needcheck = False + else: + needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, + files, labels=labels) if not needcheck: if r: