Rev 3996: Add --no-tree option to bzr branch (Daniel Watkins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Feb 10 06:29:54 GMT 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3996
revision-id: pqm at pqm.ubuntu.com-20090210062949-kj7rpejso2405ug1
parent: pqm at pqm.ubuntu.com-20090210045418-u1c0p4zpnp6nna3n
parent: ian.clatworthy at canonical.com-20090210054745-13deihx0x1om2i0m
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-02-10 06:29:49 +0000
message:
  Add --no-tree option to bzr branch (Daniel Watkins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
  bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
  bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
  bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
    ------------------------------------------------------------
    revno: 3995.1.1
    revision-id: ian.clatworthy at canonical.com-20090210054745-13deihx0x1om2i0m
    parent: pqm at pqm.ubuntu.com-20090210045418-u1c0p4zpnp6nna3n
    parent: daniel at daniel-watkins.co.uk-20090210032428-y0y9utt6kwov9h2l
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: ianc-integration
    timestamp: Tue 2009-02-10 15:47:45 +1000
    message:
      Add --no-tree option to bzr branch (Daniel Watkins)
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
      bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
      bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
    ------------------------------------------------------------
    revno: 3983.1.11
    revision-id: daniel at daniel-watkins.co.uk-20090210032428-y0y9utt6kwov9h2l
    parent: daniel at daniel-watkins.co.uk-20090210031250-15o0i4q8e9tqy86h
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: 273993-branch-no-tree
    timestamp: Tue 2009-02-10 03:24:28 +0000
    message:
      Old BzrDirs which must have working trees are now allowed for in the test.
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
    ------------------------------------------------------------
    revno: 3983.1.10
    revision-id: daniel at daniel-watkins.co.uk-20090210031250-15o0i4q8e9tqy86h
    parent: daniel at daniel-watkins.co.uk-20090210030835-evrni0nidfr1qaaj
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: 273993-branch-no-tree
    timestamp: Tue 2009-02-10 03:12:50 +0000
    message:
      Made exception message slightly better.
    modified:
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
    ------------------------------------------------------------
    revno: 3983.1.9
    revision-id: daniel at daniel-watkins.co.uk-20090210030835-evrni0nidfr1qaaj
    parent: daniel at daniel-watkins.co.uk-20090210030813-tb9tt438j9bpek9r
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: 273993-branch-no-tree
    timestamp: Tue 2009-02-10 03:08:35 +0000
    message:
      Wrapped long line.
    modified:
      bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
    ------------------------------------------------------------
    revno: 3983.1.8
    revision-id: daniel at daniel-watkins.co.uk-20090210030813-tb9tt438j9bpek9r
    parent: daniel at daniel-watkins.co.uk-20090208090702-8iisfmhhsdrpfgcq
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: 273993-branch-no-tree
    timestamp: Tue 2009-02-10 03:08:13 +0000
    message:
      Added MustHaveWorkingTree error and accompanying test.
    modified:
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
    ------------------------------------------------------------
    revno: 3983.1.7
    revision-id: daniel at daniel-watkins.co.uk-20090208090702-8iisfmhhsdrpfgcq
    parent: daniel at daniel-watkins.co.uk-20090207152002-4c2r8sgjepfzsqna
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: 273993-branch-no-tree
    timestamp: Sun 2009-02-08 10:07:02 +0100
    message:
      Review comments from jam.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
    ------------------------------------------------------------
    revno: 3983.1.6
    revision-id: daniel at daniel-watkins.co.uk-20090207152002-4c2r8sgjepfzsqna
    parent: daniel at daniel-watkins.co.uk-20090207151235-8qovn4cl9ka90jaq
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: 273993-branch-no-tree
    timestamp: Sat 2009-02-07 16:20:02 +0100
    message:
      Added NEWS entry.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3983.1.5
    revision-id: daniel at daniel-watkins.co.uk-20090207151235-8qovn4cl9ka90jaq
    parent: daniel at daniel-watkins.co.uk-20090207145655-5d34p9sb2zpb0lgj
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: 273993-branch-no-tree
    timestamp: Sat 2009-02-07 16:12:35 +0100
    message:
      Added blackbox test.
    modified:
      bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
    ------------------------------------------------------------
    revno: 3983.1.4
    revision-id: daniel at daniel-watkins.co.uk-20090207145655-5d34p9sb2zpb0lgj
    parent: daniel at daniel-watkins.co.uk-20090207145550-12avn75rmdpoplsd
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: 273993-branch-no-tree
    timestamp: Sat 2009-02-07 15:56:55 +0100
    message:
      Added 'no_tree' parameter to BzrDirPreSplitOut.
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
    ------------------------------------------------------------
    revno: 3983.1.3
    revision-id: daniel at daniel-watkins.co.uk-20090207145550-12avn75rmdpoplsd
    parent: daniel at daniel-watkins.co.uk-20090207142735-hc5el0i1gllok8dl
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: 273993-branch-no-tree
    timestamp: Sat 2009-02-07 15:55:50 +0100
    message:
      Added test to ensure BzrDirs accept the 'no_tree' argument.
    modified:
      bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
    ------------------------------------------------------------
    revno: 3983.1.2
    revision-id: daniel at daniel-watkins.co.uk-20090207142735-hc5el0i1gllok8dl
    parent: daniel at daniel-watkins.co.uk-20090207140502-ypcx3olm27z3hee4
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: 273993-branch-no-tree
    timestamp: Sat 2009-02-07 15:27:35 +0100
    message:
      Minor cleanup.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
    ------------------------------------------------------------
    revno: 3983.1.1
    revision-id: daniel at daniel-watkins.co.uk-20090207140502-ypcx3olm27z3hee4
    parent: pqm at pqm.ubuntu.com-20090205110039-w9oelsyvyx160qwy
    parent: john.klinger at gmail.com-20080403013611-pjr0meocc1lcr5by
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: 273993-branch-no-tree
    timestamp: Sat 2009-02-07 15:05:02 +0100
    message:
      Merged John Klinger's original work.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
    ------------------------------------------------------------
    revno: 3327.2.1
    revision-id: john.klinger at gmail.com-20080403013611-pjr0meocc1lcr5by
    parent: pqm at pqm.ubuntu.com-20080402090835-uq4ef5jnwo7opd9t
    committer: John Klinger <john.klinger at gmail.com>
    branch nick: no-tree
    timestamp: Thu 2008-04-03 13:36:11 +1200
    message:
      Added --no-trees option to branch command
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
=== modified file 'NEWS'
--- a/NEWS	2009-02-10 00:29:26 +0000
+++ b/NEWS	2009-02-10 05:47:45 +0000
@@ -56,6 +56,10 @@
     * ``bzr add`` more clearly communicates success vs failure.
       (Daniel Watkins)
 
+    * ``bzr branch`` now has a ``--no-tree`` option which turns off the
+      generation of a working tree in the new branch.
+      (Daniel Watkins, John Klinger, #273993)
+
     * ``bzr init`` will now print a little less verbose output.
       (Marius Kruger)
 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-02-10 01:38:33 +0000
+++ b/bzrlib/builtins.py	2009-02-10 05:47:45 +0000
@@ -999,6 +999,8 @@
     takes_args = ['from_location', 'to_location?']
     takes_options = ['revision', Option('hardlink',
         help='Hard-link working tree files where possible.'),
+        Option('no-tree',
+            help="Create a branch without a working-tree."),
         Option('stacked',
             help='Create a stacked branch referring to the source branch. '
                 'The new branch will depend on the availability of the source '
@@ -1009,7 +1011,7 @@
     aliases = ['get', 'clone']
 
     def run(self, from_location, to_location=None, revision=None,
-            hardlink=False, stacked=False, standalone=False):
+            hardlink=False, stacked=False, standalone=False, no_tree=False):
         from bzrlib.tag import _merge_tags_if_possible
 
         accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
@@ -1042,6 +1044,7 @@
                                             accelerator_tree=accelerator_tree,
                                             hardlink=hardlink, stacked=stacked,
                                             force_new_repo=standalone,
+                                            create_tree_if_local=not no_tree,
                                             source_branch=br_from)
                 branch = dir.open_branch()
             except errors.NoSuchRevision:

=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2009-02-09 06:38:29 +0000
+++ b/bzrlib/bzrdir.py	2009-02-10 05:47:45 +0000
@@ -1061,7 +1061,7 @@
     def sprout(self, url, revision_id=None, force_new_repo=False,
                recurse='down', possible_transports=None,
                accelerator_tree=None, hardlink=False, stacked=False,
-               source_branch=None):
+               source_branch=None, create_tree_if_local=True):
         """Create a copy of this bzrdir prepared for use as a new line of
         development.
 
@@ -1082,6 +1082,8 @@
             where possible.
         :param stacked: If true, create a stacked branch referring to the
             location of this control directory.
+        :param create_tree_if_local: If true, a working-tree will be created
+            when working locally.
         """
         target_transport = get_transport(url, possible_transports)
         target_transport.ensure_base()
@@ -1134,8 +1136,9 @@
             result_branch.set_parent(parent_location)
 
         # Create/update the result working tree
-        if isinstance(target_transport, local.LocalTransport) and (
-            result_repo is None or result_repo.make_working_trees()):
+        if (create_tree_if_local and
+            isinstance(target_transport, local.LocalTransport) and
+            (result_repo is None or result_repo.make_working_trees())):
             wt = result.create_workingtree(accelerator_tree=accelerator_tree,
                 hardlink=hardlink)
             wt.lock_write()
@@ -1335,11 +1338,14 @@
 
     def sprout(self, url, revision_id=None, force_new_repo=False,
                possible_transports=None, accelerator_tree=None,
-               hardlink=False, stacked=False):
+               hardlink=False, stacked=False, create_tree_if_local=True):
         """See BzrDir.sprout()."""
         if stacked:
             raise errors.UnstackableBranchFormat(
                 self._format, self.root_transport.base)
+        if not create_tree_if_local:
+            raise errors.MustHaveWorkingTree(
+                self._format, self.root_transport.base)
         from bzrlib.workingtree import WorkingTreeFormat2
         self._make_tail(url)
         result = self._format._initialize_for_clone(url)
@@ -1351,6 +1357,7 @@
             self.open_branch().sprout(result, revision_id=revision_id)
         except errors.NotBranchError:
             pass
+
         # we always want a working tree
         WorkingTreeFormat2().initialize(result,
                                         accelerator_tree=accelerator_tree,

=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2009-02-10 01:38:33 +0000
+++ b/bzrlib/errors.py	2009-02-10 05:47:45 +0000
@@ -2937,3 +2937,11 @@
 class UserAbort(BzrError):
 
     _fmt = 'The user aborted the operation.'
+
+
+class MustHaveWorkingTree(BzrError):
+
+    _fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
+
+    def __init__(self, format, url):
+        BzrError.__init__(self, format=format, url=url)

=== modified file 'bzrlib/tests/blackbox/test_branch.py'
--- a/bzrlib/tests/blackbox/test_branch.py	2008-09-13 11:17:00 +0000
+++ b/bzrlib/tests/blackbox/test_branch.py	2009-02-07 15:12:35 +0000
@@ -107,6 +107,12 @@
         self.assertEqual(strip_trailing_slash(b.repository.base),
             strip_trailing_slash(local_path_to_url(expected_repo_path)))
 
+    def test_branch_no_tree(self):
+        self.example_branch('source')
+        self.run_bzr('branch --no-tree source target')
+        self.failIfExists('target/hello')
+        self.failIfExists('target/goodbye')
+
 
 class TestBranchStacked(ExternalBase):
     """Tests for branch --stacked"""

=== modified file 'bzrlib/tests/bzrdir_implementations/test_bzrdir.py'
--- a/bzrlib/tests/bzrdir_implementations/test_bzrdir.py	2009-01-16 07:50:48 +0000
+++ b/bzrlib/tests/bzrdir_implementations/test_bzrdir.py	2009-02-10 03:24:28 +0000
@@ -191,7 +191,8 @@
                               % a_bzrdir.transport)
 
     def sproutOrSkip(self, from_bzrdir, to_url, revision_id=None,
-                     force_new_repo=False, accelerator_tree=None):
+                     force_new_repo=False, accelerator_tree=None,
+                     create_tree_if_local=True):
         """Sprout from_bzrdir into to_url, or raise TestSkipped.
         
         A simple wrapper for from_bzrdir.sprout that translates NotLocalUrl into
@@ -203,7 +204,8 @@
         target = from_bzrdir.sprout(to_url, revision_id=revision_id,
                                     force_new_repo=force_new_repo,
                                     possible_transports=[to_transport],
-                                    accelerator_tree=accelerator_tree)
+                                    accelerator_tree=accelerator_tree,
+                                    create_tree_if_local=create_tree_if_local)
         return target
 
     def test_create_null_workingtree(self):
@@ -1120,6 +1122,24 @@
                                    accelerator_tree=tree)
         self.assertEqual(['2'], target.open_workingtree().get_parent_ids())
 
+    def test_sprout_branch_no_tree(self):
+        tree = self.make_branch_and_tree('source')
+        self.build_tree(['source/foo'])
+        tree.add('foo')
+        tree.commit('revision 1', rev_id='1')
+        tree.commit('revision 2', rev_id='2', allow_pointless=True)
+        dir = tree.bzrdir
+        if isinstance(dir, (bzrdir.BzrDirPreSplitOut,)):
+            self.assertRaises(errors.MustHaveWorkingTree, self.sproutOrSkip,
+                              dir, self.get_url('target'),
+                              create_tree_if_local=False)
+            return
+        target = self.sproutOrSkip(dir, self.get_url('target'),
+                                   create_tree_if_local=False)
+        self.failIfExists('target/foo')
+        self.assertEqual(tree.branch.last_revision(),
+                         target.open_branch().last_revision())
+
     def test_format_initialize_find_open(self):
         # loopback test to check the current format initializes to itself.
         if not self.bzrdir_format.is_supported():

=== modified file 'bzrlib/tests/test_errors.py'
--- a/bzrlib/tests/test_errors.py	2009-01-06 05:59:04 +0000
+++ b/bzrlib/tests/test_errors.py	2009-02-10 03:12:50 +0000
@@ -572,6 +572,11 @@
             str(err), "The message handler raised an exception:\n")
         self.assertEndsWith(str(err), "Exception: example error\n")
 
+    def test_must_have_working_tree(self):
+        err = errors.MustHaveWorkingTree('foo', 'bar')
+        self.assertEqual(str(err), "Branching 'bar'(foo) must create a"
+                                   " working tree.")
+
 
 class PassThroughError(errors.BzrError):
     




More information about the bazaar-commits mailing list