also strip p4/ from local imports.
[gitweb.git] / contrib / fast-import / git-p4
index efec0be32c41a9114dbf83f96ee12ad414e9bd05..88ea12cb37416a51e46e521bb5713f2906f756f0 100755 (executable)
@@ -718,6 +718,11 @@ class P4Sync(Command):
                 text += filedata[j]['data']
                 j += 1
 
+
+            if not stat.has_key('depotFile'):
+                sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
+                continue
+
             contents[stat['depotFile']] = text
 
         for f in files:
@@ -907,10 +912,6 @@ class P4Sync(Command):
             return p [p.strip().rfind("/") + 1:]
 
     def getBranchMapping(self):
-
-        ## FIXME - what's a P4 projectName ?
-        self.projectName = self.guessProjectName()
-
         for info in p4CmdList("branches"):
             details = p4Cmd("branch -o %s" % info["branch"])
             viewIdx = 0
@@ -947,9 +948,9 @@ class P4Sync(Command):
             if not line.startswith('p4/') or line == "p4/HEAD":
                 continue
             branch = line
-            if self.importIntoRemotes:
-                # strip off p4
-                branch = re.sub ("^p4/", "", line)
+
+            # strip off p4
+            branch = re.sub ("^p4/", "", line)
 
             self.p4BranchesInGit.append(branch)
             self.initialParents[self.refPrefix + branch] = parseRevision(line)
@@ -1141,7 +1142,11 @@ class P4Sync(Command):
             self.getLabels();
 
         if self.detectBranches:
-            self.getBranchMapping();
+            ## FIXME - what's a P4 projectName ?
+            self.projectName = self.guessProjectName()
+
+            if not self.hasOrigin:
+                self.getBranchMapping();
             if self.verbose:
                 print "p4-git branches: %s" % self.p4BranchesInGit
                 print "initial parents: %s" % self.initialParents