comparison mercurial/filemerge.py @ 26224:a4da463df6cf

filemerge: add non-interactive :merge-local and :merge-other There are two non-interactive internal merge tools, :other and :local, but they don't really merge, they just pick all changes from the local or other version of the file. In some situations, it is known that we want a merge and also know that all merge conflicts should be resolved in one direction. Although external merge tools can do this, sometimes it can be convenient to do so from within hg, without invoking a merge tool. These new :merge-local and :merge-other tools can do just that.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Thu, 10 Sep 2015 09:41:11 -0400
parents ff12a6c63c3d
children 4c52dd406adc
comparison
equal deleted inserted replaced
26223:ed12abab068e 26224:a4da463df6cf
284 labels = _defaultconflictlabels 284 labels = _defaultconflictlabels
285 if len(labels) < 3: 285 if len(labels) < 3:
286 labels.append('base') 286 labels.append('base')
287 return _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels) 287 return _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels)
288 288
289 def _imergeauto(repo, mynode, orig, fcd, fco, fca, toolconf, files,
290 labels=None, localorother=None):
291 """
292 Generic driver for _imergelocal and _imergeother
293 """
294 assert localorother is not None
295 tool, toolpath, binary, symlink = toolconf
296 if symlink:
297 repo.ui.warn(_('warning: :merge-%s cannot merge symlinks '
298 'for %s\n') % (localorother, fcd.path()))
299 return False, 1
300 a, b, c, back = files
301 r = simplemerge.simplemerge(repo.ui, a, b, c, label=labels,
302 localorother=localorother)
303 return True, r
304
305 @internaltool('merge-local', True)
306 def _imergelocal(*args, **kwargs):
307 """
308 Like :merge, but resolve all conflicts non-interactively in favor
309 of the local changes."""
310 success, status = _imergeauto(localorother='local', *args, **kwargs)
311 return success, status
312
313 @internaltool('merge-other', True)
314 def _imergeother(*args, **kwargs):
315 """
316 Like :merge, but resolve all conflicts non-interactively in favor
317 of the other changes."""
318 success, status = _imergeauto(localorother='other', *args, **kwargs)
319 return success, status
320
289 @internaltool('tagmerge', True, 321 @internaltool('tagmerge', True,
290 _("automatic tag merging of %s failed! " 322 _("automatic tag merging of %s failed! "
291 "(use 'hg resolve --tool :merge' or another merge " 323 "(use 'hg resolve --tool :merge' or another merge "
292 "tool of your choice)\n")) 324 "tool of your choice)\n"))
293 def _itagmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): 325 def _itagmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):