mercurial/simplemerge.py
changeset 22024 372ae2745acf
parent 22023 f18830651811
child 22056 83df50a8d61c
equal deleted inserted replaced
22023:f18830651811 22024:372ae2745acf
   377                 raise util.Abort(msg)
   377                 raise util.Abort(msg)
   378         return text
   378         return text
   379 
   379 
   380     name_a = local
   380     name_a = local
   381     name_b = other
   381     name_b = other
       
   382     name_base = None
   382     labels = opts.get('label', [])
   383     labels = opts.get('label', [])
   383     if len(labels) > 0:
   384     if len(labels) > 0:
   384         name_a = labels[0]
   385         name_a = labels[0]
   385     if len(labels) > 1:
   386     if len(labels) > 1:
   386         name_b = labels[1]
   387         name_b = labels[1]
   387     if len(labels) > 2:
   388     if len(labels) > 2:
   388         raise util.Abort(_("can only specify two labels."))
   389         name_base = labels[2]
       
   390     if len(labels) > 3:
       
   391         raise util.Abort(_("can only specify three labels."))
   389 
   392 
   390     try:
   393     try:
   391         localtext = readfile(local)
   394         localtext = readfile(local)
   392         basetext = readfile(base)
   395         basetext = readfile(base)
   393         othertext = readfile(other)
   396         othertext = readfile(other)
   400         out = opener(os.path.basename(local), "w", atomictemp=True)
   403         out = opener(os.path.basename(local), "w", atomictemp=True)
   401     else:
   404     else:
   402         out = sys.stdout
   405         out = sys.stdout
   403 
   406 
   404     m3 = Merge3Text(basetext, localtext, othertext)
   407     m3 = Merge3Text(basetext, localtext, othertext)
   405     for line in m3.merge_lines(name_a=name_a, name_b=name_b):
   408     extrakwargs = {}
       
   409     if name_base is not None:
       
   410         extrakwargs['base_marker'] = '|||||||'
       
   411         extrakwargs['name_base'] = name_base
       
   412     for line in m3.merge_lines(name_a=name_a, name_b=name_b, **extrakwargs):
   406         out.write(line)
   413         out.write(line)
   407 
   414 
   408     if not opts.get('print'):
   415     if not opts.get('print'):
   409         out.close()
   416         out.close()
   410 
   417