Rev 2: Allow supplying a --revision to 'bzr start' in http://bzr.arbash-meinel.com/plugins/start
John Arbash Meinel
john at arbash-meinel.com
Wed Jan 21 17:46:03 GMT 2009
At http://bzr.arbash-meinel.com/plugins/start
------------------------------------------------------------
revno: 2
revision-id: john at arbash-meinel.com-20090121174556-pj9gfcf0a064lghc
parent: john at arbash-meinel.com-20090121174359-jwfe45i4hol31ny6
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: start
timestamp: Wed 2009-01-21 11:45:56 -0600
message:
Allow supplying a --revision to 'bzr start'
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py 2009-01-21 17:43:59 +0000
+++ b/__init__.py 2009-01-21 17:45:56 +0000
@@ -34,9 +34,9 @@
"""
takes_args = ['location']
- takes_options = []
+ takes_options = ['revision']
- def run(self, location=None):
+ def run(self, location=None, revision=None):
from bzrlib import (
branch,
config,
@@ -50,7 +50,11 @@
if trunk_branch is None:
raise errors.BzrCommandError('No "trunk_branch" configured')
b = branch.Branch.open(trunk_branch)
- new_b = b.bzrdir.sprout(location).open_branch()
+ if revision is not None:
+ revision_id = revision[0].as_revision_id(b)
+ else:
+ revision_id = None
+ new_b = b.bzrdir.sprout(location, revision_id=revision_id).open_branch()
switch.switch(wt.bzrdir, new_b)
commands.register_command(cmd_start)
=== modified file 'test_start.py'
--- a/test_start.py 2009-01-21 17:43:59 +0000
+++ b/test_start.py 2009-01-21 17:45:56 +0000
@@ -32,6 +32,7 @@
builder = self.make_branch_builder('trunk')
builder.build_snapshot('rev1', None,
[('add', ('', 'root-id', 'directory', None))])
+ builder.build_snapshot('rev2', ['rev1'], [])
b = builder.get_branch()
c = config.LocationConfig(osutils.getcwd())
c.set_user_option('trunk_branch', b.base)
@@ -47,6 +48,17 @@
# Make sure the 'foobar' branch was created, and is at the right
# revision
b = branch.Branch.open('foobar')
+ self.assertEqual((2, 'rev2'), b.last_revision_info())
+ # And that the local tree is pointing at it
+ tree = workingtree.WorkingTree.open('tree')
+ self.assertEqual(b.base, tree.branch.base)
+
+ def test_create_branch_at_rev(self):
+ self.create_trunk_and_config()
+ self.run_bzr('start ../foobar -r 1', working_dir='tree')
+ # Make sure the 'foobar' branch was created, and is at the right
+ # revision
+ b = branch.Branch.open('foobar')
self.assertEqual((1, 'rev1'), b.last_revision_info())
# And that the local tree is pointing at it
tree = workingtree.WorkingTree.open('tree')
More information about the bazaar-commits
mailing list