summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Hausmann <simon@lst.de>2007-08-26 13:56:36 (GMT)
committerSimon Hausmann <simon@lst.de>2007-09-03 18:34:32 (GMT)
commit4f6432d8cc6ebdcdc366cf67ab39e8125c449d80 (patch)
tree950f2ed02f534e3065cd4b5932d1c995379b775b
parent14594f4b5747e51b051f647f6430089e6664e77d (diff)
downloadgit-4f6432d8cc6ebdcdc366cf67ab39e8125c449d80.zip
git-4f6432d8cc6ebdcdc366cf67ab39e8125c449d80.tar.gz
git-4f6432d8cc6ebdcdc366cf67ab39e8125c449d80.tar.bz2
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>
-rwxr-xr-xcontrib/fast-import/git-p423
1 files changed, 14 insertions, 9 deletions
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 16e0a7b..e9feb74 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -281,6 +281,19 @@ def createOrUpdateBranchesFromOrigin(localRefPrefix = "refs/remotes/p4/", silent
def originP4BranchesExist():
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:
def __init__(self):
self.usage = "usage: %prog [options]"
@@ -1322,15 +1335,7 @@ class P4Sync(Command):
if self.verbose:
print "Getting p4 changes for %s...%s" % (', '.join(self.depotPaths),
self.changeRange)
- assert self.depotPaths
- 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()
+ changes = p4ChangesForPaths(self.depotPaths, self.changeRange)
if len(self.maxChanges) > 0:
changes = changes[:min(int(self.maxChanges), len(changes))]