Mercurial > python-hglib
annotate hglib/__init__.py @ 93:a4fcece7dd8e
hglib: add top level clone method
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Thu, 22 Dec 2011 19:12:47 +0200 |
parents | 07efbd3bd09a |
children | 1b47146a4a2c |
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): |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
6 ''' starts a cmdserver for the given path (or for a repository found in the |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
7 cwd). HGENCODING is set to the given encoding. configs is a list of key, value, |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
8 similar to those passed to hg --config. ''' |
59 | 9 return client.hgclient(path, encoding, configs) |
60 | 10 |
11 def init(dest=None, ssh=None, remotecmd=None, insecure=False, | |
12 encoding=None, configs=None): | |
13 args = util.cmdbuilder('init', dest, e=ssh, remotecmd=remotecmd, | |
14 insecure=insecure) | |
15 | |
16 args.insert(0, HGPATH) | |
72 | 17 proc = util.popen(args) |
60 | 18 out, err = proc.communicate() |
19 if proc.returncode: | |
20 raise error.CommandError(args, proc.returncode, out, err) | |
21 | |
92
07efbd3bd09a
hglib: change init to not open a command server instance automatically
Idan Kamara <idankk86@gmail.com>
parents:
72
diff
changeset
|
22 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
|
23 |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
24 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
|
25 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
|
26 insecure=False, encoding=None, configs=None): |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
27 args = util.cmdbuilder('clone', source, dest, noupdate=noupdate, |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
28 updaterev=updaterev, rev=rev, branch=branch, |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
29 pull=pull, uncompresses=uncompressed, |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
30 e=ssh, remotecmd=remotecmd, insecure=insecure) |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
31 |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
32 args.insert(0, HGPATH) |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
33 proc = util.popen(args) |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
34 out, err = proc.communicate() |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
35 if proc.returncode: |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
36 raise error.CommandError(args, proc.returncode, out, err) |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
37 |
a4fcece7dd8e
hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents:
92
diff
changeset
|
38 return client.hgclient(dest, encoding, configs, connect=False) |