Bug 1364588 - part 4 - compute the firefox checkout root; r=rillian

We'll need this information to be able to locate mach later, since we
can't assume that mach is just several directories above the script
we're currently running.
This commit is contained in:
Nathan Froyd 2017-05-26 16:07:01 -04:00
parent 9c82ef3194
commit 05acc3e2cb

View File

@ -278,8 +278,9 @@ class Bootstrapper(object):
state_dir_available = os.path.exists(state_dir)
checkout_type = current_firefox_checkout(check_output=self.instance.check_output,
hg=self.instance.which('hg'))
r = current_firefox_checkout(check_output=self.instance.check_output,
hg=self.instance.which('hg'))
(checkout_type, checkout_root) = r
# Possibly configure Mercurial, but not if the current checkout is Git.
# TODO offer to configure Git.
@ -307,6 +308,7 @@ class Bootstrapper(object):
if dest:
dest = os.path.expanduser(dest)
have_clone = clone_firefox(self.instance.which('hg'), dest)
checkout_root = dest
if not have_clone:
print(SOURCE_ADVERTISE)
@ -476,7 +478,7 @@ def current_firefox_checkout(check_output, hg=None):
try:
node = check_output([hg, 'log', '-r', '0', '--template', '{node}'], cwd=path)
if node in HG_ROOT_REVISIONS:
return 'hg'
return ('hg', path)
# Else the root revision is different. There could be nested
# repos. So keep traversing the parents.
except subprocess.CalledProcessError:
@ -485,10 +487,10 @@ def current_firefox_checkout(check_output, hg=None):
# TODO check git remotes or `git rev-parse -q --verify $sha1^{commit}`
# for signs of Firefox.
elif os.path.exists(git_dir):
return 'git'
return ('git', path)
path, child = os.path.split(path)
if child == '':
break
return None
return (None, None)