Mercurial > mozilla > hg > MozillaHg
view mozillahg/api.py @ 1:da64ea951cd8 default tip
notes to self
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 24 Mar 2013 00:44:33 -0700 |
parents | 1855ba0b873a |
children |
line wrap: on
line source
""" mercurial front end API using hg CLI """ import subprocess from subprocess import check_output as call class Hg(object): """front end to mercurial using subprocess""" def __init__(self, path, hg=None): self.hg = hg or 'hg' self.path = path def __call__(self, *args): call([self.hg] + list(args)) def commits(self, start, finish=None): """ list all commits in a range: [start..finish] if `finish` is omitted, tip is used """ output = self("log", "", "--template", "{rev}\n") return [line.strip() for line in output.strip().splitlines()] def clone(self): """clone a repo""" # TODO: how does this fit in with path? # probably ideally anything this class does can operate locally # or remotely (using a local clone for staging when needed) # TODO: # fill out .hgrc files default-push