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:
11
git-p4.py
11
git-p4.py
@ -1543,9 +1543,11 @@ class P4Submit(Command, P4UserMap):
|
|||||||
#
|
#
|
||||||
# Let the user edit the change description, then submit it.
|
# Let the user edit the change description, then submit it.
|
||||||
#
|
#
|
||||||
|
submitted = False
|
||||||
|
|
||||||
|
try:
|
||||||
if self.edit_template(fileName):
|
if self.edit_template(fileName):
|
||||||
# read the edited message and submit
|
# read the edited message and submit
|
||||||
ret = True
|
|
||||||
tmpFile = open(fileName, "rb")
|
tmpFile = open(fileName, "rb")
|
||||||
message = tmpFile.read()
|
message = tmpFile.read()
|
||||||
tmpFile.close()
|
tmpFile.close()
|
||||||
@ -1566,10 +1568,11 @@ class P4Submit(Command, P4UserMap):
|
|||||||
# new file. This leaves it writable, which confuses p4.
|
# new file. This leaves it writable, which confuses p4.
|
||||||
for f in pureRenameCopy:
|
for f in pureRenameCopy:
|
||||||
p4_sync(f, "-f")
|
p4_sync(f, "-f")
|
||||||
|
submitted = True
|
||||||
|
|
||||||
else:
|
finally:
|
||||||
# skip this patch
|
# skip this patch
|
||||||
ret = False
|
if not submitted:
|
||||||
print "Submission cancelled, undoing p4 changes."
|
print "Submission cancelled, undoing p4 changes."
|
||||||
for f in editedFiles:
|
for f in editedFiles:
|
||||||
p4_revert(f)
|
p4_revert(f)
|
||||||
@ -1580,7 +1583,7 @@ class P4Submit(Command, P4UserMap):
|
|||||||
p4_revert(f)
|
p4_revert(f)
|
||||||
|
|
||||||
os.remove(fileName)
|
os.remove(fileName)
|
||||||
return ret
|
return submitted
|
||||||
|
|
||||||
# Export git tags as p4 labels. Create a p4 label and then tag
|
# Export git tags as p4 labels. Create a p4 label and then tag
|
||||||
# with that.
|
# with that.
|
||||||
|
@ -389,7 +389,7 @@ test_expect_success 'description with Jobs section and bogus following text' '
|
|||||||
(
|
(
|
||||||
cd "$cli" &&
|
cd "$cli" &&
|
||||||
p4 revert desc6 &&
|
p4 revert desc6 &&
|
||||||
rm desc6
|
rm -f desc6
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user