mercurial/cmdutil.py
changeset 25257 07326d76f19d
parent 25256 5a8398b085ed
child 25258 f37a69ec3f47
equal deleted inserted replaced
25256:5a8398b085ed 25257:07326d76f19d
    19 
    19 
    20 def ishunk(x):
    20 def ishunk(x):
    21     hunkclasses = (crecordmod.uihunk, patch.recordhunk)
    21     hunkclasses = (crecordmod.uihunk, patch.recordhunk)
    22     return isinstance(x, hunkclasses)
    22     return isinstance(x, hunkclasses)
    23 
    23 
       
    24 def newandmodified(chunks, originalchunks):
       
    25     newlyaddedandmodifiedfiles = set()
       
    26     for chunk in chunks:
       
    27         if ishunk(chunk) and chunk.header.isnewfile() and chunk not in \
       
    28             originalchunks:
       
    29             newlyaddedandmodifiedfiles.add(chunk.header.filename())
       
    30     return newlyaddedandmodifiedfiles
       
    31 
    24 def parsealiases(cmd):
    32 def parsealiases(cmd):
    25     return cmd.lstrip("^").split("|")
    33     return cmd.lstrip("^").split("|")
    26 
    34 
    27 def setupwrapcolorwrite(ui):
    35 def setupwrapcolorwrite(ui):
    28     # wrap ui.write so diff output can be labeled/colorized
    36     # wrap ui.write so diff output can be labeled/colorized
   107             raise util.Abort(_('error parsing patch: %s') % err)
   115             raise util.Abort(_('error parsing patch: %s') % err)
   108 
   116 
   109         # We need to keep a backup of files that have been newly added and
   117         # We need to keep a backup of files that have been newly added and
   110         # modified during the recording process because there is a previous
   118         # modified during the recording process because there is a previous
   111         # version without the edit in the workdir
   119         # version without the edit in the workdir
   112         newlyaddedandmodifiedfiles = set()
   120         newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks)
   113         for chunk in chunks:
       
   114             if ishunk(chunk) and chunk.header.isnewfile() and chunk not in \
       
   115                 originalchunks:
       
   116                 newlyaddedandmodifiedfiles.add(chunk.header.filename())
       
   117         contenders = set()
   121         contenders = set()
   118         for h in chunks:
   122         for h in chunks:
   119             try:
   123             try:
   120                 contenders.update(set(h.files()))
   124                 contenders.update(set(h.files()))
   121             except AttributeError:
   125             except AttributeError: