git-p4: Cleanup, make listExistingP4Branches a global function for later use.
Signed-off-by: Simon Hausmann <simon@lst.de> Signed-off-by: Marius Storm-Olsen <marius@trolltech.com>
Simon Hausmann committed
Jul 18, 2007 at 10:56 UTC
062410bb9d6553e6bc4f8fa7f0cab1ed63b75628
1 file changed
+23
contrib/fast-import/git-p4
+23
@@ -181,6 +181,29 @@ def gitBranchExists(branch):
181
def gitConfig(key):
182
return read_pipe("git config %s" % key, ignore_error=True).strip()
183
184
+def p4BranchesInGit(branchesAreInRemotes = True):
185
+ branches = {}
186
+
187
+ cmdline = "git rev-parse --symbolic "
188
+ if branchesAreInRemotes:
189
+ cmdline += " --remotes"
190
+ else:
191
+ cmdline += " --branches"
192
+
193
+ for line in read_pipe_lines(cmdline):
194
+ line = line.strip()
195
+
196
+ ## only import to p4/
197
+ if not line.startswith('p4/') or line == "p4/HEAD":
198
+ continue
199
+ branch = line
200
+
201
+ # strip off p4
202
+ branch = re.sub ("^p4/", "", line)
203
+
204
+ branches[branch] = parseRevision(line)
205
+ return branches
206
+
207
def findUpstreamBranchPoint(head = "HEAD"):
208
settings = None
209
branchPoint = ""