Mercurial > mozilla > hg > MozillaHg
diff mozillahg/api.py @ 0:1855ba0b873a
initial commit
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 22 Jan 2013 21:30:20 -0800 |
parents | |
children | da64ea951cd8 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mozillahg/api.py Tue Jan 22 21:30:20 2013 -0800 @@ -0,0 +1,24 @@ +""" +mercurial front end API using hg CLI +""" + +import subprocess + +from subprocess import check_output as call + +class Hg(object): + 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()