Mercurial > python-hglib
annotate hglib/__init__.py @ 138:a05cdc1579df 1.5
context: handle tip+1 breakage in pre-3.2 default branch
Asking for rev(tip+1) could give a null changeset, which broke tests.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 01 Nov 2014 14:28:56 -0500 |
parents | 1b47146a4a2c |
children | c1b966866ed7 |
rev | line source |
---|---|
60 | 1 import client, subprocess, util, error |
2
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
2 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
3 HGPATH = 'hg' |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
4 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
5 def open(path=None, encoding=None, configs=None): |
134 | 6 '''starts a cmdserver for the given path (or for a repository found |
7 in the cwd). HGENCODING is set to the given encoding. configs is a | |
8 list of key, value, similar to those passed to hg --config. | |
9 ''' | |
59 | 10 return client.hgclient(path, encoding, configs) |
60 | 11 |
12 def init(dest=None, ssh=None, remotecmd=None, insecure=False, | |
13 encoding=None, configs=None): | |
14 args = util.cmdbuilder('init', dest, e=ssh, remotecmd=remotecmd, | |
15 insecure=insecure) | |
16 | |
17 args.insert(0, HGPATH) | |
72 | 18 proc = util.popen(args) |
60 | 19 out, err = proc.communicate() |
20 if proc.returncode: | |
21 raise error.CommandError(args, proc.returncode, out, err) | |
22 | |
92
07efbd3bd09a
hglib: change init to not open a command server instance automatically
Idan Kamara <idankk86@gmail.com>
parents:
72
diff
changeset
|
23 return client.hgclient(dest, encoding, configs, connect=False) |
93
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
24 |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
25 def clone(source=None, dest=None, noupdate=False, updaterev=None, rev=None, |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
26 branch=None, pull=False, uncompressed=False, ssh=None, remotecmd=None, |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
27 insecure=False, encoding=None, configs=None): |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
28 args = util.cmdbuilder('clone', source, dest, noupdate=noupdate, |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
29 updaterev=updaterev, rev=rev, branch=branch, |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
30 pull=pull, uncompresses=uncompressed, |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
31 e=ssh, remotecmd=remotecmd, insecure=insecure) |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
32 |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
33 args.insert(0, HGPATH) |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
34 proc = util.popen(args) |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
35 out, err = proc.communicate() |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
36 if proc.returncode: |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
37 raise error.CommandError(args, proc.returncode, out, err) |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
38 |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
39 return client.hgclient(dest, encoding, configs, connect=False) |