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>
This commit is contained in:
parent
f3e9512be1
commit
e96e400f67
@ -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):
|
|||||||
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):
|
|||||||
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()
|
||||||
|
defaultEditor = "vi"
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
defaultEditor = "notepad"
|
||||||
|
editor = os.environ.get("EDITOR", defaultEditor);
|
||||||
|
system(editor + " " + fileName)
|
||||||
|
tmpFile = open(fileName, "rb")
|
||||||
|
message = tmpFile.read()
|
||||||
|
tmpFile.close()
|
||||||
|
os.remove(fileName)
|
||||||
|
submitTemplate = message[:message.index(separatorLine)]
|
||||||
|
if self.isWindows:
|
||||||
|
submitTemplate = submitTemplate.replace("\r\n", "\n")
|
||||||
|
|
||||||
firstIteration = True
|
if self.directSubmit:
|
||||||
while response == "e":
|
print "Submitting to git first"
|
||||||
if not firstIteration:
|
os.chdir(self.oldWorkingDirectory)
|
||||||
response = raw_input("Do you want to submit this change? [y]es/[e]dit/[n]o/[s]kip ")
|
write_pipe("git commit -a -F -", submitTemplate)
|
||||||
firstIteration = False
|
os.chdir(self.clientPath)
|
||||||
if response == "e":
|
|
||||||
[handle, fileName] = tempfile.mkstemp()
|
|
||||||
tmpFile = os.fdopen(handle, "w+")
|
|
||||||
tmpFile.write(submitTemplate + separatorLine + diff)
|
|
||||||
tmpFile.close()
|
|
||||||
defaultEditor = "vi"
|
|
||||||
if platform.system() == "Windows":
|
|
||||||
defaultEditor = "notepad"
|
|
||||||
editor = os.environ.get("EDITOR", defaultEditor);
|
|
||||||
system(editor + " " + fileName)
|
|
||||||
tmpFile = open(fileName, "rb")
|
|
||||||
message = tmpFile.read()
|
|
||||||
tmpFile.close()
|
|
||||||
os.remove(fileName)
|
|
||||||
submitTemplate = message[:message.index(separatorLine)]
|
|
||||||
if self.isWindows:
|
|
||||||
submitTemplate = submitTemplate.replace("\r\n", "\n")
|
|
||||||
|
|
||||||
if response == "y" or response == "yes":
|
write_pipe("p4 submit -i", submitTemplate)
|
||||||
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):
|
|||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user