@matheusbsbs / matheus-bagliano / commits / 8f8725314d
Fork 0

cleanup, renamed self.globalPrefix to self.depotPath

Signed-off-by: Simon Hausmann <simon@lst.de>

Simon Hausmann committed May 1, 2007 at 23:23 UTC 8f8725314dbed75dc1e603646ea6a2c630025f6e
1 file changed +40 -40
contrib/fast-import/git-p4
+40 -40
@@ -465,9 +465,9 @@ class P4Sync(Command):
465 fnum = 0
466 while commit.has_key("depotFile%s" % fnum):
467 path = commit["depotFile%s" % fnum]
468 - if not path.startswith(self.globalPrefix):
468 + if not path.startswith(self.depotPath):
469 # if not self.silent:
470 - # print "\nchanged files: ignoring path %s outside of %s in change %s" % (path, self.globalPrefix, change)
470 + # print "\nchanged files: ignoring path %s outside of %s in change %s" % (path, self.depotPath, change)
471 fnum = fnum + 1
472 continue
473
@@ -491,7 +491,7 @@ class P4Sync(Command):
491 branches = Set()
492
493 for file in files:
494 - relativePath = file["path"][len(self.globalPrefix):]
494 + relativePath = file["path"][len(self.depotPath):]
495 # strip off the filename
496 relativePath = relativePath[0:relativePath.rfind("/")]
497
@@ -577,7 +577,7 @@ class P4Sync(Command):
577 sys.exit(1);
578 sourceLog = sourceLog[0]
579
580 - relPath = source[len(self.globalPrefix):]
580 + relPath = source[len(self.depotPath):]
581 # strip off the filename
582 relPath = relPath[0:relPath.rfind("/")]
583
@@ -737,7 +737,7 @@ class P4Sync(Command):
737 sys.exit(1);
738 sourceLog = sourceLog[0]
739
740 - relPath = source[len(self.globalPrefix):]
740 + relPath = source[len(self.depotPath):]
741 # strip off the filename
742 relPath = relPath[0:relPath.rfind("/")]
743
@@ -749,13 +749,13 @@ class P4Sync(Command):
749
750 def changeIsBranchMerge(self, sourceBranch, destinationBranch, change):
751 sourceFiles = {}
752 - for file in p4CmdList("files %s...@%s" % (self.globalPrefix + sourceBranch + "/", change)):
752 + for file in p4CmdList("files %s...@%s" % (self.depotPath + sourceBranch + "/", change)):
753 if file["action"] == "delete":
754 continue
755 sourceFiles[file["depotFile"]] = file
756
757 destinationFiles = {}
758 - for file in p4CmdList("files %s...@%s" % (self.globalPrefix + destinationBranch + "/", change)):
758 + for file in p4CmdList("files %s...@%s" % (self.depotPath + destinationBranch + "/", change)):
759 destinationFiles[file["depotFile"]] = file
760
761 for fileName in sourceFiles.keys():
@@ -822,9 +822,9 @@ class P4Sync(Command):
822 def getLabels(self):
823 self.labels = {}
824
825 - l = p4CmdList("labels %s..." % self.globalPrefix)
825 + l = p4CmdList("labels %s..." % self.depotPath)
826 if len(l) > 0 and not self.silent:
827 - print "Finding files belonging to labels in %s" % self.globalPrefix
827 + print "Finding files belonging to labels in %s" % self.depotPath
828
829 for output in l:
830 label = output["label"]
@@ -839,7 +839,7 @@ class P4Sync(Command):
839 self.labels[newestChange] = [output, revisions]
840
841 def run(self, args):
842 - self.globalPrefix = ""
842 + self.depotPath = ""
843 self.changeRange = ""
844 self.initialParent = ""
845
@@ -855,7 +855,7 @@ class P4Sync(Command):
855 [self.previousDepotPath, p4Change] = extractDepotPathAndChangeFromGitLog(extractLogMessageFromGitCommit(self.branch))
856 if len(self.previousDepotPath) > 0 and len(p4Change) > 0:
857 p4Change = int(p4Change) + 1
858 - self.globalPrefix = self.previousDepotPath
858 + self.depotPath = self.previousDepotPath
859 self.changeRange = "@%s,#head" % p4Change
860 self.initialParent = self.branch
861 self.tagLastChange = False
@@ -864,49 +864,49 @@ class P4Sync(Command):
864
865 self.branch = "refs/heads/" + self.branch
866
867 - if len(self.globalPrefix) == 0:
868 - self.globalPrefix = self.previousDepotPath = os.popen("git repo-config --get p4.depotpath").read()
867 + if len(self.depotPath) == 0:
868 + self.depotPath = self.previousDepotPath = os.popen("git repo-config --get p4.depotpath").read()
869
870 - if len(self.globalPrefix) != 0:
871 - self.globalPrefix = self.globalPrefix[:-1]
870 + if len(self.depotPath) != 0:
871 + self.depotPath = self.depotPath[:-1]
872
873 - if len(args) == 0 and len(self.globalPrefix) != 0:
873 + if len(args) == 0 and len(self.depotPath) != 0:
874 if not self.silent:
875 - print "Depot path: %s" % self.globalPrefix
875 + print "Depot path: %s" % self.depotPath
876 elif len(args) != 1:
877 return False
878 else:
879 - if len(self.globalPrefix) != 0 and self.globalPrefix != args[0]:
880 - print "previous import used depot path %s and now %s was specified. this doesn't work!" % (self.globalPrefix, args[0])
879 + if len(self.depotPath) != 0 and self.depotPath != args[0]:
880 + print "previous import used depot path %s and now %s was specified. this doesn't work!" % (self.depotPath, args[0])
881 sys.exit(1)
882 - self.globalPrefix = args[0]
882 + self.depotPath = args[0]
883
884 self.revision = ""
885 self.users = {}
886 self.lastChange = 0
887 self.initialTag = ""
888
889 - if self.globalPrefix.find("@") != -1:
890 - atIdx = self.globalPrefix.index("@")
891 - self.changeRange = self.globalPrefix[atIdx:]
889 + if self.depotPath.find("@") != -1:
890 + atIdx = self.depotPath.index("@")
891 + self.changeRange = self.depotPath[atIdx:]
892 if self.changeRange == "@all":
893 self.changeRange = ""
894 elif self.changeRange.find(",") == -1:
895 self.revision = self.changeRange
896 self.changeRange = ""
897 - self.globalPrefix = self.globalPrefix[0:atIdx]
898 - elif self.globalPrefix.find("#") != -1:
899 - hashIdx = self.globalPrefix.index("#")
900 - self.revision = self.globalPrefix[hashIdx:]
901 - self.globalPrefix = self.globalPrefix[0:hashIdx]
897 + self.depotPath = self.depotPath[0:atIdx]
898 + elif self.depotPath.find("#") != -1:
899 + hashIdx = self.depotPath.index("#")
900 + self.revision = self.depotPath[hashIdx:]
901 + self.depotPath = self.depotPath[0:hashIdx]
902 elif len(self.previousDepotPath) == 0:
903 self.revision = "#head"
904
905 - if self.globalPrefix.endswith("..."):
906 - self.globalPrefix = self.globalPrefix[:-3]
905 + if self.depotPath.endswith("..."):
906 + self.depotPath = self.depotPath[:-3]
907
908 - if not self.globalPrefix.endswith("/"):
909 - self.globalPrefix += "/"
908 + if not self.depotPath.endswith("/"):
909 + self.depotPath += "/"
910
911 self.getUserMap()
912 self.labels = {}
@@ -939,15 +939,15 @@ class P4Sync(Command):
939 self.gitError = importProcess.childerr
940
941 if len(self.revision) > 0:
942 - print "Doing initial import of %s from revision %s" % (self.globalPrefix, self.revision)
942 + print "Doing initial import of %s from revision %s" % (self.depotPath, self.revision)
943
944 details = { "user" : "git perforce import user", "time" : int(time.time()) }
945 - details["desc"] = "Initial import of %s from the state at revision %s" % (self.globalPrefix, self.revision)
945 + details["desc"] = "Initial import of %s from the state at revision %s" % (self.depotPath, self.revision)
946 details["change"] = self.revision
947 newestRevision = 0
948
949 fileCnt = 0
950 - for info in p4CmdList("files %s...%s" % (self.globalPrefix, self.revision)):
950 + for info in p4CmdList("files %s...%s" % (self.depotPath, self.revision)):
951 change = int(info["change"])
952 if change > newestRevision:
953 newestRevision = change
@@ -965,7 +965,7 @@ class P4Sync(Command):
965 details["change"] = newestRevision
966
967 try:
968 - self.commit(details, self.extractFilesFromCommit(details), self.branch, self.globalPrefix)
968 + self.commit(details, self.extractFilesFromCommit(details), self.branch, self.depotPath)
969 except IOError:
970 print "IO error with git fast-import. Is your git version recent enough?"
971 print self.gitError.read()
@@ -984,7 +984,7 @@ class P4Sync(Command):
984
985 changes.sort()
986 else:
987 - output = os.popen("p4 changes %s...%s" % (self.globalPrefix, self.changeRange)).readlines()
987 + output = os.popen("p4 changes %s...%s" % (self.depotPath, self.changeRange)).readlines()
988
989 for line in output:
990 changeNum = line.split(" ")[1]
@@ -1011,7 +1011,7 @@ class P4Sync(Command):
1011 if self.detectBranches:
1012 for branch in self.branchesForCommit(files):
1013 self.knownBranches.add(branch)
1014 - branchPrefix = self.globalPrefix + branch + "/"
1014 + branchPrefix = self.depotPath + branch + "/"
1015
1016 filesForCommit = self.extractFilesInCommitToBranch(files, branchPrefix)
1017
@@ -1040,7 +1040,7 @@ class P4Sync(Command):
1040 merged = "refs/heads/" + merged
1041 self.commit(description, files, branch, branchPrefix, parent, merged)
1042 else:
1043 - self.commit(description, files, self.branch, self.globalPrefix, self.initialParent)
1043 + self.commit(description, files, self.branch, self.depotPath, self.initialParent)
1044 self.initialParent = ""
1045 except IOError:
1046 print self.gitError.read()
@@ -1059,7 +1059,7 @@ class P4Sync(Command):
1059 self.gitError.close()
1060 importProcess.wait()
1061
1062 - os.popen("git repo-config p4.depotpath %s" % self.globalPrefix).read()
1062 + os.popen("git repo-config p4.depotpath %s" % self.depotPath).read()
1063 if len(self.initialTag) > 0:
1064 os.popen("git tag -d %s" % self.initialTag).read()
1065