hgext/phabricator.py
changeset 44610 022bf71515c9
parent 44609 53d75fdeaaaa
child 44643 0437959de6f5
equal deleted inserted replaced
44609:53d75fdeaaaa 44610:022bf71515c9
    59 from mercurial.pycompat import getattr
    59 from mercurial.pycompat import getattr
    60 from mercurial.thirdparty import attr
    60 from mercurial.thirdparty import attr
    61 from mercurial import (
    61 from mercurial import (
    62     cmdutil,
    62     cmdutil,
    63     context,
    63     context,
       
    64     copies,
    64     encoding,
    65     encoding,
    65     error,
    66     error,
    66     exthelper,
    67     exthelper,
    67     graphmod,
    68     graphmod,
    68     httpconnection as httpconnectionmod,
    69     httpconnection as httpconnectionmod,
   857     """add file adds to the phabdiff, both new files and copies/moves"""
   858     """add file adds to the phabdiff, both new files and copies/moves"""
   858     # Keep track of files that've been recorded as moved/copied, so if there are
   859     # Keep track of files that've been recorded as moved/copied, so if there are
   859     # additional copies we can mark them (moves get removed from removed)
   860     # additional copies we can mark them (moves get removed from removed)
   860     copiedchanges = {}
   861     copiedchanges = {}
   861     movedchanges = {}
   862     movedchanges = {}
       
   863 
       
   864     copy = {}
       
   865     if basectx != ctx:
       
   866         copy = copies.pathcopies(basectx.p1(), ctx)
       
   867 
   862     for fname in added:
   868     for fname in added:
   863         fctx = ctx[fname]
   869         fctx = ctx[fname]
   864         oldfctx = None
   870         oldfctx = None
   865         pchange = phabchange(currentPath=fname)
   871         pchange = phabchange(currentPath=fname)
   866 
   872 
   867         filemode = gitmode[fctx.flags()]
   873         filemode = gitmode[fctx.flags()]
   868         renamed = fctx.renamed()
   874 
       
   875         if copy:
       
   876             originalfname = copy.get(fname, fname)
       
   877         else:
       
   878             originalfname = fname
       
   879             if fctx.renamed():
       
   880                 originalfname = fctx.renamed()[0]
       
   881 
       
   882         renamed = fname != originalfname
   869 
   883 
   870         if renamed:
   884         if renamed:
   871             originalfname = renamed[0]
       
   872             oldfctx = basectx.p1()[originalfname]
   885             oldfctx = basectx.p1()[originalfname]
   873             originalmode = gitmode[oldfctx.flags()]
   886             originalmode = gitmode[oldfctx.flags()]
   874             pchange.oldPath = originalfname
   887             pchange.oldPath = originalfname
   875 
   888 
   876             if originalfname in removed:
   889             if originalfname in removed: