Mercurial > python-hglib
changeset 64:a7d98dc798c5
client: add manifest command
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Tue, 23 Aug 2011 21:41:17 +0300 |
parents | 939d1d763bb1 |
children | 91ffa1de398c |
files | hglib/client.py tests/test-manifest.py |
diffstat | 2 files changed, 43 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hglib/client.py Fri Aug 19 22:52:59 2011 +0300 +++ b/hglib/client.py Tue Aug 23 21:41:17 2011 +0300 @@ -553,6 +553,31 @@ return self._parserevs(out) + def manifest(self, rev=None, all=False): + """ + Yields (nodeid, permission, executable, symlink, file path) tuples for + version controlled files for the given revision. If no revision is given, + the first parent of the working directory is used, or the null revision if + no revision is checked out. + + When all is True, all files from all revisions are yielded (just the name). + This includes deleted and renamed files. + """ + args = cmdbuilder('manifest', r=rev, all=all, debug=True) + + out = self.rawcommand(args) + + if all: + for line in out.splitlines(): + yield line + else: + for line in out.splitlines(): + node = line[0:40] + perm = line[41:44] + symlink = line[45] == '@' + executable = line[45] == '*' + yield (node, perm, executable, symlink, line[47:]) + def merge(self, rev=None, force=False, tool=None, cb=merge.handlers.abort): """ merge working directory with another revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-manifest.py Tue Aug 23 21:41:17 2011 +0300 @@ -0,0 +1,18 @@ +import common, hglib, os, stat + +class test_manifest(common.basetest): + def test_basic(self): + self.append('a', 'a') + self.append('b', 'b') + os.chmod('b', os.stat('b')[0] | stat.S_IEXEC) + os.symlink('b', 'c') + self.client.commit('first', addremove=True) + + self.assertEquals(list(self.client.manifest(all=True)), ['a', 'b', 'c']) + + manifest = \ + [('047b75c6d7a3ef6a2243bd0e99f94f6ea6683597', '644', False, False, 'a'), + ('62452855512f5b81522aa3895892760bb8da9f3f', '755', True, False, 'b'), + ('62452855512f5b81522aa3895892760bb8da9f3f', '644', False, True, 'c')] + + self.assertEquals(list(self.client.manifest()), manifest)