##// END OF EJS Templates
filemerge: extract `_picklabels` as a helper function...
Phil Cohen -
r33829:aa6c290a default
parent child Browse files
Show More
@@ -408,6 +408,20 b' def _verifytext(text, path, ui, opts):'
408 raise error.Abort(msg)
408 raise error.Abort(msg)
409 return text
409 return text
410
410
411 def _picklabels(defaults, overrides):
412 name_a, name_b, name_base = defaults
413
414 if len(overrides) > 0:
415 name_a = overrides[0]
416 if len(overrides) > 1:
417 name_b = overrides[1]
418 if len(overrides) > 2:
419 name_base = overrides[2]
420 if len(overrides) > 3:
421 raise error.Abort(_("can only specify three labels."))
422
423 return [name_a, name_b, name_base]
424
411 def simplemerge(ui, localfile, basefile, otherfile,
425 def simplemerge(ui, localfile, basefile, otherfile,
412 localctx=None, basectx=None, otherctx=None, repo=None, **opts):
426 localctx=None, basectx=None, otherctx=None, repo=None, **opts):
413 """Performs the simplemerge algorithm.
427 """Performs the simplemerge algorithm.
@@ -446,23 +460,11 b' def simplemerge(ui, localfile, basefile,'
446 self.ctx.write(self.text, self.ctx.flags())
460 self.ctx.write(self.text, self.ctx.flags())
447
461
448 mode = opts.get('mode','merge')
462 mode = opts.get('mode','merge')
449 if mode == 'union':
463 name_a, name_b, name_base = None, None, None
450 name_a = None
464 if mode != 'union':
451 name_b = None
465 name_a, name_b, name_base = _picklabels([localfile,
452 name_base = None
466 otherfile, None],
453 else:
467 opts.get('label', []))
454 name_a = localfile
455 name_b = otherfile
456 name_base = None
457 labels = opts.get('label', [])
458 if len(labels) > 0:
459 name_a = labels[0]
460 if len(labels) > 1:
461 name_b = labels[1]
462 if len(labels) > 2:
463 name_base = labels[2]
464 if len(labels) > 3:
465 raise error.Abort(_("can only specify three labels."))
466
468
467 try:
469 try:
468 localtext = readctx(localctx) if localctx else readfile(localfile)
470 localtext = readctx(localctx) if localctx else readfile(localfile)
General Comments 0
You need to be logged in to leave comments. Login now