mercurial/patch.py
changeset 41365 876494fd967d
parent 40282 e4f82db071a4
child 41375 f1b0d9988825
equal deleted inserted replaced
41364:0132221c25cd 41365:876494fd967d
  1446         def getline(lr, hunk):
  1446         def getline(lr, hunk):
  1447             l = lr.readline()
  1447             l = lr.readline()
  1448             hunk.append(l)
  1448             hunk.append(l)
  1449             return l.rstrip('\r\n')
  1449             return l.rstrip('\r\n')
  1450 
  1450 
  1451         size = 0
       
  1452         while True:
  1451         while True:
  1453             line = getline(lr, self.hunk)
  1452             line = getline(lr, self.hunk)
  1454             if not line:
  1453             if not line:
  1455                 raise PatchError(_('could not extract "%s" binary data')
  1454                 raise PatchError(_('could not extract "%s" binary data')
  1456                                  % self._fname)
  1455                                  % self._fname)
  1901                 gp = gitpatches.pop()
  1900                 gp = gitpatches.pop()
  1902                 yield 'file', ('a/' + gp.path, 'b/' + gp.path, None, gp.copy())
  1901                 yield 'file', ('a/' + gp.path, 'b/' + gp.path, None, gp.copy())
  1903             if not gitpatches:
  1902             if not gitpatches:
  1904                 raise PatchError(_('failed to synchronize metadata for "%s"')
  1903                 raise PatchError(_('failed to synchronize metadata for "%s"')
  1905                                  % afile[2:])
  1904                                  % afile[2:])
  1906             gp = gitpatches[-1]
       
  1907             newfile = True
  1905             newfile = True
  1908         elif x.startswith('---'):
  1906         elif x.startswith('---'):
  1909             # check for a unified diff
  1907             # check for a unified diff
  1910             l2 = lr.readline()
  1908             l2 = lr.readline()
  1911             if not l2.startswith('+++'):
  1909             if not l2.startswith('+++'):
  2351             def filterrel(l):
  2349             def filterrel(l):
  2352                 return [f for f in l if f.startswith(relroot)]
  2350                 return [f for f in l if f.startswith(relroot)]
  2353             modified = filterrel(modified)
  2351             modified = filterrel(modified)
  2354             added = filterrel(added)
  2352             added = filterrel(added)
  2355             removed = filterrel(removed)
  2353             removed = filterrel(removed)
  2356             relfiltered = True
       
  2357         # filter out copies where either side isn't inside the relative root
  2354         # filter out copies where either side isn't inside the relative root
  2358         copy = dict(((dst, src) for (dst, src) in copy.iteritems()
  2355         copy = dict(((dst, src) for (dst, src) in copy.iteritems()
  2359                      if dst.startswith(relroot)
  2356                      if dst.startswith(relroot)
  2360                      and src.startswith(relroot)))
  2357                      and src.startswith(relroot)))
  2361 
  2358