mirror of
https://github.com/git/git.git
synced 2024-05-18 05:26:29 +02:00
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>
This commit is contained in:
parent
14594f4b57
commit
4f6432d8cc
|
@ -281,6 +281,19 @@ def createOrUpdateBranchesFromOrigin(localRefPrefix = "refs/remotes/p4/", silent
|
||||||
def originP4BranchesExist():
|
def originP4BranchesExist():
|
||||||
return gitBranchExists("origin") or gitBranchExists("origin/p4") or gitBranchExists("origin/p4/master")
|
return gitBranchExists("origin") or gitBranchExists("origin/p4") or gitBranchExists("origin/p4/master")
|
||||||
|
|
||||||
|
def p4ChangesForPaths(depotPaths, changeRange):
|
||||||
|
assert depotPaths
|
||||||
|
output = read_pipe_lines("p4 changes " + ' '.join (["%s...%s" % (p, changeRange)
|
||||||
|
for p in depotPaths]))
|
||||||
|
|
||||||
|
changes = []
|
||||||
|
for line in output:
|
||||||
|
changeNum = line.split(" ")[1]
|
||||||
|
changes.append(int(changeNum))
|
||||||
|
|
||||||
|
changes.sort()
|
||||||
|
return changes
|
||||||
|
|
||||||
class Command:
|
class Command:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.usage = "usage: %prog [options]"
|
self.usage = "usage: %prog [options]"
|
||||||
|
@ -1322,15 +1335,7 @@ class P4Sync(Command):
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "Getting p4 changes for %s...%s" % (', '.join(self.depotPaths),
|
print "Getting p4 changes for %s...%s" % (', '.join(self.depotPaths),
|
||||||
self.changeRange)
|
self.changeRange)
|
||||||
assert self.depotPaths
|
changes = p4ChangesForPaths(self.depotPaths, self.changeRange)
|
||||||
output = read_pipe_lines("p4 changes " + ' '.join (["%s...%s" % (p, self.changeRange)
|
|
||||||
for p in self.depotPaths]))
|
|
||||||
|
|
||||||
for line in output:
|
|
||||||
changeNum = line.split(" ")[1]
|
|
||||||
changes.append(int(changeNum))
|
|
||||||
|
|
||||||
changes.sort()
|
|
||||||
|
|
||||||
if len(self.maxChanges) > 0:
|
if len(self.maxChanges) > 0:
|
||||||
changes = changes[:min(int(self.maxChanges), len(changes))]
|
changes = changes[:min(int(self.maxChanges), len(changes))]
|
||||||
|
|
Loading…
Reference in New Issue