Mercurial > python-hglib
comparison hglib/client.py @ 12:c2a9b716cd80
client: rewrite branches(), return a list of (branchname, rev, node)
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Wed, 10 Aug 2011 00:24:01 +0300 |
parents | 0549d00a617d |
children | 400cb1520834 |
comparison
equal
deleted
inserted
replaced
11:0549d00a617d | 12:c2a9b716cd80 |
---|---|
154 return out | 154 return out |
155 else: | 155 else: |
156 # len('reset working directory to branch ') == 34 | 156 # len('reset working directory to branch ') == 34 |
157 return out[34:] | 157 return out[34:] |
158 | 158 |
159 def branches(self): | 159 def branches(self, active=False, closed=False): |
160 out = self.rawcommand(['branches']) | 160 args = cmdbuilder('branches', a=active, c=closed) |
161 branches = {} | 161 out = self.rawcommand(args) |
162 for line in out.rstrip().split('\n'): | 162 |
163 branch, revnode = line.split() | 163 branches = [] |
164 branches[branch] = self.log(revrange=[revnode.split(':')[0]])[0] | 164 for line in out.rstrip().splitlines(): |
165 | 165 name, line = line.split(' ', 1) |
166 rev, node = line.split(':') | |
167 node = node.split()[0] # get rid of ' (inactive)' | |
168 branches.append((name, int(rev), node)) | |
166 return branches | 169 return branches |
167 | 170 |
168 def cat(self, files, rev=None, output=None): | 171 def cat(self, files, rev=None, output=None): |
169 args = cmdbuilder('cat', *files, r=rev, o=output) | 172 args = cmdbuilder('cat', *files, r=rev, o=output) |
170 out = self.rawcommand(args) | 173 out = self.rawcommand(args) |