comparison hglib/client.py @ 6:96f8c5095e2e

client: use --template instead of --style for cset display
author Idan Kamara <idankk86@gmail.com>
date Sat, 23 Jul 2011 22:55:39 +0300
parents 3182303f388d
children 3ac38d500d68
comparison
equal deleted inserted replaced
5:3182303f388d 6:96f8c5095e2e
1 import subprocess, os, struct, cStringIO, collections 1 import subprocess, os, struct, cStringIO, collections
2 import hglib, error, util 2 import hglib, error, util, templates
3 3
4 from util import cmdbuilder 4 from util import cmdbuilder
5 5
6 class hgclient(object): 6 class hgclient(object):
7 inputfmt = '>I' 7 inputfmt = '>I'
8 outputfmt = '>cI' 8 outputfmt = '>cI'
9 outputfmtsize = struct.calcsize(outputfmt) 9 outputfmtsize = struct.calcsize(outputfmt)
10 retfmt = '>i' 10 retfmt = '>i'
11
12 # XXX fix this hack
13 _stylesdir = os.path.join(os.path.dirname(__file__), 'styles')
14 revstyle = os.path.join(_stylesdir, 'rev.style')
15 11
16 revision = collections.namedtuple('revision', 'rev, node, tags, ' 12 revision = collections.namedtuple('revision', 'rev, node, tags, '
17 'branch, author, desc') 13 'branch, author, desc')
18 14
19 def __init__(self, path, encoding, configs): 15 def __init__(self, path, encoding, configs):
188 d[t].append(f) 184 d[t].append(f)
189 185
190 return d 186 return d
191 187
192 def log(self, revrange=None): 188 def log(self, revrange=None):
193 args = cmdbuilder('log', style=hgclient.revstyle, rev=revrange) 189 args = cmdbuilder('log', template=templates.changeset, rev=revrange)
194 190
195 out = self.rawcommand(args) 191 out = self.rawcommand(args)
196 out = out.split('\0')[:-1] 192 out = out.split('\0')[:-1]
197 193
198 return self._parserevs(out) 194 return self._parserevs(out)
199 195
200 def incoming(self, revrange=None, path=None): 196 def incoming(self, revrange=None, path=None):
201 args = cmdbuilder('incoming', 197 args = cmdbuilder('incoming',
202 path, 198 path,
203 style=hgclient.revstyle, rev=revrange) 199 template=templates.changeset, rev=revrange)
204 200
205 def eh(ret, out, err): 201 def eh(ret, out, err):
206 if ret != 1: 202 if ret != 1:
207 raise error.CommandError(args, ret, out, err) 203 raise error.CommandError(args, ret, out, err)
208 204
213 out = self._eatlines(out, 2).split('\0')[:-1] 209 out = self._eatlines(out, 2).split('\0')[:-1]
214 return self._parserevs(out) 210 return self._parserevs(out)
215 211
216 def outgoing(self, revrange=None, path=None): 212 def outgoing(self, revrange=None, path=None):
217 args = cmdbuilder('outgoing', 213 args = cmdbuilder('outgoing',
218 path, style=hgclient.revstyle, rev=revrange) 214 path, template=templates.changeset, rev=revrange)
219 215
220 def eh(ret, out, err): 216 def eh(ret, out, err):
221 if ret != 1: 217 if ret != 1:
222 raise error.CommandError(args, ret, out, err) 218 raise error.CommandError(args, ret, out, err)
223 219
262 revrange=None): 258 revrange=None):
263 args = cmdbuilder('clone', source, dest, b=branch, u=updaterev, r=revrange) 259 args = cmdbuilder('clone', source, dest, b=branch, u=updaterev, r=revrange)
264 self.rawcommand(args) 260 self.rawcommand(args)
265 261
266 def tip(self): 262 def tip(self):
267 args = cmdbuilder('tip', style=hgclient.revstyle) 263 args = cmdbuilder('tip', template=templates.changeset)
268 out = self.rawcommand(args) 264 out = self.rawcommand(args)
269 out = out.split('\0') 265 out = out.split('\0')
270 266
271 return self._parserevs(out)[0] 267 return self._parserevs(out)[0]
272 268