@@ -1543,44 +1543,47 @@ def applyCommit(self, id):
1543
1543
#
1544
1544
# Let the user edit the change description, then submit it.
1545
1545
#
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
1569
1547
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 :
1571
1574
# 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 )
1581
1584
1582
1585
os .remove (fileName )
1583
- return ret
1586
+ return submitted
1584
1587
1585
1588
# Export git tags as p4 labels. Create a p4 label and then tag
1586
1589
# with that.
0 commit comments