@@ -543,13 +543,13 @@ class P4Submit(Command):
543
543
self .options = [
544
544
optparse .make_option ("--verbose" , dest = "verbose" , action = "store_true" ),
545
545
optparse .make_option ("--origin" , dest = "origin" ),
546
- optparse .make_option ("-M" , dest = "detectRename " , action = "store_true" ),
546
+ optparse .make_option ("-M" , dest = "detectRenames " , action = "store_true" ),
547
547
]
548
548
self .description = "Submit changes from git to the perforce depot."
549
549
self .usage += " [name of git branch to submit into perforce depot]"
550
550
self .interactive = True
551
551
self .origin = ""
552
- self .detectRename = False
552
+ self .detectRenames = False
553
553
self .verbose = False
554
554
self .isWindows = (platform .system () == "Windows" )
555
555
@@ -613,7 +613,22 @@ class P4Submit(Command):
613
613
614
614
def applyCommit (self , id ):
615
615
print "Applying %s" % (read_pipe ("git log --max-count=1 --pretty=oneline %s" % id ))
616
- diffOpts = ("" , "-M" )[self .detectRename ]
616
+
617
+ if not self .detectRenames :
618
+ # If not explicitly set check the config variable
619
+ self .detectRenames = gitConfig ("git-p4.detectRenames" ).lower () == "true"
620
+
621
+ if self .detectRenames :
622
+ diffOpts = "-M"
623
+ else :
624
+ diffOpts = ""
625
+
626
+ if gitConfig ("git-p4.detectCopies" ).lower () == "true" :
627
+ diffOpts += " -C"
628
+
629
+ if gitConfig ("git-p4.detectCopiesHarder" ).lower () == "true" :
630
+ diffOpts += " --find-copies-harder"
631
+
617
632
diff = read_pipe_lines ("git diff-tree -r %s \" %s^\" \" %s\" " % (diffOpts , id , id ))
618
633
filesToAdd = set ()
619
634
filesToDelete = set ()
@@ -637,11 +652,23 @@ class P4Submit(Command):
637
652
filesToDelete .add (path )
638
653
if path in filesToAdd :
639
654
filesToAdd .remove (path )
655
+ elif modifier == "C" :
656
+ src , dest = diff ['src' ], diff ['dst' ]
657
+ p4_system ("integrate -Dt \" %s\" \" %s\" " % (src , dest ))
658
+ if diff ['src_sha1' ] != diff ['dst_sha1' ]:
659
+ p4_system ("edit \" %s\" " % (dest ))
660
+ if isModeExecChanged (diff ['src_mode' ], diff ['dst_mode' ]):
661
+ p4_system ("edit \" %s\" " % (dest ))
662
+ filesToChangeExecBit [dest ] = diff ['dst_mode' ]
663
+ os .unlink (dest )
664
+ editedFiles .add (dest )
640
665
elif modifier == "R" :
641
666
src , dest = diff ['src' ], diff ['dst' ]
642
667
p4_system ("integrate -Dt \" %s\" \" %s\" " % (src , dest ))
643
- p4_system ("edit \" %s\" " % (dest ))
668
+ if diff ['src_sha1' ] != diff ['dst_sha1' ]:
669
+ p4_system ("edit \" %s\" " % (dest ))
644
670
if isModeExecChanged (diff ['src_mode' ], diff ['dst_mode' ]):
671
+ p4_system ("edit \" %s\" " % (dest ))
645
672
filesToChangeExecBit [dest ] = diff ['dst_mode' ]
646
673
os .unlink (dest )
647
674
editedFiles .add (dest )
0 commit comments