[Pkg-bazaar-commits] ./bzr/unstable r176: New cat command contributed by janmar.
mbp at sourcefrog.net
mbp at sourcefrog.net
Fri Apr 10 07:44:05 UTC 2009
------------------------------------------------------------
revno: 176
committer: mbp at sourcefrog.net
timestamp: Wed 2005-04-06 12:05:46 +1000
message:
New cat command contributed by janmar.
modified:
NEWS
bzrlib/branch.py
bzrlib/commands.py
bzrlib/tree.py
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2005-04-05 13:46:36 +0000
+++ b/NEWS 2005-04-06 02:05:46 +0000
@@ -19,6 +19,8 @@
* New "renames" command lists files renamed since base revision.
+ * New cat command contributed by janmar.
+
CHANGES:
* .bzr.log is placed in $HOME (not pwd) and is always written in
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2005-04-05 13:50:26 +0000
+++ b/bzrlib/branch.py 2005-04-06 02:05:46 +0000
@@ -301,6 +301,11 @@
self._write_inventory(inv)
+ def print_file(self, file, revno):
+ """Print `file` to stdout."""
+ tree = self.revision_tree(self.lookup_revision(revno))
+ tree.print_file(self.inventory.path2id(file))
+
def remove(self, files, verbose=False):
"""Mark nominated files for removal from the inventory.
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2005-04-05 13:46:36 +0000
+++ b/bzrlib/commands.py 2005-04-06 02:05:46 +0000
@@ -538,6 +538,10 @@
t = b.revision_tree(rh)
t.export(dest)
+def cmd_cat(revision, filename):
+ """Print file to stdout."""
+ b = Branch('.')
+ b.print_file(b.relpath(filename), int(revision))
######################################################################
@@ -725,6 +729,7 @@
# listed take none.
cmd_options = {
'add': ['verbose'],
+ 'cat': ['revision'],
'commit': ['message', 'verbose'],
'deleted': ['show-ids'],
'diff': ['revision'],
@@ -738,6 +743,7 @@
cmd_args = {
'add': ['file+'],
+ 'cat': ['filename'],
'commit': [],
'diff': [],
'export': ['revno', 'dest'],
@@ -923,6 +929,10 @@
bailout("option %r is not allowed for command %r"
% (oname, cmd))
+ # TODO: give an error if there are any mandatory options which are
+ # not specified? Or maybe there shouldn't be any "mandatory
+ # options" (it is an oxymoron)
+
# mix arguments and options into one dictionary
cmdargs = _match_args(cmd, args)
for k, v in opts.items():
=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py 2005-04-04 13:10:26 +0000
+++ b/bzrlib/tree.py 2005-04-06 02:05:46 +0000
@@ -92,7 +92,13 @@
"store is probably damaged/corrupt"])
- def export(self, dest):
+ def print_file(self, fileid):
+ """Print file with id `fileid` to stdout."""
+ import sys
+ pumpfile(self.get_file(fileid), sys.stdout)
+
+
+ def export(self, dest):
"""Export this tree to a new directory.
`dest` should not exist, and will be created holding the
More information about the Pkg-bazaar-commits
mailing list