@matheusbsbs / matheus-bagliano / commits / 0e36f2d726
Fork 0

git-p4: Removed git-p4 submit --direct.

This feature was originally meant to allow for quicker direct submits into perforce, but it turns out that it is not actually quicker than doing a git commit and then running git-p4 submit. Signed-off-by: Simon Hausmann <simon@lst.de>

Simon Hausmann committed Feb 19, 2008 at 09:33 UTC 0e36f2d726d4ce50c3f128bcc168d59ad03e804f
1 file changed +11 -45
contrib/fast-import/git-p4
+11 -45
@@ -468,7 +468,6 @@ class P4Submit(Command):
468 optparse.make_option("--verbose", dest="verbose", action="store_true"),
469 optparse.make_option("--origin", dest="origin"),
470 optparse.make_option("--reset", action="store_true", dest="reset"),
471 - optparse.make_option("--direct", dest="directSubmit", action="store_true"),
471 optparse.make_option("-M", dest="detectRename", action="store_true"),
472 ]
473 self.description = "Submit changes from git to the perforce depot."
@@ -478,7 +477,6 @@ class P4Submit(Command):
477 self.interactive = True
478 self.firstTime = True
479 self.origin = ""
481 - self.directSubmit = False
480 self.detectRename = False
481 self.verbose = False
482 self.isWindows = (platform.system() == "Windows")
@@ -494,12 +492,9 @@ class P4Submit(Command):
492 "maybe you want to call git-p4 submit --reset" % self.configFile)
493
494 commits = []
497 - if self.directSubmit:
498 - commits.append("0")
499 - else:
500 - for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)):
501 - commits.append(line.strip())
502 - commits.reverse()
495 + for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)):
496 + commits.append(line.strip())
497 + commits.reverse()
498
499 self.config["commits"] = commits
500
@@ -556,13 +551,9 @@ class P4Submit(Command):
551 return template
552
553 def applyCommit(self, id):
559 - if self.directSubmit:
560 - print "Applying local change in working directory/index"
561 - diff = self.diffStatus
562 - else:
563 - print "Applying %s" % (read_pipe("git log --max-count=1 --pretty=oneline %s" % id))
564 - diffOpts = ("", "-M")[self.detectRename]
565 - diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (diffOpts, id, id))
554 + print "Applying %s" % (read_pipe("git log --max-count=1 --pretty=oneline %s" % id))
555 + diffOpts = ("", "-M")[self.detectRename]
556 + diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (diffOpts, id, id))
557 filesToAdd = set()
558 filesToDelete = set()
559 editedFiles = set()
@@ -597,10 +588,7 @@ class P4Submit(Command):
588 else:
589 die("unknown modifier %s for %s" % (modifier, path))
590
600 - if self.directSubmit:
601 - diffcmd = "cat \"%s\"" % self.diffFile
602 - else:
603 - diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
591 + diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
592 patchcmd = diffcmd + " | git apply "
593 tryPatchCmd = patchcmd + "--check -"
594 applyPatchCmd = patchcmd + "--check --apply -"
@@ -648,12 +636,10 @@ class P4Submit(Command):
636 mode = filesToChangeExecBit[f]
637 setP4ExecBit(f, mode)
638
651 - logMessage = ""
652 - if not self.directSubmit:
653 - logMessage = extractLogMessageFromGitCommit(id)
654 - if self.isWindows:
655 - logMessage = logMessage.replace("\n", "\r\n")
656 - logMessage = logMessage.strip()
639 + logMessage = extractLogMessageFromGitCommit(id)
640 + if self.isWindows:
641 + logMessage = logMessage.replace("\n", "\r\n")
642 + logMessage = logMessage.strip()
643
644 template = self.prepareSubmitTemplate()
645
@@ -692,12 +678,6 @@ class P4Submit(Command):
678 if self.isWindows:
679 submitTemplate = submitTemplate.replace("\r\n", "\n")
680
695 - if self.directSubmit:
696 - print "Submitting to git first"
697 - os.chdir(self.oldWorkingDirectory)
698 - write_pipe("git commit -a -F -", submitTemplate)
699 - os.chdir(self.clientPath)
700 -
681 write_pipe("p4 submit -i", submitTemplate)
682 else:
683 fileName = "submit.txt"
@@ -739,17 +719,6 @@ class P4Submit(Command):
719 print "Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath)
720 self.oldWorkingDirectory = os.getcwd()
721
742 - if self.directSubmit:
743 - self.diffStatus = read_pipe_lines("git diff -r --name-status HEAD")
744 - if len(self.diffStatus) == 0:
745 - print "No changes in working directory to submit."
746 - return True
747 - patch = read_pipe("git diff -p --binary --diff-filter=ACMRTUXB HEAD")
748 - self.diffFile = self.gitdir + "/p4-git-diff"
749 - f = open(self.diffFile, "wb")
750 - f.write(patch)
751 - f.close();
752 -
722 os.chdir(self.clientPath)
723 print "Syncronizing p4 checkout..."
724 system("p4 sync ...")
@@ -777,9 +746,6 @@ class P4Submit(Command):
746
747 self.config.close()
748
780 - if self.directSubmit:
781 - os.remove(self.diffFile)
782 -
749 if len(commits) == 0:
750 if self.firstTime:
751 print "No changes found to apply between %s and current HEAD" % self.origin