index 3d97ce1a247ad31df911975d59aed6add21091ec..f12ad8baffd73b753aa9aec59e278106159d65a3 100755 (executable)
def __init__(self):
Command.__init__(self)
self.options = [
- optparse.make_option("--verbose", dest="verbose", action="store_true")
+ optparse.make_option("--verbose", dest="verbose", action="store_true"),
+ optparse.make_option("--local", dest="rollbackLocalBranches", action="store_true")
]
self.description = "A tool to debug the multi-branch import. Don't use :)"
self.verbose = False
+ self.rollbackLocalBranches = False
def run(self, args):
if len(args) != 1:
return False
maxChange = int(args[0])
- for line in mypopen("git rev-parse --symbolic --remotes").readlines():
- if line.startswith("p4/") and line != "p4/HEAD\n":
- ref = "refs/remotes/" + line[:-1]
+
+ if self.rollbackLocalBranches:
+ refPrefix = "refs/heads/"
+ lines = mypopen("git rev-parse --symbolic --branches").readlines()
+ else:
+ refPrefix = "refs/remotes/"
+ lines = mypopen("git rev-parse --symbolic --remotes").readlines()
+
+ for line in lines:
+ if self.rollbackLocalBranches or (line.startswith("p4/") and line != "p4/HEAD\n"):
+ ref = refPrefix + line[:-1]
log = extractLogMessageFromGitCommit(ref)
depotPath, change = extractDepotPathAndChangeFromGitLog(log)
changed = False
cmdline += " --branches"
for line in mypopen(cmdline).readlines():
- if line.startswith("p4/") and line != "p4/HEAD\n":
+ if self.importIntoRemotes and ((not line.startswith("p4/")) or line == "p4/HEAD\n"):
+ continue
+ if self.importIntoRemotes:
+ # strip off p4
branch = line[3:-1]
- self.p4BranchesInGit.append(branch)
- self.initialParents[self.refPrefix + branch] = parseRevision(line[:-1])
+ else:
+ branch = line[:-1]
+ self.p4BranchesInGit.append(branch)
+ self.initialParents[self.refPrefix + branch] = parseRevision(line[:-1])
def run(self, args):
self.depotPath = ""
if self.importIntoRemotes:
self.refPrefix = "refs/remotes/p4/"
else:
- self.refPrefix = "refs/heads/p4/"
+ self.refPrefix = "refs/heads/"
createP4HeadRef = False;
- if self.syncWithOrigin and gitBranchExists("origin") and gitBranchExists(self.refPrefix + "master") and not self.detectBranches:
+ if self.syncWithOrigin and gitBranchExists("origin") and gitBranchExists(self.refPrefix + "master") and not self.detectBranches and self.importIntoRemotes:
### needs to be ported to multi branch import
print "Syncing with origin first as requested by calling git fetch origin"
self.gitError.close()
if createP4HeadRef:
- system("git symbolic-ref %s/HEAD %s" % (self.refPrefix, self.branch))
+ system("git symbolic-ref %sHEAD %s" % (self.refPrefix, self.branch))
return True