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

git-p4: Fix submit user-interface.

Don't ask any questions when submitting, behave similar to git-svn dcommit. Signed-off-by: Simon Hausmann <simon@lst.de>

Simon Hausmann committed Jan 4, 2008 at 14:27 UTC e96e400f67b8478a99f9d2b5d82f08cd21f51a88
1 file changed +26 -59
contrib/fast-import/git-p4
+26 -59
@@ -469,9 +469,7 @@ class P4Submit(Command):
469 optparse.make_option("--origin", dest="origin"),
470 optparse.make_option("--reset", action="store_true", dest="reset"),
471 optparse.make_option("--log-substitutions", dest="substFile"),
472 - optparse.make_option("--dry-run", action="store_true"),
472 optparse.make_option("--direct", dest="directSubmit", action="store_true"),
474 - optparse.make_option("--trust-me-like-a-fool", dest="trustMeLikeAFool", action="store_true"),
473 optparse.make_option("-M", dest="detectRename", action="store_true"),
474 ]
475 self.description = "Submit changes from git to the perforce depot."
@@ -479,12 +477,10 @@ class P4Submit(Command):
477 self.firstTime = True
478 self.reset = False
479 self.interactive = True
482 - self.dryRun = False
480 self.substFile = ""
481 self.firstTime = True
482 self.origin = ""
483 self.directSubmit = False
487 - self.trustMeLikeAFool = False
484 self.detectRename = False
485 self.verbose = False
486 self.isWindows = (platform.system() == "Windows")
@@ -681,57 +677,30 @@ class P4Submit(Command):
677 separatorLine += "\r"
678 separatorLine += "\n"
679
684 - response = "e"
685 - if self.trustMeLikeAFool:
686 - response = "y"
687 -
688 - firstIteration = True
689 - while response == "e":
690 - if not firstIteration:
691 - response = raw_input("Do you want to submit this change? [y]es/[e]dit/[n]o/[s]kip ")
692 - firstIteration = False
693 - if response == "e":
694 - [handle, fileName] = tempfile.mkstemp()
695 - tmpFile = os.fdopen(handle, "w+")
696 - tmpFile.write(submitTemplate + separatorLine + diff)
697 - tmpFile.close()
698 - defaultEditor = "vi"
699 - if platform.system() == "Windows":
700 - defaultEditor = "notepad"
701 - editor = os.environ.get("EDITOR", defaultEditor);
702 - system(editor + " " + fileName)
703 - tmpFile = open(fileName, "rb")
704 - message = tmpFile.read()
705 - tmpFile.close()
706 - os.remove(fileName)
707 - submitTemplate = message[:message.index(separatorLine)]
708 - if self.isWindows:
709 - submitTemplate = submitTemplate.replace("\r\n", "\n")
710 -
711 - if response == "y" or response == "yes":
712 - if self.dryRun:
713 - print submitTemplate
714 - raw_input("Press return to continue...")
715 - else:
716 - if self.directSubmit:
717 - print "Submitting to git first"
718 - os.chdir(self.oldWorkingDirectory)
719 - write_pipe("git commit -a -F -", submitTemplate)
720 - os.chdir(self.clientPath)
721 -
722 - write_pipe("p4 submit -i", submitTemplate)
723 - elif response == "s":
724 - for f in editedFiles:
725 - system("p4 revert \"%s\"" % f);
726 - for f in filesToAdd:
727 - system("p4 revert \"%s\"" % f);
728 - system("rm %s" %f)
729 - for f in filesToDelete:
730 - system("p4 delete \"%s\"" % f);
731 - return
732 - else:
733 - print "Not submitting!"
734 - self.interactive = False
680 + [handle, fileName] = tempfile.mkstemp()
681 + tmpFile = os.fdopen(handle, "w+")
682 + tmpFile.write(submitTemplate + separatorLine + diff)
683 + tmpFile.close()
684 + defaultEditor = "vi"
685 + if platform.system() == "Windows":
686 + defaultEditor = "notepad"
687 + editor = os.environ.get("EDITOR", defaultEditor);
688 + system(editor + " " + fileName)
689 + tmpFile = open(fileName, "rb")
690 + message = tmpFile.read()
691 + tmpFile.close()
692 + os.remove(fileName)
693 + submitTemplate = message[:message.index(separatorLine)]
694 + if self.isWindows:
695 + submitTemplate = submitTemplate.replace("\r\n", "\n")
696 +
697 + if self.directSubmit:
698 + print "Submitting to git first"
699 + os.chdir(self.oldWorkingDirectory)
700 + write_pipe("git commit -a -F -", submitTemplate)
701 + os.chdir(self.clientPath)
702 +
703 + write_pipe("p4 submit -i", submitTemplate)
704 else:
705 fileName = "submit.txt"
706 file = open(fileName, "w+")
@@ -828,10 +797,8 @@ class P4Submit(Command):
797 sync = P4Sync()
798 sync.run([])
799
831 - response = raw_input("Do you want to rebase current HEAD from Perforce now using git-p4 rebase? [y]es/[n]o ")
832 - if response == "y" or response == "yes":
833 - rebase = P4Rebase()
834 - rebase.rebase()
800 + rebase = P4Rebase()
801 + rebase.rebase()
802 os.remove(self.configFile)
803
804 return True