[PATCH 1 of 9 hglib] client: add manifest command
Idan Kamara
idankk86 at gmail.com
Tue Aug 23 14:04:29 CDT 2011
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1314124877 -10800
# Node ID a7d98dc798c5ccba32ee3be5dcda3a2e5c70550b
# Parent 939d1d763bb11e83c33f05b04d6fbc3b25a68d85
client: add manifest command
diff -r 939d1d763bb1 -r a7d98dc798c5 hglib/client.py
--- 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
diff -r 939d1d763bb1 -r a7d98dc798c5 tests/test-manifest.py
--- /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)
More information about the Mercurial-devel
mailing list