mercurial/patch.py
changeset 7267 6a51ca1e05c3
parent 7247 c4461ea8b4c8
child 7308 b6f5490effbf
equal deleted inserted replaced
7266:e7f6401584f7 7267:6a51ca1e05c3
  1320         single(rev, seqno+1, fp)
  1320         single(rev, seqno+1, fp)
  1321 
  1321 
  1322 def diffstat(patchlines):
  1322 def diffstat(patchlines):
  1323     if not util.find_exe('diffstat'):
  1323     if not util.find_exe('diffstat'):
  1324         return
  1324         return
  1325     fd, name = tempfile.mkstemp(prefix="hg-patchbomb-", suffix=".txt")
  1325     output = util.filter('\n'.join(patchlines),
  1326     try:
  1326                          'diffstat -p1 -w79 2>%s' % util.nulldev)
  1327         p = util.Popen3('diffstat -p1 -w79 2>/dev/null > ' + name)
  1327     stat = [l.lstrip() for l in output.splitlines(True)]
  1328         try:
  1328     last = stat.pop()
  1329             for line in patchlines:
  1329     stat.insert(0, last)
  1330                 p.tochild.write(line + "\n")
  1330     stat = ''.join(stat)
  1331             p.tochild.close()
  1331     return stat
  1332             if p.wait(): return
       
  1333             fp = os.fdopen(fd, 'r')
       
  1334             stat = []
       
  1335             for line in fp: stat.append(line.lstrip())
       
  1336             last = stat.pop()
       
  1337             stat.insert(0, last)
       
  1338             stat = ''.join(stat)
       
  1339             return stat
       
  1340         except: raise
       
  1341     finally:
       
  1342         try: os.unlink(name)
       
  1343         except: pass