@matheusbsbs / matheus-bagliano / commits / 463e8af655
Fork 0

Clean up code duplication for revision parsing and fix previous commit to not import into remotes/p4 (yet!).

Clean up code duplication for revision parsing and fix previous commit to not import into remotes/p4 (yet!). Signed-off-by: Simon Hausmann <simon@lst.de>

Simon Hausmann committed May 17, 2007 at 09:13 UTC 463e8af65577b1df4495cb08640840234ac80c86
1 file changed +6 -3
contrib/fast-import/git-p4
+6 -3
@@ -69,6 +69,9 @@ def isValidGitDir(path):
69 return True;
70 return False
71
72 +def parseRevision(ref):
73 + return mypopen("git rev-parse %s" % ref).read()[:-1]
74 +
75 def system(cmd):
76 if os.system(cmd) != 0:
77 die("command failed: %s" % cmd)
@@ -865,7 +868,7 @@ class P4Sync(Command):
868 self.previousDepotPath = ""
869
870 if len(self.branch) == 0:
868 - self.branch = "refs/remotes/p4"
871 + self.branch = "p4"
872
873 if len(args) == 0:
874 if not gitBranchExists(self.branch) and gitBranchExists("origin"):
@@ -878,7 +881,7 @@ class P4Sync(Command):
881 p4Change = int(p4Change) + 1
882 self.depotPath = self.previousDepotPath
883 self.changeRange = "@%s,#head" % p4Change
881 - self.initialParent = mypopen("git rev-parse %s" % self.branch).read()[:-1]
884 + self.initialParent = parseRevision(self.branch)
885 if not self.silent:
886 print "Performing incremental import into %s git branch" % self.branch
887
@@ -943,7 +946,7 @@ class P4Sync(Command):
946 endPos = caretIdx
947 self.rev = int(output[tagIdx + 9 : endPos]) + 1
948 self.changeRange = "@%s,#head" % self.rev
946 - self.initialParent = mypopen("git rev-parse %s" % self.branch).read()[:-1]
949 + self.initialParent = parseRevision(self.branch)
950 except:
951 pass
952