More cleanups and speedups for labels and branches
Signed-off-by: Simon Hausmann <shausman@trolltech.com>
This commit is contained in:
@ -461,17 +461,32 @@ class P4Sync(Command):
|
|||||||
fnum = fnum + 1
|
fnum = fnum + 1
|
||||||
return files
|
return files
|
||||||
|
|
||||||
def splitFilesIntoBranches(self, files):
|
def splitFilesIntoBranches(self, commit):
|
||||||
branches = {}
|
branches = {}
|
||||||
|
|
||||||
for file in files:
|
fnum = 0
|
||||||
path = file["path"][len(self.depotPath):]
|
while commit.has_key("depotFile%s" % fnum):
|
||||||
|
path = commit["depotFile%s" % fnum]
|
||||||
|
if not path.startswith(self.depotPath):
|
||||||
|
# if not self.silent:
|
||||||
|
# print "\nchanged files: ignoring path %s outside of %s in change %s" % (path, self.depotPath, change)
|
||||||
|
fnum = fnum + 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
file = {}
|
||||||
|
file["path"] = path
|
||||||
|
file["rev"] = commit["rev%s" % fnum]
|
||||||
|
file["action"] = commit["action%s" % fnum]
|
||||||
|
file["type"] = commit["type%s" % fnum]
|
||||||
|
fnum = fnum + 1
|
||||||
|
|
||||||
|
relPath = path[len(self.depotPath):]
|
||||||
|
|
||||||
for branch in self.knownBranches.keys():
|
for branch in self.knownBranches.keys():
|
||||||
if path.startswith(branch):
|
if relPath.startswith(branch):
|
||||||
if branch not in branches:
|
if branch not in branches:
|
||||||
branches[branch] = []
|
branches[branch] = []
|
||||||
branches[branch].append(file["path"])
|
branches[branch].append(file)
|
||||||
|
|
||||||
return branches
|
return branches
|
||||||
|
|
||||||
@ -542,6 +557,8 @@ class P4Sync(Command):
|
|||||||
label = self.labels[change]
|
label = self.labels[change]
|
||||||
labelDetails = label[0]
|
labelDetails = label[0]
|
||||||
labelRevisions = label[1]
|
labelRevisions = label[1]
|
||||||
|
if self.verbose:
|
||||||
|
print "Change %s is labelled %s" % (change, labelDetails)
|
||||||
|
|
||||||
files = p4CmdList("files %s...@%s" % (branchPrefix, change))
|
files = p4CmdList("files %s...@%s" % (branchPrefix, change))
|
||||||
|
|
||||||
@ -595,13 +612,15 @@ class P4Sync(Command):
|
|||||||
label = output["label"]
|
label = output["label"]
|
||||||
revisions = {}
|
revisions = {}
|
||||||
newestChange = 0
|
newestChange = 0
|
||||||
for file in p4CmdList("files //...@%s" % label):
|
if self.verbose:
|
||||||
|
print "Querying files for label %s" % label
|
||||||
|
for file in p4CmdList("files %s...@%s" % (self.depotPath, label)):
|
||||||
revisions[file["depotFile"]] = file["rev"]
|
revisions[file["depotFile"]] = file["rev"]
|
||||||
change = int(file["change"])
|
change = int(file["change"])
|
||||||
if change > newestChange:
|
if change > newestChange:
|
||||||
newestChange = change
|
newestChange = change
|
||||||
|
|
||||||
self.labels[newestChange] = [output, revisions]
|
self.labels[int(newestChange)] = [output, revisions]
|
||||||
|
|
||||||
def getBranchMapping(self):
|
def getBranchMapping(self):
|
||||||
self.projectName = self.depotPath[self.depotPath[:-1].rfind("/") + 1:]
|
self.projectName = self.depotPath[self.depotPath[:-1].rfind("/") + 1:]
|
||||||
@ -846,9 +865,8 @@ class P4Sync(Command):
|
|||||||
cnt = cnt + 1
|
cnt = cnt + 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
files = self.extractFilesFromCommit(description)
|
|
||||||
if self.detectBranches:
|
if self.detectBranches:
|
||||||
branches = self.splitFilesIntoBranches(files)
|
branches = self.splitFilesIntoBranches(description)
|
||||||
for branch in branches.keys():
|
for branch in branches.keys():
|
||||||
branchPrefix = self.depotPath + branch + "/"
|
branchPrefix = self.depotPath + branch + "/"
|
||||||
|
|
||||||
@ -889,8 +907,9 @@ class P4Sync(Command):
|
|||||||
parent = self.initialParents[branch]
|
parent = self.initialParents[branch]
|
||||||
del self.initialParents[branch]
|
del self.initialParents[branch]
|
||||||
|
|
||||||
self.commit(description, files, branch, branchPrefix, parent)
|
self.commit(description, filesForCommit, branch, branchPrefix, parent)
|
||||||
else:
|
else:
|
||||||
|
files = self.extractFilesFromCommit(description)
|
||||||
self.commit(description, files, self.branch, self.depotPath, self.initialParent)
|
self.commit(description, files, self.branch, self.depotPath, self.initialParent)
|
||||||
self.initialParent = ""
|
self.initialParent = ""
|
||||||
except IOError:
|
except IOError:
|
||||||
|
Reference in New Issue
Block a user