annotate hglib/client.py @ 216:68588c652ac6

client: handle commit messages with \0 characters Mercurial allows commit messages containing \0 characters, but hglib does not properly handle them. By using the json template, these characters are correctly escaped. Note: initial change only modifies this for the 'log' command, I'll follow-up for other commands if this is ok.
author Mathias De Mare <mathias.de_mare@nokia.com>
date Wed, 08 Mar 2023 16:22:21 +0100
parents 388820908580
children 2ab42323f149
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
216
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
1 import struct, re, datetime, json
148
c1b966866ed7 hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents: 147
diff changeset
2 import hglib
c1b966866ed7 hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents: 147
diff changeset
3 from hglib import error, util, templates, merge, context
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4
154
11202c85737e hglib: make sure hgclient.diff() works with bytes (issue4520)
Brett Cannon <brett@python.org>
parents: 148
diff changeset
5 from hglib.util import b, cmdbuilder, BytesIO, strtobytes
4
a3a9cf58801f client: use the cmdbuilder
Idan Kamara <idankk86@gmail.com>
parents: 2
diff changeset
6
90
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
7 class revision(tuple):
99
2b36619ec0a0 client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents: 98
diff changeset
8 def __new__(cls, rev, node, tags, branch, author, desc, date):
2b36619ec0a0 client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents: 98
diff changeset
9 return tuple.__new__(cls, (rev, node, tags, branch, author, desc, date))
90
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
10
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
11 @property
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
12 def rev(self):
98
972d069051c5 client: fix indentation
Idan Kamara <idankk86@gmail.com>
parents: 97
diff changeset
13 return self[0]
90
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
14
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
15 @property
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
16 def node(self):
98
972d069051c5 client: fix indentation
Idan Kamara <idankk86@gmail.com>
parents: 97
diff changeset
17 return self[1]
90
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
18
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
19 @property
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
20 def tags(self):
98
972d069051c5 client: fix indentation
Idan Kamara <idankk86@gmail.com>
parents: 97
diff changeset
21 return self[2]
90
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
22
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
23 @property
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
24 def branch(self):
98
972d069051c5 client: fix indentation
Idan Kamara <idankk86@gmail.com>
parents: 97
diff changeset
25 return self[3]
90
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
26
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
27 @property
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
28 def author(self):
98
972d069051c5 client: fix indentation
Idan Kamara <idankk86@gmail.com>
parents: 97
diff changeset
29 return self[4]
90
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
30
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
31 @property
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
32 def desc(self):
98
972d069051c5 client: fix indentation
Idan Kamara <idankk86@gmail.com>
parents: 97
diff changeset
33 return self[5]
90
b894c2222dff client: replace usage of namedtuple for python 2.4 compatibility
Idan Kamara <idankk86@gmail.com>
parents: 89
diff changeset
34
99
2b36619ec0a0 client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents: 98
diff changeset
35 @property
2b36619ec0a0 client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents: 98
diff changeset
36 def date(self):
2b36619ec0a0 client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents: 98
diff changeset
37 return self[6]
2b36619ec0a0 client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents: 98
diff changeset
38
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
39 class hgclient(object):
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
40 inputfmt = '>I'
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
41 outputfmt = '>cI'
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
42 outputfmtsize = struct.calcsize(outputfmt)
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
43 retfmt = '>i'
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
44
91
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
45 def __init__(self, path, encoding, configs, connect=True):
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
46 self._args = [hglib.HGPATH, 'serve', '--cmdserver', 'pipe',
44
3a661f63107e client: tell the server we're interactive
Idan Kamara <idankk86@gmail.com>
parents: 43
diff changeset
47 '--config', 'ui.interactive=True']
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
48 if path:
194
22767a1e61ac client: make it robust for weird repository path
Yuya Nishihara <yuya@tcha.org>
parents: 192
diff changeset
49 # perhaps path shouldn't be a unicode string, but accepted for
22767a1e61ac client: make it robust for weird repository path
Yuya Nishihara <yuya@tcha.org>
parents: 192
diff changeset
50 # backward compatibility.
22767a1e61ac client: make it robust for weird repository path
Yuya Nishihara <yuya@tcha.org>
parents: 192
diff changeset
51 if isinstance(path, str):
22767a1e61ac client: make it robust for weird repository path
Yuya Nishihara <yuya@tcha.org>
parents: 192
diff changeset
52 # py2: bytes + bytes, py3: unicode + unicode
22767a1e61ac client: make it robust for weird repository path
Yuya Nishihara <yuya@tcha.org>
parents: 192
diff changeset
53 self._args += ['-R' + path]
22767a1e61ac client: make it robust for weird repository path
Yuya Nishihara <yuya@tcha.org>
parents: 192
diff changeset
54 else:
22767a1e61ac client: make it robust for weird repository path
Yuya Nishihara <yuya@tcha.org>
parents: 192
diff changeset
55 # py2: (ascii) bytes + unicode, py3: bytes + bytes
22767a1e61ac client: make it robust for weird repository path
Yuya Nishihara <yuya@tcha.org>
parents: 192
diff changeset
56 self._args += [b('-R') + path]
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
57 if configs:
194
22767a1e61ac client: make it robust for weird repository path
Yuya Nishihara <yuya@tcha.org>
parents: 192
diff changeset
58 # don't use "--config=<value>" form for hg 1.9 compatibility
132
9ecb271600fc client: fix passing multiple config settings
Julien Cristau <julien.cristau@logilab.fr>
parents: 127
diff changeset
59 for config in configs:
9ecb271600fc client: fix passing multiple config settings
Julien Cristau <julien.cristau@logilab.fr>
parents: 127
diff changeset
60 self._args += ['--config', config]
105
86ff8611a8fa client: always set HGPLAIN=1 (issue3502)
Siddharth Agarwal <sid0@fb.com>
parents: 100
diff changeset
61 self._env = {'HGPLAIN': '1'}
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
62 if encoding:
91
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
63 self._env['HGENCODING'] = encoding
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
64
91
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
65 self.server = None
41
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
66 self._version = None
133
b6f601ba7f3c style: fixup whitespace
Matt Mackall <mpm@selenic.com>
parents: 132
diff changeset
67 # include the hidden changesets if True
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
68 self.hidden = None
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
69
180
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
70 self._cbout = None
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
71 self._cberr = None
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
72 self._cbprompt = None
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
73
91
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
74 if connect:
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
75 self.open()
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
76
179
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
77 self._protocoltracefn = None
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
78
180
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
79 def setcbout(self, cbout):
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
80 """
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
81 cbout is a function that will be called with the stdout data of
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
82 the command as it runs. Call with None to stop getting call backs.
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
83 """
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
84 self._cbout = cbout
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
85
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
86 def setcberr(self, cberr):
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
87 """
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
88 cberr is a function that will be called with the stderr data of
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
89 the command as it runs.Call with None to stop getting call backs.
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
90 """
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
91 self._cberr = cberr
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
92
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
93 def setcbprompt(self, cbprompt):
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
94 """
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
95 cbprompt is used to reply to prompts by the server
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
96 It receives the max number of bytes to return and the
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
97 contents of stdout received so far.
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
98
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
99 Call with None to stop getting call backs.
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
100
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
101 cbprompt is never called from merge() or import_()
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
102 which already handle the prompt.
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
103 """
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
104 self._cbprompt = cbprompt
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
105
179
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
106 def setprotocoltrace(self, tracefn=None):
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
107 """
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
108 if tracefn is None no trace calls will be made.
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
109 Otherwise tracefn is call as tracefn( direction, channel, data )
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
110 direction is 'r' for read from server and 'w' for write to server
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
111 channel is always None when direction is 'w'
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
112 and the channel-identified when the direction is 'r'
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
113 """
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
114 self._protocoltracefn = tracefn
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
115
89
351d2799f145 client: added context manager protocol methods
Jeff Laughlin <jmlaughlin@integrated-informatics.com>
parents: 87
diff changeset
116 def __enter__(self):
127
53387d1e620b client: connect to repo if necessary when using "with" statement
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 125
diff changeset
117 if self.server is None:
53387d1e620b client: connect to repo if necessary when using "with" statement
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 125
diff changeset
118 self.open()
89
351d2799f145 client: added context manager protocol methods
Jeff Laughlin <jmlaughlin@integrated-informatics.com>
parents: 87
diff changeset
119 return self
351d2799f145 client: added context manager protocol methods
Jeff Laughlin <jmlaughlin@integrated-informatics.com>
parents: 87
diff changeset
120
351d2799f145 client: added context manager protocol methods
Jeff Laughlin <jmlaughlin@integrated-informatics.com>
parents: 87
diff changeset
121 def __exit__(self, exc_type, exc_val, exc_tb):
351d2799f145 client: added context manager protocol methods
Jeff Laughlin <jmlaughlin@integrated-informatics.com>
parents: 87
diff changeset
122 self.close()
351d2799f145 client: added context manager protocol methods
Jeff Laughlin <jmlaughlin@integrated-informatics.com>
parents: 87
diff changeset
123
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
124 def _readhello(self):
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
125 """ read the hello message the server sends when started """
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
126 ch, msg = self._readchannel()
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
127 assert ch == b('o')
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
128
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
129 msg = msg.split(b('\n'))
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
130
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
131 self.capabilities = msg[0][len(b('capabilities: ')):]
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
132 if not self.capabilities:
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
133 raise error.ResponseError(
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
134 "bad hello message: expected 'capabilities: '"
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
135 ", got %r" % msg[0])
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
136
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
137 self.capabilities = set(self.capabilities.split())
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
138
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
139 # at the very least the server should be able to run commands
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
140 assert b('runcommand') in self.capabilities
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
141
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
142 self._encoding = msg[1][len(b('encoding: ')):]
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
143 if not self._encoding:
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
144 raise error.ResponseError("bad hello message: expected 'encoding: '"
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
145 ", got %r" % msg[1])
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
146
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
147 def _readchannel(self):
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
148 data = self.server.stdout.read(hgclient.outputfmtsize)
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
149 if not data:
196
c586d02f7cda _readchannel: if a read failure is due to a broken server, report that
Augie Fackler <raf@durin42.com>
parents: 195
diff changeset
150 ret, serr = self._close()
c586d02f7cda _readchannel: if a read failure is due to a broken server, report that
Augie Fackler <raf@durin42.com>
parents: 195
diff changeset
151 if ret != 0:
c586d02f7cda _readchannel: if a read failure is due to a broken server, report that
Augie Fackler <raf@durin42.com>
parents: 195
diff changeset
152 raise error.ServerError('server exited with status %d: %s'
c586d02f7cda _readchannel: if a read failure is due to a broken server, report that
Augie Fackler <raf@durin42.com>
parents: 195
diff changeset
153 % (ret, serr.strip()))
191
6987d6cd420c client: raise ResponseError in _readchannel()
Gábor Stefanik <gabor.stefanik@nng.com>
parents: 190
diff changeset
154 raise error.ResponseError('no response received from server')
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
155 channel, length = struct.unpack(hgclient.outputfmt, data)
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
156 if channel in b('IL'):
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
157 return channel, length
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
158 else:
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
159 return channel, self.server.stdout.read(length)
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
160
100
dd63d69a5ebf client: make _parserevs a static method
Idan Kamara <idankk86@gmail.com>
parents: 99
diff changeset
161 @staticmethod
dd63d69a5ebf client: make _parserevs a static method
Idan Kamara <idankk86@gmail.com>
parents: 99
diff changeset
162 def _parserevs(splitted):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
163 '''splitted is a list of fields according to our rev.style, where
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
164 each 6 fields compose one revision.
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
165 '''
99
2b36619ec0a0 client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents: 98
diff changeset
166 revs = []
2b36619ec0a0 client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents: 98
diff changeset
167 for rev in util.grouper(7, splitted):
2b36619ec0a0 client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents: 98
diff changeset
168 # truncate the timezone and convert to a local datetime
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
169 posixtime = float(rev[6].split(b('.'), 1)[0])
99
2b36619ec0a0 client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents: 98
diff changeset
170 dt = datetime.datetime.fromtimestamp(posixtime)
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
171 revs.append(revision(rev[0], rev[1], rev[2], rev[3],
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
172 rev[4], rev[5], dt))
99
2b36619ec0a0 client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents: 98
diff changeset
173 return revs
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
174
216
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
175 @staticmethod
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
176 def _parsejsonrevs(jsonrevs):
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
177 revs = []
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
178 for rev in jsonrevs:
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
179 # truncate the timezone and convert to a local datetime
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
180 posixtime = float(rev["date"][0])
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
181 dt = datetime.datetime.fromtimestamp(posixtime)
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
182 revs.append(revision(str(rev["rev"]).encode(), rev["node"].encode(),
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
183 ' '.join(rev["tags"]).encode(),
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
184 rev["branch"].encode(), rev["user"].encode(),
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
185 rev["desc"].encode(), dt))
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
186 return revs
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
187
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
188 def runcommand(self, args, inchannels, outchannels):
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
189 def writeblock(data):
179
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
190 if self._protocoltracefn is not None:
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
191 self._protocoltracefn('w', None, data)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
192 self.server.stdin.write(struct.pack(self.inputfmt, len(data)))
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
193 self.server.stdin.write(data)
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
194 self.server.stdin.flush()
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
195
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
196 if not self.server:
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
197 raise ValueError("server not connected")
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
198
201
67398bbf788d client: do not accept NULL character as command arguments
Yuya Nishihara <yuya@tcha.org>
parents: 200
diff changeset
199 if any(b('\0') in a for a in args):
67398bbf788d client: do not accept NULL character as command arguments
Yuya Nishihara <yuya@tcha.org>
parents: 200
diff changeset
200 raise ValueError('null character in command arguments')
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
201 self.server.stdin.write(b('runcommand\n'))
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
202 writeblock(b('\0').join(args))
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
203
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
204 while True:
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
205 channel, data = self._readchannel()
179
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
206 if self._protocoltracefn is not None:
c4c0efb37187 protocol: add the abilty to trace the protocol between the client and server
Barry A. Scott <barry@barrys-emacs.org>
parents: 178
diff changeset
207 self._protocoltracefn('r', channel, data)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
208
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
209 # input channels
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
210 if channel in inchannels:
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
211 writeblock(inchannels[channel](data))
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
212 # output channels
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
213 elif channel in outchannels:
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
214 outchannels[channel](data)
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
215 # result channel, command finished
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
216 elif channel == b('r'):
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
217 return struct.unpack(hgclient.retfmt, data)[0]
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
218 # a channel that we don't know and can't ignore
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
219 elif channel.isupper():
189
8054e925d9c7 client: kill the server on unrecoverable communication errors (issue5516)
Gábor Stefanik <gabor.stefanik@nng.com>
parents: 188
diff changeset
220 self.close()
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
221 raise error.ResponseError(
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
222 "unexpected data on required channel '%s'" % channel)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
223 # optional channel
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
224 else:
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
225 pass
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
226
5
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
227 def rawcommand(self, args, eh=None, prompt=None, input=None):
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
228 """
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
229 args is the cmdline (usually built using util.cmdbuilder)
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
230
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
231 eh is an error handler that is passed the return code, stdout and stderr
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
232 If no eh is given, we raise a CommandError if ret != 0
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
233
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
234 prompt is used to reply to prompts by the server
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
235 It receives the max number of bytes to return and the contents of stdout
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
236 received so far
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
237
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
238 input is used to reply to bulk data requests by the server
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
239 It receives the max number of bytes to return
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
240 """
145
f3c430afa598 hglib: abstract out use of cStringIO.StringIO (issue4520)
Brett Cannon <brett@python.org>
parents: 142
diff changeset
241 out, err = BytesIO(), BytesIO()
180
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
242 outchannels = {}
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
243 if self._cbout is None:
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
244 outchannels[b('o')] = out.write
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
245 else:
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
246 def out_handler(data):
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
247 out.write(data)
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
248 self._cbout(data)
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
249 outchannels[b('o')] = out_handler
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
250 if self._cberr is None:
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
251 outchannels[b('e')] = err.write
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
252 else:
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
253 def err_handler(data):
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
254 err.write(data)
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
255 self._cberr(data)
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
256 outchannels[b('e')] = err_handler
5
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
257
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
258 inchannels = {}
180
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
259 if prompt is None:
ff6efc1ab9e4 protocol: allow hglib user to get call backs for prompts, output and errors
Barry A. Scott <barry@barrys-emacs.org>
parents: 179
diff changeset
260 prompt = self._cbprompt
5
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
261 if prompt is not None:
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
262 def func(size):
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
263 reply = prompt(size, out.getvalue())
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
264 return reply
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
265 inchannels[b('L')] = func
188
5609a21fe39a client: fail gracefully on unexpected prompts (issue5516)
Gábor Stefanik <gabor.stefanik@nng.com>
parents: 187
diff changeset
266 else:
5609a21fe39a client: fail gracefully on unexpected prompts (issue5516)
Gábor Stefanik <gabor.stefanik@nng.com>
parents: 187
diff changeset
267 inchannels[b('L')] = lambda _: ''
5
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
268 if input is not None:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
269 inchannels[b('I')] = input
5
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
270
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
271 ret = self.runcommand(args, inchannels, outchannels)
5
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
272 out, err = out.getvalue(), err.getvalue()
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
273
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
274 if ret:
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
275 if eh is None:
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
276 raise error.CommandError(args, ret, out, err)
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
277 else:
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
278 return eh(ret, out, err)
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
279 return out
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
280
91
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
281 def open(self):
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
282 if self.server is not None:
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
283 raise ValueError('server already open')
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
284
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
285 self.server = util.popen(self._args, self._env)
169
e6589149b2c8 client: include stderr message in ServerError on initial communication failure
Yuya Nishihara <yuya@tcha.org>
parents: 168
diff changeset
286 try:
e6589149b2c8 client: include stderr message in ServerError on initial communication failure
Yuya Nishihara <yuya@tcha.org>
parents: 168
diff changeset
287 self._readhello()
190
f38bc0569671 client: don't swallow ResponseError inside open()
Gábor Stefanik <gabor.stefanik@nng.com>
parents: 189
diff changeset
288 except error.ResponseError:
197
6949fc164439 hgclient: look for an open server before closing it in ResponseError block
Augie Fackler <raf@durin42.com>
parents: 196
diff changeset
289 if self.server is not None:
6949fc164439 hgclient: look for an open server before closing it in ResponseError block
Augie Fackler <raf@durin42.com>
parents: 196
diff changeset
290 self._close()
190
f38bc0569671 client: don't swallow ResponseError inside open()
Gábor Stefanik <gabor.stefanik@nng.com>
parents: 189
diff changeset
291 raise
169
e6589149b2c8 client: include stderr message in ServerError on initial communication failure
Yuya Nishihara <yuya@tcha.org>
parents: 168
diff changeset
292 except error.ServerError:
196
c586d02f7cda _readchannel: if a read failure is due to a broken server, report that
Augie Fackler <raf@durin42.com>
parents: 195
diff changeset
293 if self.server is None:
c586d02f7cda _readchannel: if a read failure is due to a broken server, report that
Augie Fackler <raf@durin42.com>
parents: 195
diff changeset
294 # server is already closed, hopefully the ServerError
c586d02f7cda _readchannel: if a read failure is due to a broken server, report that
Augie Fackler <raf@durin42.com>
parents: 195
diff changeset
295 # we got has enough information.
c586d02f7cda _readchannel: if a read failure is due to a broken server, report that
Augie Fackler <raf@durin42.com>
parents: 195
diff changeset
296 raise
169
e6589149b2c8 client: include stderr message in ServerError on initial communication failure
Yuya Nishihara <yuya@tcha.org>
parents: 168
diff changeset
297 ret, serr = self._close()
e6589149b2c8 client: include stderr message in ServerError on initial communication failure
Yuya Nishihara <yuya@tcha.org>
parents: 168
diff changeset
298 raise error.ServerError('server exited with status %d: %s'
e6589149b2c8 client: include stderr message in ServerError on initial communication failure
Yuya Nishihara <yuya@tcha.org>
parents: 168
diff changeset
299 % (ret, serr.strip()))
91
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
300 return self
0383fc37102b client: refactor opening of the cmd server to an open method
Idan Kamara <idankk86@gmail.com>
parents: 90
diff changeset
301
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
302 def close(self):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
303 """Closes the command server instance and waits for it to exit,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
304 returns the exit code.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
305
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
306 Attempting to call any function afterwards that needs to
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
307 communicate with the server will raise a ValueError.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
308 """
200
7da1dad166b5 client: ignore close() on non-open clients (issue5751)
Gábor Stefanik <gabor.stefanik@nng.com>
parents: 197
diff changeset
309 if not self.server:
7da1dad166b5 client: ignore close() on non-open clients (issue5751)
Gábor Stefanik <gabor.stefanik@nng.com>
parents: 197
diff changeset
310 return 0
168
d71bd813c9d7 client: use subprocess.communicate() to shut down server process
Yuya Nishihara <yuya@tcha.org>
parents: 167
diff changeset
311 return self._close()[0]
167
f22f3ff3cfae client: extract stub to read server's stderr on close()
Yuya Nishihara <yuya@tcha.org>
parents: 154
diff changeset
312
f22f3ff3cfae client: extract stub to read server's stderr on close()
Yuya Nishihara <yuya@tcha.org>
parents: 154
diff changeset
313 def _close(self):
168
d71bd813c9d7 client: use subprocess.communicate() to shut down server process
Yuya Nishihara <yuya@tcha.org>
parents: 167
diff changeset
314 _sout, serr = self.server.communicate()
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
315 ret = self.server.returncode
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
316 self.server = None
168
d71bd813c9d7 client: use subprocess.communicate() to shut down server process
Yuya Nishihara <yuya@tcha.org>
parents: 167
diff changeset
317 return ret, serr
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
318
28
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
319 def add(self, files=[], dryrun=False, subrepos=False, include=None,
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
320 exclude=None):
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
321 """
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
322 Add the specified files on the next commit.
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
323 If no files are given, add all files to the repository.
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
324
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
325 dryrun - do no perform actions
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
326 subrepos - recurse into subrepositories
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
327 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
328 exclude - exclude names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
329
28
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
330 Return whether all given files were added.
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
331 """
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
332 if not isinstance(files, list):
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
333 files = [files]
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
334
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
335 args = cmdbuilder(b('add'), n=dryrun, S=subrepos, I=include, X=exclude,
87
5661d5f7e39b client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents: 79
diff changeset
336 *files)
28
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
337
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
338 eh = util.reterrorhandler(args)
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
339 self.rawcommand(args, eh=eh)
28
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
340
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
341 return bool(eh)
28
221eeb3693f4 client: add add command
Idan Kamara <idankk86@gmail.com>
parents: 27
diff changeset
342
48
82d927ac1329 client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents: 47
diff changeset
343 def addremove(self, files=[], similarity=None, dryrun=False, include=None,
82d927ac1329 client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents: 47
diff changeset
344 exclude=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
345 """Add all new files and remove all missing files from the repository.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
346
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
347 New files are ignored if they match any of the patterns in
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
348 ".hgignore". As with add, these changes take effect at the
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
349 next commit.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
350
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
351 similarity - used to detect renamed files. With a parameter
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
352 greater than 0, this compares every removed file with every
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
353 added file and records those similar enough as renames. This
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
354 option takes a percentage between 0 (disabled) and 100 (files
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
355 must be identical) as its parameter. Detecting renamed files
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
356 this way can be expensive. After using this option, "hg status
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
357 -C" can be used to check which files were identified as moved
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
358 or renamed.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
359
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
360 dryrun - do no perform actions
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
361 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
362 exclude - exclude names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
363
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
364 Return True if all files are successfully added.
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
365
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
366 """
48
82d927ac1329 client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents: 47
diff changeset
367 if not isinstance(files, list):
82d927ac1329 client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents: 47
diff changeset
368 files = [files]
82d927ac1329 client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents: 47
diff changeset
369
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
370 args = cmdbuilder(b('addremove'), s=similarity, n=dryrun, I=include,
87
5661d5f7e39b client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents: 79
diff changeset
371 X=exclude, *files)
48
82d927ac1329 client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents: 47
diff changeset
372
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
373 eh = util.reterrorhandler(args)
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
374 self.rawcommand(args, eh=eh)
48
82d927ac1329 client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents: 47
diff changeset
375
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
376 return bool(eh)
48
82d927ac1329 client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents: 47
diff changeset
377
52
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
378 def annotate(self, files, rev=None, nofollow=False, text=False, user=False,
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
379 file=False, date=False, number=False, changeset=False,
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
380 line=False, verbose=False, include=None, exclude=None):
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
381 """
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
382 Show changeset information by line for each file in files.
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
383
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
384 rev - annotate the specified revision
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
385 nofollow - don't follow copies and renames
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
386 text - treat all files as text
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
387 user - list the author (long with -v)
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
388 file - list the filename
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
389 date - list the date
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
390 number - list the revision number (default)
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
391 changeset - list the changeset
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
392 line - show line number at the first appearance
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
393 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
394 exclude - exclude names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
395
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
396 Yields a (info, contents) tuple for each line in a file. Info is a space
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
397 separated string according to the given options.
52
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
398 """
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
399 if not isinstance(files, list):
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
400 files = [files]
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
401
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
402 args = cmdbuilder(b('annotate'), r=rev, no_follow=nofollow, a=text,
87
5661d5f7e39b client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents: 79
diff changeset
403 u=user, f=file, d=date, n=number, c=changeset,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
404 l=line, v=verbose, I=include, X=exclude,
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
405 hidden=self.hidden, *files)
52
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
406
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
407 out = self.rawcommand(args)
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
408
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
409 for line in out.splitlines():
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
410 yield tuple(line.split(b(': '), 1))
52
18f72b255553 client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
411
53
066dfa5c0b70 client: add archive command
Idan Kamara <idankk86@gmail.com>
parents: 52
diff changeset
412 def archive(self, dest, rev=None, nodecode=False, prefix=None, type=None,
066dfa5c0b70 client: add archive command
Idan Kamara <idankk86@gmail.com>
parents: 52
diff changeset
413 subrepos=False, include=None, exclude=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
414 """Create an unversioned archive of a repository revision.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
415
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
416 The exact name of the destination archive or directory is given using a
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
417 format string; see export for details.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
418
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
419 Each member added to an archive file has a directory prefix
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
420 prepended. Use prefix to specify a format string for the
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
421 prefix. The default is the basename of the archive, with
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
422 suffixes removed.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
423
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
424 dest - destination path
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
425 rev - revision to distribute. The revision used is the parent of the
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
426 working directory if one isn't given.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
427
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
428 nodecode - do not pass files through decoders
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
429 prefix - directory prefix for files in archive
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
430 type - type of distribution to create. The archive type is automatically
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
431 detected based on file extension if one isn't given.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
432
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
433 Valid types are:
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
434
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
435 "files" a directory full of files (default)
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
436 "tar" tar archive, uncompressed
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
437 "tbz2" tar archive, compressed using bzip2
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
438 "tgz" tar archive, compressed using gzip
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
439 "uzip" zip archive, uncompressed
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
440 "zip" zip archive, compressed using deflate
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
441
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
442 subrepos - recurse into subrepositories
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
443 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
444 exclude - exclude names matching the given patterns
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
445
53
066dfa5c0b70 client: add archive command
Idan Kamara <idankk86@gmail.com>
parents: 52
diff changeset
446 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
447 args = cmdbuilder(b('archive'), dest, r=rev,
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
448 no_decode=nodecode, p=prefix,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
449 t=type, S=subrepos, I=include, X=exclude,
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
450 hidden=self.hidden)
53
066dfa5c0b70 client: add archive command
Idan Kamara <idankk86@gmail.com>
parents: 52
diff changeset
451
066dfa5c0b70 client: add archive command
Idan Kamara <idankk86@gmail.com>
parents: 52
diff changeset
452 self.rawcommand(args)
066dfa5c0b70 client: add archive command
Idan Kamara <idankk86@gmail.com>
parents: 52
diff changeset
453
22
297df22d6091 client: add backout command
Idan Kamara <idankk86@gmail.com>
parents: 21
diff changeset
454 def backout(self, rev, merge=False, parent=None, tool=None, message=None,
297df22d6091 client: add backout command
Idan Kamara <idankk86@gmail.com>
parents: 21
diff changeset
455 logfile=None, date=None, user=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
456 """Prepare a new changeset with the effect of rev undone in the current
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
457 working directory.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
458
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
459 If rev is the parent of the working directory, then this new
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
460 changeset is committed automatically. Otherwise, hg needs to
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
461 merge the changes and the merged result is left uncommitted.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
462
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
463 rev - revision to backout
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
464 merge - merge with old dirstate parent after backout
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
465 parent - parent to choose when backing out merge
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
466 tool - specify merge tool
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
467 message - use text as commit message
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
468 logfile - read commit message from file
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
469 date - record the specified date as commit date
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
470 user - record the specified user as committer
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
471
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
472 """
22
297df22d6091 client: add backout command
Idan Kamara <idankk86@gmail.com>
parents: 21
diff changeset
473 if message and logfile:
297df22d6091 client: add backout command
Idan Kamara <idankk86@gmail.com>
parents: 21
diff changeset
474 raise ValueError("cannot specify both a message and a logfile")
297df22d6091 client: add backout command
Idan Kamara <idankk86@gmail.com>
parents: 21
diff changeset
475
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
476 args = cmdbuilder(b('backout'), r=rev, merge=merge, parent=parent,
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
477 t=tool, m=message, l=logfile, d=date, u=user,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
478 hidden=self.hidden)
22
297df22d6091 client: add backout command
Idan Kamara <idankk86@gmail.com>
parents: 21
diff changeset
479
297df22d6091 client: add backout command
Idan Kamara <idankk86@gmail.com>
parents: 21
diff changeset
480 self.rawcommand(args)
297df22d6091 client: add backout command
Idan Kamara <idankk86@gmail.com>
parents: 21
diff changeset
481
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
482 def bookmark(self, name, rev=None, force=False, delete=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
483 inactive=False, rename=None):
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
484 """
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
485 Set a bookmark on the working directory's parent revision or rev,
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
486 with the given name.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
487
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
488 name - bookmark name
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
489 rev - revision to bookmark
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
490 force - bookmark even if another bookmark with the same name exists
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
491 delete - delete the given bookmark
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
492 inactive - do not mark the new bookmark active
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
493 rename - rename the bookmark given by rename to name
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
494 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
495 args = cmdbuilder(b('bookmark'), name, r=rev, f=force, d=delete,
23
223e463c25e0 client: add bookmark command
Idan Kamara <idankk86@gmail.com>
parents: 22
diff changeset
496 i=inactive, m=rename)
223e463c25e0 client: add bookmark command
Idan Kamara <idankk86@gmail.com>
parents: 22
diff changeset
497
223e463c25e0 client: add bookmark command
Idan Kamara <idankk86@gmail.com>
parents: 22
diff changeset
498 self.rawcommand(args)
223e463c25e0 client: add bookmark command
Idan Kamara <idankk86@gmail.com>
parents: 22
diff changeset
499
24
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
500 def bookmarks(self):
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
501 """
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
502 Return the bookmarks as a list of (name, rev, node) and the index of the
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
503 current one.
24
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
504
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
505 If there isn't a current one, -1 is returned as the index.
24
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
506 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
507 args = cmdbuilder(b('bookmarks'), hidden=self.hidden)
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
508 out = self.rawcommand(args)
24
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
509
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
510 bms = []
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
511 current = -1
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
512 if out.rstrip() != b('no bookmarks set'):
24
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
513 for line in out.splitlines():
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
514 iscurrent, line = line[0:3], line[3:]
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
515 if b('*') in iscurrent:
24
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
516 current = len(bms)
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
517 name, line = line.split(b(' '), 1)
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
518 rev, node = line.split(b(':'))
24
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
519 bms.append((name, int(rev), node))
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
520 return bms, current
ca0d7e212cf8 client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents: 23
diff changeset
521
11
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
522 def branch(self, name=None, clean=False, force=False):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
523 """When name isn't given, return the current branch name. Otherwise
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
524 set the working directory branch name (the branch will not
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
525 exist in the repository until the next commit). Standard
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
526 practice recommends that primary development take place on the
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
527 'default' branch.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
528
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
529 When clean is True, reset and return the working directory
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
530 branch to that of the parent of the working directory,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
531 negating a previous branch change.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
532
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
533 name - new branch name
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
534 clean - reset branch name to parent branch name
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
535 force - set branch name even if it shadows an existing branch
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
536
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
537 """
11
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
538 if name and clean:
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
539 raise ValueError('cannot use both name and clean')
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
540
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
541 args = cmdbuilder(b('branch'), name, f=force, C=clean)
11
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
542 out = self.rawcommand(args).rstrip()
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
543
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
544 if name:
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
545 return name
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
546 elif not clean:
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
547 return out
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
548 else:
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
549 # len('reset working directory to branch ') == 34
0549d00a617d client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents: 10
diff changeset
550 return out[34:]
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
551
12
c2a9b716cd80 client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents: 11
diff changeset
552 def branches(self, active=False, closed=False):
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
553 """
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
554 Returns the repository's named branches as a list of (name, rev, node).
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
555
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
556 active - show only branches that have unmerged heads
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
557 closed - show normal and closed branches
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
558 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
559 args = cmdbuilder(b('branches'), a=active, c=closed, hidden=self.hidden)
12
c2a9b716cd80 client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents: 11
diff changeset
560 out = self.rawcommand(args)
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
561
12
c2a9b716cd80 client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents: 11
diff changeset
562 branches = []
c2a9b716cd80 client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents: 11
diff changeset
563 for line in out.rstrip().splitlines():
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
564 namerev, node = line.rsplit(b(':'), 1)
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
565 name, rev = namerev.rsplit(b(' '), 1)
79
ca5f8f43e585 branches: more robust parsing strategy
Matt Mackall <mpm@selenic.com>
parents: 72
diff changeset
566 name = name.rstrip()
12
c2a9b716cd80 client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents: 11
diff changeset
567 node = node.split()[0] # get rid of ' (inactive)'
c2a9b716cd80 client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents: 11
diff changeset
568 branches.append((name, int(rev), node))
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
569 return branches
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
570
54
29d01b5dc38c client: add bundle command
Idan Kamara <idankk86@gmail.com>
parents: 53
diff changeset
571 def bundle(self, file, destrepo=None, rev=[], branch=[], base=[], all=False,
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
572 force=False, type=None, ssh=None, remotecmd=None,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
573 insecure=False):
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
574 """Generate a compressed changegroup file collecting changesets not
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
575 known to be in another repository.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
576
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
577 If destrepo isn't given, then hg assumes the destination will have all
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
578 the nodes you specify with base. To create a bundle containing all
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
579 changesets, use all (or set base to 'null').
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
580
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
581 file - destination file name
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
582 destrepo - repository to look for changes
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
583 rev - a changeset intended to be added to the destination
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
584 branch - a specific branch you would like to bundle
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
585 base - a base changeset assumed to be available at the destination
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
586 all - bundle all changesets in the repository
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
587 type - bundle compression type to use, available compression
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
588 methods are: none, bzip2, and gzip (default: bzip2)
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
589
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
590 force - run even when the destrepo is unrelated
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
591 ssh - specify ssh command to use
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
592 remotecmd - specify hg command to run on the remote side
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
593 insecure - do not verify server certificate (ignoring
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
594 web.cacerts config)
54
29d01b5dc38c client: add bundle command
Idan Kamara <idankk86@gmail.com>
parents: 53
diff changeset
595
29d01b5dc38c client: add bundle command
Idan Kamara <idankk86@gmail.com>
parents: 53
diff changeset
596 Return True if a bundle was created, False if no changes were found.
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
597
54
29d01b5dc38c client: add bundle command
Idan Kamara <idankk86@gmail.com>
parents: 53
diff changeset
598 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
599 args = cmdbuilder(b('bundle'), file, destrepo, f=force, r=rev, b=branch,
54
29d01b5dc38c client: add bundle command
Idan Kamara <idankk86@gmail.com>
parents: 53
diff changeset
600 base=base, a=all, t=type, e=ssh, remotecmd=remotecmd,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
601 insecure=insecure, hidden=self.hidden)
54
29d01b5dc38c client: add bundle command
Idan Kamara <idankk86@gmail.com>
parents: 53
diff changeset
602
29d01b5dc38c client: add bundle command
Idan Kamara <idankk86@gmail.com>
parents: 53
diff changeset
603 eh = util.reterrorhandler(args)
29d01b5dc38c client: add bundle command
Idan Kamara <idankk86@gmail.com>
parents: 53
diff changeset
604 self.rawcommand(args, eh=eh)
29d01b5dc38c client: add bundle command
Idan Kamara <idankk86@gmail.com>
parents: 53
diff changeset
605
29d01b5dc38c client: add bundle command
Idan Kamara <idankk86@gmail.com>
parents: 53
diff changeset
606 return bool(eh)
29d01b5dc38c client: add bundle command
Idan Kamara <idankk86@gmail.com>
parents: 53
diff changeset
607
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
608 def cat(self, files, rev=None, output=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
609 """Return a string containing the specified files as they were at the
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
610 given revision. If no revision is given, the parent of the working
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
611 directory is used, or tip if no revision is checked out.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
612
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
613 If output is given, writes the contents to the specified file.
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
614 The name of the file is given using a format string. The
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
615 formatting rules are the same as for the export command, with
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
616 the following additions:
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
617
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
618 "%s" basename of file being printed
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
619 "%d" dirname of file being printed, or '.' if in repository root
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
620 "%p" root-relative path name of file being printed
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
621
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
622 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
623 args = cmdbuilder(b('cat'), r=rev, o=output, hidden=self.hidden, *files)
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
624 out = self.rawcommand(args)
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
625
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
626 if not output:
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
627 return out
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
628
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
629 def clone(self, source=b('.'), dest=None, branch=None, updaterev=None,
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
630 revrange=None):
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
631 """
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
632 Create a copy of an existing repository specified by source in a new
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
633 directory dest.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
634
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
635 If dest isn't specified, it defaults to the basename of source.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
636
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
637 branch - clone only the specified branch
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
638 updaterev - revision, tag or branch to check out
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
639 revrange - include the specified changeset
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
640 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
641 args = cmdbuilder(b('clone'), source, dest, b=branch,
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
642 u=updaterev, r=revrange)
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
643 self.rawcommand(args)
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
644
178
77a5fded9f45 init: add init() to hgclient to allow progress to be reported
Barry A. Scott <barry@barrys-emacs.org>
parents: 176
diff changeset
645 def init(self, dest, ssh=None, remotecmd=None, insecure=False):
77a5fded9f45 init: add init() to hgclient to allow progress to be reported
Barry A. Scott <barry@barrys-emacs.org>
parents: 176
diff changeset
646 args = util.cmdbuilder('init', dest, e=ssh, remotecmd=remotecmd,
77a5fded9f45 init: add init() to hgclient to allow progress to be reported
Barry A. Scott <barry@barrys-emacs.org>
parents: 176
diff changeset
647 insecure=insecure)
77a5fded9f45 init: add init() to hgclient to allow progress to be reported
Barry A. Scott <barry@barrys-emacs.org>
parents: 176
diff changeset
648 self.rawcommand(args)
77a5fded9f45 init: add init() to hgclient to allow progress to be reported
Barry A. Scott <barry@barrys-emacs.org>
parents: 176
diff changeset
649
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
650 def commit(self, message=None, logfile=None, addremove=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
651 closebranch=False, date=None, user=None, include=None,
136
dc63978871ed client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents: 134
diff changeset
652 exclude=None, amend=False):
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
653 """
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
654 Commit changes reported by status into the repository.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
655
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
656 message - the commit message
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
657 logfile - read commit message from file
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
658 addremove - mark new/missing files as added/removed before committing
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
659 closebranch - mark a branch as closed, hiding it from the branch list
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
660 date - record the specified date as commit date
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
661 user - record the specified user as committer
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
662 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
663 exclude - exclude names matching the given patterns
136
dc63978871ed client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents: 134
diff changeset
664 amend - amend the parent of the working dir
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
665 """
136
dc63978871ed client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents: 134
diff changeset
666 if amend and message is None and logfile is None:
dc63978871ed client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents: 134
diff changeset
667 # retrieve current commit message
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
668 message = self.log(b('.'))[0][5]
136
dc63978871ed client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents: 134
diff changeset
669 if message is None and logfile is None and not amend:
16
943aff89b068 client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents: 15
diff changeset
670 raise ValueError("must provide at least a message or a logfile")
943aff89b068 client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents: 15
diff changeset
671 elif message and logfile:
943aff89b068 client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents: 15
diff changeset
672 raise ValueError("cannot specify both a message and a logfile")
943aff89b068 client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents: 15
diff changeset
673
14
e0d21c9db20b client: use --debug when committing to get the new node info
Idan Kamara <idankk86@gmail.com>
parents: 13
diff changeset
674 # --debug will print the committed cset
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
675 args = cmdbuilder(b('commit'), debug=True, m=message, A=addremove,
16
943aff89b068 client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents: 15
diff changeset
676 close_branch=closebranch, d=date, u=user, l=logfile,
136
dc63978871ed client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents: 134
diff changeset
677 I=include, X=exclude, amend=amend)
14
e0d21c9db20b client: use --debug when committing to get the new node info
Idan Kamara <idankk86@gmail.com>
parents: 13
diff changeset
678 out = self.rawcommand(args)
171
2725547a5f92 commit: allow rev and node to be anywhere in the output
Idan Kamara <idankk86@gmail.com>
parents: 169
diff changeset
679 m = re.search(b(r'^committed changeset (\d+):([0-9a-f]+)'), out,
2725547a5f92 commit: allow rev and node to be anywhere in the output
Idan Kamara <idankk86@gmail.com>
parents: 169
diff changeset
680 re.MULTILINE)
2725547a5f92 commit: allow rev and node to be anywhere in the output
Idan Kamara <idankk86@gmail.com>
parents: 169
diff changeset
681 if not m:
181
cdb5a320d2bf client: wrap long lines at 80 chars
Yuya Nishihara <yuya@tcha.org>
parents: 180
diff changeset
682 raise ValueError('revision and node not found in hg output: %r'
cdb5a320d2bf client: wrap long lines at 80 chars
Yuya Nishihara <yuya@tcha.org>
parents: 180
diff changeset
683 % out)
171
2725547a5f92 commit: allow rev and node to be anywhere in the output
Idan Kamara <idankk86@gmail.com>
parents: 169
diff changeset
684 rev, node = m.groups()
2725547a5f92 commit: allow rev and node to be anywhere in the output
Idan Kamara <idankk86@gmail.com>
parents: 169
diff changeset
685 return int(rev), node
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
686
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
687 def config(self, names=[], untrusted=False, showsource=False):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
688 """Return a list of (section, key, value) config settings from all
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
689 hgrc files
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
690
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
691 When showsource is specified, return (source, section, key, value) where
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
692 source is of the form filename:[line]
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
693
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
694 """
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
695 def splitline(s):
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
696 k, value = s.rstrip().split(b('='), 1)
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
697 section, key = k.split(b('.'), 1)
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
698 return section, key, value
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
699
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
700 if not isinstance(names, list):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
701 names = [names]
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
702
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
703 args = cmdbuilder(b('showconfig'), u=untrusted, debug=showsource,
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
704 *names)
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
705 out = self.rawcommand(args)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
706
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
707 conf = []
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
708 if showsource:
195
7c37f08d303d config: un-break showconfig wrapper when environment variables are used
Augie Fackler <raf@durin42.com>
parents: 194
diff changeset
709 out = util.skiplines(out, (b('read config from: '),
7c37f08d303d config: un-break showconfig wrapper when environment variables are used
Augie Fackler <raf@durin42.com>
parents: 194
diff changeset
710 b('set config by: ')))
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
711 for line in out.splitlines():
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
712 m = re.match(b(r"(.+?:(?:\d+:)?) (.*)"), line)
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
713 t = splitline(m.group(2))
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
714 conf.append((m.group(1)[:-1], t[0], t[1], t[2]))
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
715 else:
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
716 for line in out.splitlines():
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
717 conf.append(splitline(line))
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
718
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
719 return conf
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
720
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
721 @property
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
722 def encoding(self):
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
723 """
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
724 Return the server's encoding (as reported in the hello message).
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
725 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
726 if not b('getencoding') in self.capabilities:
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
727 raise CapabilityError('getencoding')
5
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
728
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
729 if not self._encoding:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
730 self.server.stdin.write(b('getencoding\n'))
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
731 self._encoding = self._readfromchannel('r')
5
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
732
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
733 return self._encoding
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
734
29
c072f525ea3e client: add copy command
Idan Kamara <idankk86@gmail.com>
parents: 28
diff changeset
735 def copy(self, source, dest, after=False, force=False, dryrun=False,
c072f525ea3e client: add copy command
Idan Kamara <idankk86@gmail.com>
parents: 28
diff changeset
736 include=None, exclude=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
737 """Mark dest as having copies of source files. If dest is a
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
738 directory, copies are put in that directory. If dest is a
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
739 file, then source must be a string.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
740
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
741 Returns True on success, False if errors are encountered.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
742
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
743 source - a file or a list of files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
744 dest - a destination file or directory
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
745 after - record a copy that has already occurred
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
746 force - forcibly copy over an existing managed file
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
747 dryrun - do not perform actions, just print output
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
748 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
749 exclude - exclude names matching the given patterns
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
750
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
751 """
29
c072f525ea3e client: add copy command
Idan Kamara <idankk86@gmail.com>
parents: 28
diff changeset
752 if not isinstance(source, list):
c072f525ea3e client: add copy command
Idan Kamara <idankk86@gmail.com>
parents: 28
diff changeset
753 source = [source]
c072f525ea3e client: add copy command
Idan Kamara <idankk86@gmail.com>
parents: 28
diff changeset
754
c072f525ea3e client: add copy command
Idan Kamara <idankk86@gmail.com>
parents: 28
diff changeset
755 source.append(dest)
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
756 args = cmdbuilder(b('copy'), A=after, f=force, n=dryrun,
87
5661d5f7e39b client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents: 79
diff changeset
757 I=include, X=exclude, *source)
29
c072f525ea3e client: add copy command
Idan Kamara <idankk86@gmail.com>
parents: 28
diff changeset
758
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
759 eh = util.reterrorhandler(args)
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
760 self.rawcommand(args, eh=eh)
29
c072f525ea3e client: add copy command
Idan Kamara <idankk86@gmail.com>
parents: 28
diff changeset
761
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
762 return bool(eh)
29
c072f525ea3e client: add copy command
Idan Kamara <idankk86@gmail.com>
parents: 28
diff changeset
763
61
d0b9215180a4 client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents: 57
diff changeset
764 def diff(self, files=[], revs=[], change=None, text=False,
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
765 git=False, nodates=False, showfunction=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
766 reverse=False, ignoreallspace=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
767 ignorespacechange=False, ignoreblanklines=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
768 unified=None, stat=False, subrepos=False, include=None,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
769 exclude=None):
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
770 """
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
771 Return differences between revisions for the specified files.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
772
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
773 revs - a revision or a list of two revisions to diff
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
774 change - change made by revision
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
775 text - treat all files as text
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
776 git - use git extended diff format
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
777 nodates - omit dates from diff headers
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
778 showfunction - show which function each change is in
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
779 reverse - produce a diff that undoes the changes
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
780 ignoreallspace - ignore white space when comparing lines
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
781 ignorespacechange - ignore changes in the amount of white space
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
782 ignoreblanklines - ignore changes whose lines are all blank
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
783 unified - number of lines of context to show
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
784 stat - output diffstat-style summary of changes
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
785 subrepos - recurse into subrepositories
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
786 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
787 exclude - exclude names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
788 """
61
d0b9215180a4 client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents: 57
diff changeset
789 if change and revs:
d0b9215180a4 client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents: 57
diff changeset
790 raise ValueError('cannot specify both change and rev')
d0b9215180a4 client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents: 57
diff changeset
791
154
11202c85737e hglib: make sure hgclient.diff() works with bytes (issue4520)
Brett Cannon <brett@python.org>
parents: 148
diff changeset
792 args = cmdbuilder(b('diff'), r=list(map(strtobytes, revs)), c=change,
61
d0b9215180a4 client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents: 57
diff changeset
793 a=text, g=git, nodates=nodates,
d0b9215180a4 client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents: 57
diff changeset
794 p=showfunction, reverse=reverse,
d0b9215180a4 client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents: 57
diff changeset
795 w=ignoreallspace, b=ignorespacechange,
d0b9215180a4 client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents: 57
diff changeset
796 B=ignoreblanklines, U=unified, stat=stat,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
797 S=subrepos, I=include, X=exclude, hidden=self.hidden,
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
798 *files)
61
d0b9215180a4 client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents: 57
diff changeset
799
d0b9215180a4 client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents: 57
diff changeset
800 return self.rawcommand(args)
d0b9215180a4 client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents: 57
diff changeset
801
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
802 def export(self, revs, output=None, switchparent=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
803 text=False, git=False, nodates=False):
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
804 """Return the header and diffs for one or more changesets. When
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
805 output is given, dumps to file. The name of the file is given
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
806 using a format string. The formatting rules are as follows:
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
807
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
808 "%%" literal "%" character
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
809 "%H" changeset hash (40 hexadecimal digits)
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
810 "%N" number of patches being generated
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
811 "%R" changeset revision number
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
812 "%b" basename of the exporting repository
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
813 "%h" short-form changeset hash (12 hexadecimal digits)
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
814 "%n" zero-padded sequence number, starting at 1
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
815 "%r" zero-padded changeset revision number
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
816
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
817 output - print output to file with formatted name
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
818 switchparent - diff against the second parent
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
819 rev - a revision or list of revisions to export
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
820 text - treat all files as text
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
821 git - use git extended diff format
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
822 nodates - omit dates from diff headers
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
823
55
5833f6ac0929 client: add export command
Idan Kamara <idankk86@gmail.com>
parents: 54
diff changeset
824 """
5833f6ac0929 client: add export command
Idan Kamara <idankk86@gmail.com>
parents: 54
diff changeset
825 if not isinstance(revs, list):
5833f6ac0929 client: add export command
Idan Kamara <idankk86@gmail.com>
parents: 54
diff changeset
826 revs = [revs]
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
827 args = cmdbuilder(b('export'), o=output, switch_parent=switchparent,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
828 a=text, g=git, nodates=nodates, hidden=self.hidden,
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
829 *revs)
55
5833f6ac0929 client: add export command
Idan Kamara <idankk86@gmail.com>
parents: 54
diff changeset
830
5833f6ac0929 client: add export command
Idan Kamara <idankk86@gmail.com>
parents: 54
diff changeset
831 out = self.rawcommand(args)
5833f6ac0929 client: add export command
Idan Kamara <idankk86@gmail.com>
parents: 54
diff changeset
832
5833f6ac0929 client: add export command
Idan Kamara <idankk86@gmail.com>
parents: 54
diff changeset
833 if output is None:
5833f6ac0929 client: add export command
Idan Kamara <idankk86@gmail.com>
parents: 54
diff changeset
834 return out
5833f6ac0929 client: add export command
Idan Kamara <idankk86@gmail.com>
parents: 54
diff changeset
835
31
ee8863882aae client: add forget command
Idan Kamara <idankk86@gmail.com>
parents: 30
diff changeset
836 def forget(self, files, include=None, exclude=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
837 """Mark the specified files so they will no longer be tracked after
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
838 the next commit.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
839
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
840 This only removes files from the current branch, not from the entire
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
841 project history, and it does not delete them from the working directory.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
842
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
843 Returns True on success.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
844
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
845 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
846 exclude - exclude names matching the given patterns
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
847
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
848 """
31
ee8863882aae client: add forget command
Idan Kamara <idankk86@gmail.com>
parents: 30
diff changeset
849 if not isinstance(files, list):
ee8863882aae client: add forget command
Idan Kamara <idankk86@gmail.com>
parents: 30
diff changeset
850 files = [files]
ee8863882aae client: add forget command
Idan Kamara <idankk86@gmail.com>
parents: 30
diff changeset
851
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
852 args = cmdbuilder(b('forget'), I=include, X=exclude, *files)
31
ee8863882aae client: add forget command
Idan Kamara <idankk86@gmail.com>
parents: 30
diff changeset
853
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
854 eh = util.reterrorhandler(args)
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
855 self.rawcommand(args, eh=eh)
31
ee8863882aae client: add forget command
Idan Kamara <idankk86@gmail.com>
parents: 30
diff changeset
856
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
857 return bool(eh)
31
ee8863882aae client: add forget command
Idan Kamara <idankk86@gmail.com>
parents: 30
diff changeset
858
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
859 def grep(self, pattern, files=[], all=False, text=False, follow=False,
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
860 ignorecase=False, fileswithmatches=False, line=False, user=False,
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
861 date=False, include=None, exclude=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
862 """Search for a pattern in specified files and revisions.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
863
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
864 This behaves differently than Unix grep. It only accepts Python/Perl
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
865 regexps. It searches repository history, not the working directory.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
866 It always prints the revision number in which a match appears.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
867
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
868 Yields (filename, revision, [line, [match status, [user,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
869 [date, [match]]]]]) per match depending on the given options.
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
870
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
871 all - print all revisions that match
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
872 text - treat all files as text
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
873 follow - follow changeset history, or file history across
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
874 copies and renames
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
875 ignorecase - ignore case when matching
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
876 fileswithmatches - return only filenames and revisions that match
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
877 line - return line numbers in the result tuple
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
878 user - return the author in the result tuple
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
879 date - return the date in the result tuple
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
880 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
881 exclude - exclude names matching the given patterns
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
882
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
883 """
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
884 if not isinstance(files, list):
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
885 files = [files]
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
886
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
887 args = cmdbuilder(b('grep'), all=all, a=text, f=follow, i=ignorecase,
87
5661d5f7e39b client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents: 79
diff changeset
888 l=fileswithmatches, n=line, u=user, d=date,
192
7a84a8656679 client: do not append an option to a list of arguments
Yuya Nishihara <yuya@tcha.org>
parents: 191
diff changeset
889 I=include, X=exclude, hidden=self.hidden, print0=True,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
890 *[pattern] + files)
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
891
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
892 def eh(ret, out, err):
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
893 if ret != 1:
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
894 raise error.CommandError(args, ret, out, err)
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
895 return b('')
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
896
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 201
diff changeset
897 out = self.rawcommand(args, eh=eh).split(b('\0'))[:-1]
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
898
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 201
diff changeset
899 fieldcount = 1
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 201
diff changeset
900 if all or self.version < (5, 2):
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 201
diff changeset
901 fieldcount += 1
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
902 if user:
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
903 fieldcount += 1
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
904 if date:
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
905 fieldcount += 1
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
906 if line:
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
907 fieldcount += 1
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
908 if all:
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
909 fieldcount += 1
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 201
diff changeset
910 if not fileswithmatches:
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 201
diff changeset
911 fieldcount += 1
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
912
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
913 return util.grouper(fieldcount, out)
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents: 55
diff changeset
914
57
2657fd6fef04 client: add heads command
Idan Kamara <idankk86@gmail.com>
parents: 56
diff changeset
915 def heads(self, rev=[], startrev=[], topological=False, closed=False):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
916 """Return a list of current repository heads or branch heads.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
917
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
918 rev - return only branch heads on the branches associated with
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
919 the specified changesets.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
920
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
921 startrev - return only heads which are descendants of the given revs.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
922 topological - named branch mechanics will be ignored and only changesets
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
923 without children will be shown.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
924
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
925 closed - normal and closed branch heads.
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
926
57
2657fd6fef04 client: add heads command
Idan Kamara <idankk86@gmail.com>
parents: 56
diff changeset
927 """
2657fd6fef04 client: add heads command
Idan Kamara <idankk86@gmail.com>
parents: 56
diff changeset
928 if not isinstance(rev, list):
2657fd6fef04 client: add heads command
Idan Kamara <idankk86@gmail.com>
parents: 56
diff changeset
929 rev = [rev]
2657fd6fef04 client: add heads command
Idan Kamara <idankk86@gmail.com>
parents: 56
diff changeset
930
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
931 args = cmdbuilder(b('heads'), r=startrev, t=topological, c=closed,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
932 template=templates.changeset, hidden=self.hidden,
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
933 *rev)
57
2657fd6fef04 client: add heads command
Idan Kamara <idankk86@gmail.com>
parents: 56
diff changeset
934
2657fd6fef04 client: add heads command
Idan Kamara <idankk86@gmail.com>
parents: 56
diff changeset
935 def eh(ret, out, err):
2657fd6fef04 client: add heads command
Idan Kamara <idankk86@gmail.com>
parents: 56
diff changeset
936 if ret != 1:
2657fd6fef04 client: add heads command
Idan Kamara <idankk86@gmail.com>
parents: 56
diff changeset
937 raise error.CommandError(args, ret, out, err)
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
938 return b('')
57
2657fd6fef04 client: add heads command
Idan Kamara <idankk86@gmail.com>
parents: 56
diff changeset
939
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
940 out = self.rawcommand(args, eh=eh).split(b('\0'))[:-1]
57
2657fd6fef04 client: add heads command
Idan Kamara <idankk86@gmail.com>
parents: 56
diff changeset
941 return self._parserevs(out)
2657fd6fef04 client: add heads command
Idan Kamara <idankk86@gmail.com>
parents: 56
diff changeset
942
38
32f6a2bbf63e client: add identify command
Idan Kamara <idankk86@gmail.com>
parents: 37
diff changeset
943 def identify(self, rev=None, source=None, num=False, id=False, branch=False,
32f6a2bbf63e client: add identify command
Idan Kamara <idankk86@gmail.com>
parents: 37
diff changeset
944 tags=False, bookmarks=False):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
945 """Return a summary string identifying the repository state at rev
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
946 using one or two parent hash identifiers, followed by a "+" if
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
947 the working directory has uncommitted changes, the branch name
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
948 (if not default), a list of tags, and a list of bookmarks.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
949
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
950 When rev is not given, return a summary string of the current
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
951 state of the repository.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
952
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
953 Specifying source as a repository root or Mercurial bundle will cause
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
954 lookup to operate on that repository/bundle.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
955
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
956 num - show local revision number
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
957 id - show global revision id
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
958 branch - show branch
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
959 tags - show tags
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
960 bookmarks - show bookmarks
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
961
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
962 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
963 args = cmdbuilder(b('identify'), source, r=rev, n=num, i=id,
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
964 b=branch, t=tags, B=bookmarks,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
965 hidden=self.hidden)
38
32f6a2bbf63e client: add identify command
Idan Kamara <idankk86@gmail.com>
parents: 37
diff changeset
966
32f6a2bbf63e client: add identify command
Idan Kamara <idankk86@gmail.com>
parents: 37
diff changeset
967 return self.rawcommand(args)
32f6a2bbf63e client: add identify command
Idan Kamara <idankk86@gmail.com>
parents: 37
diff changeset
968
13
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
969 def import_(self, patches, strip=None, force=False, nocommit=False,
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
970 bypass=False, exact=False, importbranch=False, message=None,
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
971 date=None, user=None, similarity=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
972 """Import the specified patches which can be a list of file names or a
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
973 file-like object and commit them individually (unless nocommit is
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
974 specified).
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
975
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
976 strip - directory strip option for patch. This has the same
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
977 meaning as the corresponding patch option (default: 1)
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
978
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
979 force - skip check for outstanding uncommitted changes
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
980 nocommit - don't commit, just update the working directory
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
981 bypass - apply patch without touching the working directory
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
982 exact - apply patch to the nodes from which it was generated
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
983 importbranch - use any branch information in patch (implied by exact)
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
984 message - the commit message
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
985 date - record the specified date as commit date
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
986 user - record the specified user as committer
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
987 similarity - guess renamed files by similarity (0<=s<=100)
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
988
13
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
989 """
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
990 if hasattr(patches, 'read') and hasattr(patches, 'readline'):
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
991 patch = patches
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
992
13
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
993 def readline(size, output):
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
994 return patch.readline(size)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
995
13
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
996 stdin = True
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
997 patches = ()
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
998 prompt = readline
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
999 input = patch.read
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
1000 else:
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
1001 stdin = False
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
1002 prompt = None
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
1003 input = None
5
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
1004
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1005 args = cmdbuilder(b('import'), strip=strip, force=force,
96
9746227239e0 client: fix import --no-commit flag (issue3206)
Idan Kamara <idankk86@gmail.com>
parents: 95
diff changeset
1006 no_commit=nocommit, bypass=bypass, exact=exact,
97
705e601e6085 client: fix import --import-branch flag
Idan Kamara <idankk86@gmail.com>
parents: 96
diff changeset
1007 import_branch=importbranch, message=message,
87
5661d5f7e39b client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents: 79
diff changeset
1008 date=date, user=user, similarity=similarity, _=stdin,
5661d5f7e39b client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents: 79
diff changeset
1009 *patches)
13
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
1010
400cb1520834 client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents: 12
diff changeset
1011 self.rawcommand(args, prompt=prompt, input=input)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1012
25
85ae94b98324 client: add missing options to incoming
Idan Kamara <idankk86@gmail.com>
parents: 24
diff changeset
1013 def incoming(self, revrange=None, path=None, force=False, newest=False,
85ae94b98324 client: add missing options to incoming
Idan Kamara <idankk86@gmail.com>
parents: 24
diff changeset
1014 bundle=None, bookmarks=False, branch=None, limit=None,
85ae94b98324 client: add missing options to incoming
Idan Kamara <idankk86@gmail.com>
parents: 24
diff changeset
1015 nomerges=False, subrepos=False):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1016 """Return new changesets found in the specified path or the default pull
27
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1017 location.
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1018
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1019 When bookmarks=True, return a list of (name, node) of incoming
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1020 bookmarks.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1021
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1022 revrange - a remote changeset or list of changesets intended to be added
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1023 force - run even if remote repository is unrelated
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1024 newest - show newest record first
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1025 bundle - avoid downloading the changesets twice and store the
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1026 bundles into the specified file.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1027
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1028 bookmarks - compare bookmarks (this changes the return value)
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1029 branch - a specific branch you would like to pull
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1030 limit - limit number of changes returned
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1031 nomerges - do not show merges
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1032 ssh - specify ssh command to use
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1033 remotecmd - specify hg command to run on the remote side
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1034 insecure- do not verify server certificate (ignoring web.cacerts config)
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1035 subrepos - recurse into subrepositories
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1036
27
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1037 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1038 args = cmdbuilder(b('incoming'), path,
25
85ae94b98324 client: add missing options to incoming
Idan Kamara <idankk86@gmail.com>
parents: 24
diff changeset
1039 template=templates.changeset, r=revrange,
85ae94b98324 client: add missing options to incoming
Idan Kamara <idankk86@gmail.com>
parents: 24
diff changeset
1040 f=force, n=newest, bundle=bundle,
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1041 B=bookmarks, b=branch, l=limit, M=nomerges,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1042 S=subrepos)
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1043
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1044 def eh(ret, out, err):
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1045 if ret != 1:
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1046 raise error.CommandError(args, ret, out, err)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1047
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1048 out = self.rawcommand(args, eh=eh)
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1049 if not out:
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1050 return []
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1051
27
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1052 out = util.eatlines(out, 2)
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1053 if bookmarks:
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1054 bms = []
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1055 for line in out.splitlines():
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1056 bms.append(tuple(line.split()))
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1057 return bms
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1058 else:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1059 out = out.split(b('\0'))[:-1]
27
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1060 return self._parserevs(out)
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1061
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1062 def log(self, revrange=None, files=[], follow=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1063 followfirst=False, date=None, copies=False, keyword=None,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1064 removed=False, onlymerges=False, user=None, branch=None,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1065 prune=None, hidden=None, limit=None, nomerges=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1066 include=None, exclude=None):
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1067 """Return the revision history of the specified files or the entire
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1068 project.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1069
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1070 File history is shown without following rename or copy history of files.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1071 Use follow with a filename to follow history across renames and copies.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1072 follow without a filename will only show ancestors or descendants of the
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1073 starting revision. followfirst only follows the first parent of merge
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1074 revisions.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1075
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1076 If revrange isn't specified, the default is "tip:0" unless
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1077 follow is set, in which case the working directory parent is
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1078 used as the starting revision.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1079
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1080 The returned changeset is a named tuple with the following
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1081 string fields:
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1082
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1083 - rev
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1084 - node
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1085 - tags (space delimited)
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1086 - branch
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1087 - author
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1088 - desc
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1089
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1090 follow - follow changeset history, or file history across
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1091 copies and renames
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1092 followfirst - only follow the first parent of merge changesets
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1093 date - show revisions matching date spec
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1094 copies - show copied files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1095 keyword - do case-insensitive search for a given text
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1096 removed - include revisions where files were removed
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1097 onlymerges - show only merges
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1098 user - revisions committed by user
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1099 branch - show changesets within the given named branch
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1100 prune - do not display revision or any of its ancestors
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1101 hidden - show hidden changesets
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1102 limit - limit number of changes displayed
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1103 nomerges - do not show merges
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1104 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1105 exclude - exclude names matching the given patterns
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1106
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1107 """
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
1108 if hidden is None:
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
1109 hidden = self.hidden
216
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
1110 args = cmdbuilder(b('log'), template="json",
17
b68c444d42bb client: add missing options to log()
Idan Kamara <idankk86@gmail.com>
parents: 16
diff changeset
1111 r=revrange, f=follow, follow_first=followfirst,
b68c444d42bb client: add missing options to log()
Idan Kamara <idankk86@gmail.com>
parents: 16
diff changeset
1112 d=date, C=copies, k=keyword, removed=removed,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
1113 m=onlymerges, u=user, b=branch, P=prune,
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
1114 l=limit, M=nomerges, I=include, X=exclude,
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
1115 hidden=hidden, *files)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1116
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1117 out = self.rawcommand(args)
216
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
1118 json_out = json.loads(out)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1119
216
68588c652ac6 client: handle commit messages with \0 characters
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 213
diff changeset
1120 return self._parsejsonrevs(json_out)
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1121
64
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1122 def manifest(self, rev=None, all=False):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1123 """Yields (nodeid, permission, executable, symlink, file path) tuples
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1124 for version controlled files for the given revision. If no
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1125 revision is given, the first parent of the working directory
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1126 is used, or the null revision if no revision is checked out.
64
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1127
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1128 When all is True, all files from all revisions are yielded
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1129 (just the name). This includes deleted and renamed files.
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1130
64
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1131 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1132 args = cmdbuilder(b('manifest'), r=rev, all=all, debug=True,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
1133 hidden=self.hidden)
64
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1134
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1135 out = self.rawcommand(args)
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1136
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1137 if all:
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1138 for line in out.splitlines():
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1139 yield line
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1140 else:
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1141 for line in out.splitlines():
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1142 node = line[0:40]
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1143 perm = line[41:44]
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1144 symlink = line[45:46] == b('@')
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1145 executable = line[45:46] == b('*')
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1146 yield node, perm, executable, symlink, line[47:]
64
a7d98dc798c5 client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents: 63
diff changeset
1147
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
1148 def merge(self, rev=None, force=False, tool=None, cb=merge.handlers.abort):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1149 """Merge working directory with rev. If no revision is specified, the
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1150 working directory's parent is a head revision, and the current
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1151 branch contains exactly one other head, the other head is
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1152 merged with by default.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1153
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1154 The current working directory is updated with all changes made in the
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1155 requested revision since the last common predecessor revision.
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
1156
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1157 Files that changed between either parent are marked as changed for the
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1158 next commit and a commit must be performed before any further updates to
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1159 the repository are allowed. The next commit will have two parents.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1160
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1161 force - force a merge with outstanding changes
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1162 tool - can be used to specify the merge tool used for file merges. It
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1163 overrides the HGMERGE environment variable and your configuration files.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1164
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1165 cb - controls the behaviour when Mercurial prompts what to do
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1166 with regard to a specific file, e.g. when one parent modified
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1167 a file and the other removed it. It can be one of
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1168 merge.handlers, or a function that gets a single argument
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1169 which are the contents of stdout. It should return one of the
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1170 expected choices (a single character).
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1171
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
1172 """
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents: 44
diff changeset
1173 # we can't really use --preview since merge doesn't support --template
192
7a84a8656679 client: do not append an option to a list of arguments
Yuya Nishihara <yuya@tcha.org>
parents: 191
diff changeset
1174 args = cmdbuilder(b('merge'), r=rev, f=force, t=tool,
7a84a8656679 client: do not append an option to a list of arguments
Yuya Nishihara <yuya@tcha.org>
parents: 191
diff changeset
1175 y=(cb is merge.handlers.noninteractive))
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents: 44
diff changeset
1176
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
1177 prompt = None
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
1178 if cb is merge.handlers.abort:
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
1179 prompt = cb
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
1180 elif cb is merge.handlers.noninteractive:
192
7a84a8656679 client: do not append an option to a list of arguments
Yuya Nishihara <yuya@tcha.org>
parents: 191
diff changeset
1181 pass
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
1182 else:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1183 prompt = lambda size, output: cb(output) + b('\n')
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
1184
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
1185 self.rawcommand(args, prompt=prompt)
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents: 44
diff changeset
1186
32
a2fc0a7f648e client: add move command
Idan Kamara <idankk86@gmail.com>
parents: 31
diff changeset
1187 def move(self, source, dest, after=False, force=False, dryrun=False,
a2fc0a7f648e client: add move command
Idan Kamara <idankk86@gmail.com>
parents: 31
diff changeset
1188 include=None, exclude=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1189 """Mark dest as copies of source; mark source for deletion. If dest
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1190 is a directory, copies are put in that directory. If dest is a
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1191 file, then source must be a string.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1192
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1193 Returns True on success, False if errors are encountered.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1194
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1195 source - a file or a list of files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1196 dest - a destination file or directory
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1197 after - record a rename that has already occurred
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1198 force - forcibly copy over an existing managed file
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1199 dryrun - do not perform actions, just print output
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1200 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1201 exclude - exclude names matching the given patterns
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1202
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1203 """
32
a2fc0a7f648e client: add move command
Idan Kamara <idankk86@gmail.com>
parents: 31
diff changeset
1204 if not isinstance(source, list):
a2fc0a7f648e client: add move command
Idan Kamara <idankk86@gmail.com>
parents: 31
diff changeset
1205 source = [source]
a2fc0a7f648e client: add move command
Idan Kamara <idankk86@gmail.com>
parents: 31
diff changeset
1206
a2fc0a7f648e client: add move command
Idan Kamara <idankk86@gmail.com>
parents: 31
diff changeset
1207 source.append(dest)
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1208 args = cmdbuilder(b('move'), A=after, f=force, n=dryrun,
87
5661d5f7e39b client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents: 79
diff changeset
1209 I=include, X=exclude, *source)
32
a2fc0a7f648e client: add move command
Idan Kamara <idankk86@gmail.com>
parents: 31
diff changeset
1210
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1211 eh = util.reterrorhandler(args)
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1212 self.rawcommand(args, eh=eh)
32
a2fc0a7f648e client: add move command
Idan Kamara <idankk86@gmail.com>
parents: 31
diff changeset
1213
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1214 return bool(eh)
32
a2fc0a7f648e client: add move command
Idan Kamara <idankk86@gmail.com>
parents: 31
diff changeset
1215
26
b4e5c8745ef3 client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents: 25
diff changeset
1216 def outgoing(self, revrange=None, path=None, force=False, newest=False,
b4e5c8745ef3 client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents: 25
diff changeset
1217 bookmarks=False, branch=None, limit=None, nomerges=False,
b4e5c8745ef3 client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents: 25
diff changeset
1218 subrepos=False):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1219 """Return changesets not found in the specified path or the default push
27
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1220 location.
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1221
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1222 When bookmarks=True, return a list of (name, node) of
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1223 bookmarks that will be pushed.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1224
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1225 revrange - a (list of) changeset intended to be included in
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1226 the destination force - run even when the destination is
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1227 unrelated newest - show newest record first branch - a
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1228 specific branch you would like to push limit - limit number of
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1229 changes displayed nomerges - do not show merges ssh - specify
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1230 ssh command to use remotecmd - specify hg command to run on
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1231 the remote side insecure - do not verify server certificate
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1232 (ignoring web.cacerts config) subrepos - recurse into
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1233 subrepositories
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1234
27
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1235 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1236 args = cmdbuilder(b('outgoing'),
26
b4e5c8745ef3 client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents: 25
diff changeset
1237 path,
b4e5c8745ef3 client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents: 25
diff changeset
1238 template=templates.changeset, r=revrange,
b4e5c8745ef3 client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents: 25
diff changeset
1239 f=force, n=newest, B=bookmarks,
b4e5c8745ef3 client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents: 25
diff changeset
1240 b=branch, S=subrepos)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1241
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1242 def eh(ret, out, err):
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1243 if ret != 1:
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1244 raise error.CommandError(args, ret, out, err)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1245
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1246 out = self.rawcommand(args, eh=eh)
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1247 if not out:
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1248 return []
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1249
27
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1250 out = util.eatlines(out, 2)
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1251 if bookmarks:
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1252 bms = []
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1253 for line in out.splitlines():
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1254 bms.append(tuple(line.split()))
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1255 return bms
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1256 else:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1257 out = out.split(b('\0'))[:-1]
27
46908f4b87d5 client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents: 26
diff changeset
1258 return self._parserevs(out)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1259
18
518149e32888 client: add parents command
Idan Kamara <idankk86@gmail.com>
parents: 17
diff changeset
1260 def parents(self, rev=None, file=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1261 """Return the working directory's parent revisions. If rev is given,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1262 the parent of that revision will be printed. If file is given,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1263 the revision in which the file was last changed (before the
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1264 working directory revision or the revision specified by rev)
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1265 is returned.
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1266
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1267 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1268 args = cmdbuilder(b('parents'), file, template=templates.changeset,
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1269 r=rev, hidden=self.hidden)
18
518149e32888 client: add parents command
Idan Kamara <idankk86@gmail.com>
parents: 17
diff changeset
1270
518149e32888 client: add parents command
Idan Kamara <idankk86@gmail.com>
parents: 17
diff changeset
1271 out = self.rawcommand(args)
518149e32888 client: add parents command
Idan Kamara <idankk86@gmail.com>
parents: 17
diff changeset
1272 if not out:
518149e32888 client: add parents command
Idan Kamara <idankk86@gmail.com>
parents: 17
diff changeset
1273 return
518149e32888 client: add parents command
Idan Kamara <idankk86@gmail.com>
parents: 17
diff changeset
1274
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1275 out = out.split(b('\0'))[:-1]
18
518149e32888 client: add parents command
Idan Kamara <idankk86@gmail.com>
parents: 17
diff changeset
1276
518149e32888 client: add parents command
Idan Kamara <idankk86@gmail.com>
parents: 17
diff changeset
1277 return self._parserevs(out)
518149e32888 client: add parents command
Idan Kamara <idankk86@gmail.com>
parents: 17
diff changeset
1278
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1279 def paths(self, name=None):
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1280 """
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1281 Return the definition of given symbolic path name. If no name is given,
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1282 return a dictionary of pathname : url of all available names.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1283
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1284 Path names are defined in the [paths] section of your configuration file
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1285 and in "/etc/mercurial/hgrc". If run inside a repository, ".hg/hgrc" is
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1286 used, too.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1287 """
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1288 if not name:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1289 out = self.rawcommand([b('paths')])
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1290 if not out:
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1291 return {}
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1292
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1293 return dict([s.split(b(' = '))
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1294 for s in out.rstrip().split(b('\n'))])
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1295 else:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1296 args = cmdbuilder(b('paths'), name)
5
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
1297 out = self.rawcommand(args)
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1298 return out.rstrip()
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1299
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1300 def pull(self, source=None, rev=None, update=False, force=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1301 bookmark=None, branch=None, ssh=None, remotecmd=None,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1302 insecure=False, tool=None):
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1303 """Pull changes from a remote repository.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1304
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1305 This finds all changes from the repository specified by source
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1306 and adds them to this repository. If source is omitted, the
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1307 'default' path will be used. By default, this does not update
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1308 the copy of the project in the working directory.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1309
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1310 Returns True on success, False if update was given and there were
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1311 unresolved files.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1312
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1313 update - update to new branch head if changesets were pulled
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1314 force - run even when remote repository is unrelated
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1315 rev - a (list of) remote changeset intended to be added
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1316 bookmark - (list of) bookmark to pull
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1317 branch - a (list of) specific branch you would like to pull
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1318 ssh - specify ssh command to use
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1319 remotecmd - specify hg command to run on the remote side
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1320 insecure - do not verify server certificate (ignoring
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1321 web.cacerts config)
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1322 tool - specify merge tool for rebase
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1323
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1324 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1325 args = cmdbuilder(b('pull'), source, r=rev, u=update, f=force,
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1326 B=bookmark, b=branch, e=ssh,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1327 remotecmd=remotecmd, insecure=insecure,
40
238efe4fd7db client: add pull command
Idan Kamara <idankk86@gmail.com>
parents: 39
diff changeset
1328 t=tool)
238efe4fd7db client: add pull command
Idan Kamara <idankk86@gmail.com>
parents: 39
diff changeset
1329
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1330 eh = util.reterrorhandler(args)
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1331 self.rawcommand(args, eh=eh)
40
238efe4fd7db client: add pull command
Idan Kamara <idankk86@gmail.com>
parents: 39
diff changeset
1332
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1333 return bool(eh)
40
238efe4fd7db client: add pull command
Idan Kamara <idankk86@gmail.com>
parents: 39
diff changeset
1334
39
0555d58a7313 client: add push command
Idan Kamara <idankk86@gmail.com>
parents: 38
diff changeset
1335 def push(self, dest=None, rev=None, force=False, bookmark=None, branch=None,
0555d58a7313 client: add push command
Idan Kamara <idankk86@gmail.com>
parents: 38
diff changeset
1336 newbranch=False, ssh=None, remotecmd=None, insecure=False):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1337 """Push changesets from this repository to the specified destination.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1338
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1339 This operation is symmetrical to pull: it is identical to a pull in the
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1340 destination repository from the current one.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1341
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1342 Returns True if push was successful, False if nothing to push.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1343
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1344 rev - the (list of) specified revision and all its ancestors
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1345 will be pushed to the remote repository.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1346
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1347 force - override the default behavior and push all changesets on all
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1348 branches.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1349
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1350 bookmark - (list of) bookmark to push
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1351 branch - a (list of) specific branch you would like to push
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1352 newbranch - allows push to create a new named branch that is
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1353 not present at the destination. This allows you to only create
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1354 a new branch without forcing other changes.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1355
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1356 ssh - specify ssh command to use
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1357 remotecmd - specify hg command to run on the remote side
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1358 insecure - do not verify server certificate (ignoring
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1359 web.cacerts config)
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1360
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1361 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1362 args = cmdbuilder(b('push'), dest, r=rev, f=force, B=bookmark, b=branch,
39
0555d58a7313 client: add push command
Idan Kamara <idankk86@gmail.com>
parents: 38
diff changeset
1363 new_branch=newbranch, e=ssh, remotecmd=remotecmd,
0555d58a7313 client: add push command
Idan Kamara <idankk86@gmail.com>
parents: 38
diff changeset
1364 insecure=insecure)
0555d58a7313 client: add push command
Idan Kamara <idankk86@gmail.com>
parents: 38
diff changeset
1365
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1366 eh = util.reterrorhandler(args)
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1367 self.rawcommand(args, eh=eh)
39
0555d58a7313 client: add push command
Idan Kamara <idankk86@gmail.com>
parents: 38
diff changeset
1368
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1369 return bool(eh)
39
0555d58a7313 client: add push command
Idan Kamara <idankk86@gmail.com>
parents: 38
diff changeset
1370
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1371 def remove(self, files, after=False, force=False, include=None,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1372 exclude=None):
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1373 """Schedule the indicated files for removal from the repository. This
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1374 only removes files from the current branch, not from the
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1375 entire project history.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1376
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1377 Returns True on success, False if any warnings encountered.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1378
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1379 after - used to remove only files that have already been deleted
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1380 force - remove (and delete) file even if added or modified
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1381 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1382 exclude - exclude names matching the given patterns
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1383
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1384 """
30
b7042bb3dbfd client: add remove command
Idan Kamara <idankk86@gmail.com>
parents: 29
diff changeset
1385 if not isinstance(files, list):
b7042bb3dbfd client: add remove command
Idan Kamara <idankk86@gmail.com>
parents: 29
diff changeset
1386 files = [files]
b7042bb3dbfd client: add remove command
Idan Kamara <idankk86@gmail.com>
parents: 29
diff changeset
1387
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1388 args = cmdbuilder(b('remove'), A=after, f=force, I=include, X=exclude,
87
5661d5f7e39b client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents: 79
diff changeset
1389 *files)
30
b7042bb3dbfd client: add remove command
Idan Kamara <idankk86@gmail.com>
parents: 29
diff changeset
1390
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1391 eh = util.reterrorhandler(args)
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1392 self.rawcommand(args, eh=eh)
30
b7042bb3dbfd client: add remove command
Idan Kamara <idankk86@gmail.com>
parents: 29
diff changeset
1393
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1394 return bool(eh)
30
b7042bb3dbfd client: add remove command
Idan Kamara <idankk86@gmail.com>
parents: 29
diff changeset
1395
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1396 def resolve(self, file=[], all=False, listfiles=False, mark=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1397 unmark=False, tool=None, include=None, exclude=None):
63
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1398 """
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1399 Redo merges or set/view the merge status of given files.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1400
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1401 Returns True on success, False if any files fail a resolve attempt.
63
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1402
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1403 When listfiles is True, returns a list of (code, file path) of resolved
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1404 and unresolved files. Code will be 'R' or 'U' accordingly.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1405
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1406 all - select all unresolved files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1407 mark - mark files as resolved
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1408 unmark - mark files as unresolved
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1409 tool - specify merge tool
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1410 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1411 exclude - exclude names matching the given patterns
63
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1412 """
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1413 if not isinstance(file, list):
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1414 file = [file]
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1415
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1416 args = cmdbuilder(b('resolve'), a=all, l=listfiles, m=mark, u=unmark,
87
5661d5f7e39b client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents: 79
diff changeset
1417 t=tool, I=include, X=exclude, *file)
63
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1418
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1419 out = self.rawcommand(args)
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1420
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1421 if listfiles:
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1422 l = []
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1423 for line in out.splitlines():
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1424 l.append(tuple(line.split(b(' '), 1)))
63
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1425 return l
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents: 62
diff changeset
1426
47
94d2988e55b7 client: add revert command
Idan Kamara <idankk86@gmail.com>
parents: 46
diff changeset
1427 def revert(self, files, rev=None, all=False, date=None, nobackup=False,
94d2988e55b7 client: add revert command
Idan Kamara <idankk86@gmail.com>
parents: 46
diff changeset
1428 dryrun=False, include=None, exclude=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1429 """With no revision specified, revert the specified files or
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1430 directories to the contents they had in the parent of the
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1431 working directory. This restores the contents of files to an
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1432 unmodified state and unschedules adds, removes, copies, and
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1433 renames. If the working directory has two parents, you must
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1434 explicitly specify a revision.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1435
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1436 Specifying rev or date will revert the given files or
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1437 directories to their states as of a specific revision. Because
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1438 revert does not change the working directory parents, this
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1439 will cause these files to appear modified. This can be helpful
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1440 to "back out" some or all of an earlier change.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1441
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1442 Modified files are saved with a .orig suffix before reverting.
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1443 To disable these backups, use nobackup.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1444
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1445 Returns True on success.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1446
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1447 all - revert all changes when no arguments given
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1448 date - tipmost revision matching date
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1449 rev - revert to the specified revision
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1450 nobackup - do not save backup copies of files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1451 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1452 exclude - exclude names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1453 dryrun - do not perform actions, just print output
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1454
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1455 """
47
94d2988e55b7 client: add revert command
Idan Kamara <idankk86@gmail.com>
parents: 46
diff changeset
1456 if not isinstance(files, list):
94d2988e55b7 client: add revert command
Idan Kamara <idankk86@gmail.com>
parents: 46
diff changeset
1457 files = [files]
94d2988e55b7 client: add revert command
Idan Kamara <idankk86@gmail.com>
parents: 46
diff changeset
1458
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1459 args = cmdbuilder(b('revert'), r=rev, a=all, d=date,
87
5661d5f7e39b client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents: 79
diff changeset
1460 no_backup=nobackup, n=dryrun, I=include, X=exclude,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
1461 hidden=self.hidden, *files)
47
94d2988e55b7 client: add revert command
Idan Kamara <idankk86@gmail.com>
parents: 46
diff changeset
1462
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1463 eh = util.reterrorhandler(args)
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1464 self.rawcommand(args, eh=eh)
47
94d2988e55b7 client: add revert command
Idan Kamara <idankk86@gmail.com>
parents: 46
diff changeset
1465
50
bd7dfd94b0d9 client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents: 48
diff changeset
1466 return bool(eh)
47
94d2988e55b7 client: add revert command
Idan Kamara <idankk86@gmail.com>
parents: 46
diff changeset
1467
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1468 def root(self):
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1469 """
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1470 Return the root directory of the current repository.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1471 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1472 return self.rawcommand([b('root')]).rstrip()
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1473
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1474 def status(self, rev=None, change=None, all=False, modified=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1475 added=False, removed=False, deleted=False, clean=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1476 unknown=False, ignored=False, copies=False,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1477 subrepos=False, include=None, exclude=None):
33
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1478 """
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1479 Return status of files in the repository as a list of (code, file path)
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1480 where code can be:
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1481
33
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1482 M = modified
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1483 A = added
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1484 R = removed
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1485 C = clean
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1486 ! = missing (deleted by non-hg command, but still tracked)
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1487 ? = untracked
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1488 I = ignored
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1489 = origin of the previous file listed as A (added)
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1490
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1491 rev - show difference from (list of) revision
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1492 change - list the changed files of a revision
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1493 all - show status of all files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1494 modified - show only modified files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1495 added - show only added files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1496 removed - show only removed files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1497 deleted - show only deleted (but tracked) files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1498 clean - show only files without changes
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1499 unknown - show only unknown (not tracked) files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1500 ignored - show only ignored files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1501 copies - show source of copied files
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1502 subrepos - recurse into subrepositories
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1503 include - include names matching the given patterns
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1504 exclude - exclude names matching the given patterns
33
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1505 """
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1506 if rev and change:
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1507 raise ValueError('cannot specify both rev and change')
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1508
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1509 args = cmdbuilder(b('status'), rev=rev, change=change, A=all,
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1510 m=modified, a=added, r=removed, d=deleted, c=clean,
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1511 u=unknown, i=ignored, C=copies, S=subrepos, I=include,
192
7a84a8656679 client: do not append an option to a list of arguments
Yuya Nishihara <yuya@tcha.org>
parents: 191
diff changeset
1512 X=exclude, hidden=self.hidden, print0=True)
33
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1513
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents: 32
diff changeset
1514 out = self.rawcommand(args)
34
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 33
diff changeset
1515 l = []
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1516
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1517 for entry in out.split(b('\0')):
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1518 if entry:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1519 if entry[0:1] == b(' '):
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1520 l.append((b(' '), entry[2:]))
35
1e33bbea23e5 client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents: 34
diff changeset
1521 else:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1522 l.append(tuple(entry.split(b(' '), 1)))
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1523
34
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 33
diff changeset
1524 return l
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1525
42
b6b75c71ac58 client: add tag command
Idan Kamara <idankk86@gmail.com>
parents: 41
diff changeset
1526 def tag(self, names, rev=None, message=None, force=False, local=False,
b6b75c71ac58 client: add tag command
Idan Kamara <idankk86@gmail.com>
parents: 41
diff changeset
1527 remove=False, date=None, user=None):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1528 """Add one or more tags specified by names for the current or given
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1529 revision.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1530
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1531 Changing an existing tag is normally disallowed; use force to override.
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1532
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1533 Tag commits are usually made at the head of a branch. If the
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1534 parent of the working directory is not a branch head, a
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1535 CommandError will be raised. force can be specified to force
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1536 the tag commit to be based on a non-head changeset.
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1537
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1538 local - make the tag local
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1539 rev - revision to tag
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1540 remove - remove a tag
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1541 message - set commit message
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1542 date - record the specified date as commit date
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1543 user - record the specified user as committer
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1544
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1545 """
42
b6b75c71ac58 client: add tag command
Idan Kamara <idankk86@gmail.com>
parents: 41
diff changeset
1546 if not isinstance(names, list):
b6b75c71ac58 client: add tag command
Idan Kamara <idankk86@gmail.com>
parents: 41
diff changeset
1547 names = [names]
b6b75c71ac58 client: add tag command
Idan Kamara <idankk86@gmail.com>
parents: 41
diff changeset
1548
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1549 args = cmdbuilder(b('tag'), r=rev, m=message, f=force, l=local,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
1550 remove=remove, d=date, u=user, hidden=self.hidden,
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
1551 *names)
42
b6b75c71ac58 client: add tag command
Idan Kamara <idankk86@gmail.com>
parents: 41
diff changeset
1552
b6b75c71ac58 client: add tag command
Idan Kamara <idankk86@gmail.com>
parents: 41
diff changeset
1553 self.rawcommand(args)
b6b75c71ac58 client: add tag command
Idan Kamara <idankk86@gmail.com>
parents: 41
diff changeset
1554
43
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1555 def tags(self):
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1556 """
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1557 Return a list of repository tags as: (name, rev, node, islocal)
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1558 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1559 args = cmdbuilder(b('tags'), v=True)
43
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1560
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1561 out = self.rawcommand(args)
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1562
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1563 t = []
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1564 for line in out.splitlines():
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1565 taglocal = line.endswith(b(' local'))
43
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1566 if taglocal:
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1567 line = line[:-6]
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1568 name, rev = line.rsplit(b(' '), 1)
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1569 rev, node = rev.split(b(':'))
43
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1570 t.append((name.rstrip(), int(rev), node, taglocal))
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1571 return t
77ebb51f5f36 client: add tags command
Idan Kamara <idankk86@gmail.com>
parents: 42
diff changeset
1572
125
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1573 def phase(self, revs=(), secret=False, draft=False, public=False,
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1574 force=False):
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1575 '''Set or show the current phase name.
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1576
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1577 revs - target revision(s)
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1578 public - set changeset phase to public
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1579 draft - set changeset phase to draft
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1580 secret - set changeset phase to secret
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1581 force - allow to move boundary backward
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1582
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1583 output format: [(id, phase) ...] for each changeset
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1584
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1585 The arguments match the mercurial API.
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1586 '''
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1587 if not isinstance(revs, (list, tuple)):
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1588 revs = [revs]
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1589 args = util.cmdbuilder(b('phase'), secret=secret, draft=draft,
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1590 public=public, force=force,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1591 hidden=self.hidden, *revs)
125
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1592 out = self.rawcommand(args)
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1593 if draft or public or secret:
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1594 return
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1595 else:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1596 output = [i.split(b(': '))for i in out.strip().split(b('\n'))]
125
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1597 return [(int(num), phase) for (num, phase) in output]
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 123
diff changeset
1598
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1599 def summary(self, remote=False):
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1600 """
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1601 Return a dictionary with a brief summary of the working directory state,
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1602 including parents, branch, commit status, and available updates.
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1603
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1604 'parent' : a list of (rev, node, tags, message)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1605 'branch' : the current branch
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1606 'commit' : True if the working directory is clean, False otherwise
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1607 'update' : number of available updates,
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1608 ['remote' : (in, in bookmarks, out, out bookmarks),]
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1609 ['mq': (applied, unapplied) mq patches,]
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1610
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1611 unparsed entries will be of them form key : value
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1612 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1613 args = cmdbuilder(b('summary'), remote=remote, hidden=self.hidden)
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1614
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1615 out = self.rawcommand(args).splitlines()
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1616
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1617 d = {}
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1618 while out:
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1619 line = out.pop(0)
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1620 name, value = line.split(b(': '), 1)
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1621
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1622 if name == b('parent'):
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1623 parent, tags = value.split(b(' '), 1)
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1624 rev, node = parent.split(b(':'))
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1625
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1626 if tags:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1627 tags = tags.replace(b(' (empty repository)'), b(''))
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1628 else:
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1629 tags = None
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1630
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1631 value = d.get(name, [])
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1632
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1633 if rev == b('-1'):
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1634 value.append((int(rev), node, tags, None))
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1635 else:
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1636 message = out.pop(0)[1:]
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1637 value.append((int(rev), node, tags, message))
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1638 elif name == b('branch'):
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1639 pass
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1640 elif name == b('commit'):
187
9062a6b935ad summary: parse commit line less strictly (issue5637)
Yuya Nishihara <yuya@tcha.org>
parents: 181
diff changeset
1641 value = b('(clean)') in value
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1642 elif name == b('update'):
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1643 if value == b('(current)'):
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1644 value = 0
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1645 else:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1646 value = int(value.split(b(' '), 1)[0])
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1647 elif remote and name == b('remote'):
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1648 if value == b('(synced)'):
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1649 value = 0, 0, 0, 0
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1650 else:
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1651 inc = incb = out_ = outb = 0
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1652
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1653 for v in value.split(b(', ')):
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1654 count, v = v.split(b(' '), 1)
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1655 if v == b('outgoing'):
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1656 out_ = int(count)
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1657 elif v.endswith(b('incoming')):
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1658 inc = int(count)
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1659 elif v == b('incoming bookmarks'):
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1660 incb = int(count)
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1661 elif v == b('outgoing bookmarks'):
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1662 outb = int(count)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1663
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1664 value = inc, incb, out_, outb
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1665 elif name == b('mq'):
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1666 applied = unapplied = 0
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1667 for v in value.split(b(', ')):
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1668 count, v = v.split(b(' '), 1)
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1669 if v == b('applied'):
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1670 applied = int(count)
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1671 elif v == b('unapplied'):
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1672 unapplied = int(count)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1673 value = applied, unapplied
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1674
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1675 d[name] = value
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1676
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1677 return d
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents: 50
diff changeset
1678
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1679 def tip(self):
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1680 """
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1681 Return the tip revision (usually just called the tip) which is the
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1682 changeset most recently added to the repository (and therefore the most
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1683 recently changed head).
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1684 """
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1685 args = cmdbuilder(b('tip'), template=templates.changeset,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
1686 hidden=self.hidden)
5
3182303f388d client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents: 4
diff changeset
1687 out = self.rawcommand(args)
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1688 out = out.split(b('\0'))
2
5fa34c3ac9a0 turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1689
10
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1690 return self._parserevs(out)[0]
fce3102c19e5 client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents: 8
diff changeset
1691
20
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1692 def update(self, rev=None, clean=False, check=False, date=None):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1693 """
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1694 Update the repository's working directory to changeset specified by rev.
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1695 If rev isn't specified, update to the tip of the current named branch.
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1696
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1697 Return the number of files (updated, merged, removed, unresolved)
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1698
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1699 clean - discard uncommitted changes (no backup)
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1700 check - update across branches if no uncommitted changes
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1701 date - tipmost revision matching date
20
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1702 """
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1703 if clean and check:
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1704 raise ValueError('clean and check cannot both be True')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1705
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1706 args = cmdbuilder(b('update'), r=rev, C=clean, c=check, d=date,
123
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 122
diff changeset
1707 hidden=self.hidden)
20
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1708
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1709 def eh(ret, out, err):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1710 if ret == 1:
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1711 return out
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1712
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1713 raise error.CommandError(args, ret, out, err)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1714
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1715
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1716 out = self.rawcommand(args, eh=eh)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents: 18
diff changeset
1717
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1718 m = re.search(b(r'^(\d+).+, (\d+).+, (\d+).+, (\d+)'), out,
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1719 re.MULTILINE)
133
b6f601ba7f3c style: fixup whitespace
Matt Mackall <mpm@selenic.com>
parents: 132
diff changeset
1720 return tuple(map(int, list(m.groups())))
41
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1721
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1722 @property
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1723 def version(self):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1724 """Return hg version that runs the command server as a 4 fielded
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1725 tuple: major, minor, micro and local build info. e.g. (1, 9,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 133
diff changeset
1726 1, '+4-3095db9f5c2c')
65
91ffa1de398c document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents: 64
diff changeset
1727 """
41
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1728 if self._version is None:
142
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1729 v = self.rawcommand(cmdbuilder(b('version'), q=True))
fe74d5599539 hglib: wrap all application string literals in util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 136
diff changeset
1730 v = list(re.match(b(r'.*?(\d+)\.(\d+)\.?(\d+)?(\+[0-9a-f-]+)?'),
41
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1731 v).groups())
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1732
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1733 for i in range(3):
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1734 try:
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1735 v[i] = int(v[i])
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1736 except TypeError:
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1737 v[i] = 0
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1738
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1739 self._version = tuple(v)
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1740
e185c3922c68 client: add version command
Idan Kamara <idankk86@gmail.com>
parents: 40
diff changeset
1741 return self._version
95
bd23bc72e662 client: add a convenience method __getitem__ to return a changectx
Idan Kamara <idankk86@gmail.com>
parents: 91
diff changeset
1742
bd23bc72e662 client: add a convenience method __getitem__ to return a changectx
Idan Kamara <idankk86@gmail.com>
parents: 91
diff changeset
1743 def __getitem__(self, changeid):
176
3f854e3bcdd1 client: raise KeyError from __getitem__ (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 175
diff changeset
1744 try:
3f854e3bcdd1 client: raise KeyError from __getitem__ (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 175
diff changeset
1745 return context.changectx(self, changeid)
3f854e3bcdd1 client: raise KeyError from __getitem__ (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 175
diff changeset
1746 except ValueError as e:
3f854e3bcdd1 client: raise KeyError from __getitem__ (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 175
diff changeset
1747 raise KeyError(*e.args)
122
e05b0cf920bb client: implement the 'in' keyword for a client object
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 120
diff changeset
1748
e05b0cf920bb client: implement the 'in' keyword for a client object
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 120
diff changeset
1749 def __contains__(self, changeid):
e05b0cf920bb client: implement the 'in' keyword for a client object
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 120
diff changeset
1750 """
e05b0cf920bb client: implement the 'in' keyword for a client object
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 120
diff changeset
1751 check if changeid, which can be either a local revision number or a
e05b0cf920bb client: implement the 'in' keyword for a client object
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 120
diff changeset
1752 changeset id, matches a changeset in the client.
e05b0cf920bb client: implement the 'in' keyword for a client object
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 120
diff changeset
1753 """
e05b0cf920bb client: implement the 'in' keyword for a client object
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 120
diff changeset
1754 try:
e05b0cf920bb client: implement the 'in' keyword for a client object
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 120
diff changeset
1755 context.changectx(self, changeid)
e05b0cf920bb client: implement the 'in' keyword for a client object
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 120
diff changeset
1756 return True
e05b0cf920bb client: implement the 'in' keyword for a client object
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 120
diff changeset
1757 except ValueError:
e05b0cf920bb client: implement the 'in' keyword for a client object
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 120
diff changeset
1758 return False