Rev 846: Add propset, propget, proplist and propdel commands. in file:///data/jelmer/bzr-svn/fileprops/
Jelmer Vernooij
jelmer at samba.org
Sat Jan 19 01:00:03 GMT 2008
At file:///data/jelmer/bzr-svn/fileprops/
------------------------------------------------------------
revno: 846
revision-id:jelmer at samba.org-20080119005924-j13h7fncqdasp8os
parent: jelmer at samba.org-20080118225921-r4y0rceu6pae58zt
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: fileprops
timestamp: Sat 2008-01-19 01:59:24 +0100
message:
Add propset, propget, proplist and propdel commands.
modified:
__init__.py __init__.py-20051008155114-eae558e6cf149e1d
=== modified file '__init__.py'
--- a/__init__.py 2008-01-12 23:55:48 +0000
+++ b/__init__.py 2008-01-19 00:59:24 +0000
@@ -366,6 +366,72 @@
register_command(cmd_svn_branching_scheme)
+def tree_check_file_properties(tree):
+ from bzrlib.errors import BzrCommandError
+ if not hasattr(tree, 'supports_file_properties') or not tree.supports_file_properties():
+ raise BzrCommandError("%r does not support file properties" % tree)
+
+
+class cmd_propset(Command):
+ """Change a file property.
+ """
+ takes_args = ['propname', 'propval', 'location?']
+
+ def run(self, propname, propval, location="."):
+ from bzrlib.workingtree import WorkingTree
+ wt, path = WorkingTree.open_containing(location)
+ tree_check_file_properties(wt)
+ wt.set_property(path, propname, propval)
+
+
+register_command(cmd_propset)
+
+
+class cmd_propdel(Command):
+ """Delete a file property.
+ """
+ takes_args = ['propname', 'location?']
+
+ def run(self, propname, location="."):
+ from bzrlib.workingtree import WorkingTree
+ wt, path = WorkingTree.open_containing(location)
+ tree_check_file_properties(wt)
+ wt.del_property(path, propname)
+
+
+register_command(cmd_propdel)
+
+
+class cmd_proplist(Command):
+ """List available file properties.
+ """
+ takes_args = ['location?']
+
+ def run(self, propname, location="."):
+ from bzrlib.workingtree import WorkingTree
+ wt, path = WorkingTree.open_containing(location)
+ tree_check_file_properties(wt)
+ for p in wt.list_properties(path):
+ self.outf(p)
+
+
+register_command(cmd_proplist)
+
+
+class cmd_propget(Command):
+ """Get file property contents.
+ """
+ takes_args = ['location?']
+
+ def run(self, propname, location="."):
+ from bzrlib.workingtree import WorkingTree
+ wt, path = WorkingTree.open_containing(location)
+ tree_check_file_properties(wt)
+ for p in wt.list_properties(path):
+ self.outf(p)
+
+
+register_command(cmd_propget)
def test_suite():
from unittest import TestSuite
More information about the bazaar-commits
mailing list