annotate hglib/__init__.py @ 227:484b56ac4aec default tip

hglib: cat accepts a template argument
author Julien Cristau <jcristau@mozilla.com>
date Mon, 17 Jun 2024 17:17:58 +0200
parents 934608d4fcba
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
148
c1b966866ed7 hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
1 import subprocess
c1b966866ed7 hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
2 from hglib import client, 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
3
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 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
5
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 def open(path=None, encoding=None, configs=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 93
diff changeset
7 '''starts a cmdserver for the given path (or for a repository found
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 93
diff changeset
8 in the cwd). HGENCODING is set to the given encoding. configs is a
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 93
diff changeset
9 list of key, value, similar to those passed to hg --config.
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 93
diff changeset
10 '''
59
f4cc7ff53cf8 hglib: change import style
Idan Kamara <idankk86@gmail.com>
parents: 2
diff changeset
11 return client.hgclient(path, encoding, configs)
60
ce516ed9bc0d hglib: add init command
Idan Kamara <idankk86@gmail.com>
parents: 59
diff changeset
12
ce516ed9bc0d hglib: add init command
Idan Kamara <idankk86@gmail.com>
parents: 59
diff changeset
13 def init(dest=None, ssh=None, remotecmd=None, insecure=False,
ce516ed9bc0d hglib: add init command
Idan Kamara <idankk86@gmail.com>
parents: 59
diff changeset
14 encoding=None, configs=None):
ce516ed9bc0d hglib: add init command
Idan Kamara <idankk86@gmail.com>
parents: 59
diff changeset
15 args = util.cmdbuilder('init', dest, e=ssh, remotecmd=remotecmd,
ce516ed9bc0d hglib: add init command
Idan Kamara <idankk86@gmail.com>
parents: 59
diff changeset
16 insecure=insecure)
ce516ed9bc0d hglib: add init command
Idan Kamara <idankk86@gmail.com>
parents: 59
diff changeset
17
ce516ed9bc0d hglib: add init command
Idan Kamara <idankk86@gmail.com>
parents: 59
diff changeset
18 args.insert(0, HGPATH)
72
15485fa4b35e util: introduce popen
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
19 proc = util.popen(args)
60
ce516ed9bc0d hglib: add init command
Idan Kamara <idankk86@gmail.com>
parents: 59
diff changeset
20 out, err = proc.communicate()
ce516ed9bc0d hglib: add init command
Idan Kamara <idankk86@gmail.com>
parents: 59
diff changeset
21 if proc.returncode:
ce516ed9bc0d hglib: add init command
Idan Kamara <idankk86@gmail.com>
parents: 59
diff changeset
22 raise error.CommandError(args, proc.returncode, out, err)
ce516ed9bc0d hglib: add init command
Idan Kamara <idankk86@gmail.com>
parents: 59
diff changeset
23
92
07efbd3bd09a hglib: change init to not open a command server instance automatically
Idan Kamara <idankk86@gmail.com>
parents: 72
diff changeset
24 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
25
a4fcece7dd8e hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents: 92
diff changeset
26 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
27 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
28 insecure=False, encoding=None, configs=None):
a4fcece7dd8e hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents: 92
diff changeset
29 args = util.cmdbuilder('clone', source, dest, noupdate=noupdate,
a4fcece7dd8e hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents: 92
diff changeset
30 updaterev=updaterev, rev=rev, branch=branch,
184
820d7c1e470a hglib: fix hg clone --uncompressed option typo (issue5458)
Long Vu <long@tlvu.ca>
parents: 148
diff changeset
31 pull=pull, uncompressed=uncompressed,
93
a4fcece7dd8e hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents: 92
diff changeset
32 e=ssh, remotecmd=remotecmd, insecure=insecure)
a4fcece7dd8e hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents: 92
diff changeset
33
218
934608d4fcba hglib: make sure configs can be passed to clone command
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 184
diff changeset
34 # insert configs at the front so they don't interfere with positional args
934608d4fcba hglib: make sure configs can be passed to clone command
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 184
diff changeset
35 if configs:
934608d4fcba hglib: make sure configs can be passed to clone command
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 184
diff changeset
36 cmdconfigs = []
934608d4fcba hglib: make sure configs can be passed to clone command
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 184
diff changeset
37 for config in configs:
934608d4fcba hglib: make sure configs can be passed to clone command
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 184
diff changeset
38 cmdconfigs.extend(["--config", config])
934608d4fcba hglib: make sure configs can be passed to clone command
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 184
diff changeset
39 args = cmdconfigs + args
934608d4fcba hglib: make sure configs can be passed to clone command
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 184
diff changeset
40
93
a4fcece7dd8e hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents: 92
diff changeset
41 args.insert(0, HGPATH)
a4fcece7dd8e hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents: 92
diff changeset
42 proc = util.popen(args)
a4fcece7dd8e hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents: 92
diff changeset
43 out, err = proc.communicate()
a4fcece7dd8e hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents: 92
diff changeset
44 if proc.returncode:
a4fcece7dd8e hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents: 92
diff changeset
45 raise error.CommandError(args, proc.returncode, out, err)
a4fcece7dd8e hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents: 92
diff changeset
46
a4fcece7dd8e hglib: add top level clone method
Idan Kamara <idankk86@gmail.com>
parents: 92
diff changeset
47 return client.hgclient(dest, encoding, configs, connect=False)