python/mozversioncontrol/mozversioncontrol/repoupdate.py

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     1 # This Source Code Form is subject to the terms of the Mozilla Public
     2 # License, v. 2.0. If a copy of the MPL was not distributed with this,
     3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     5 from __future__ import unicode_literals
     7 import os
     8 import subprocess
    11 # The logic here is far from robust. Improvements are welcome.
    13 def update_mercurial_repo(hg, repo, path, revision='default',
    14     hostfingerprints=None):
    15     """Ensure a HG repository exists at a path and is up to date."""
    16     hostfingerprints = hostfingerprints or {}
    18     args = [hg]
    20     for host, fingerprint in sorted(hostfingerprints.items()):
    21         args.extend(['--config', 'hostfingerprints.%s=%s' % (host,
    22             fingerprint)])
    24     if os.path.exists(path):
    25         subprocess.check_call(args + ['pull', repo], cwd=path)
    26     else:
    27         subprocess.check_call(args + ['clone', repo, path])
    29     subprocess.check_call([hg, 'update', '-r', revision], cwd=path)
    32 def update_git_repo(git, repo, path, revision='origin/master'):
    33     """Ensure a Git repository exists at a path and is up to date."""
    34     if os.path.exists(path):
    35         subprocess.check_call([git, 'fetch', '--all'], cwd=path)
    36     else:
    37         subprocess.check_call([git, 'clone', repo, path])
    39     subprocess.check_call([git, 'checkout', revision], cwd=path)

mercurial