hgext/phabricator.py
changeset 43190 c19b327017b9
parent 43189 9f802243a42e
child 43258 d5d1edf66091
equal deleted inserted replaced
43189:9f802243a42e 43190:c19b327017b9
   680     if mimeguess:
   680     if mimeguess:
   681         mimeguess = pycompat.bytestr(mimeguess)
   681         mimeguess = pycompat.bytestr(mimeguess)
   682         pchange.metadata[b'new:file:mime-type'] = mimeguess
   682         pchange.metadata[b'new:file:mime-type'] = mimeguess
   683         if mimeguess.startswith(b'image/'):
   683         if mimeguess.startswith(b'image/'):
   684             pchange.fileType = DiffFileType.IMAGE
   684             pchange.fileType = DiffFileType.IMAGE
       
   685 
       
   686 
       
   687 # Copied from mercurial/patch.py
       
   688 gitmode = {b'l': b'120000', b'x': b'100755', b'': b'100644'}
       
   689 
       
   690 
       
   691 def addremoved(pdiff, ctx, removed):
       
   692     """add removed files to the phabdiff. Shouldn't include moves"""
       
   693     for fname in removed:
       
   694         pchange = phabchange(
       
   695             currentPath=fname, oldPath=fname, type=DiffChangeType.DELETE
       
   696         )
       
   697         pchange.addoldmode(gitmode[ctx.p1()[fname].flags()])
       
   698         fctx = ctx.p1()[fname]
       
   699         if not fctx.isbinary():
       
   700             maketext(pchange, ctx, fname)
       
   701 
       
   702         pdiff.addchange(pchange)
       
   703 
       
   704 
       
   705 def addmodified(pdiff, ctx, modified):
       
   706     """add modified files to the phabdiff"""
       
   707     for fname in modified:
       
   708         fctx = ctx[fname]
       
   709         pchange = phabchange(currentPath=fname, oldPath=fname)
       
   710         filemode = gitmode[ctx[fname].flags()]
       
   711         originalmode = gitmode[ctx.p1()[fname].flags()]
       
   712         if filemode != originalmode:
       
   713             pchange.addoldmode(originalmode)
       
   714             pchange.addnewmode(filemode)
       
   715 
       
   716         if fctx.isbinary():
       
   717             makebinary(pchange, fctx)
       
   718             addoldbinary(pchange, fctx, fname)
       
   719         else:
       
   720             maketext(pchange, ctx, fname)
       
   721 
       
   722         pdiff.addchange(pchange)
   685 
   723 
   686 
   724 
   687 def creatediff(ctx):
   725 def creatediff(ctx):
   688     """create a Differential Diff"""
   726     """create a Differential Diff"""
   689     repo = ctx.repo()
   727     repo = ctx.repo()