Mercurial > python-hglib
annotate hglib/client.py @ 89:351d2799f145
client: added context manager protocol methods
This allows client objects to be used with the 'with' statement and be closed
automatically when the 'with' context exits.
author | Jeff Laughlin <jmlaughlin@integrated-informatics.com> |
---|---|
date | Wed, 23 Nov 2011 09:57:37 -0500 |
parents | 5661d5f7e39b |
children | b894c2222dff |
rev | line source |
---|---|
21 | 1 import subprocess, os, struct, cStringIO, collections, re |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
2 import hglib, error, util, templates, merge |
2
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
3 |
4 | 4 from util import cmdbuilder |
5 | |
2
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
6 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
|
7 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
|
8 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
|
9 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
|
10 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
|
11 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
12 revision = collections.namedtuple('revision', 'rev, node, tags, ' |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
13 'branch, author, desc') |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
14 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
15 def __init__(self, path, encoding, configs): |
44
3a661f63107e
client: tell the server we're interactive
Idan Kamara <idankk86@gmail.com>
parents:
43
diff
changeset
|
16 args = [hglib.HGPATH, 'serve', '--cmdserver', 'pipe', |
3a661f63107e
client: tell the server we're interactive
Idan Kamara <idankk86@gmail.com>
parents:
43
diff
changeset
|
17 '--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
|
18 if path: |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
19 args += ['-R', path] |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
20 if configs: |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
21 args += ['--config'] + configs |
72 | 22 env = {} |
2
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
23 if encoding: |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
24 env['HGENCODING'] = encoding |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
25 |
72 | 26 self.server = util.popen(args, env) |
2
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
27 self._readhello() |
41
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
28 self._version = 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
|
29 |
89
351d2799f145
client: added context manager protocol methods
Jeff Laughlin <jmlaughlin@integrated-informatics.com>
parents:
87
diff
changeset
|
30 def __enter__(self): |
351d2799f145
client: added context manager protocol methods
Jeff Laughlin <jmlaughlin@integrated-informatics.com>
parents:
87
diff
changeset
|
31 return self |
351d2799f145
client: added context manager protocol methods
Jeff Laughlin <jmlaughlin@integrated-informatics.com>
parents:
87
diff
changeset
|
32 |
351d2799f145
client: added context manager protocol methods
Jeff Laughlin <jmlaughlin@integrated-informatics.com>
parents:
87
diff
changeset
|
33 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
|
34 self.close() |
351d2799f145
client: added context manager protocol methods
Jeff Laughlin <jmlaughlin@integrated-informatics.com>
parents:
87
diff
changeset
|
35 |
2
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
36 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
|
37 """ 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
|
38 ch, msg = self._readchannel() |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
39 assert ch == 'o' |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
40 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
41 msg = msg.split('\n') |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
42 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
43 self.capabilities = msg[0][len('capabilities: '):] |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
44 if not self.capabilities: |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
45 raise error.ResponseError("bad hello message: expected 'capabilities: '" |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
46 ", got %r" % msg[0]) |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
47 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
48 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
|
49 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
50 # at the very least the server should be able to run commands |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
51 assert 'runcommand' in self.capabilities |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
52 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
53 self._encoding = msg[1][len('encoding: '):] |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
54 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
|
55 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
|
56 ", 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
|
57 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
58 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
|
59 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
|
60 if not data: |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
61 raise error.ServerError() |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
62 channel, length = struct.unpack(hgclient.outputfmt, data) |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
63 if channel in 'IL': |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
64 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
|
65 else: |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
66 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
|
67 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
68 def _parserevs(self, splitted): |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
69 ''' splitted is a list of fields according to our rev.style, where each 6 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
70 fields compose one revision. ''' |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
71 return [self.revision._make(rev) for rev in util.grouper(6, splitted)] |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
72 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
73 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
|
74 def writeblock(data): |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
75 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
|
76 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
|
77 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
|
78 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
79 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
|
80 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
|
81 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
82 self.server.stdin.write('runcommand\n') |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
83 writeblock('\0'.join(args)) |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
84 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
85 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
|
86 channel, data = self._readchannel() |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
87 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
88 # 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
|
89 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
|
90 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
|
91 # 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
|
92 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
|
93 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
|
94 # result channel, command finished |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
95 elif channel == 'r': |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
96 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
|
97 # 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
|
98 elif channel.isupper(): |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
99 raise error.ResponseError("unexpected data on required channel '%s'" |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
100 % channel) |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
101 # 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
|
102 else: |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
103 pass |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
104 |
5
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
105 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
|
106 """ |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
107 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
|
108 |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
109 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
|
110 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
|
111 |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
112 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
|
113 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
|
114 received so far |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
115 |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
116 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
|
117 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
|
118 """ |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
119 |
2
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
120 out, err = cStringIO.StringIO(), cStringIO.StringIO() |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
121 outchannels = {'o' : out.write, 'e' : err.write} |
5
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
122 |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
123 inchannels = {} |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
124 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
|
125 def func(size): |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
126 reply = prompt(size, out.getvalue()) |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
127 return str(reply) |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
128 inchannels['L'] = func |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
129 if input is not None: |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
130 inchannels['I'] = input |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
131 |
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 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
|
133 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
|
134 |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
135 if ret: |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
136 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
|
137 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
|
138 else: |
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
139 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
|
140 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
|
141 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
142 def close(self): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
143 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
144 Closes the command server instance and waits for it to exit, returns the |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
145 exit code. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
146 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
147 Attempting to call any function afterwards that needs to communicate with |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
148 the server will raise a ValueError. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
149 """ |
2
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
150 self.server.stdin.close() |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
151 self.server.wait() |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
152 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
|
153 self.server = None |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
154 return ret |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
155 |
28 | 156 def add(self, files=[], dryrun=False, subrepos=False, include=None, |
157 exclude=None): | |
158 """ | |
159 Add the specified files on the next commit. | |
160 If no files are given, add all files to the repository. | |
161 | |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
162 dryrun - do no perform actions |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
163 subrepos - recurse into subrepositories |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
164 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
165 exclude - exclude names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
166 |
28 | 167 Return whether all given files were added. |
168 """ | |
169 if not isinstance(files, list): | |
170 files = [files] | |
171 | |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
172 args = cmdbuilder('add', n=dryrun, S=subrepos, I=include, X=exclude, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
173 *files) |
28 | 174 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
175 eh = util.reterrorhandler(args) |
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
176 self.rawcommand(args, eh=eh) |
28 | 177 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
178 return bool(eh) |
28 | 179 |
48
82d927ac1329
client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents:
47
diff
changeset
|
180 def addremove(self, files=[], similarity=None, dryrun=False, include=None, |
82d927ac1329
client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents:
47
diff
changeset
|
181 exclude=None): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
182 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
183 Add all new files and remove all missing files from the repository. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
184 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
185 New files are ignored if they match any of the patterns in ".hgignore". As |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
186 with add, these changes take effect at the next commit. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
187 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
188 similarity - used to detect renamed files. With a parameter |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
189 greater than 0, this compares every removed file with every added file and |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
190 records those similar enough as renames. This option takes a percentage |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
191 between 0 (disabled) and 100 (files must be identical) as its parameter. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
192 Detecting renamed files this way can be expensive. After using this |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
193 option, "hg status -C" can be used to check which files were identified as |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
194 moved or renamed. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
195 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
196 dryrun - do no perform actions |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
197 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
198 exclude - exclude names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
199 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
200 Return True if all files are successfully added. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
201 """ |
48
82d927ac1329
client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents:
47
diff
changeset
|
202 if not isinstance(files, list): |
82d927ac1329
client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents:
47
diff
changeset
|
203 files = [files] |
82d927ac1329
client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents:
47
diff
changeset
|
204 |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
205 args = cmdbuilder('addremove', s=similarity, n=dryrun, I=include, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
206 X=exclude, *files) |
48
82d927ac1329
client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents:
47
diff
changeset
|
207 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
208 eh = util.reterrorhandler(args) |
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
209 self.rawcommand(args, eh=eh) |
48
82d927ac1329
client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents:
47
diff
changeset
|
210 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
211 return bool(eh) |
48
82d927ac1329
client: add addremove command
Idan Kamara <idankk86@gmail.com>
parents:
47
diff
changeset
|
212 |
52
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
213 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
|
214 file=False, date=False, number=False, changeset=False, |
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
215 line=False, verbose=False, include=None, exclude=None): |
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
216 """ |
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
217 Show changeset information by line for each file in files. |
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
218 |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
219 rev - annotate the specified revision |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
220 nofollow - don't follow copies and renames |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
221 text - treat all files as text |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
222 user - list the author (long with -v) |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
223 file - list the filename |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
224 date - list the date |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
225 number - list the revision number (default) |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
226 changeset - list the changeset |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
227 line - show line number at the first appearance |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
228 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
229 exclude - exclude names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
230 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
231 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
|
232 separated string according to the given options. |
52
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
233 """ |
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
234 if not isinstance(files, list): |
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
235 files = [files] |
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
236 |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
237 args = cmdbuilder('annotate', r=rev, no_follow=nofollow, a=text, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
238 u=user, f=file, d=date, n=number, c=changeset, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
239 l=line, v=verbose, I=include, X=exclude, *files) |
52
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
240 |
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
241 out = self.rawcommand(args) |
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
242 |
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
243 for line in out.splitlines(): |
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
244 yield tuple(line.split(': ', 1)) |
18f72b255553
client: add annotate command
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
245 |
53
066dfa5c0b70
client: add archive command
Idan Kamara <idankk86@gmail.com>
parents:
52
diff
changeset
|
246 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
|
247 subrepos=False, include=None, exclude=None): |
066dfa5c0b70
client: add archive command
Idan Kamara <idankk86@gmail.com>
parents:
52
diff
changeset
|
248 """ |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
249 Create an unversioned archive of a repository revision. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
250 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
251 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
|
252 format string; see export for details. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
253 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
254 Each member added to an archive file has a directory prefix prepended. Use |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
255 prefix to specify a format string for the prefix. The default is the |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
256 basename of the archive, with suffixes removed. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
257 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
258 dest - destination path |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
259 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
|
260 working directory if one isn't given. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
261 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
262 nodecode - do not pass files through decoders |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
263 prefix - directory prefix for files in archive |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
264 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
|
265 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
|
266 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
267 Valid types are: |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
268 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
269 "files" a directory full of files (default) |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
270 "tar" tar archive, uncompressed |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
271 "tbz2" tar archive, compressed using bzip2 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
272 "tgz" tar archive, compressed using gzip |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
273 "uzip" zip archive, uncompressed |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
274 "zip" zip archive, compressed using deflate |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
275 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
276 subrepos - recurse into subrepositories |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
277 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
278 exclude - exclude names matching the given patterns |
53
066dfa5c0b70
client: add archive command
Idan Kamara <idankk86@gmail.com>
parents:
52
diff
changeset
|
279 """ |
066dfa5c0b70
client: add archive command
Idan Kamara <idankk86@gmail.com>
parents:
52
diff
changeset
|
280 args = cmdbuilder('archive', dest, r=rev, no_decode=nodecode, p=prefix, |
066dfa5c0b70
client: add archive command
Idan Kamara <idankk86@gmail.com>
parents:
52
diff
changeset
|
281 t=type, S=subrepos, I=include, X=exclude) |
066dfa5c0b70
client: add archive command
Idan Kamara <idankk86@gmail.com>
parents:
52
diff
changeset
|
282 |
066dfa5c0b70
client: add archive command
Idan Kamara <idankk86@gmail.com>
parents:
52
diff
changeset
|
283 self.rawcommand(args) |
066dfa5c0b70
client: add archive command
Idan Kamara <idankk86@gmail.com>
parents:
52
diff
changeset
|
284 |
22
297df22d6091
client: add backout command
Idan Kamara <idankk86@gmail.com>
parents:
21
diff
changeset
|
285 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
|
286 logfile=None, date=None, user=None): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
287 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
288 Prepare a new changeset with the effect of rev undone in the current |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
289 working directory. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
290 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
291 If rev is the parent of the working directory, then this new changeset is |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
292 committed automatically. Otherwise, hg needs to merge the changes and the |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
293 merged result is left uncommitted. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
294 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
295 rev - revision to backout |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
296 merge - merge with old dirstate parent after backout |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
297 parent - parent to choose when backing out merge |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
298 tool - specify merge tool |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
299 message - use text as commit message |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
300 logfile - read commit message from file |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
301 date - record the specified date as commit date |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
302 user - record the specified user as committer |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
303 """ |
22
297df22d6091
client: add backout command
Idan Kamara <idankk86@gmail.com>
parents:
21
diff
changeset
|
304 if message and logfile: |
297df22d6091
client: add backout command
Idan Kamara <idankk86@gmail.com>
parents:
21
diff
changeset
|
305 raise ValueError("cannot specify both a message and a logfile") |
297df22d6091
client: add backout command
Idan Kamara <idankk86@gmail.com>
parents:
21
diff
changeset
|
306 |
297df22d6091
client: add backout command
Idan Kamara <idankk86@gmail.com>
parents:
21
diff
changeset
|
307 args = cmdbuilder('backout', r=rev, merge=merge, parent=parent, t=tool, |
297df22d6091
client: add backout command
Idan Kamara <idankk86@gmail.com>
parents:
21
diff
changeset
|
308 m=message, l=logfile, d=date, u=user) |
297df22d6091
client: add backout command
Idan Kamara <idankk86@gmail.com>
parents:
21
diff
changeset
|
309 |
297df22d6091
client: add backout command
Idan Kamara <idankk86@gmail.com>
parents:
21
diff
changeset
|
310 self.rawcommand(args) |
297df22d6091
client: add backout command
Idan Kamara <idankk86@gmail.com>
parents:
21
diff
changeset
|
311 |
23
223e463c25e0
client: add bookmark command
Idan Kamara <idankk86@gmail.com>
parents:
22
diff
changeset
|
312 def bookmark(self, name, rev=None, force=False, delete=False, inactive=False, |
223e463c25e0
client: add bookmark command
Idan Kamara <idankk86@gmail.com>
parents:
22
diff
changeset
|
313 rename=None): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
314 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
315 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
|
316 with the given name. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
317 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
318 name - bookmark name |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
319 rev - revision to bookmark |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
320 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
|
321 delete - delete the given bookmark |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
322 inactive - do not mark the new bookmark active |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
323 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
|
324 """ |
23
223e463c25e0
client: add bookmark command
Idan Kamara <idankk86@gmail.com>
parents:
22
diff
changeset
|
325 args = cmdbuilder('bookmark', name, r=rev, f=force, d=delete, |
223e463c25e0
client: add bookmark command
Idan Kamara <idankk86@gmail.com>
parents:
22
diff
changeset
|
326 i=inactive, m=rename) |
223e463c25e0
client: add bookmark command
Idan Kamara <idankk86@gmail.com>
parents:
22
diff
changeset
|
327 |
223e463c25e0
client: add bookmark command
Idan Kamara <idankk86@gmail.com>
parents:
22
diff
changeset
|
328 self.rawcommand(args) |
223e463c25e0
client: add bookmark command
Idan Kamara <idankk86@gmail.com>
parents:
22
diff
changeset
|
329 |
24
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
330 def bookmarks(self): |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
331 """ |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
332 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
|
333 current one. |
24
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
334 |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
335 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
|
336 """ |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
337 out = self.rawcommand(['bookmarks']) |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
338 |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
339 bms = [] |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
340 current = -1 |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
341 if out.rstrip() != 'no bookmarks set': |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
342 for line in out.splitlines(): |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
343 iscurrent, line = line[0:3], line[3:] |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
344 if '*' in iscurrent: |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
345 current = len(bms) |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
346 name, line = line.split(' ', 1) |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
347 rev, node = line.split(':') |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
348 bms.append((name, int(rev), node)) |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
349 return bms, current |
ca0d7e212cf8
client: add bookmarks command
Idan Kamara <idankk86@gmail.com>
parents:
23
diff
changeset
|
350 |
11
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
351 def branch(self, name=None, clean=False, force=False): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
352 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
353 When name isn't given, return the current branch name. Otherwise set the |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
354 working directory branch name (the branch will not exist in the repository |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
355 until the next commit). Standard practice recommends that primary |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
356 development take place on the 'default' branch. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
357 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
358 When clean is True, reset and return the working directory branch to that |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
359 of the parent of the working directory, negating a previous branch change. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
360 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
361 name - new branch name |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
362 clean - reset branch name to parent branch name |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
363 force - set branch name even if it shadows an existing branch |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
364 """ |
11
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
365 if name and clean: |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
366 raise ValueError('cannot use both name and clean') |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
367 |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
368 args = cmdbuilder('branch', name, f=force, C=clean) |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
369 out = self.rawcommand(args).rstrip() |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
370 |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
371 if name: |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
372 return name |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
373 elif not clean: |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
374 return out |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
375 else: |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
376 # len('reset working directory to branch ') == 34 |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
10
diff
changeset
|
377 return out[34:] |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
378 |
12
c2a9b716cd80
client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents:
11
diff
changeset
|
379 def branches(self, active=False, closed=False): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
380 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
381 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
|
382 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
383 active - show only branches that have unmerged heads |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
384 closed - show normal and closed branches |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
385 """ |
12
c2a9b716cd80
client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents:
11
diff
changeset
|
386 args = cmdbuilder('branches', a=active, c=closed) |
c2a9b716cd80
client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents:
11
diff
changeset
|
387 out = self.rawcommand(args) |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
388 |
12
c2a9b716cd80
client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents:
11
diff
changeset
|
389 branches = [] |
c2a9b716cd80
client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents:
11
diff
changeset
|
390 for line in out.rstrip().splitlines(): |
79
ca5f8f43e585
branches: more robust parsing strategy
Matt Mackall <mpm@selenic.com>
parents:
72
diff
changeset
|
391 namerev, node = line.rsplit(':', 1) |
ca5f8f43e585
branches: more robust parsing strategy
Matt Mackall <mpm@selenic.com>
parents:
72
diff
changeset
|
392 name, rev = namerev.rsplit(' ', 1) |
ca5f8f43e585
branches: more robust parsing strategy
Matt Mackall <mpm@selenic.com>
parents:
72
diff
changeset
|
393 name = name.rstrip() |
12
c2a9b716cd80
client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents:
11
diff
changeset
|
394 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
|
395 branches.append((name, int(rev), node)) |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
396 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
|
397 |
54 | 398 def bundle(self, file, destrepo=None, rev=[], branch=[], base=[], all=False, |
399 force=False, type=None, ssh=None, remotecmd=None, insecure=False): | |
400 """ | |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
401 Generate a compressed changegroup file collecting changesets not known to |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
402 be in another repository. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
403 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
404 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
|
405 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
|
406 changesets, use all (or set base to 'null'). |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
407 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
408 file - destination file name |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
409 destrepo - repository to look for changes |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
410 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
|
411 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
|
412 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
|
413 all - bundle all changesets in the repository |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
414 type - bundle compression type to use, available compression methods are: |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
415 none, bzip2, and gzip (default: bzip2) |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
416 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
417 force - run even when the destrepo is unrelated |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
418 ssh - specify ssh command to use |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
419 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
|
420 insecure - do not verify server certificate (ignoring web.cacerts config) |
54 | 421 |
422 Return True if a bundle was created, False if no changes were found. | |
423 """ | |
424 args = cmdbuilder('bundle', file, destrepo, f=force, r=rev, b=branch, | |
425 base=base, a=all, t=type, e=ssh, remotecmd=remotecmd, | |
426 insecure=insecure) | |
427 | |
428 eh = util.reterrorhandler(args) | |
429 self.rawcommand(args, eh=eh) | |
430 | |
431 return bool(eh) | |
432 | |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
433 def cat(self, files, rev=None, output=None): |
65
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 Return a string containing the specified files as they were at the |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
436 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
|
437 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
|
438 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
439 If output is given, writes the contents to the specified file. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
440 The name of the file is given using a format string. The formatting rules |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
441 are the same as for the export command, with the following additions: |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
442 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
443 "%s" basename of file being printed |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
444 "%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
|
445 "%p" root-relative path name of file being printed |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
446 """ |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
447 args = cmdbuilder('cat', r=rev, o=output, *files) |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
448 out = self.rawcommand(args) |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
449 |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
450 if not output: |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
451 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
|
452 |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
453 def clone(self, source='.', dest=None, branch=None, updaterev=None, |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
454 revrange=None): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
455 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
456 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
|
457 directory dest. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
458 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
459 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
|
460 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
461 branch - clone only the specified branch |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
462 updaterev - revision, tag or branch to check out |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
463 revrange - include the specified changeset |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
464 """ |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
465 args = cmdbuilder('clone', source, dest, b=branch, u=updaterev, r=revrange) |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
466 self.rawcommand(args) |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
467 |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
15
diff
changeset
|
468 def commit(self, message=None, logfile=None, addremove=False, closebranch=False, |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
15
diff
changeset
|
469 date=None, user=None, include=None, exclude=None): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
470 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
471 Commit changes reported by status into the repository. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
472 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
473 message - the commit message |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
474 logfile - read commit message from file |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
475 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
|
476 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
|
477 date - record the specified date as commit date |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
478 user - record the specified user as committer |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
479 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
480 exclude - exclude names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
481 """ |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
15
diff
changeset
|
482 if message is None and logfile is None: |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
15
diff
changeset
|
483 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
|
484 elif message and logfile: |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
15
diff
changeset
|
485 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
|
486 |
14
e0d21c9db20b
client: use --debug when committing to get the new node info
Idan Kamara <idankk86@gmail.com>
parents:
13
diff
changeset
|
487 # --debug will print the committed cset |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
15
diff
changeset
|
488 args = cmdbuilder('commit', debug=True, m=message, A=addremove, |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
15
diff
changeset
|
489 close_branch=closebranch, d=date, u=user, l=logfile, |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
15
diff
changeset
|
490 I=include, X=exclude) |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
491 |
14
e0d21c9db20b
client: use --debug when committing to get the new node info
Idan Kamara <idankk86@gmail.com>
parents:
13
diff
changeset
|
492 out = self.rawcommand(args) |
e0d21c9db20b
client: use --debug when committing to get the new node info
Idan Kamara <idankk86@gmail.com>
parents:
13
diff
changeset
|
493 rev, node = out.splitlines()[-1].rsplit(':') |
15
f1af31960414
client: change return value of commit() to (rev, node)
Idan Kamara <idankk86@gmail.com>
parents:
14
diff
changeset
|
494 return int(rev.split()[-1]), 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
|
495 |
21 | 496 def config(self, names=[], untrusted=False, showsource=False): |
497 """ | |
498 Return a list of (section, key, value) config settings from all 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
|
499 |
21 | 500 When showsource is specified, return (source, section, key, value) where |
501 source is of the form filename:[line] | |
502 """ | |
503 def splitline(s): | |
504 k, value = s.rstrip().split('=', 1) | |
505 section, key = k.split('.', 1) | |
506 return (section, key, value) | |
507 | |
508 if not isinstance(names, list): | |
509 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
|
510 |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
511 args = cmdbuilder('showconfig', u=untrusted, debug=showsource, *names) |
21 | 512 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
|
513 |
21 | 514 conf = [] |
515 if showsource: | |
516 out = util.skiplines(out, 'read config from: ') | |
517 for line in out.splitlines(): | |
518 m = re.match(r"(.+?:(?:\d+:)?) (.*)", line) | |
519 t = splitline(m.group(2)) | |
520 conf.append((m.group(1)[:-1], t[0], t[1], t[2])) | |
521 else: | |
522 for line in out.splitlines(): | |
523 conf.append(splitline(line)) | |
524 | |
525 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
|
526 |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
527 @property |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
528 def encoding(self): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
529 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
530 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
|
531 """ |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
532 if not 'getencoding' in self.capabilities: |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
533 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
|
534 |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
535 if not self._encoding: |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
536 self.server.stdin.write('getencoding\n') |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
537 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
|
538 |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
539 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
|
540 |
29 | 541 def copy(self, source, dest, after=False, force=False, dryrun=False, |
542 include=None, exclude=None): | |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
543 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
544 Mark dest as having copies of source files. If dest is a directory, copies |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
545 are put in that directory. If dest is a file, then source must be a string. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
546 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
547 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
|
548 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
549 source - a file or a list of files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
550 dest - a destination file or directory |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
551 after - record a copy that has already occurred |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
552 force - forcibly copy over an existing managed file |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
553 dryrun - do not perform actions, just print output |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
554 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
555 exclude - exclude names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
556 """ |
29 | 557 if not isinstance(source, list): |
558 source = [source] | |
559 | |
560 source.append(dest) | |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
561 args = cmdbuilder('copy', A=after, f=force, n=dryrun, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
562 I=include, X=exclude, *source) |
29 | 563 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
564 eh = util.reterrorhandler(args) |
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
565 self.rawcommand(args, eh=eh) |
29 | 566 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
567 return bool(eh) |
29 | 568 |
61
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
569 def diff(self, files=[], revs=[], change=None, text=False, |
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
570 git=False, nodates=False, showfunction=False, reverse=False, |
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
571 ignoreallspace=False, ignorespacechange=False, ignoreblanklines=False, |
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
572 unified=None, stat=False, subrepos=False, include=None, exclude=None): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
573 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
574 Return differences between revisions for the specified files. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
575 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
576 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
|
577 change - change made by revision |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
578 text - treat all files as text |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
579 git - use git extended diff format |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
580 nodates - omit dates from diff headers |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
581 showfunction - show which function each change is in |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
582 reverse - produce a diff that undoes the changes |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
583 ignoreallspace - ignore white space when comparing lines |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
584 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
|
585 ignoreblanklines - ignore changes whose lines are all blank |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
586 unified - number of lines of context to show |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
587 stat - output diffstat-style summary of changes |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
588 subrepos - recurse into subrepositories |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
589 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
590 exclude - exclude names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
591 """ |
61
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
592 if change and revs: |
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
593 raise ValueError('cannot specify both change and rev') |
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
594 |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
595 args = cmdbuilder('diff', r=revs, c=change, |
61
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
596 a=text, g=git, nodates=nodates, |
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
597 p=showfunction, reverse=reverse, |
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
598 w=ignoreallspace, b=ignorespacechange, |
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
599 B=ignoreblanklines, U=unified, stat=stat, |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
600 S=subrepos, I=include, X=exclude, *files) |
61
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
601 |
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
602 return self.rawcommand(args) |
d0b9215180a4
client: fix diff indentation and position
Idan Kamara <idankk86@gmail.com>
parents:
57
diff
changeset
|
603 |
55 | 604 def export(self, revs, output=None, switchparent=False, text=False, git=False, |
605 nodates=False): | |
606 """ | |
607 Return the header and diffs for one or more changesets. When output is | |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
608 given, dumps to file. The name of the file is given using a format string. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
609 The formatting rules are as follows: |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
610 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
611 "%%" literal "%" character |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
612 "%H" changeset hash (40 hexadecimal digits) |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
613 "%N" number of patches being generated |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
614 "%R" changeset revision number |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
615 "%b" basename of the exporting repository |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
616 "%h" short-form changeset hash (12 hexadecimal digits) |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
617 "%n" zero-padded sequence number, starting at 1 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
618 "%r" zero-padded changeset revision number |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
619 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
620 output - print output to file with formatted name |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
621 switchparent - diff against the second parent |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
622 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
|
623 text - treat all files as text |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
624 git - use git extended diff format |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
625 nodates - omit dates from diff headers |
55 | 626 """ |
627 if not isinstance(revs, list): | |
628 revs = [revs] | |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
629 args = cmdbuilder('export', o=output, switch_parent=switchparent, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
630 a=text, g=git, nodates=nodates, *revs) |
55 | 631 |
632 out = self.rawcommand(args) | |
633 | |
634 if output is None: | |
635 return out | |
636 | |
31 | 637 def forget(self, files, include=None, exclude=None): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
638 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
639 Mark the specified files so they will no longer be tracked after the next |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
640 commit. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
641 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
642 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
|
643 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
|
644 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
645 Returns True on success. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
646 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
647 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
648 exclude - exclude names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
649 """ |
31 | 650 if not isinstance(files, list): |
651 files = [files] | |
652 | |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
653 args = cmdbuilder('forget', I=include, X=exclude, *files) |
31 | 654 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
655 eh = util.reterrorhandler(args) |
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
656 self.rawcommand(args, eh=eh) |
31 | 657 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
658 return bool(eh) |
31 | 659 |
56 | 660 def grep(self, pattern, files=[], all=False, text=False, follow=False, |
661 ignorecase=False, fileswithmatches=False, line=False, user=False, | |
662 date=False, include=None, exclude=None): | |
663 """ | |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
664 Search for a pattern in specified files and revisions. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
665 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
666 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
|
667 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
|
668 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
|
669 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
670 Yields (filename, revision, [line, [match status, [user, [date, [match]]]]]) |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
671 per match depending on the given options. |
56 | 672 |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
673 all - print all revisions that match |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
674 text - treat all files as text |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
675 follow - follow changeset history, or file history across copies and renames |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
676 ignorecase - ignore case when matching |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
677 fileswithmatches - return only filenames and revisions that match |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
678 line - return line numbers in the result tuple |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
679 user - return the author in the result tuple |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
680 date - return the date in the result tuple |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
681 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
682 exclude - exclude names matching the given patterns |
56 | 683 """ |
684 if not isinstance(files, list): | |
685 files = [files] | |
686 | |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
687 args = cmdbuilder('grep', all=all, a=text, f=follow, i=ignorecase, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
688 l=fileswithmatches, n=line, u=user, d=date, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
689 I=include, X=exclude, *[pattern] + files) |
56 | 690 args.append('-0') |
691 | |
692 def eh(ret, out, err): | |
693 if ret != 1: | |
694 raise error.CommandError(args, ret, out, err) | |
695 return '' | |
696 | |
697 out = self.rawcommand(args, eh=eh).split('\0') | |
698 | |
699 fieldcount = 3 | |
700 if user: | |
701 fieldcount += 1 | |
702 if date: | |
703 fieldcount += 1 | |
704 if line: | |
705 fieldcount += 1 | |
706 if all: | |
707 fieldcount += 1 | |
708 if fileswithmatches: | |
709 fieldcount -= 1 | |
710 | |
711 return util.grouper(fieldcount, out) | |
712 | |
57 | 713 def heads(self, rev=[], startrev=[], topological=False, closed=False): |
714 """ | |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
715 Return a list of current repository heads or branch heads. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
716 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
717 rev - return only branch heads on the branches associated with the specified |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
718 changesets. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
719 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
720 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
|
721 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
|
722 without children will be shown. |
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 closed - normal and closed branch heads. |
57 | 725 """ |
726 if not isinstance(rev, list): | |
727 rev = [rev] | |
728 | |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
729 args = cmdbuilder('heads', r=startrev, t=topological, c=closed, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
730 template=templates.changeset, *rev) |
57 | 731 |
732 def eh(ret, out, err): | |
733 if ret != 1: | |
734 raise error.CommandError(args, ret, out, err) | |
735 return '' | |
736 | |
737 out = self.rawcommand(args, eh=eh).split('\0')[:-1] | |
738 return self._parserevs(out) | |
739 | |
38
32f6a2bbf63e
client: add identify command
Idan Kamara <idankk86@gmail.com>
parents:
37
diff
changeset
|
740 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
|
741 tags=False, bookmarks=False): |
65
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 Return a summary string identifying the repository state at rev using one or |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
744 two parent hash identifiers, followed by a "+" if the working directory has |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
745 uncommitted changes, the branch name (if not default), a list of tags, and |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
746 a list of bookmarks. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
747 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
748 When rev is not given, return a summary string of the current state of the |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
749 repository. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
750 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
751 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
|
752 lookup to operate on that repository/bundle. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
753 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
754 num - show local revision number |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
755 id - show global revision id |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
756 branch - show branch |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
757 tags - show tags |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
758 bookmarks - show bookmarks |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
759 """ |
38
32f6a2bbf63e
client: add identify command
Idan Kamara <idankk86@gmail.com>
parents:
37
diff
changeset
|
760 args = cmdbuilder('identify', source, r=rev, n=num, i=id, b=branch, t=tags, |
32f6a2bbf63e
client: add identify command
Idan Kamara <idankk86@gmail.com>
parents:
37
diff
changeset
|
761 B=bookmarks) |
32f6a2bbf63e
client: add identify command
Idan Kamara <idankk86@gmail.com>
parents:
37
diff
changeset
|
762 |
32f6a2bbf63e
client: add identify command
Idan Kamara <idankk86@gmail.com>
parents:
37
diff
changeset
|
763 return self.rawcommand(args) |
32f6a2bbf63e
client: add identify command
Idan Kamara <idankk86@gmail.com>
parents:
37
diff
changeset
|
764 |
13
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
765 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
|
766 bypass=False, exact=False, importbranch=False, message=None, |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
767 date=None, user=None, similarity=None): |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
768 """ |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
769 Import the specified patches which can be a list of file names or a |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
770 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
|
771 specified). |
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 strip - directory strip option for patch. This has the same meaning as the |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
774 corresponding patch option (default: 1) |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
775 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
776 force - skip check for outstanding uncommitted changes |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
777 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
|
778 bypass - apply patch without touching the working directory |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
779 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
|
780 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
|
781 message - the commit message |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
782 date - record the specified date as commit date |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
783 user - record the specified user as committer |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
784 similarity - guess renamed files by similarity (0<=s<=100) |
13
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
785 """ |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
786 if hasattr(patches, 'read') and hasattr(patches, 'readline'): |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
787 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
|
788 |
13
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
789 def readline(size, output): |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
790 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
|
791 |
13
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
792 stdin = True |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
793 patches = () |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
794 prompt = readline |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
795 input = patch.read |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
796 else: |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
797 stdin = False |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
798 prompt = None |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
799 input = None |
5
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
800 |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
801 args = cmdbuilder('import', strip=strip, force=force, |
13
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
802 nocommit=nocommit, bypass=bypass, exact=exact, |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
803 importbranch=importbranch, message=message, |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
804 date=date, user=user, similarity=similarity, _=stdin, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
805 *patches) |
13
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
806 |
400cb1520834
client: add missing options to import_()
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
807 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
|
808 |
25
85ae94b98324
client: add missing options to incoming
Idan Kamara <idankk86@gmail.com>
parents:
24
diff
changeset
|
809 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
|
810 bundle=None, bookmarks=False, branch=None, limit=None, |
85ae94b98324
client: add missing options to incoming
Idan Kamara <idankk86@gmail.com>
parents:
24
diff
changeset
|
811 nomerges=False, subrepos=False): |
27
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
812 """ |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
813 Return new changesets found in the specified path or the default pull |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
814 location. |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
815 |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
816 When bookmarks=True, return a list of (name, node) of incoming bookmarks. |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
817 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
818 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
|
819 force - run even if remote repository is unrelated |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
820 newest - show newest record first |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
821 bundle - avoid downloading the changesets twice and store the bundles into |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
822 the specified file. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
823 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
824 bookmarks - compare bookmarks (this changes the return value) |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
825 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
|
826 limit - limit number of changes returned |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
827 nomerges - do not show merges |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
828 ssh - specify ssh command to use |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
829 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
|
830 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
|
831 subrepos - recurse into subrepositories |
27
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
832 """ |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
833 args = cmdbuilder('incoming', |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
834 path, |
25
85ae94b98324
client: add missing options to incoming
Idan Kamara <idankk86@gmail.com>
parents:
24
diff
changeset
|
835 template=templates.changeset, r=revrange, |
85ae94b98324
client: add missing options to incoming
Idan Kamara <idankk86@gmail.com>
parents:
24
diff
changeset
|
836 f=force, n=newest, bundle=bundle, |
85ae94b98324
client: add missing options to incoming
Idan Kamara <idankk86@gmail.com>
parents:
24
diff
changeset
|
837 B=bookmarks, b=branch, l=limit, M=nomerges, S=subrepos) |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
838 |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
839 def eh(ret, out, err): |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
840 if ret != 1: |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
841 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
|
842 |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
843 out = self.rawcommand(args, eh=eh) |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
844 if not out: |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
845 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
|
846 |
27
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
847 out = util.eatlines(out, 2) |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
848 if bookmarks: |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
849 bms = [] |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
850 for line in out.splitlines(): |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
851 bms.append(tuple(line.split())) |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
852 return bms |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
853 else: |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
854 out = out.split('\0')[:-1] |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
855 return self._parserevs(out) |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
856 |
17
b68c444d42bb
client: add missing options to log()
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
857 def log(self, revrange=None, files=[], follow=False, followfirst=False, |
b68c444d42bb
client: add missing options to log()
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
858 date=None, copies=False, keyword=None, removed=False, onlymerges=False, |
b68c444d42bb
client: add missing options to log()
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
859 user=None, branch=None, prune=None, hidden=False, limit=None, |
b68c444d42bb
client: add missing options to log()
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
860 nomerges=False, include=None, exclude=None): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
861 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
862 Return the revision history of the specified files or the entire project. |
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 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
|
865 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
|
866 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
|
867 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
|
868 revisions. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
869 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
870 If revrange isn't specified, the default is "tip:0" unless follow is set, |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
871 in which case the working directory parent is used as the starting |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
872 revision. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
873 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
874 The returned changeset is a named tuple with the following string fields: |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
875 - rev |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
876 - node |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
877 - tags (space delimited) |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
878 - branch |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
879 - author |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
880 - desc |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
881 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
882 follow - follow changeset history, or file history across copies and renames |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
883 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
|
884 date - show revisions matching date spec |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
885 copies - show copied files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
886 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
|
887 removed - include revisions where files were removed |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
888 onlymerges - show only merges |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
889 user - revisions committed by user |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
890 branch - show changesets within the given named branch |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
891 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
|
892 hidden - show hidden changesets |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
893 limit - limit number of changes displayed |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
894 nomerges - do not show merges |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
895 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
896 exclude - exclude names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
897 """ |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
898 args = cmdbuilder('log', template=templates.changeset, |
17
b68c444d42bb
client: add missing options to log()
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
899 r=revrange, f=follow, follow_first=followfirst, |
b68c444d42bb
client: add missing options to log()
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
900 d=date, C=copies, k=keyword, removed=removed, |
b68c444d42bb
client: add missing options to log()
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
901 m=onlymerges, u=user, b=branch, P=prune, h=hidden, |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
902 l=limit, M=nomerges, I=include, X=exclude, *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
|
903 |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
904 out = self.rawcommand(args) |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
905 out = out.split('\0')[:-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
|
906 |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
907 return self._parserevs(out) |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
908 |
64
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
909 def manifest(self, rev=None, all=False): |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
910 """ |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
911 Yields (nodeid, permission, executable, symlink, file path) tuples for |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
912 version controlled files for the given revision. If no revision is given, |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
913 the first parent of the working directory is used, or the null revision if |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
914 no revision is checked out. |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
915 |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
916 When all is True, all files from all revisions are yielded (just the name). |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
917 This includes deleted and renamed files. |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
918 """ |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
919 args = cmdbuilder('manifest', r=rev, all=all, debug=True) |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
920 |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
921 out = self.rawcommand(args) |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
922 |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
923 if all: |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
924 for line in out.splitlines(): |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
925 yield line |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
926 else: |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
927 for line in out.splitlines(): |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
928 node = line[0:40] |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
929 perm = line[41:44] |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
930 symlink = line[45] == '@' |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
931 executable = line[45] == '*' |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
932 yield (node, perm, executable, symlink, line[47:]) |
a7d98dc798c5
client: add manifest command
Idan Kamara <idankk86@gmail.com>
parents:
63
diff
changeset
|
933 |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
934 def merge(self, rev=None, force=False, tool=None, cb=merge.handlers.abort): |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
935 """ |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
936 Merge working directory with rev. If no revision is specified, the working |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
937 directory's parent is a head revision, and the current branch contains |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
938 exactly one other head, the other head is merged with by default. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
939 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
940 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
|
941 requested revision since the last common predecessor revision. |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
942 |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
943 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
|
944 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
|
945 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
|
946 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
947 force - force a merge with outstanding changes |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
948 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
|
949 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
|
950 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
951 cb - controls the behaviour when Mercurial prompts what to do with regard |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
952 to a specific file, e.g. when one parent modified a file and the other |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
953 removed it. It can be one of merge.handlers, or a function that gets a |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
954 single argument which are the contents of stdout. It should return one |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
955 of the expected choices (a single character). |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
956 """ |
45 | 957 # we can't really use --preview since merge doesn't support --template |
958 args = cmdbuilder('merge', r=rev, f=force, t=tool) | |
959 | |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
960 prompt = None |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
961 if cb is merge.handlers.abort: |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
962 prompt = cb |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
963 elif cb is merge.handlers.noninteractive: |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
964 args.append('-y') |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
965 else: |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
966 prompt = lambda size, output: cb(output) + '\n' |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
967 |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
968 self.rawcommand(args, prompt=prompt) |
45 | 969 |
32 | 970 def move(self, source, dest, after=False, force=False, dryrun=False, |
971 include=None, exclude=None): | |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
972 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
973 Mark dest as copies of source; mark source for deletion. If dest is a |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
974 directory, copies are put in that directory. If dest is a file, then source |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
975 must be a string. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
976 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
977 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
|
978 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
979 source - a file or a list of files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
980 dest - a destination file or directory |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
981 after - record a rename that has already occurred |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
982 force - forcibly copy over an existing managed file |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
983 dryrun - do not perform actions, just print output |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
984 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
985 exclude - exclude names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
986 """ |
32 | 987 if not isinstance(source, list): |
988 source = [source] | |
989 | |
990 source.append(dest) | |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
991 args = cmdbuilder('move', A=after, f=force, n=dryrun, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
992 I=include, X=exclude, *source) |
32 | 993 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
994 eh = util.reterrorhandler(args) |
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
995 self.rawcommand(args, eh=eh) |
32 | 996 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
997 return bool(eh) |
32 | 998 |
26
b4e5c8745ef3
client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents:
25
diff
changeset
|
999 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
|
1000 bookmarks=False, branch=None, limit=None, nomerges=False, |
b4e5c8745ef3
client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents:
25
diff
changeset
|
1001 subrepos=False): |
27
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1002 """ |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1003 Return changesets not found in the specified path or the default push |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1004 location. |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1005 |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1006 When bookmarks=True, return a list of (name, node) of bookmarks that will |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1007 be pushed. |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1008 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1009 revrange - a (list of) changeset intended to be included in the destination |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1010 force - run even when the destination is unrelated |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1011 newest - show newest record first |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1012 branch - a specific branch you would like to push |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1013 limit - limit number of changes displayed |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1014 nomerges - do not show merges |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1015 ssh - specify ssh command to use |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1016 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
|
1017 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
|
1018 subrepos - recurse into subrepositories |
27
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1019 """ |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1020 args = cmdbuilder('outgoing', |
26
b4e5c8745ef3
client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents:
25
diff
changeset
|
1021 path, |
b4e5c8745ef3
client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents:
25
diff
changeset
|
1022 template=templates.changeset, r=revrange, |
b4e5c8745ef3
client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents:
25
diff
changeset
|
1023 f=force, n=newest, B=bookmarks, |
b4e5c8745ef3
client: add missing options to outgoing
Idan Kamara <idankk86@gmail.com>
parents:
25
diff
changeset
|
1024 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
|
1025 |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1026 def eh(ret, out, err): |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1027 if ret != 1: |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1028 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
|
1029 |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1030 out = self.rawcommand(args, eh=eh) |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1031 if not out: |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1032 return [] |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1033 |
27
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1034 out = util.eatlines(out, 2) |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1035 if bookmarks: |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1036 bms = [] |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1037 for line in out.splitlines(): |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1038 bms.append(tuple(line.split())) |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1039 return bms |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1040 else: |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1041 out = out.split('\0')[:-1] |
46908f4b87d5
client: add bookmarks support to incoming and outgoing
Idan Kamara <idankk86@gmail.com>
parents:
26
diff
changeset
|
1042 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
|
1043 |
18
518149e32888
client: add parents command
Idan Kamara <idankk86@gmail.com>
parents:
17
diff
changeset
|
1044 def parents(self, rev=None, file=None): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1045 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1046 Return the working directory's parent revisions. If rev is given, the |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1047 parent of that revision will be printed. If file is given, the revision |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1048 in which the file was last changed (before the working directory revision |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1049 or the revision specified by rev) is returned. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1050 """ |
18
518149e32888
client: add parents command
Idan Kamara <idankk86@gmail.com>
parents:
17
diff
changeset
|
1051 args = cmdbuilder('parents', file, template=templates.changeset, r=rev) |
518149e32888
client: add parents command
Idan Kamara <idankk86@gmail.com>
parents:
17
diff
changeset
|
1052 |
518149e32888
client: add parents command
Idan Kamara <idankk86@gmail.com>
parents:
17
diff
changeset
|
1053 out = self.rawcommand(args) |
518149e32888
client: add parents command
Idan Kamara <idankk86@gmail.com>
parents:
17
diff
changeset
|
1054 if not out: |
518149e32888
client: add parents command
Idan Kamara <idankk86@gmail.com>
parents:
17
diff
changeset
|
1055 return |
518149e32888
client: add parents command
Idan Kamara <idankk86@gmail.com>
parents:
17
diff
changeset
|
1056 |
518149e32888
client: add parents command
Idan Kamara <idankk86@gmail.com>
parents:
17
diff
changeset
|
1057 out = out.split('\0')[:-1] |
518149e32888
client: add parents command
Idan Kamara <idankk86@gmail.com>
parents:
17
diff
changeset
|
1058 |
518149e32888
client: add parents command
Idan Kamara <idankk86@gmail.com>
parents:
17
diff
changeset
|
1059 return self._parserevs(out) |
518149e32888
client: add parents command
Idan Kamara <idankk86@gmail.com>
parents:
17
diff
changeset
|
1060 |
2
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
1061 def paths(self, name=None): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1062 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1063 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
|
1064 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
|
1065 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1066 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
|
1067 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
|
1068 used, too. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1069 """ |
2
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
1070 if not name: |
5
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
1071 out = self.rawcommand(['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
|
1072 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
|
1073 return {} |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
1074 |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
1075 return dict([s.split(' = ') for s in out.rstrip().split('\n')]) |
5fa34c3ac9a0
turn hglib into a module and expose open (previously connect) in its __init__.py
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
1076 else: |
4 | 1077 args = cmdbuilder('paths', name) |
5
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
1078 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
|
1079 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
|
1080 |
40 | 1081 def pull(self, source=None, rev=None, update=False, force=False, bookmark=None, |
1082 branch=None, ssh=None, remotecmd=None, insecure=False, tool=None): | |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1083 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1084 Pull changes from a remote repository. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1085 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1086 This finds all changes from the repository specified by source and adds |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1087 them to this repository. If source is omitted, the 'default' path will be |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1088 used. By default, this does not update the copy of the project in the |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1089 working directory. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1090 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1091 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
|
1092 unresolved files. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1093 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1094 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
|
1095 force - run even when remote repository is unrelated |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1096 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
|
1097 bookmark - (list of) bookmark to pull |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1098 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
|
1099 ssh - specify ssh command to use |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1100 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
|
1101 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
|
1102 tool - specify merge tool for rebase |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1103 """ |
40 | 1104 args = cmdbuilder('pull', source, r=rev, u=update, f=force, B=bookmark, |
1105 b=branch, e=ssh, remotecmd=remotecmd, insecure=insecure, | |
1106 t=tool) | |
1107 | |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
1108 eh = util.reterrorhandler(args) |
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
1109 self.rawcommand(args, eh=eh) |
40 | 1110 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
1111 return bool(eh) |
40 | 1112 |
39 | 1113 def push(self, dest=None, rev=None, force=False, bookmark=None, branch=None, |
1114 newbranch=False, ssh=None, remotecmd=None, insecure=False): | |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1115 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1116 Push changesets from this repository to the specified destination. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1117 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1118 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
|
1119 destination repository from the current one. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1120 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1121 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
|
1122 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1123 rev - the (list of) specified revision and all its ancestors will be pushed |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1124 to the remote repository. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1125 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1126 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
|
1127 branches. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1128 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1129 bookmark - (list of) bookmark to push |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1130 branch - a (list of) specific branch you would like to push |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1131 newbranch - allows push to create a new named branch that is not present at |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1132 the destination. This allows you to only create a new branch without |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1133 forcing other changes. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1134 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1135 ssh - specify ssh command to use |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1136 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
|
1137 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
|
1138 """ |
39 | 1139 args = cmdbuilder('push', dest, r=rev, f=force, B=bookmark, b=branch, |
1140 new_branch=newbranch, e=ssh, remotecmd=remotecmd, | |
1141 insecure=insecure) | |
1142 | |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
1143 eh = util.reterrorhandler(args) |
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
1144 self.rawcommand(args, eh=eh) |
39 | 1145 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
1146 return bool(eh) |
39 | 1147 |
30 | 1148 def remove(self, files, after=False, force=False, include=None, exclude=None): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1149 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1150 Schedule the indicated files for removal from the repository. This only |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1151 removes files from the current branch, not from the entire project history. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1152 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1153 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
|
1154 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1155 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
|
1156 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
|
1157 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1158 exclude - exclude names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1159 """ |
30 | 1160 if not isinstance(files, list): |
1161 files = [files] | |
1162 | |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
1163 args = cmdbuilder('remove', A=after, f=force, I=include, X=exclude, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
1164 *files) |
30 | 1165 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
1166 eh = util.reterrorhandler(args) |
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
1167 self.rawcommand(args, eh=eh) |
30 | 1168 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
1169 return bool(eh) |
30 | 1170 |
63
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1171 def resolve(self, file=[], all=False, listfiles=False, mark=False, unmark=False, |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1172 tool=None, include=None, exclude=None): |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1173 """ |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1174 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
|
1175 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1176 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
|
1177 |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1178 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
|
1179 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
|
1180 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1181 all - select all unresolved files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1182 mark - mark files as resolved |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1183 unmark - mark files as unresolved |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1184 tool - specify merge tool |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1185 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1186 exclude - exclude names matching the given patterns |
63
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1187 """ |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1188 if not isinstance(file, list): |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1189 file = [file] |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1190 |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
1191 args = cmdbuilder('resolve', a=all, l=listfiles, m=mark, u=unmark, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
1192 t=tool, I=include, X=exclude, *file) |
63
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1193 |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1194 out = self.rawcommand(args) |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1195 |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1196 if listfiles: |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1197 l = [] |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1198 for line in out.splitlines(): |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1199 l.append(tuple(line.split(' ', 1))) |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1200 return l |
939d1d763bb1
client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
62
diff
changeset
|
1201 |
47 | 1202 def revert(self, files, rev=None, all=False, date=None, nobackup=False, |
1203 dryrun=False, include=None, exclude=None): | |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1204 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1205 With no revision specified, revert the specified files or directories to |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1206 the contents they had in the parent of the working directory. This |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1207 restores the contents of files to an unmodified state and unschedules |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1208 adds, removes, copies, and renames. If the working directory has two |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1209 parents, you must explicitly specify a revision. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1210 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1211 Specifying rev or date will revert the given files or directories to their |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1212 states as of a specific revision. Because revert does not change the |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1213 working directory parents, this will cause these files to appear modified. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1214 This can be helpful to "back out" some or all of an earlier change. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1215 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1216 Modified files are saved with a .orig suffix before reverting. To disable |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1217 these backups, use nobackup. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1218 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1219 Returns True on success. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1220 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1221 all - revert all changes when no arguments given |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1222 date - tipmost revision matching date |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1223 rev - revert to the specified revision |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1224 nobackup - do not save backup copies of files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1225 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1226 exclude - exclude names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1227 dryrun - do not perform actions, just print output |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1228 """ |
47 | 1229 if not isinstance(files, list): |
1230 files = [files] | |
1231 | |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
1232 args = cmdbuilder('revert', r=rev, a=all, d=date, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
1233 no_backup=nobackup, n=dryrun, I=include, X=exclude, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
1234 *files) |
47 | 1235 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
1236 eh = util.reterrorhandler(args) |
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
1237 self.rawcommand(args, eh=eh) |
47 | 1238 |
50
bd7dfd94b0d9
client: use util.reterrorhandler
Idan Kamara <idankk86@gmail.com>
parents:
48
diff
changeset
|
1239 return bool(eh) |
47 | 1240 |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1241 def root(self): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1242 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1243 Return the root directory of the current repository. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1244 """ |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1245 return self.rawcommand(['root']).rstrip() |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1246 |
33
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1247 def status(self, rev=None, change=None, all=False, modified=False, added=False, |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1248 removed=False, deleted=False, clean=False, unknown=False, |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1249 ignored=False, copies=False, subrepos=False, include=None, |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1250 exclude=None): |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1251 """ |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1252 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
|
1253 where code can be: |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1254 |
33
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1255 M = modified |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1256 A = added |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1257 R = removed |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1258 C = clean |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1259 ! = 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
|
1260 ? = untracked |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1261 I = ignored |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1262 = 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
|
1263 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1264 rev - show difference from (list of) revision |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1265 change - list the changed files of a revision |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1266 all - show status of all files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1267 modified - show only modified files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1268 added - show only added files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1269 removed - show only removed files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1270 deleted - show only deleted (but tracked) files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1271 clean - show only files without changes |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1272 unknown - show only unknown (not tracked) files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1273 ignored - show only ignored files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1274 copies - show source of copied files |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1275 subrepos - recurse into subrepositories |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1276 include - include names matching the given patterns |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1277 exclude - exclude names matching the given patterns |
33
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1278 """ |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1279 if rev and change: |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1280 raise ValueError('cannot specify both rev and change') |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1281 |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1282 args = cmdbuilder('status', rev=rev, change=change, A=all, m=modified, |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1283 a=added, r=removed, d=deleted, c=clean, u=unknown, |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1284 i=ignored, C=copies, S=subrepos, I=include, X=exclude) |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1285 |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1286 args.append('-0') |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1287 |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
32
diff
changeset
|
1288 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
|
1289 l = [] |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1290 |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1291 for entry in out.split('\0'): |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1292 if entry: |
35
1e33bbea23e5
client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents:
34
diff
changeset
|
1293 if entry[0] == ' ': |
1e33bbea23e5
client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents:
34
diff
changeset
|
1294 l.append((' ', entry[2:])) |
1e33bbea23e5
client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents:
34
diff
changeset
|
1295 else: |
1e33bbea23e5
client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents:
34
diff
changeset
|
1296 l.append(tuple(entry.split(' ', 1))) |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1297 |
34
f6e1d9a6e0cd
client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents:
33
diff
changeset
|
1298 return l |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1299 |
42 | 1300 def tag(self, names, rev=None, message=None, force=False, local=False, |
1301 remove=False, date=None, user=None): | |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1302 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1303 Add one or more tags specified by names for the current or given revision. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1304 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1305 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
|
1306 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1307 Tag commits are usually made at the head of a branch. If the parent of the |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1308 working directory is not a branch head, a CommandError will be raised. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1309 force can be specified to force the tag commit to be based on a non-head |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1310 changeset. |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1311 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1312 local - make the tag local |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1313 rev - revision to tag |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1314 remove - remove a tag |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1315 message - set commit message |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1316 date - record the specified date as commit date |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1317 user - record the specified user as committer |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1318 """ |
42 | 1319 if not isinstance(names, list): |
1320 names = [names] | |
1321 | |
87
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
1322 args = cmdbuilder('tag', r=rev, m=message, f=force, l=local, |
5661d5f7e39b
client: make varargs ordering py2.4-compatible
Matt Mackall <mpm@selenic.com>
parents:
79
diff
changeset
|
1323 remove=remove, d=date, u=user, *names) |
42 | 1324 |
1325 self.rawcommand(args) | |
1326 | |
43 | 1327 def tags(self): |
1328 """ | |
1329 Return a list of repository tags as: (name, rev, node, islocal) | |
1330 """ | |
1331 args = cmdbuilder('tags', v=True) | |
1332 | |
1333 out = self.rawcommand(args) | |
1334 | |
1335 t = [] | |
1336 for line in out.splitlines(): | |
1337 taglocal = line.endswith(' local') | |
1338 if taglocal: | |
1339 line = line[:-6] | |
1340 name, rev = line.rsplit(' ', 1) | |
1341 rev, node = rev.split(':') | |
1342 t.append((name.rstrip(), int(rev), node, taglocal)) | |
1343 return t | |
1344 | |
51
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1345 def summary(self, remote=False): |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1346 """ |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1347 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
|
1348 including parents, branch, commit status, and available updates. |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1349 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1350 'parent' : a list of (rev, node, tags, message) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1351 'branch' : the current branch |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1352 'commit' : True if the working directory is clean, False otherwise |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1353 'update' : number of available updates, |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1354 ['remote' : (in, in bookmarks, out, out bookmarks),] |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1355 ['mq': (applied, unapplied) mq patches,] |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1356 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1357 unparsed entries will be of them form key : value |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1358 """ |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1359 args = cmdbuilder('summary', remote=remote) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1360 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1361 out = self.rawcommand(args).splitlines() |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1362 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1363 d = {} |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1364 while out: |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1365 line = out.pop(0) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1366 name, value = line.split(': ', 1) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1367 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1368 if name == 'parent': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1369 parent, tags = value.split(' ', 1) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1370 rev, node = parent.split(':') |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1371 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1372 if tags: |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1373 tags = tags.replace(' (empty repository)', '') |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1374 else: |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1375 tags = None |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1376 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1377 value = d.get(name, []) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1378 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1379 if rev == '-1': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1380 value.append((int(rev), node, tags, None)) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1381 else: |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1382 message = out.pop(0)[1:] |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1383 value.append((int(rev), node, tags, message)) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1384 elif name == 'branch': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1385 pass |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1386 elif name == 'commit': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1387 value = value == '(clean)' |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1388 elif name == 'update': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1389 if value == '(current)': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1390 value = 0 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1391 else: |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1392 value = int(value.split(' ', 1)[0]) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1393 elif remote and name == 'remote': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1394 if value == '(synced)': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1395 value = 0, 0, 0, 0 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1396 else: |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1397 inc = incb = out_ = outb = 0 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1398 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1399 for v in value.split(', '): |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1400 count, v = v.split(' ', 1) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1401 if v == 'outgoing': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1402 out_ = int(count) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1403 elif v.endswith('incoming'): |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1404 inc = int(count) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1405 elif v == 'incoming bookmarks': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1406 incb = int(count) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1407 elif v == 'outgoing bookmarks': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1408 outb = int(count) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1409 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1410 value = inc, incb, out_, outb |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1411 elif name == 'mq': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1412 applied = unapplied = 0 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1413 for v in value.split(', '): |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1414 count, v = v.split(' ', 1) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1415 if v == 'applied': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1416 applied = int(count) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1417 elif v == 'unapplied': |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1418 unapplied = int(count) |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1419 value = applied, unapplied |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1420 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1421 d[name] = value |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1422 |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1423 return d |
c52383a550fb
client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
50
diff
changeset
|
1424 |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1425 def tip(self): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1426 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1427 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
|
1428 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
|
1429 recently changed head). |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1430 """ |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1431 args = cmdbuilder('tip', template=templates.changeset) |
5
3182303f388d
client: rawcommand, more convenient helper to run commands instead of outputruncommand
Idan Kamara <idankk86@gmail.com>
parents:
4
diff
changeset
|
1432 out = self.rawcommand(args) |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1433 out = out.split('\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
|
1434 |
10
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1435 return self._parserevs(out)[0] |
fce3102c19e5
client: sort commands by name
Idan Kamara <idankk86@gmail.com>
parents:
8
diff
changeset
|
1436 |
20 | 1437 def update(self, rev=None, clean=False, check=False, date=None): |
1438 """ | |
1439 Update the repository's working directory to changeset specified by rev. | |
1440 If rev isn't specified, update to the tip of the current named branch. | |
1441 | |
1442 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
|
1443 |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1444 clean - discard uncommitted changes (no backup) |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1445 check - update across branches if no uncommitted changes |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1446 date - tipmost revision matching date |
20 | 1447 """ |
1448 if clean and check: | |
1449 raise ValueError('clean and check cannot both be True') | |
1450 | |
1451 args = cmdbuilder('update', r=rev, C=clean, c=check, d=date) | |
1452 | |
1453 def eh(ret, out, err): | |
1454 if ret == 1: | |
1455 return out | |
1456 | |
1457 raise error.CommandError(args, ret, out, err) | |
1458 | |
1459 | |
1460 out = self.rawcommand(args, eh=eh) | |
1461 | |
1462 # filter out 'merging ...' lines | |
1463 out = util.skiplines(out, 'merging ') | |
1464 | |
1465 counters = out.rstrip().split(', ') | |
1466 return tuple(int(s.split(' ', 1)[0]) for s in counters) | |
41
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1467 |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1468 @property |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1469 def version(self): |
65
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1470 """ |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1471 Return hg version that runs the command server as a 4 fielded tuple: major, |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1472 minor, micro and local build info. e.g. (1, 9, 1, '+4-3095db9f5c2c') |
91ffa1de398c
document all commands in client.py
Idan Kamara <idankk86@gmail.com>
parents:
64
diff
changeset
|
1473 """ |
41
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1474 if self._version is None: |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1475 v = self.rawcommand(cmdbuilder('version', q=True)) |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1476 v = list(re.match(r'.*?(\d+)\.(\d+)\.?(\d+)?(\+[0-9a-f-]+)?', |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1477 v).groups()) |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1478 |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1479 for i in range(3): |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1480 try: |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1481 v[i] = int(v[i]) |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1482 except TypeError: |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1483 v[i] = 0 |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1484 |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1485 self._version = tuple(v) |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1486 |
e185c3922c68
client: add version command
Idan Kamara <idankk86@gmail.com>
parents:
40
diff
changeset
|
1487 return self._version |