##// END OF EJS Templates
filemerge: switch trymerge boolean to mergetype enum...
Siddharth Agarwal -
r26526:7fa35604 default
parent child Browse files
Show More
@@ -43,7 +43,7 nomerge = None
43 mergeonly = 'mergeonly' # just the full merge, no premerge
43 mergeonly = 'mergeonly' # just the full merge, no premerge
44 fullmerge = 'fullmerge' # both premerge and merge
44 fullmerge = 'fullmerge' # both premerge and merge
45
45
46 def internaltool(name, trymerge, onfailure=None, precheck=None):
46 def internaltool(name, mergetype, onfailure=None, precheck=None):
47 '''return a decorator for populating internal merge tool table'''
47 '''return a decorator for populating internal merge tool table'''
48 def decorator(func):
48 def decorator(func):
49 fullname = ':' + name
49 fullname = ':' + name
@@ -51,7 +51,7 def internaltool(name, trymerge, onfailu
51 internals[fullname] = func
51 internals[fullname] = func
52 internals['internal:' + name] = func
52 internals['internal:' + name] = func
53 internalsdoc[fullname] = func
53 internalsdoc[fullname] = func
54 func.trymerge = trymerge
54 func.mergetype = mergetype
55 func.onfailure = onfailure
55 func.onfailure = onfailure
56 func.precheck = precheck
56 func.precheck = precheck
57 return func
57 return func
@@ -165,7 +165,7 def _matcheol(file, origfile):
165 if newdata != data:
165 if newdata != data:
166 util.writefile(file, newdata)
166 util.writefile(file, newdata)
167
167
168 @internaltool('prompt', False)
168 @internaltool('prompt', nomerge)
169 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf):
169 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf):
170 """Asks the user which of the local or the other version to keep as
170 """Asks the user which of the local or the other version to keep as
171 the merged version."""
171 the merged version."""
@@ -179,18 +179,18 def _iprompt(repo, mynode, orig, fcd, fc
179 else:
179 else:
180 return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf)
180 return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf)
181
181
182 @internaltool('local', False)
182 @internaltool('local', nomerge)
183 def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf):
183 def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf):
184 """Uses the local version of files as the merged version."""
184 """Uses the local version of files as the merged version."""
185 return 0
185 return 0
186
186
187 @internaltool('other', False)
187 @internaltool('other', nomerge)
188 def _iother(repo, mynode, orig, fcd, fco, fca, toolconf):
188 def _iother(repo, mynode, orig, fcd, fco, fca, toolconf):
189 """Uses the other version of files as the merged version."""
189 """Uses the other version of files as the merged version."""
190 repo.wwrite(fcd.path(), fco.data(), fco.flags())
190 repo.wwrite(fcd.path(), fco.data(), fco.flags())
191 return 0
191 return 0
192
192
193 @internaltool('fail', False)
193 @internaltool('fail', nomerge)
194 def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf):
194 def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf):
195 """
195 """
196 Rather than attempting to merge files that were modified on both
196 Rather than attempting to merge files that were modified on both
@@ -257,7 +257,7 def _merge(repo, mynode, orig, fcd, fco,
257 return True, r
257 return True, r
258 return False, 0
258 return False, 0
259
259
260 @internaltool('union', True,
260 @internaltool('union', fullmerge,
261 _("merging %s incomplete! "
261 _("merging %s incomplete! "
262 "(edit conflicts, then use 'hg resolve --mark')\n"),
262 "(edit conflicts, then use 'hg resolve --mark')\n"),
263 precheck=_symlinkcheck)
263 precheck=_symlinkcheck)
@@ -269,7 +269,7 def _iunion(repo, mynode, orig, fcd, fco
269 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
269 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
270 files, labels, 'union')
270 files, labels, 'union')
271
271
272 @internaltool('merge', True,
272 @internaltool('merge', fullmerge,
273 _("merging %s incomplete! "
273 _("merging %s incomplete! "
274 "(edit conflicts, then use 'hg resolve --mark')\n"),
274 "(edit conflicts, then use 'hg resolve --mark')\n"),
275 precheck=_symlinkcheck)
275 precheck=_symlinkcheck)
@@ -282,7 +282,7 def _imerge(repo, mynode, orig, fcd, fco
282 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
282 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
283 files, labels, 'merge')
283 files, labels, 'merge')
284
284
285 @internaltool('merge3', True,
285 @internaltool('merge3', fullmerge,
286 _("merging %s incomplete! "
286 _("merging %s incomplete! "
287 "(edit conflicts, then use 'hg resolve --mark')\n"),
287 "(edit conflicts, then use 'hg resolve --mark')\n"),
288 precheck=_symlinkcheck)
288 precheck=_symlinkcheck)
@@ -314,7 +314,7 def _imergeauto(repo, mynode, orig, fcd,
314 localorother=localorother)
314 localorother=localorother)
315 return True, r
315 return True, r
316
316
317 @internaltool('merge-local', True)
317 @internaltool('merge-local', mergeonly)
318 def _imergelocal(*args, **kwargs):
318 def _imergelocal(*args, **kwargs):
319 """
319 """
320 Like :merge, but resolve all conflicts non-interactively in favor
320 Like :merge, but resolve all conflicts non-interactively in favor
@@ -322,7 +322,7 def _imergelocal(*args, **kwargs):
322 success, status = _imergeauto(localorother='local', *args, **kwargs)
322 success, status = _imergeauto(localorother='local', *args, **kwargs)
323 return success, status
323 return success, status
324
324
325 @internaltool('merge-other', True)
325 @internaltool('merge-other', mergeonly)
326 def _imergeother(*args, **kwargs):
326 def _imergeother(*args, **kwargs):
327 """
327 """
328 Like :merge, but resolve all conflicts non-interactively in favor
328 Like :merge, but resolve all conflicts non-interactively in favor
@@ -330,7 +330,7 def _imergeother(*args, **kwargs):
330 success, status = _imergeauto(localorother='other', *args, **kwargs)
330 success, status = _imergeauto(localorother='other', *args, **kwargs)
331 return success, status
331 return success, status
332
332
333 @internaltool('tagmerge', True,
333 @internaltool('tagmerge', mergeonly,
334 _("automatic tag merging of %s failed! "
334 _("automatic tag merging of %s failed! "
335 "(use 'hg resolve --tool :merge' or another merge "
335 "(use 'hg resolve --tool :merge' or another merge "
336 "tool of your choice)\n"))
336 "tool of your choice)\n"))
@@ -340,7 +340,7 def _itagmerge(repo, mynode, orig, fcd,
340 """
340 """
341 return tagmerge.merge(repo, fcd, fco, fca)
341 return tagmerge.merge(repo, fcd, fco, fca)
342
342
343 @internaltool('dump', True)
343 @internaltool('dump', fullmerge)
344 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
344 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
345 """
345 """
346 Creates three versions of the files to merge, containing the
346 Creates three versions of the files to merge, containing the
@@ -479,18 +479,18 def filemerge(repo, mynode, orig, fcd, f
479
479
480 if tool in internals:
480 if tool in internals:
481 func = internals[tool]
481 func = internals[tool]
482 trymerge = func.trymerge
482 mergetype = func.mergetype
483 onfailure = func.onfailure
483 onfailure = func.onfailure
484 precheck = func.precheck
484 precheck = func.precheck
485 else:
485 else:
486 func = _xmerge
486 func = _xmerge
487 trymerge = True
487 mergetype = fullmerge
488 onfailure = _("merging %s failed!\n")
488 onfailure = _("merging %s failed!\n")
489 precheck = None
489 precheck = None
490
490
491 toolconf = tool, toolpath, binary, symlink
491 toolconf = tool, toolpath, binary, symlink
492
492
493 if not trymerge:
493 if mergetype == nomerge:
494 return func(repo, mynode, orig, fcd, fco, fca, toolconf)
494 return func(repo, mynode, orig, fcd, fco, fca, toolconf)
495
495
496 a = repo.wjoin(fd)
496 a = repo.wjoin(fd)
General Comments 0
You need to be logged in to leave comments. Login now