return False
maxChange = int(args[0])
- if "p4ExitCode" in p4Cmd("p4 changes -m 1"):
+ if "p4ExitCode" in p4Cmd("changes -m 1"):
die("Problems executing p4");
if self.rollbackLocalBranches:
self.verbose = False
self.importIntoRemotes = True
self.maxChanges = ""
+ self.isWindows = (platform.system() == "Windows")
def p4File(self, depotPath):
return os.popen("p4 print -q \"%s\"" % depotPath, "rb").read()
data = self.p4File(depotPath)
+ if self.isWindows and file["type"].endswith("text"):
+ data = data.replace("\r\n", "\n")
+
self.gitStream.write("M %s inline %s\n" % (mode, relPath))
self.gitStream.write("data %s\n" % len(data))
self.gitStream.write(data)
print "Tag %s does not match with change %s: file count is different." % (labelDetails["label"], change)
def getUserMapFromPerforceServer(self):
+ if self.userMapFromPerforceServer:
+ return
self.users = {}
for output in p4CmdList("users"):
for user in self.users.keys():
cache.write("%s\t%s\n" % (user, self.users[user]))
cache.close();
+ self.userMapFromPerforceServer = True
def loadUserMapFromCache(self):
self.users = {}
+ self.userMapFromPerforceServer = False
try:
cache = open(gitdir + "/p4-usercache.txt", "rb")
lines = cache.readlines()
self.p4BranchesInGit.append(branch)
self.initialParents[self.refPrefix + branch] = parseRevision(line[:-1])
+ def createBranchesFromOrigin(self):
+ if not self.silent:
+ print "Creating branch(es) in %s based on origin branch(es)" % self.refPrefix
+
+ for line in mypopen("git rev-parse --symbolic --remotes"):
+ if (not line.startswith("origin/")) or line.endswith("HEAD\n"):
+ continue
+ headName = line[len("origin/"):-1]
+ remoteHead = self.refPrefix + headName
+ if not os.path.exists(gitdir + "/" + remoteHead):
+ if self.verbose:
+ print "creating %s" % remoteHead
+ system("git update-ref %s origin/%s" % (remoteHead, headName))
+
def run(self, args):
self.depotPath = ""
self.changeRange = ""
# this needs to be called after the conversion from heads/p4 to remotes/p4/master
self.listExistingP4GitBranches()
- if len(self.p4BranchesInGit) > 1 and not self.silent:
- print "Importing from/into multiple branches"
+ if len(self.p4BranchesInGit) > 1:
+ if not self.silent:
+ print "Importing from/into multiple branches"
self.detectBranches = True
if len(args) == 0:
- if not gitBranchExists(self.branch) and gitBranchExists("origin") and not self.detectBranches:
- ### needs to be ported to multi branch import
- if not self.silent:
- print "Creating %s branch in git repository based on origin" % self.branch
- branch = self.branch
- if not branch.startswith("refs"):
- branch = "refs/heads/" + branch
- system("git update-ref %s origin" % branch)
+ if len(self.p4BranchesInGit) == 0:
+ self.createBranchesFromOrigin()
+ self.listExistingP4GitBranches()
+ return True
if self.verbose:
print "branches: %s" % self.p4BranchesInGit