minor cleanups
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
This commit is contained in:
parent
bce4c5fc0b
commit
6754a299d8
@ -30,6 +30,7 @@ def write_pipe(c, str):
|
|||||||
return val
|
return val
|
||||||
|
|
||||||
def read_pipe(c):
|
def read_pipe(c):
|
||||||
|
if not silent:
|
||||||
sys.stderr.write('reading pipe: %s\n' % c)
|
sys.stderr.write('reading pipe: %s\n' % c)
|
||||||
## todo: check return status
|
## todo: check return status
|
||||||
pipe = os.popen(c, 'rb')
|
pipe = os.popen(c, 'rb')
|
||||||
@ -42,6 +43,7 @@ def read_pipe(c):
|
|||||||
|
|
||||||
|
|
||||||
def read_pipe_lines(c):
|
def read_pipe_lines(c):
|
||||||
|
if not silent:
|
||||||
sys.stderr.write('reading pipe: %s\n' % c)
|
sys.stderr.write('reading pipe: %s\n' % c)
|
||||||
## todo: check return status
|
## todo: check return status
|
||||||
pipe = os.popen(c, 'rb')
|
pipe = os.popen(c, 'rb')
|
||||||
@ -52,6 +54,14 @@ def read_pipe_lines(c):
|
|||||||
|
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
def system(cmd):
|
||||||
|
if not silent:
|
||||||
|
sys.stderr.write("executing %s" % cmd)
|
||||||
|
if os.system(cmd) != 0:
|
||||||
|
die("command failed: %s" % cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def p4CmdList(cmd):
|
def p4CmdList(cmd):
|
||||||
cmd = "p4 -G %s" % cmd
|
cmd = "p4 -G %s" % cmd
|
||||||
pipe = os.popen(cmd, "rb")
|
pipe = os.popen(cmd, "rb")
|
||||||
@ -111,10 +121,6 @@ def isValidGitDir(path):
|
|||||||
def parseRevision(ref):
|
def parseRevision(ref):
|
||||||
return read_pipe("git rev-parse %s" % ref)[:-1]
|
return read_pipe("git rev-parse %s" % ref)[:-1]
|
||||||
|
|
||||||
def system(cmd):
|
|
||||||
if os.system(cmd) != 0:
|
|
||||||
die("command failed: %s" % cmd)
|
|
||||||
|
|
||||||
def extractLogMessageFromGitCommit(commit):
|
def extractLogMessageFromGitCommit(commit):
|
||||||
logMessage = ""
|
logMessage = ""
|
||||||
|
|
||||||
@ -571,7 +577,6 @@ class P4Sync(Command):
|
|||||||
(a ... is not needed in the path p4 specification, it's added implicitly)"""
|
(a ... is not needed in the path p4 specification, it's added implicitly)"""
|
||||||
|
|
||||||
self.usage += " //depot/path[@revRange]"
|
self.usage += " //depot/path[@revRange]"
|
||||||
|
|
||||||
self.silent = False
|
self.silent = False
|
||||||
self.createdBranches = Set()
|
self.createdBranches = Set()
|
||||||
self.committedChanges = Set()
|
self.committedChanges = Set()
|
||||||
@ -584,6 +589,7 @@ class P4Sync(Command):
|
|||||||
self.importIntoRemotes = True
|
self.importIntoRemotes = True
|
||||||
self.maxChanges = ""
|
self.maxChanges = ""
|
||||||
self.isWindows = (platform.system() == "Windows")
|
self.isWindows = (platform.system() == "Windows")
|
||||||
|
self.depotPath = None
|
||||||
|
|
||||||
if gitConfig("git-p4.syncFromOrigin") == "false":
|
if gitConfig("git-p4.syncFromOrigin") == "false":
|
||||||
self.syncWithOrigin = False
|
self.syncWithOrigin = False
|
||||||
@ -611,9 +617,11 @@ class P4Sync(Command):
|
|||||||
fnum = fnum + 1
|
fnum = fnum + 1
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
def stripRepoPath(self, path):
|
||||||
|
return path[len(self.depotPath):]
|
||||||
|
|
||||||
def splitFilesIntoBranches(self, commit):
|
def splitFilesIntoBranches(self, commit):
|
||||||
branches = {}
|
branches = {}
|
||||||
|
|
||||||
fnum = 0
|
fnum = 0
|
||||||
while commit.has_key("depotFile%s" % fnum):
|
while commit.has_key("depotFile%s" % fnum):
|
||||||
path = commit["depotFile%s" % fnum]
|
path = commit["depotFile%s" % fnum]
|
||||||
@ -630,10 +638,12 @@ class P4Sync(Command):
|
|||||||
file["type"] = commit["type%s" % fnum]
|
file["type"] = commit["type%s" % fnum]
|
||||||
fnum = fnum + 1
|
fnum = fnum + 1
|
||||||
|
|
||||||
relPath = path[len(self.depotPath):]
|
relPath = self.stripRepoPath(path)
|
||||||
|
|
||||||
for branch in self.knownBranches.keys():
|
for branch in self.knownBranches.keys():
|
||||||
if relPath.startswith(branch + "/"): # add a trailing slash so that a commit into qt/4.2foo doesn't end up in qt/4.2
|
|
||||||
|
# add a trailing slash so that a commit into qt/4.2foo doesn't end up in qt/4.2
|
||||||
|
if relPath.startswith(branch + "/"):
|
||||||
if branch not in branches:
|
if branch not in branches:
|
||||||
branches[branch] = []
|
branches[branch] = []
|
||||||
branches[branch].append(file)
|
branches[branch].append(file)
|
||||||
|
Loading…
Reference in New Issue
Block a user