mercurial/patch.py
changeset 9243 df21a009c9c4
parent 9123 360f61c2919f
child 9248 ac02b43bc08a
child 9573 b8352a3617f3
equal deleted inserted replaced
9242:6fd3f795e908 9243:df21a009c9c4
   180     dopatch = 0
   180     dopatch = 0
   181 
   181 
   182     lineno = 0
   182     lineno = 0
   183     for line in lr:
   183     for line in lr:
   184         lineno += 1
   184         lineno += 1
       
   185         line = line.rstrip(' \r\n')
   185         if line.startswith('diff --git'):
   186         if line.startswith('diff --git'):
   186             m = gitre.match(line)
   187             m = gitre.match(line)
   187             if m:
   188             if m:
   188                 if gp:
   189                 if gp:
   189                     gitpatches.append(gp)
   190                     gitpatches.append(gp)
   198                 gp = None
   199                 gp = None
   199                 dopatch |= GP_PATCH
   200                 dopatch |= GP_PATCH
   200                 continue
   201                 continue
   201             if line.startswith('rename from '):
   202             if line.startswith('rename from '):
   202                 gp.op = 'RENAME'
   203                 gp.op = 'RENAME'
   203                 gp.oldpath = line[12:].rstrip()
   204                 gp.oldpath = line[12:]
   204             elif line.startswith('rename to '):
   205             elif line.startswith('rename to '):
   205                 gp.path = line[10:].rstrip()
   206                 gp.path = line[10:]
   206             elif line.startswith('copy from '):
   207             elif line.startswith('copy from '):
   207                 gp.op = 'COPY'
   208                 gp.op = 'COPY'
   208                 gp.oldpath = line[10:].rstrip()
   209                 gp.oldpath = line[10:]
   209             elif line.startswith('copy to '):
   210             elif line.startswith('copy to '):
   210                 gp.path = line[8:].rstrip()
   211                 gp.path = line[8:]
   211             elif line.startswith('deleted file'):
   212             elif line.startswith('deleted file'):
   212                 gp.op = 'DELETE'
   213                 gp.op = 'DELETE'
   213                 # is the deleted file a symlink?
   214                 # is the deleted file a symlink?
   214                 gp.setmode(int(line.rstrip()[-6:], 8))
   215                 gp.setmode(int(line[-6:], 8))
   215             elif line.startswith('new file mode '):
   216             elif line.startswith('new file mode '):
   216                 gp.op = 'ADD'
   217                 gp.op = 'ADD'
   217                 gp.setmode(int(line.rstrip()[-6:], 8))
   218                 gp.setmode(int(line[-6:], 8))
   218             elif line.startswith('new mode '):
   219             elif line.startswith('new mode '):
   219                 gp.setmode(int(line.rstrip()[-6:], 8))
   220                 gp.setmode(int(line[-6:], 8))
   220             elif line.startswith('GIT binary patch'):
   221             elif line.startswith('GIT binary patch'):
   221                 dopatch |= GP_BINARY
   222                 dopatch |= GP_BINARY
   222                 gp.binary = True
   223                 gp.binary = True
   223     if gp:
   224     if gp:
   224         gitpatches.append(gp)
   225         gitpatches.append(gp)