@@ -1178,6 +1178,12 @@ def __init__(self):
1178
1178
self .needsGit = True
1179
1179
self .verbose = False
1180
1180
1181
+ # This is required for the "append" cloneExclude action
1182
+ def ensure_value (self , attr , value ):
1183
+ if not hasattr (self , attr ) or getattr (self , attr ) is None :
1184
+ setattr (self , attr , value )
1185
+ return getattr (self , attr )
1186
+
1181
1187
class P4UserMap :
1182
1188
def __init__ (self ):
1183
1189
self .userMapFromPerforceServer = False
@@ -1343,9 +1349,10 @@ def __init__(self):
1343
1349
optparse .make_option ("--shelve" , dest = "shelve" , action = "store_true" ,
1344
1350
help = "Shelve instead of submit. Shelved files are reverted, "
1345
1351
"restoring the workspace to the state before the shelve" ),
1346
- optparse .make_option ("--update-shelve" , dest = "update_shelve" , action = "store " , type = "int" ,
1352
+ optparse .make_option ("--update-shelve" , dest = "update_shelve" , action = "append " , type = "int" ,
1347
1353
metavar = "CHANGELIST" ,
1348
- help = "update an existing shelved changelist, implies --shelve" )
1354
+ help = "update an existing shelved changelist, implies --shelve, "
1355
+ "repeat in-order for multiple shelved changelists" )
1349
1356
]
1350
1357
self .description = "Submit changes from git to the perforce depot."
1351
1358
self .usage += " [name of git branch to submit into perforce depot]"
@@ -1354,7 +1361,7 @@ def __init__(self):
1354
1361
self .preserveUser = gitConfigBool ("git-p4.preserveUser" )
1355
1362
self .dry_run = False
1356
1363
self .shelve = False
1357
- self .update_shelve = None
1364
+ self .update_shelve = list ()
1358
1365
self .prepare_p4_only = False
1359
1366
self .conflict_behavior = None
1360
1367
self .isWindows = (platform .system () == "Windows" )
@@ -1809,9 +1816,10 @@ def applyCommit(self, id):
1809
1816
mode = filesToChangeExecBit [f ]
1810
1817
setP4ExecBit (f , mode )
1811
1818
1812
- if self .update_shelve :
1813
- print ("all_files = %s" % str (all_files ))
1814
- p4_reopen_in_change (self .update_shelve , all_files )
1819
+ update_shelve = 0
1820
+ if len (self .update_shelve ) > 0 :
1821
+ update_shelve = self .update_shelve .pop (0 )
1822
+ p4_reopen_in_change (update_shelve , all_files )
1815
1823
1816
1824
#
1817
1825
# Build p4 change description, starting with the contents
@@ -1821,7 +1829,7 @@ def applyCommit(self, id):
1821
1829
logMessage = logMessage .strip ()
1822
1830
(logMessage , jobs ) = self .separate_jobs_from_description (logMessage )
1823
1831
1824
- template = self .prepareSubmitTemplate (self . update_shelve )
1832
+ template = self .prepareSubmitTemplate (update_shelve )
1825
1833
submitTemplate = self .prepareLogMessage (template , logMessage , jobs )
1826
1834
1827
1835
if self .preserveUser :
@@ -1894,7 +1902,7 @@ def applyCommit(self, id):
1894
1902
message = message .replace ("\r \n " , "\n " )
1895
1903
submitTemplate = message [:message .index (separatorLine )]
1896
1904
1897
- if self . update_shelve :
1905
+ if update_shelve :
1898
1906
p4_write_pipe (['shelve' , '-r' , '-i' ], submitTemplate )
1899
1907
elif self .shelve :
1900
1908
p4_write_pipe (['shelve' , '-i' ], submitTemplate )
@@ -2012,6 +2020,10 @@ def run(self, args):
2012
2020
else :
2013
2021
return False
2014
2022
2023
+ for i in self .update_shelve :
2024
+ if i <= 0 :
2025
+ sys .exit ("invalid changelist %d" % i )
2026
+
2015
2027
if self .master :
2016
2028
allowSubmit = gitConfig ("git-p4.allowSubmit" )
2017
2029
if len (allowSubmit ) > 0 and not self .master in allowSubmit .split ("," ):
@@ -2022,7 +2034,7 @@ def run(self, args):
2022
2034
if len (self .origin ) == 0 :
2023
2035
self .origin = upstream
2024
2036
2025
- if self .update_shelve :
2037
+ if len ( self .update_shelve ) > 0 :
2026
2038
self .shelve = True
2027
2039
2028
2040
if self .preserveUser :
@@ -2134,6 +2146,11 @@ def run(self, args):
2134
2146
if gitConfigBool ("git-p4.detectCopiesHarder" ):
2135
2147
self .diffOpts += " --find-copies-harder"
2136
2148
2149
+ num_shelves = len (self .update_shelve )
2150
+ if num_shelves > 0 and num_shelves != len (commits ):
2151
+ sys .exit ("number of commits (%d) must match number of shelved changelist (%d)" %
2152
+ (len (commits ), num_shelves ))
2153
+
2137
2154
#
2138
2155
# Apply the commits, one at a time. On failure, ask if should
2139
2156
# continue to try the rest of the patches, or quit.
@@ -2404,12 +2421,6 @@ def __init__(self):
2404
2421
if gitConfig ("git-p4.syncFromOrigin" ) == "false" :
2405
2422
self .syncWithOrigin = False
2406
2423
2407
- # This is required for the "append" cloneExclude action
2408
- def ensure_value (self , attr , value ):
2409
- if not hasattr (self , attr ) or getattr (self , attr ) is None :
2410
- setattr (self , attr , value )
2411
- return getattr (self , attr )
2412
-
2413
2424
# Force a checkpoint in fast-import and wait for it to finish
2414
2425
def checkpoint (self ):
2415
2426
self .gitStream .write ("checkpoint\n \n " )
0 commit comments