@@ -854,13 +854,15 @@ def __init__(self):
854
854
optparse .make_option ("--preserve-user" , dest = "preserveUser" , action = "store_true" ),
855
855
optparse .make_option ("--export-labels" , dest = "exportLabels" , action = "store_true" ),
856
856
optparse .make_option ("--dry-run" , "-n" , dest = "dry_run" , action = "store_true" ),
857
+ optparse .make_option ("--prepare-p4-only" , dest = "prepare_p4_only" , action = "store_true" ),
857
858
]
858
859
self .description = "Submit changes from git to the perforce depot."
859
860
self .usage += " [name of git branch to submit into perforce depot]"
860
861
self .origin = ""
861
862
self .detectRenames = False
862
863
self .preserveUser = gitConfig ("git-p4.preserveUser" ).lower () == "true"
863
864
self .dry_run = False
865
+ self .prepare_p4_only = False
864
866
self .isWindows = (platform .system () == "Windows" )
865
867
self .exportLabels = False
866
868
self .p4HasMoveCommand = p4_has_command ("move" )
@@ -1270,6 +1272,41 @@ def applyCommit(self, id):
1270
1272
tmpFile .write (submitTemplate + separatorLine + diff + newdiff )
1271
1273
tmpFile .close ()
1272
1274
1275
+ if self .prepare_p4_only :
1276
+ #
1277
+ # Leave the p4 tree prepared, and the submit template around
1278
+ # and let the user decide what to do next
1279
+ #
1280
+ print
1281
+ print "P4 workspace prepared for submission."
1282
+ print "To submit or revert, go to client workspace"
1283
+ print " " + self .clientPath
1284
+ print
1285
+ print "To submit, use \" p4 submit\" to write a new description,"
1286
+ print "or \" p4 submit -i %s\" to use the one prepared by" \
1287
+ " \" git p4\" ." % fileName
1288
+ print "You can delete the file \" %s\" when finished." % fileName
1289
+
1290
+ if self .preserveUser and p4User and not self .p4UserIsMe (p4User ):
1291
+ print "To preserve change ownership by user %s, you must\n " \
1292
+ "do \" p4 change -f <change>\" after submitting and\n " \
1293
+ "edit the User field."
1294
+ if pureRenameCopy :
1295
+ print "After submitting, renamed files must be re-synced."
1296
+ print "Invoke \" p4 sync -f\" on each of these files:"
1297
+ for f in pureRenameCopy :
1298
+ print " " + f
1299
+
1300
+ print
1301
+ print "To revert the changes, use \" p4 revert ...\" , and delete"
1302
+ print "the submit template file \" %s\" " % fileName
1303
+ if filesToAdd :
1304
+ print "Since the commit adds new files, they must be deleted:"
1305
+ for f in filesToAdd :
1306
+ print " " + f
1307
+ print
1308
+ return True
1309
+
1273
1310
#
1274
1311
# Let the user edit the change description, then submit it.
1275
1312
#
@@ -1370,6 +1407,9 @@ def exportGitTags(self, gitTags):
1370
1407
1371
1408
if self .dry_run :
1372
1409
print "Would create p4 label %s for tag" % name
1410
+ elif self .prepare_p4_only :
1411
+ print "Not creating p4 label %s for tag due to option" \
1412
+ " --prepare-p4-only" % name
1373
1413
else :
1374
1414
p4_write_pipe (["label" , "-i" ], labelTemplate )
1375
1415
@@ -1510,6 +1550,10 @@ def run(self, args):
1510
1550
if ok :
1511
1551
applied .append (commit )
1512
1552
else :
1553
+ if self .prepare_p4_only and i < last :
1554
+ print "Processing only the first commit due to option" \
1555
+ " --prepare-p4-only"
1556
+ break
1513
1557
if i < last :
1514
1558
quit = False
1515
1559
while True :
@@ -1532,6 +1576,8 @@ def run(self, args):
1532
1576
1533
1577
if self .dry_run :
1534
1578
pass
1579
+ elif self .prepare_p4_only :
1580
+ pass
1535
1581
elif len (commits ) == len (applied ):
1536
1582
print "All commits applied!"
1537
1583
0 commit comments