# HG changeset patch # User Siddharth Agarwal # Date 1444278136 25200 # 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 -r 58880acd2369 -r f18646cf0e93 mercurial/filemerge.py --- a/mercurial/filemerge.py Mon Oct 05 16:19:54 2015 -0700 +++ b/mercurial/filemerge.py Wed Oct 07 21:22:16 2015 -0700 @@ -247,7 +247,7 @@ 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 @@ ``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 @@ 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 @@ 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: