Show More
@@ -550,11 +550,11 b' def getdrevmap(repo, revs):' | |||
|
550 | 550 | return result |
|
551 | 551 | |
|
552 | 552 | |
|
553 | def getdiff(ctx, diffopts): | |
|
553 | def getdiff(basectx, ctx, diffopts): | |
|
554 | 554 | """plain-text diff without header (user, commit message, etc)""" |
|
555 | 555 | output = util.stringio() |
|
556 | 556 | for chunk, _label in patch.diffui( |
|
557 | ctx.repo(), ctx.p1().node(), ctx.node(), None, opts=diffopts | |
|
557 | ctx.repo(), basectx.p1().node(), ctx.node(), None, opts=diffopts | |
|
558 | 558 | ): |
|
559 | 559 | output.write(chunk) |
|
560 | 560 | return output.getvalue() |
@@ -661,13 +661,13 b' class phabdiff(object):' | |||
|
661 | 661 | ) |
|
662 | 662 | |
|
663 | 663 | |
|
664 | def maketext(pchange, ctx, fname): | |
|
664 | def maketext(pchange, basectx, ctx, fname): | |
|
665 | 665 | """populate the phabchange for a text file""" |
|
666 | 666 | repo = ctx.repo() |
|
667 | 667 | fmatcher = match.exact([fname]) |
|
668 | 668 | diffopts = mdiff.diffopts(git=True, context=32767) |
|
669 | 669 | _pfctx, _fctx, header, fhunks = next( |
|
670 | patch.diffhunks(repo, ctx.p1(), ctx, fmatcher, opts=diffopts) | |
|
670 | patch.diffhunks(repo, basectx.p1(), ctx, fmatcher, opts=diffopts) | |
|
671 | 671 | ) |
|
672 | 672 | |
|
673 | 673 | for fhunk in fhunks: |
@@ -813,25 +813,25 b' def notutf8(fctx):' | |||
|
813 | 813 | return True |
|
814 | 814 | |
|
815 | 815 | |
|
816 | def addremoved(pdiff, ctx, removed): | |
|
816 | def addremoved(pdiff, basectx, ctx, removed): | |
|
817 | 817 | """add removed files to the phabdiff. Shouldn't include moves""" |
|
818 | 818 | for fname in removed: |
|
819 | 819 | pchange = phabchange( |
|
820 | 820 | currentPath=fname, oldPath=fname, type=DiffChangeType.DELETE |
|
821 | 821 | ) |
|
822 | oldfctx = ctx.p1()[fname] | |
|
822 | oldfctx = basectx.p1()[fname] | |
|
823 | 823 | pchange.addoldmode(gitmode[oldfctx.flags()]) |
|
824 | 824 | if not (oldfctx.isbinary() or notutf8(oldfctx)): |
|
825 | maketext(pchange, ctx, fname) | |
|
825 | maketext(pchange, basectx, ctx, fname) | |
|
826 | 826 | |
|
827 | 827 | pdiff.addchange(pchange) |
|
828 | 828 | |
|
829 | 829 | |
|
830 | def addmodified(pdiff, ctx, modified): | |
|
830 | def addmodified(pdiff, basectx, ctx, modified): | |
|
831 | 831 | """add modified files to the phabdiff""" |
|
832 | 832 | for fname in modified: |
|
833 | 833 | fctx = ctx[fname] |
|
834 | oldfctx = ctx.p1()[fname] | |
|
834 | oldfctx = basectx.p1()[fname] | |
|
835 | 835 | pchange = phabchange(currentPath=fname, oldPath=fname) |
|
836 | 836 | filemode = gitmode[fctx.flags()] |
|
837 | 837 | originalmode = gitmode[oldfctx.flags()] |
@@ -848,12 +848,12 b' def addmodified(pdiff, ctx, modified):' | |||
|
848 | 848 | makebinary(pchange, fctx) |
|
849 | 849 | addoldbinary(pchange, oldfctx, fctx) |
|
850 | 850 | else: |
|
851 | maketext(pchange, ctx, fname) | |
|
851 | maketext(pchange, basectx, ctx, fname) | |
|
852 | 852 | |
|
853 | 853 | pdiff.addchange(pchange) |
|
854 | 854 | |
|
855 | 855 | |
|
856 | def addadded(pdiff, ctx, added, removed): | |
|
856 | def addadded(pdiff, basectx, ctx, added, removed): | |
|
857 | 857 | """add file adds to the phabdiff, both new files and copies/moves""" |
|
858 | 858 | # Keep track of files that've been recorded as moved/copied, so if there are |
|
859 | 859 | # additional copies we can mark them (moves get removed from removed) |
@@ -869,7 +869,7 b' def addadded(pdiff, ctx, added, removed)' | |||
|
869 | 869 | |
|
870 | 870 | if renamed: |
|
871 | 871 | originalfname = renamed[0] |
|
872 | oldfctx = ctx.p1()[originalfname] | |
|
872 | oldfctx = basectx.p1()[originalfname] | |
|
873 | 873 | originalmode = gitmode[oldfctx.flags()] |
|
874 | 874 | pchange.oldPath = originalfname |
|
875 | 875 | |
@@ -914,7 +914,7 b' def addadded(pdiff, ctx, added, removed)' | |||
|
914 | 914 | if renamed: |
|
915 | 915 | addoldbinary(pchange, oldfctx, fctx) |
|
916 | 916 | else: |
|
917 | maketext(pchange, ctx, fname) | |
|
917 | maketext(pchange, basectx, ctx, fname) | |
|
918 | 918 | |
|
919 | 919 | pdiff.addchange(pchange) |
|
920 | 920 | |
@@ -924,21 +924,21 b' def addadded(pdiff, ctx, added, removed)' | |||
|
924 | 924 | pdiff.addchange(movedchange) |
|
925 | 925 | |
|
926 | 926 | |
|
927 | def creatediff(ctx): | |
|
927 | def creatediff(basectx, ctx): | |
|
928 | 928 | """create a Differential Diff""" |
|
929 | 929 | repo = ctx.repo() |
|
930 | 930 | repophid = getrepophid(repo) |
|
931 | 931 | # Create a "Differential Diff" via "differential.creatediff" API |
|
932 | 932 | pdiff = phabdiff( |
|
933 | sourceControlBaseRevision=b'%s' % ctx.p1().hex(), | |
|
933 | sourceControlBaseRevision=b'%s' % basectx.p1().hex(), | |
|
934 | 934 | branch=b'%s' % ctx.branch(), |
|
935 | 935 | ) |
|
936 | modified, added, removed, _d, _u, _i, _c = ctx.p1().status(ctx) | |
|
936 | modified, added, removed, _d, _u, _i, _c = basectx.p1().status(ctx) | |
|
937 | 937 | # addadded will remove moved files from removed, so addremoved won't get |
|
938 | 938 | # them |
|
939 | addadded(pdiff, ctx, added, removed) | |
|
940 | addmodified(pdiff, ctx, modified) | |
|
941 | addremoved(pdiff, ctx, removed) | |
|
939 | addadded(pdiff, basectx, ctx, added, removed) | |
|
940 | addmodified(pdiff, basectx, ctx, modified) | |
|
941 | addremoved(pdiff, basectx, ctx, removed) | |
|
942 | 942 | if repophid: |
|
943 | 943 | pdiff.repositoryPHID = repophid |
|
944 | 944 | diff = callconduit( |
@@ -947,7 +947,11 b' def creatediff(ctx):' | |||
|
947 | 947 | pycompat.byteskwargs(attr.asdict(pdiff)), |
|
948 | 948 | ) |
|
949 | 949 | if not diff: |
|
950 | raise error.Abort(_(b'cannot create diff for %s') % ctx) | |
|
950 | if basectx != ctx: | |
|
951 | msg = _(b'cannot create diff for %s::%s') % (basectx, ctx) | |
|
952 | else: | |
|
953 | msg = _(b'cannot create diff for %s') % ctx | |
|
954 | raise error.Abort(msg) | |
|
951 | 955 | return diff |
|
952 | 956 | |
|
953 | 957 | |
@@ -1008,17 +1012,21 b' def createdifferentialrevision(' | |||
|
1008 | 1012 | |
|
1009 | 1013 | If actions is not None, they will be appended to the transaction. |
|
1010 | 1014 | """ |
|
1015 | basectx = ctx | |
|
1011 | 1016 | repo = ctx.repo() |
|
1012 | 1017 | if oldnode: |
|
1013 | 1018 | diffopts = mdiff.diffopts(git=True, context=32767) |
|
1014 | 1019 | oldctx = repo.unfiltered()[oldnode] |
|
1015 | neednewdiff = getdiff(ctx, diffopts) != getdiff(oldctx, diffopts) | |
|
1020 | oldbasectx = oldctx | |
|
1021 | neednewdiff = getdiff(basectx, ctx, diffopts) != getdiff( | |
|
1022 | oldbasectx, oldctx, diffopts | |
|
1023 | ) | |
|
1016 | 1024 | else: |
|
1017 | 1025 | neednewdiff = True |
|
1018 | 1026 | |
|
1019 | 1027 | transactions = [] |
|
1020 | 1028 | if neednewdiff: |
|
1021 | diff = creatediff(ctx) | |
|
1029 | diff = creatediff(basectx, ctx) | |
|
1022 | 1030 | transactions.append({b'type': b'update', b'value': diff[b'phid']}) |
|
1023 | 1031 | if comment: |
|
1024 | 1032 | transactions.append({b'type': b'comment', b'value': comment}) |
General Comments 0
You need to be logged in to leave comments.
Login now