##// END OF EJS Templates
phabricator: add addadded function...
Ian Moody -
r43552:d5d1edf6 default
parent child Browse files
Show More
@@ -722,6 +722,71 b' def addmodified(pdiff, ctx, modified):'
722 pdiff.addchange(pchange)
722 pdiff.addchange(pchange)
723
723
724
724
725 def addadded(pdiff, ctx, added, removed):
726 """add file adds to the phabdiff, both new files and copies/moves"""
727 # Keep track of files that've been recorded as moved/copied, so if there are
728 # additional copies we can mark them (moves get removed from removed)
729 copiedchanges = {}
730 movedchanges = {}
731 for fname in added:
732 fctx = ctx[fname]
733 pchange = phabchange(currentPath=fname)
734
735 filemode = gitmode[ctx[fname].flags()]
736 renamed = fctx.renamed()
737
738 if renamed:
739 originalfname = renamed[0]
740 originalmode = gitmode[ctx.p1()[originalfname].flags()]
741 pchange.oldPath = originalfname
742
743 if originalfname in removed:
744 origpchange = phabchange(
745 currentPath=originalfname,
746 oldPath=originalfname,
747 type=DiffChangeType.MOVE_AWAY,
748 awayPaths=[fname],
749 )
750 movedchanges[originalfname] = origpchange
751 removed.remove(originalfname)
752 pchange.type = DiffChangeType.MOVE_HERE
753 elif originalfname in movedchanges:
754 movedchanges[originalfname].type = DiffChangeType.MULTICOPY
755 movedchanges[originalfname].awayPaths.append(fname)
756 pchange.type = DiffChangeType.COPY_HERE
757 else: # pure copy
758 if originalfname not in copiedchanges:
759 origpchange = phabchange(
760 currentPath=originalfname, type=DiffChangeType.COPY_AWAY
761 )
762 copiedchanges[originalfname] = origpchange
763 else:
764 origpchange = copiedchanges[originalfname]
765 origpchange.awayPaths.append(fname)
766 pchange.type = DiffChangeType.COPY_HERE
767
768 if filemode != originalmode:
769 pchange.addoldmode(originalmode)
770 pchange.addnewmode(filemode)
771 else: # Brand-new file
772 pchange.addnewmode(gitmode[fctx.flags()])
773 pchange.type = DiffChangeType.ADD
774
775 if fctx.isbinary():
776 makebinary(pchange, fctx)
777 if renamed:
778 addoldbinary(pchange, fctx, originalfname)
779 else:
780 maketext(pchange, ctx, fname)
781
782 pdiff.addchange(pchange)
783
784 for _path, copiedchange in copiedchanges.items():
785 pdiff.addchange(copiedchange)
786 for _path, movedchange in movedchanges.items():
787 pdiff.addchange(movedchange)
788
789
725 def creatediff(ctx):
790 def creatediff(ctx):
726 """create a Differential Diff"""
791 """create a Differential Diff"""
727 repo = ctx.repo()
792 repo = ctx.repo()
General Comments 0
You need to be logged in to leave comments. Login now