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