0
|
1 """
|
|
2 mercurial front end API using hg CLI
|
|
3 """
|
|
4
|
|
5 import subprocess
|
|
6 from subprocess import check_output as call
|
|
7
|
|
8 class Hg(object):
|
1
|
9 """front end to mercurial using subprocess"""
|
|
10
|
0
|
11 def __init__(self, path, hg=None):
|
|
12 self.hg = hg or 'hg'
|
|
13 self.path = path
|
|
14
|
|
15 def __call__(self, *args):
|
|
16 call([self.hg] + list(args))
|
|
17
|
|
18 def commits(self, start, finish=None):
|
|
19 """
|
|
20 list all commits in a range: [start..finish]
|
|
21 if `finish` is omitted, tip is used
|
|
22 """
|
|
23
|
|
24 output = self("log", "", "--template", "{rev}\n")
|
1
|
25 return [line.strip() for line in output.strip().splitlines()]
|
|
26
|
|
27 def clone(self):
|
|
28 """clone a repo"""
|
|
29
|
|
30 # TODO: how does this fit in with path?
|
|
31 # probably ideally anything this class does can operate locally
|
|
32 # or remotely (using a local clone for staging when needed)
|
|
33
|
|
34 # TODO:
|
|
35 # fill out .hgrc files default-push
|