Mercurial > public > mercurial-scm > hg
comparison hgext/phabricator.py @ 44610:022bf71515c9
phabricator: account for `basectx != ctx` when calculating renames
No functional changes here because the two are the currently same, but they
won't be with a `--fold` option.
Differential Revision: https://phab.mercurial-scm.org/D8307
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 24 Feb 2020 13:22:15 -0500 |
parents | 53d75fdeaaaa |
children | 0437959de6f5 |
comparison
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: |