提交 e96e400f 编写于 作者: S Simon Hausmann

git-p4: Fix submit user-interface.

Don't ask any questions when submitting, behave similar to git-svn dcommit.
Signed-off-by: NSimon Hausmann <simon@lst.de>
上级 f3e9512b
...@@ -469,9 +469,7 @@ class P4Submit(Command): ...@@ -469,9 +469,7 @@ class P4Submit(Command):
optparse.make_option("--origin", dest="origin"), optparse.make_option("--origin", dest="origin"),
optparse.make_option("--reset", action="store_true", dest="reset"), optparse.make_option("--reset", action="store_true", dest="reset"),
optparse.make_option("--log-substitutions", dest="substFile"), optparse.make_option("--log-substitutions", dest="substFile"),
optparse.make_option("--dry-run", action="store_true"),
optparse.make_option("--direct", dest="directSubmit", action="store_true"), optparse.make_option("--direct", dest="directSubmit", action="store_true"),
optparse.make_option("--trust-me-like-a-fool", dest="trustMeLikeAFool", action="store_true"),
optparse.make_option("-M", dest="detectRename", action="store_true"), optparse.make_option("-M", dest="detectRename", action="store_true"),
] ]
self.description = "Submit changes from git to the perforce depot." self.description = "Submit changes from git to the perforce depot."
...@@ -479,12 +477,10 @@ class P4Submit(Command): ...@@ -479,12 +477,10 @@ class P4Submit(Command):
self.firstTime = True self.firstTime = True
self.reset = False self.reset = False
self.interactive = True self.interactive = True
self.dryRun = False
self.substFile = "" self.substFile = ""
self.firstTime = True self.firstTime = True
self.origin = "" self.origin = ""
self.directSubmit = False self.directSubmit = False
self.trustMeLikeAFool = False
self.detectRename = False self.detectRename = False
self.verbose = False self.verbose = False
self.isWindows = (platform.system() == "Windows") self.isWindows = (platform.system() == "Windows")
...@@ -681,57 +677,30 @@ class P4Submit(Command): ...@@ -681,57 +677,30 @@ class P4Submit(Command):
separatorLine += "\r" separatorLine += "\r"
separatorLine += "\n" separatorLine += "\n"
response = "e" [handle, fileName] = tempfile.mkstemp()
if self.trustMeLikeAFool: tmpFile = os.fdopen(handle, "w+")
response = "y" tmpFile.write(submitTemplate + separatorLine + diff)
tmpFile.close()
firstIteration = True defaultEditor = "vi"
while response == "e": if platform.system() == "Windows":
if not firstIteration: defaultEditor = "notepad"
response = raw_input("Do you want to submit this change? [y]es/[e]dit/[n]o/[s]kip ") editor = os.environ.get("EDITOR", defaultEditor);
firstIteration = False system(editor + " " + fileName)
if response == "e": tmpFile = open(fileName, "rb")
[handle, fileName] = tempfile.mkstemp() message = tmpFile.read()
tmpFile = os.fdopen(handle, "w+") tmpFile.close()
tmpFile.write(submitTemplate + separatorLine + diff) os.remove(fileName)
tmpFile.close() submitTemplate = message[:message.index(separatorLine)]
defaultEditor = "vi" if self.isWindows:
if platform.system() == "Windows": submitTemplate = submitTemplate.replace("\r\n", "\n")
defaultEditor = "notepad"
editor = os.environ.get("EDITOR", defaultEditor); if self.directSubmit:
system(editor + " " + fileName) print "Submitting to git first"
tmpFile = open(fileName, "rb") os.chdir(self.oldWorkingDirectory)
message = tmpFile.read() write_pipe("git commit -a -F -", submitTemplate)
tmpFile.close() os.chdir(self.clientPath)
os.remove(fileName)
submitTemplate = message[:message.index(separatorLine)] write_pipe("p4 submit -i", submitTemplate)
if self.isWindows:
submitTemplate = submitTemplate.replace("\r\n", "\n")
if response == "y" or response == "yes":
if self.dryRun:
print submitTemplate
raw_input("Press return to continue...")
else:
if self.directSubmit:
print "Submitting to git first"
os.chdir(self.oldWorkingDirectory)
write_pipe("git commit -a -F -", submitTemplate)
os.chdir(self.clientPath)
write_pipe("p4 submit -i", submitTemplate)
elif response == "s":
for f in editedFiles:
system("p4 revert \"%s\"" % f);
for f in filesToAdd:
system("p4 revert \"%s\"" % f);
system("rm %s" %f)
for f in filesToDelete:
system("p4 delete \"%s\"" % f);
return
else:
print "Not submitting!"
self.interactive = False
else: else:
fileName = "submit.txt" fileName = "submit.txt"
file = open(fileName, "w+") file = open(fileName, "w+")
...@@ -828,10 +797,8 @@ class P4Submit(Command): ...@@ -828,10 +797,8 @@ class P4Submit(Command):
sync = P4Sync() sync = P4Sync()
sync.run([]) sync.run([])
response = raw_input("Do you want to rebase current HEAD from Perforce now using git-p4 rebase? [y]es/[n]o ") rebase = P4Rebase()
if response == "y" or response == "yes": rebase.rebase()
rebase = P4Rebase()
rebase.rebase()
os.remove(self.configFile) os.remove(self.configFile)
return True return True
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册