Mercurial > public > mercurial-scm > python-hglib
comparison hglib/client.py @ 24:ca0d7e212cf8
client: add bookmarks command
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Thu, 11 Aug 2011 17:54:09 +0300 |
parents | 223e463c25e0 |
children | 85ae94b98324 |
comparison
equal
deleted
inserted
replaced
23:223e463c25e0 | 24:ca0d7e212cf8 |
---|---|
155 args = cmdbuilder('bookmark', name, r=rev, f=force, d=delete, | 155 args = cmdbuilder('bookmark', name, r=rev, f=force, d=delete, |
156 i=inactive, m=rename) | 156 i=inactive, m=rename) |
157 | 157 |
158 self.rawcommand(args) | 158 self.rawcommand(args) |
159 | 159 |
160 def bookmarks(self): | |
161 """ | |
162 Return the bookmarks as a list of (name, rev, node) and the | |
163 index of the current one. | |
164 | |
165 If there isn't a current one, -1 is returned as the index | |
166 """ | |
167 out = self.rawcommand(['bookmarks']) | |
168 | |
169 bms = [] | |
170 current = -1 | |
171 if out.rstrip() != 'no bookmarks set': | |
172 for line in out.splitlines(): | |
173 iscurrent, line = line[0:3], line[3:] | |
174 if '*' in iscurrent: | |
175 current = len(bms) | |
176 name, line = line.split(' ', 1) | |
177 rev, node = line.split(':') | |
178 bms.append((name, int(rev), node)) | |
179 return bms, current | |
180 | |
160 def branch(self, name=None, clean=False, force=False): | 181 def branch(self, name=None, clean=False, force=False): |
161 if name and clean: | 182 if name and clean: |
162 raise ValueError('cannot use both name and clean') | 183 raise ValueError('cannot use both name and clean') |
163 | 184 |
164 args = cmdbuilder('branch', name, f=force, C=clean) | 185 args = cmdbuilder('branch', name, f=force, C=clean) |