Merge branch 'maint'
[gitweb.git] / contrib / fast-import / git-p4
index a65f53a47b92da7c3cdd5c477c3e2ce252e6f4ca..1f5a56ee7ffcedb854d84023fdf61570dcffe67e 100755 (executable)
@@ -901,7 +901,8 @@ class P4Sync(Command):
                            % (labelDetails["label"], change))
 
     def getUserCacheFilename(self):
-        return os.environ["HOME"] + "/.gitp4-usercache.txt"
+        home = os.environ.get("HOME", os.environ.get("USERPROFILE"))
+        return home + "/.gitp4-usercache.txt"
 
     def getUserMapFromPerforceServer(self):
         if self.userMapFromPerforceServer:
@@ -1006,27 +1007,11 @@ class P4Sync(Command):
             self.knownBranches[branch] = branch
 
     def listExistingP4GitBranches(self):
-        self.p4BranchesInGit = []
-
-        cmdline = "git rev-parse --symbolic "
-        if self.importIntoRemotes:
-            cmdline += " --remotes"
-        else:
-            cmdline += " --branches"
-
-        for line in read_pipe_lines(cmdline):
-            line = line.strip()
-
-            ## only import to p4/
-            if not line.startswith('p4/') or line == "p4/HEAD":
-                continue
-            branch = line
-
-            # strip off p4
-            branch = re.sub ("^p4/", "", line)
-
-            self.p4BranchesInGit.append(branch)
-            self.initialParents[self.refPrefix + branch] = parseRevision(line)
+        # branches holds mapping from name to commit
+        branches = p4BranchesInGit(self.importIntoRemotes)
+        self.p4BranchesInGit = branches.keys()
+        for branch in branches.keys():
+            self.initialParents[self.refPrefix + branch] = branches[branch]
 
     def createOrUpdateBranchesFromOrigin(self):
         if not self.silent: