MCPcopy Create free account
hub / github.com/git/git / p4ChangesForPaths

Function p4ChangesForPaths

git-p4.py:1284–1360  ·  view source on GitHub ↗
(depotPaths, changeRange, requestedBlockSize)

Source from the content-addressed store, hash-verified

1282
1283
1284def p4ChangesForPaths(depotPaths, changeRange, requestedBlockSize):
1285 assert depotPaths
1286
1287 # Parse the change range into start and end. Try to find integer
1288 # revision ranges as these can be broken up into blocks to avoid
1289 # hitting server-side limits (maxrows, maxscanresults). But if
1290 # that doesn't work, fall back to using the raw revision specifier
1291 # strings, without using block mode.
1292
1293 if changeRange is None or changeRange == '':
1294 changeStart = 1
1295 changeEnd = p4_last_change()
1296 block_size = chooseBlockSize(requestedBlockSize)
1297 else:
1298 parts = changeRange.split(',')
1299 assert len(parts) == 2
1300 try:
1301 changeStart, changeEnd = p4ParseNumericChangeRange(parts)
1302 block_size = chooseBlockSize(requestedBlockSize)
1303 except ValueError:
1304 changeStart = parts[0][1:]
1305 changeEnd = parts[1]
1306 if requestedBlockSize:
1307 die("cannot use --changes-block-size with non-numeric revisions")
1308 block_size = None
1309
1310 changes = set()
1311
1312 # Retrieve changes a block at a time, to prevent running
1313 # into a MaxResults/MaxScanRows error from the server. If
1314 # we _do_ hit one of those errors, turn down the block size
1315
1316 while True:
1317 cmd = ['changes']
1318
1319 if block_size:
1320 end = min(changeEnd, changeStart + block_size)
1321 revisionRange = "%d,%d" % (changeStart, end)
1322 else:
1323 revisionRange = "%s,%s" % (changeStart, changeEnd)
1324
1325 for p in depotPaths:
1326 cmd += ["%s...@%s" % (p, revisionRange)]
1327
1328 # fetch the changes
1329 try:
1330 result = p4CmdList(cmd, errors_as_exceptions=True)
1331 except P4RequestSizeException as e:
1332 if not block_size:
1333 block_size = e.limit
1334 elif block_size > e.limit:
1335 block_size = e.limit
1336 else:
1337 block_size = max(2, block_size // 2)
1338
1339 if verbose:
1340 print("block size error, retrying with block size {0}".format(block_size))
1341 continue

Callers 2

importNewBranchMethod · 0.85
importRevisionsMethod · 0.85

Calls 5

p4_last_changeFunction · 0.85
chooseBlockSizeFunction · 0.85
p4CmdListFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected