@@ -1543,44 +1543,47 @@ def applyCommit(self, id):
15431543 #
15441544 # Let the user edit the change description, then submit it.
15451545 #
1546- if self .edit_template (fileName ):
1547- # read the edited message and submit
1548- ret = True
1549- tmpFile = open (fileName , "rb" )
1550- message = tmpFile .read ()
1551- tmpFile .close ()
1552- if self .isWindows :
1553- message = message .replace ("\r \n " , "\n " )
1554- submitTemplate = message [:message .index (separatorLine )]
1555- p4_write_pipe (['submit' , '-i' ], submitTemplate )
1556-
1557- if self .preserveUser :
1558- if p4User :
1559- # Get last changelist number. Cannot easily get it from
1560- # the submit command output as the output is
1561- # unmarshalled.
1562- changelist = self .lastP4Changelist ()
1563- self .modifyChangelistUser (changelist , p4User )
1564-
1565- # The rename/copy happened by applying a patch that created a
1566- # new file. This leaves it writable, which confuses p4.
1567- for f in pureRenameCopy :
1568- p4_sync (f , "-f" )
1546+ submitted = False
15691547
1570- else :
1548+ try :
1549+ if self .edit_template (fileName ):
1550+ # read the edited message and submit
1551+ tmpFile = open (fileName , "rb" )
1552+ message = tmpFile .read ()
1553+ tmpFile .close ()
1554+ if self .isWindows :
1555+ message = message .replace ("\r \n " , "\n " )
1556+ submitTemplate = message [:message .index (separatorLine )]
1557+ p4_write_pipe (['submit' , '-i' ], submitTemplate )
1558+
1559+ if self .preserveUser :
1560+ if p4User :
1561+ # Get last changelist number. Cannot easily get it from
1562+ # the submit command output as the output is
1563+ # unmarshalled.
1564+ changelist = self .lastP4Changelist ()
1565+ self .modifyChangelistUser (changelist , p4User )
1566+
1567+ # The rename/copy happened by applying a patch that created a
1568+ # new file. This leaves it writable, which confuses p4.
1569+ for f in pureRenameCopy :
1570+ p4_sync (f , "-f" )
1571+ submitted = True
1572+
1573+ finally :
15711574 # skip this patch
1572- ret = False
1573- print "Submission cancelled, undoing p4 changes."
1574- for f in editedFiles :
1575- p4_revert (f )
1576- for f in filesToAdd :
1577- p4_revert (f )
1578- os .remove (f )
1579- for f in filesToDelete :
1580- p4_revert (f )
1575+ if not submitted :
1576+ print "Submission cancelled, undoing p4 changes."
1577+ for f in editedFiles :
1578+ p4_revert (f )
1579+ for f in filesToAdd :
1580+ p4_revert (f )
1581+ os .remove (f )
1582+ for f in filesToDelete :
1583+ p4_revert (f )
15811584
15821585 os .remove (fileName )
1583- return ret
1586+ return submitted
15841587
15851588 # Export git tags as p4 labels. Create a p4 label and then tag
15861589 # with that.
0 commit comments