mercurial/patch.py
changeset 24306 6ddc86eedc3b
parent 24269 9a745ced79a9
child 24341 616c01b69898
equal deleted inserted replaced
24305:867c3649be5d 24306:6ddc86eedc3b
   257         message = '%s\n%s' % (subject, message)
   257         message = '%s\n%s' % (subject, message)
   258     tmpfp.close()
   258     tmpfp.close()
   259     if not diffs_seen:
   259     if not diffs_seen:
   260         os.unlink(tmpname)
   260         os.unlink(tmpname)
   261         return None, message, user, date, branch, None, None, None
   261         return None, message, user, date, branch, None, None, None
   262     p1 = parents and parents.pop(0) or None
   262 
   263     p2 = parents and parents.pop(0) or None
   263     if parents:
       
   264         p1 = parents.pop(0)
       
   265     else:
       
   266         p1 = None
       
   267 
       
   268     if parents:
       
   269         p2 = parents.pop(0)
       
   270     else:
       
   271         p2 = None
       
   272 
   264     return tmpname, message, user, date, branch, nodeid, p1, p2
   273     return tmpname, message, user, date, branch, nodeid, p1, p2
   265 
   274 
   266 class patchmeta(object):
   275 class patchmeta(object):
   267     """Patched file metadata
   276     """Patched file metadata
   268 
   277 
  1487     # file should be patched (see original mpatch code).
  1496     # file should be patched (see original mpatch code).
  1488     isbackup = (abase == bbase and bfile.startswith(afile))
  1497     isbackup = (abase == bbase and bfile.startswith(afile))
  1489     fname = None
  1498     fname = None
  1490     if not missing:
  1499     if not missing:
  1491         if gooda and goodb:
  1500         if gooda and goodb:
  1492             fname = isbackup and afile or bfile
  1501             if isbackup:
       
  1502                 fname = afile
       
  1503             else:
       
  1504                 fname = bfile
  1493         elif gooda:
  1505         elif gooda:
  1494             fname = afile
  1506             fname = afile
  1495 
  1507 
  1496     if not fname:
  1508     if not fname:
  1497         if not nullb:
  1509         if not nullb:
  1498             fname = isbackup and afile or bfile
  1510             if isbackup:
       
  1511                 fname = afile
       
  1512             else:
       
  1513                 fname = bfile
  1499         elif not nulla:
  1514         elif not nulla:
  1500             fname = afile
  1515             fname = afile
  1501         else:
  1516         else:
  1502             raise PatchError(_("undefined source and destination files"))
  1517             raise PatchError(_("undefined source and destination files"))
  1503 
  1518 
  2068     modified, added, removed = changes[:3]
  2083     modified, added, removed = changes[:3]
  2069 
  2084 
  2070     if not modified and not added and not removed:
  2085     if not modified and not added and not removed:
  2071         return []
  2086         return []
  2072 
  2087 
  2073     hexfunc = repo.ui.debugflag and hex or short
  2088     if repo.ui.debugflag:
       
  2089         hexfunc = hex
       
  2090     else:
       
  2091         hexfunc = short
  2074     revs = [hexfunc(node) for node in [ctx1.node(), ctx2.node()] if node]
  2092     revs = [hexfunc(node) for node in [ctx1.node(), ctx2.node()] if node]
  2075 
  2093 
  2076     copy = {}
  2094     copy = {}
  2077     if opts.git or opts.upgrade:
  2095     if opts.git or opts.upgrade:
  2078         copy = copies.pathcopies(ctx1, ctx2)
  2096         copy = copies.pathcopies(ctx1, ctx2)