mirror of
https://github.com/git/git.git
synced 2024-11-27 20:14:30 +08:00
Merge branch 'eg/p4-submit-catch-failure' into maint
Just like the working tree is cleaned up when the user cancelled submission in P4Submit.applyCommit(), clean up the mess if "p4 submit" fails. * eg/p4-submit-catch-failure: git-p4: clean up after p4 submit failure
This commit is contained in:
commit
908a6e4156
67
git-p4.py
67
git-p4.py
@ -1543,44 +1543,47 @@ class P4Submit(Command, P4UserMap):
|
||||
#
|
||||
# Let the user edit the change description, then submit it.
|
||||
#
|
||||
if self.edit_template(fileName):
|
||||
# read the edited message and submit
|
||||
ret = True
|
||||
tmpFile = open(fileName, "rb")
|
||||
message = tmpFile.read()
|
||||
tmpFile.close()
|
||||
if self.isWindows:
|
||||
message = message.replace("\r\n", "\n")
|
||||
submitTemplate = message[:message.index(separatorLine)]
|
||||
p4_write_pipe(['submit', '-i'], submitTemplate)
|
||||
submitted = False
|
||||
|
||||
if self.preserveUser:
|
||||
if p4User:
|
||||
# Get last changelist number. Cannot easily get it from
|
||||
# the submit command output as the output is
|
||||
# unmarshalled.
|
||||
changelist = self.lastP4Changelist()
|
||||
self.modifyChangelistUser(changelist, p4User)
|
||||
try:
|
||||
if self.edit_template(fileName):
|
||||
# read the edited message and submit
|
||||
tmpFile = open(fileName, "rb")
|
||||
message = tmpFile.read()
|
||||
tmpFile.close()
|
||||
if self.isWindows:
|
||||
message = message.replace("\r\n", "\n")
|
||||
submitTemplate = message[:message.index(separatorLine)]
|
||||
p4_write_pipe(['submit', '-i'], submitTemplate)
|
||||
|
||||
# The rename/copy happened by applying a patch that created a
|
||||
# new file. This leaves it writable, which confuses p4.
|
||||
for f in pureRenameCopy:
|
||||
p4_sync(f, "-f")
|
||||
if self.preserveUser:
|
||||
if p4User:
|
||||
# Get last changelist number. Cannot easily get it from
|
||||
# the submit command output as the output is
|
||||
# unmarshalled.
|
||||
changelist = self.lastP4Changelist()
|
||||
self.modifyChangelistUser(changelist, p4User)
|
||||
|
||||
else:
|
||||
# The rename/copy happened by applying a patch that created a
|
||||
# new file. This leaves it writable, which confuses p4.
|
||||
for f in pureRenameCopy:
|
||||
p4_sync(f, "-f")
|
||||
submitted = True
|
||||
|
||||
finally:
|
||||
# skip this patch
|
||||
ret = False
|
||||
print "Submission cancelled, undoing p4 changes."
|
||||
for f in editedFiles:
|
||||
p4_revert(f)
|
||||
for f in filesToAdd:
|
||||
p4_revert(f)
|
||||
os.remove(f)
|
||||
for f in filesToDelete:
|
||||
p4_revert(f)
|
||||
if not submitted:
|
||||
print "Submission cancelled, undoing p4 changes."
|
||||
for f in editedFiles:
|
||||
p4_revert(f)
|
||||
for f in filesToAdd:
|
||||
p4_revert(f)
|
||||
os.remove(f)
|
||||
for f in filesToDelete:
|
||||
p4_revert(f)
|
||||
|
||||
os.remove(fileName)
|
||||
return ret
|
||||
return submitted
|
||||
|
||||
# Export git tags as p4 labels. Create a p4 label and then tag
|
||||
# with that.
|
||||
|
@ -389,7 +389,7 @@ test_expect_success 'description with Jobs section and bogus following text' '
|
||||
(
|
||||
cd "$cli" &&
|
||||
p4 revert desc6 &&
|
||||
rm desc6
|
||||
rm -f desc6
|
||||
)
|
||||
'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user