Skip to content

Commit 4f6432d

Browse files
committed
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>
1 parent 14594f4 commit 4f6432d

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

contrib/fast-import/git-p4

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,19 @@ def createOrUpdateBranchesFromOrigin(localRefPrefix = "refs/remotes/p4/", silent
281281
def originP4BranchesExist():
282282
return gitBranchExists("origin") or gitBranchExists("origin/p4") or gitBranchExists("origin/p4/master")
283283

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+
284297
class Command:
285298
def __init__(self):
286299
self.usage = "usage: %prog [options]"
@@ -1322,15 +1335,7 @@ class P4Sync(Command):
13221335
if self.verbose:
13231336
print "Getting p4 changes for %s...%s" % (', '.join(self.depotPaths),
13241337
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)
13341339

13351340
if len(self.maxChanges) > 0:
13361341
changes = changes[:min(int(self.maxChanges), len(changes))]

0 commit comments

Comments
 (0)