Browse Source

Moved the code from git-p4 submit to figure out the upstream branch point

into a separate helper method.

Signed-off-by: Simon Hausmann <shausman@trolltech.com>
maint
Simon Hausmann 18 years ago
parent
commit
27d2d8119b
  1. 45
      contrib/fast-import/git-p4

45
contrib/fast-import/git-p4

@ -168,6 +168,28 @@ def gitBranchExists(branch):
def gitConfig(key): def gitConfig(key):
return read_pipe("git config %s" % key, ignore_error=True).strip() return read_pipe("git config %s" % key, ignore_error=True).strip()


def findUpstreamBranchPoint():
settings = None
branchPoint = ""
parent = 0
while parent < 65535:
commit = "HEAD~%s" % parent
log = extractLogMessageFromGitCommit(commit)
settings = extractSettingsGitLog(log)
if not settings.has_key("depot-paths"):
parent = parent + 1
continue

names = read_pipe_lines("git name-rev '--refs=refs/remotes/p4/*' '%s'" % commit)
if len(names) <= 0:
continue

# strip away the beginning of 'HEAD~42 refs/remotes/p4/foo'
branchPoint = names[0].strip()[len(commit) + 1:]
break

return [branchPoint, settings]

class Command: class Command:
def __init__(self): def __init__(self):
self.usage = "usage: %prog [options]" self.usage = "usage: %prog [options]"
@ -494,25 +516,10 @@ class P4Submit(Command):
else: else:
return False return False


depotPath = "" [upstream, settings] = findUpstreamBranchPoint()
parent = 0 depotPath = settings['depot-paths'][0]
while parent < 65535: if len(self.origin) == 0:
commit = "HEAD~%s" % parent self.origin = upstream
log = extractLogMessageFromGitCommit(commit)
settings = extractSettingsGitLog(log)
if not settings.has_key("depot-paths"):
parent = parent + 1
continue

depotPath = settings['depot-paths'][0]

if len(self.origin) == 0:
names = read_pipe_lines("git name-rev '--refs=refs/remotes/p4/*' '%s'" % commit)
if len(names) > 0:
# strip away the beginning of 'HEAD~42 refs/remotes/p4/foo'
self.origin = names[0].strip()[len(commit) + 1:]

break


if self.verbose: if self.verbose:
print "Origin branch is " + self.origin print "Origin branch is " + self.origin

Loading…
Cancel
Save