Mercurial > python-hglib
comparison hglib/client.py @ 8:3ac38d500d68
move hgclient._eatlines to util
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Wed, 10 Aug 2011 01:38:18 +0300 |
parents | 96f8c5095e2e |
children | fce3102c19e5 |
comparison
equal
deleted
inserted
replaced
7:eac8be119d81 | 8:3ac38d500d68 |
---|---|
62 | 62 |
63 def _parserevs(self, splitted): | 63 def _parserevs(self, splitted): |
64 ''' splitted is a list of fields according to our rev.style, where each 6 | 64 ''' splitted is a list of fields according to our rev.style, where each 6 |
65 fields compose one revision. ''' | 65 fields compose one revision. ''' |
66 return [self.revision._make(rev) for rev in util.grouper(6, splitted)] | 66 return [self.revision._make(rev) for rev in util.grouper(6, splitted)] |
67 | |
68 def _eatlines(self, s, n): | |
69 idx = 0 | |
70 for i in xrange(n): | |
71 idx = s.find('\n', idx) + 1 | |
72 | |
73 return s[idx:] | |
74 | 67 |
75 def runcommand(self, args, inchannels, outchannels): | 68 def runcommand(self, args, inchannels, outchannels): |
76 def writeblock(data): | 69 def writeblock(data): |
77 self.server.stdin.write(struct.pack(self.inputfmt, len(data))) | 70 self.server.stdin.write(struct.pack(self.inputfmt, len(data))) |
78 self.server.stdin.write(data) | 71 self.server.stdin.write(data) |
204 | 197 |
205 out = self.rawcommand(args, eh=eh) | 198 out = self.rawcommand(args, eh=eh) |
206 if not out: | 199 if not out: |
207 return [] | 200 return [] |
208 | 201 |
209 out = self._eatlines(out, 2).split('\0')[:-1] | 202 out = util.eatlines(out, 2).split('\0')[:-1] |
210 return self._parserevs(out) | 203 return self._parserevs(out) |
211 | 204 |
212 def outgoing(self, revrange=None, path=None): | 205 def outgoing(self, revrange=None, path=None): |
213 args = cmdbuilder('outgoing', | 206 args = cmdbuilder('outgoing', |
214 path, template=templates.changeset, rev=revrange) | 207 path, template=templates.changeset, rev=revrange) |
219 | 212 |
220 out = self.rawcommand(args, eh=eh) | 213 out = self.rawcommand(args, eh=eh) |
221 if not out: | 214 if not out: |
222 return [] | 215 return [] |
223 | 216 |
224 out = self._eatlines(out, 2).split('\0')[:-1] | 217 out = util.eatlines(out, 2).split('\0')[:-1] |
225 return self._parserevs(out) | 218 return self._parserevs(out) |
226 | 219 |
227 def commit(self, message, addremove=False): | 220 def commit(self, message, addremove=False): |
228 args = cmdbuilder('commit', m=message, A=addremove) | 221 args = cmdbuilder('commit', m=message, A=addremove) |
229 | 222 |