Files
tubestation/python/mozversioncontrol/mozversioncontrol/repoupdate.py
Gregory Szorc 96c0ce82ef Bug 1033656 - Add reviewboard to mach mercurial-setup; version checking; r=smacleod
We want to make it turnkey for people to use reviewboard. So, we add
reviewboard and related functionality to |mach mercurial-setup|.

Since the reviewboard extension only works in Mercurial 3.0 and newer,
we add some version detection for the Mercurial version. This should
have been done months ago. We now have it.

I also took the opportunity to inform |mach bootstrap| that Mercurial
2.x is no longer modern.

I also updated the messaging around mq to encourage fewer new users to
use it. You may find this controversial. People can always ignore the
message.

Finally, I also added a histedit prompt to the mix, since a lot of
people don't know about that and many find it useful.

I could have broken this into multiple patches. Meh.
2014-07-02 14:05:42 -07:00

39 lines
1.3 KiB
Python

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this,
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import unicode_literals
import os
import subprocess
# The logic here is far from robust. Improvements are welcome.
def update_mercurial_repo(hg, repo, path, revision='default',
hostfingerprints=None):
"""Ensure a HG repository exists at a path and is up to date."""
hostfingerprints = hostfingerprints or {}
args = [hg]
for host, fingerprint in sorted(hostfingerprints.items()):
args.extend(['--config', 'hostfingerprints.%s=%s' % (host,
fingerprint)])
if os.path.exists(path):
subprocess.check_call(args + ['pull', repo], cwd=path)
else:
subprocess.check_call(args + ['clone', repo, path])
subprocess.check_call([hg, 'update', '-r', revision], cwd=path)
def update_git_repo(git, repo, path, revision='origin/master'):
"""Ensure a Git repository exists at a path and is up to date."""
if os.path.exists(path):
subprocess.check_call([git, 'fetch', '--all'], cwd=path)
else:
subprocess.check_call([git, 'clone', repo, path])
subprocess.check_call([git, 'checkout', revision], cwd=path)