[MERGE] Add an optional location parameter to the 'revision-history' command.
Michael Ellerman
michael at ellerman.id.au
Tue May 30 16:31:16 BST 2006
Hi guys,
This came in handy, so I coded it up properly.
Pullable from:
http://michael.ellerman.id.au/bzr/branches/mpe/
I was going to do the same for 'ancestry', but there's a TODO in there
about using tree.last_revision() instead of branch.last_revision() which
got me confused. How would the working tree ancestry differ from the
branches?
cheers
=== added file 'bzrlib/tests/blackbox/test_revision_history.py'
--- /dev/null
+++ bzrlib/tests/blackbox/test_revision_history.py
@@ -0,0 +1,75 @@
+# Copyright (C) 2006, Michael Ellerman
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import os
+from bzrlib.tests import TestCaseWithTransport
+from bzrlib.branch import Branch
+
+
+class TestRevisionHistory(TestCaseWithTransport):
+
+ def _build_branch(self):
+ # setup a standalone branch with three commits
+ tree = self.make_branch_and_tree('test')
+ open('test/foo', 'wb').write('1111\n')
+ tree.add('foo')
+ tree.commit('added foo',rev_id='revision_1')
+ open('test/foo', 'wb').write('2222\n')
+ tree.commit('updated foo',rev_id='revision_2')
+ open('test/foo', 'wb').write('3333\n')
+ tree.commit('updated foo again',rev_id='revision_3')
+ return tree
+
+ def _check_revision_history(self, location=''):
+ rh = self.capture('revision-history ' + location)
+ self.assertEqual(rh, 'revision_1\nrevision_2\nrevision_3\n')
+
+ def test_revision_history(self):
+ """Tests 'revision_history' command"""
+ self._build_branch()
+ os.chdir('test')
+ self._check_revision_history()
+
+ def test_revision_history_with_location(self):
+ """Tests 'revision_history' command with a specified location."""
+ self._build_branch()
+ self._check_revision_history('test')
+
+ def test_revision_history_with_repo_branch(self):
+ """Tests 'revision_history' command with a location that is a
+ repository branch."""
+ self._build_branch()
+ self.run_bzr('init-repo', 'repo')
+ self.run_bzr('branch', 'test', 'repo/test')
+ self._check_revision_history('repo/test')
+
+ def test_revision_history_with_checkout(self):
+ """Tests 'revision_history' command with a location that is a
+ checkout of a repository branch."""
+ self._build_branch()
+ self.run_bzr('init-repo', 'repo')
+ self.run_bzr('branch', 'test', 'repo/test')
+ self.run_bzr('checkout', 'repo/test', 'test-checkout')
+ self._check_revision_history('test-checkout')
+
+ def test_revision_history_with_lightweight_checkout(self):
+ """Tests 'revision_history' command with a location that is a
+ lightweight checkout of a repository branch."""
+ self._build_branch()
+ self.run_bzr('init-repo', 'repo')
+ self.run_bzr('branch', 'test', 'repo/test')
+ self.run_bzr('checkout', '--lightweight', 'repo/test', 'test-checkout')
+ self._check_revision_history('test-checkout')
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py
+++ bzrlib/builtins.py
@@ -867,13 +867,15 @@
class cmd_revision_history(Command):
- """Display list of revision ids on this branch."""
+ """Display the list of revision ids on a branch."""
+ takes_args = ['location?']
+
hidden = True
@display_command
- def run(self):
- branch = WorkingTree.open_containing(u'.')[0].branch
- for patchid in branch.revision_history():
- print patchid
+ def run(self, location="."):
+ branch = Branch.open_containing(location)[0]
+ for revid in branch.revision_history():
+ print revid
class cmd_ancestry(Command):
=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- bzrlib/tests/blackbox/__init__.py
+++ bzrlib/tests/blackbox/__init__.py
@@ -65,6 +65,7 @@
'bzrlib.tests.blackbox.test_re_sign',
'bzrlib.tests.blackbox.test_revert',
'bzrlib.tests.blackbox.test_revno',
+ 'bzrlib.tests.blackbox.test_revision_history',
'bzrlib.tests.blackbox.test_revision_info',
'bzrlib.tests.blackbox.test_selftest',
'bzrlib.tests.blackbox.test_shared_repository',
--
Michael Ellerman
IBM OzLabs
wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)
We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060531/e61bb4c5/attachment.pgp
More information about the bazaar
mailing list