@matheusbsbs / matheus-bagliano / commits / 4f6432d8cc
Fork 0

git-p4: Cleanup; moved the code for getting a sorted list of p4 changes for a list of given depot paths into a standalone method.

Signed-off-by: Simon Hausmann <simon@lst.de>

Simon Hausmann committed Aug 26, 2007 at 15:56 UTC 4f6432d8cc6ebdcdc366cf67ab39e8125c449d80
1 file changed +14 -9
contrib/fast-import/git-p4
+14 -9
@@ -281,6 +281,19 @@ def createOrUpdateBranchesFromOrigin(localRefPrefix = "refs/remotes/p4/", silent
281 def originP4BranchesExist():
282 return gitBranchExists("origin") or gitBranchExists("origin/p4") or gitBranchExists("origin/p4/master")
283
284 +def p4ChangesForPaths(depotPaths, changeRange):
285 + assert depotPaths
286 + output = read_pipe_lines("p4 changes " + ' '.join (["%s...%s" % (p, changeRange)
287 + for p in depotPaths]))
288 +
289 + changes = []
290 + for line in output:
291 + changeNum = line.split(" ")[1]
292 + changes.append(int(changeNum))
293 +
294 + changes.sort()
295 + return changes
296 +
297 class Command:
298 def __init__(self):
299 self.usage = "usage: %prog [options]"
@@ -1322,15 +1335,7 @@ class P4Sync(Command):
1335 if self.verbose:
1336 print "Getting p4 changes for %s...%s" % (', '.join(self.depotPaths),
1337 self.changeRange)
1325 - assert self.depotPaths
1326 - output = read_pipe_lines("p4 changes " + ' '.join (["%s...%s" % (p, self.changeRange)
1327 - for p in self.depotPaths]))
1328 -
1329 - for line in output:
1330 - changeNum = line.split(" ")[1]
1331 - changes.append(int(changeNum))
1332 -
1333 - changes.sort()
1338 + changes = p4ChangesForPaths(self.depotPaths, self.changeRange)
1339
1340 if len(self.maxChanges) > 0:
1341 changes = changes[:min(int(self.maxChanges), len(changes))]