comparison mercurial/filemerge.py @ 26567:f18646cf0e93

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.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 07 Oct 2015 21:22:16 -0700
parents 7833b13b001f
children c7850af6bb75
comparison
equal deleted inserted replaced
26566:58880acd2369 26567:f18646cf0e93
245 """ 245 """
246 Uses the internal non-interactive simple merge algorithm for merging 246 Uses the internal non-interactive simple merge algorithm for merging
247 files. It will fail if there are any conflicts and leave markers in 247 files. It will fail if there are any conflicts and leave markers in
248 the partially merged file. Markers will have two sections, one for each side 248 the partially merged file. Markers will have two sections, one for each side
249 of merge, unless mode equals 'union' which suppresses the markers.""" 249 of merge, unless mode equals 'union' which suppresses the markers."""
250 r = _premerge(repo, toolconf, files, labels=labels) 250 r = 1
251 if r: 251 if r:
252 a, b, c, back = files 252 a, b, c, back = files
253 253
254 ui = repo.ui 254 ui = repo.ui
255 255
347 contents of local, other and base. These files can then be used to 347 contents of local, other and base. These files can then be used to
348 perform a merge manually. If the file to be merged is named 348 perform a merge manually. If the file to be merged is named
349 ``a.txt``, these files will accordingly be named ``a.txt.local``, 349 ``a.txt``, these files will accordingly be named ``a.txt.local``,
350 ``a.txt.other`` and ``a.txt.base`` and they will be placed in the 350 ``a.txt.other`` and ``a.txt.base`` and they will be placed in the
351 same directory as ``a.txt``.""" 351 same directory as ``a.txt``."""
352 r = _premerge(repo, toolconf, files, labels=labels) 352 r = 1
353 if r: 353 if r:
354 a, b, c, back = files 354 a, b, c, back = files
355 355
356 fd = fcd.path() 356 fd = fcd.path()
357 357
359 repo.wwrite(fd + ".other", fco.data(), fco.flags()) 359 repo.wwrite(fd + ".other", fco.data(), fco.flags())
360 repo.wwrite(fd + ".base", fca.data(), fca.flags()) 360 repo.wwrite(fd + ".base", fca.data(), fca.flags())
361 return False, r 361 return False, r
362 362
363 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): 363 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
364 r = _premerge(repo, toolconf, files, labels=labels) 364 r = 1
365 if r: 365 if r:
366 tool, toolpath, binary, symlink = toolconf 366 tool, toolpath, binary, symlink = toolconf
367 a, b, c, back = files 367 a, b, c, back = files
368 out = "" 368 out = ""
369 env = {'HG_FILE': fcd.path(), 369 env = {'HG_FILE': fcd.path(),
517 if not labels: 517 if not labels:
518 labels = _defaultconflictlabels 518 labels = _defaultconflictlabels
519 if markerstyle != 'basic': 519 if markerstyle != 'basic':
520 labels = _formatlabels(repo, fcd, fco, fca, labels) 520 labels = _formatlabels(repo, fcd, fco, fca, labels)
521 521
522 needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, files, 522 r = 1
523 labels=labels) 523 if mergetype == fullmerge:
524 r = _premerge(repo, toolconf, files, labels=labels)
525
526 if not r: # premerge successfully merged the file
527 needcheck = False
528 else:
529 needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf,
530 files, labels=labels)
524 531
525 if not needcheck: 532 if not needcheck:
526 if r: 533 if r:
527 if onfailure: 534 if onfailure:
528 ui.warn(onfailure % fd) 535 ui.warn(onfailure % fd)