Merge lp:~mgordon/bzr/506730-add-no-tree-to-bzr-push into lp:bzr

Proposed by Matthew Gordon
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 5488
Proposed branch: lp:~mgordon/bzr/506730-add-no-tree-to-bzr-push
Merge into: lp:bzr
Diff against target: 207 lines (+48/-13)
7 files modified
NEWS (+4/-0)
bzrlib/branch.py (+4/-2)
bzrlib/builtins.py (+17/-6)
bzrlib/bzrdir.py (+2/-2)
bzrlib/push.py (+3/-2)
bzrlib/tests/blackbox/test_init.py (+7/-1)
bzrlib/tests/blackbox/test_push.py (+11/-0)
To merge this branch: bzr merge lp:~mgordon/bzr/506730-add-no-tree-to-bzr-push
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Review via email: mp+36946@code.launchpad.net

Commit message

Add a --no-tree option for init and push

Description of the change

Bug 506730
Added a --notree option for init and push

Added the option, when pushing to a new location or initializing a new branch, to create the branch with no working trees.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

What can I say...

The feature is tested, documented, the bug marked in progress...

Well done !

I'd wait a day or two for a second review in case I missed something obvious and I'll land.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-10-01 08:49:39 +0000
3+++ NEWS 2010-10-02 02:11:05 +0000
4@@ -27,6 +27,10 @@
5 hook.
6 (Parth Malwankar, #403687)
7
8+* Add --no-tree option to 'bzr push' and 'bzr init' for creating a
9+ new or mirrored branch without working trees.
10+ (Matthew Gordon, #506730)
11+
12 Bug Fixes
13 *********
14
15
16=== modified file 'bzrlib/branch.py'
17--- bzrlib/branch.py 2010-09-28 18:51:47 +0000
18+++ bzrlib/branch.py 2010-10-02 02:11:05 +0000
19@@ -1372,7 +1372,8 @@
20 return format
21
22 def create_clone_on_transport(self, to_transport, revision_id=None,
23- stacked_on=None, create_prefix=False, use_existing_dir=False):
24+ stacked_on=None, create_prefix=False, use_existing_dir=False,
25+ no_tree=None):
26 """Create a clone of this branch and its bzrdir.
27
28 :param to_transport: The transport to clone onto.
29@@ -1391,7 +1392,8 @@
30 revision_id = self.last_revision()
31 dir_to = self.bzrdir.clone_on_transport(to_transport,
32 revision_id=revision_id, stacked_on=stacked_on,
33- create_prefix=create_prefix, use_existing_dir=use_existing_dir)
34+ create_prefix=create_prefix, use_existing_dir=use_existing_dir,
35+ no_tree=no_tree)
36 return dir_to.open_branch()
37
38 def create_checkout(self, to_location, revision_id=None,
39
40=== modified file 'bzrlib/builtins.py'
41--- bzrlib/builtins.py 2010-10-01 08:49:39 +0000
42+++ bzrlib/builtins.py 2010-10-02 02:11:05 +0000
43@@ -1063,6 +1063,9 @@
44 Option('strict',
45 help='Refuse to push if there are uncommitted changes in'
46 ' the working tree, --no-strict disables the check.'),
47+ Option('no-tree',
48+ help="Don't populate the working tree, even for protocols"
49+ " that support it."),
50 ]
51 takes_args = ['location?']
52 encoding_type = 'replace'
53@@ -1070,7 +1073,7 @@
54 def run(self, location=None, remember=False, overwrite=False,
55 create_prefix=False, verbose=False, revision=None,
56 use_existing_dir=False, directory=None, stacked_on=None,
57- stacked=False, strict=None):
58+ stacked=False, strict=None, no_tree=False):
59 from bzrlib.push import _show_push_branch
60
61 if directory is None:
62@@ -1122,7 +1125,7 @@
63 _show_push_branch(br_from, revision_id, location, self.outf,
64 verbose=verbose, overwrite=overwrite, remember=remember,
65 stacked_on=stacked_on, create_prefix=create_prefix,
66- use_existing_dir=use_existing_dir)
67+ use_existing_dir=use_existing_dir, no_tree=no_tree)
68
69
70 class cmd_branch(Command):
71@@ -1699,10 +1702,12 @@
72 ),
73 Option('append-revisions-only',
74 help='Never change revnos or the existing log.'
75- ' Append revisions to it only.')
76+ ' Append revisions to it only.'),
77+ Option('no-tree',
78+ 'Create a branch without a working tree.')
79 ]
80 def run(self, location=None, format=None, append_revisions_only=False,
81- create_prefix=False):
82+ create_prefix=False, no_tree=False):
83 if format is None:
84 format = bzrdir.format_registry.make_bzrdir('default')
85 if location is None:
86@@ -1731,8 +1736,13 @@
87 except errors.NotBranchError:
88 # really a NotBzrDir error...
89 create_branch = bzrdir.BzrDir.create_branch_convenience
90+ if no_tree:
91+ force_new_tree = False
92+ else:
93+ force_new_tree = None
94 branch = create_branch(to_transport.base, format=format,
95- possible_transports=[to_transport])
96+ possible_transports=[to_transport],
97+ force_new_tree=force_new_tree)
98 a_bzrdir = branch.bzrdir
99 else:
100 from bzrlib.transport.local import LocalTransport
101@@ -1742,7 +1752,8 @@
102 raise errors.BranchExistsWithoutWorkingTree(location)
103 raise errors.AlreadyBranchError(location)
104 branch = a_bzrdir.create_branch()
105- a_bzrdir.create_workingtree()
106+ if not no_tree:
107+ a_bzrdir.create_workingtree()
108 if append_revisions_only:
109 try:
110 branch.set_append_revisions_only(True)
111
112=== modified file 'bzrlib/bzrdir.py'
113--- bzrlib/bzrdir.py 2010-09-10 09:46:15 +0000
114+++ bzrlib/bzrdir.py 2010-10-02 02:11:05 +0000
115@@ -167,7 +167,7 @@
116
117 def clone_on_transport(self, transport, revision_id=None,
118 force_new_repo=False, preserve_stacking=False, stacked_on=None,
119- create_prefix=False, use_existing_dir=True):
120+ create_prefix=False, use_existing_dir=True, no_tree=False):
121 """Clone this bzrdir and its contents to transport verbatim.
122
123 :param transport: The transport for the location to produce the clone
124@@ -215,7 +215,7 @@
125 # we should look up the policy needs first, or just use it as a hint,
126 # or something.
127 if local_repo:
128- make_working_trees = local_repo.make_working_trees()
129+ make_working_trees = local_repo.make_working_trees() and not no_tree
130 want_shared = local_repo.is_shared()
131 repo_format_name = format.repository_format.network_name()
132 else:
133
134=== modified file 'bzrlib/push.py'
135--- bzrlib/push.py 2010-04-30 11:03:59 +0000
136+++ bzrlib/push.py 2010-10-02 02:11:05 +0000
137@@ -57,7 +57,7 @@
138
139 def _show_push_branch(br_from, revision_id, location, to_file, verbose=False,
140 overwrite=False, remember=False, stacked_on=None, create_prefix=False,
141- use_existing_dir=False):
142+ use_existing_dir=False, no_tree=False):
143 """Push a branch to a location.
144
145 :param br_from: the source branch
146@@ -87,7 +87,8 @@
147 try:
148 br_to = br_from.create_clone_on_transport(to_transport,
149 revision_id=revision_id, stacked_on=stacked_on,
150- create_prefix=create_prefix, use_existing_dir=use_existing_dir)
151+ create_prefix=create_prefix, use_existing_dir=use_existing_dir,
152+ no_tree=no_tree)
153 except errors.FileExists, err:
154 if err.path.endswith('/.bzr'):
155 raise errors.BzrCommandError(
156
157=== modified file 'bzrlib/tests/blackbox/test_init.py'
158--- bzrlib/tests/blackbox/test_init.py 2010-06-11 07:32:12 +0000
159+++ bzrlib/tests/blackbox/test_init.py 2010-10-02 02:11:05 +0000
160@@ -15,7 +15,7 @@
161 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
162
163
164-"""Test "bzr init"""
165+"""Test 'bzr init'"""
166
167 import os
168 import re
169@@ -163,6 +163,11 @@
170 self.run_bzr('init ../new/tree --create-prefix', working_dir='tree')
171 self.failUnlessExists('new/tree/.bzr')
172
173+ def test_init_no_tree(self):
174+ """'bzr init --no-tree' creates a branch with no working tree."""
175+ out, err = self.run_bzr('init --no-tree')
176+ self.assertStartsWith(out, 'Created a standalone branch')
177+
178
179 class TestSFTPInit(TestCaseWithSFTPServer):
180
181@@ -216,3 +221,4 @@
182 out, err = self.run_bzr(['init', 'foo'])
183 self.assertEqual(err, '')
184 self.assertTrue(os.path.exists('foo'))
185+
186
187=== modified file 'bzrlib/tests/blackbox/test_push.py'
188--- bzrlib/tests/blackbox/test_push.py 2010-06-11 07:32:12 +0000
189+++ bzrlib/tests/blackbox/test_push.py 2010-10-02 02:11:05 +0000
190@@ -146,6 +146,17 @@
191 b2 = branch.Branch.open('pushed-location')
192 self.assertEndsWith(b2.base, 'pushed-location/')
193
194+ def test_push_no_tree(self):
195+ # bzr push --no-tree of a branch with working trees
196+ b = self.make_branch_and_tree('push-from')
197+ self.build_tree(['push-from/file'])
198+ b.add('file')
199+ b.commit('commit 1')
200+ out, err = self.run_bzr('push --no-tree -d push-from push-to')
201+ self.assertEqual('', out)
202+ self.assertEqual('Created new branch.\n', err)
203+ self.failIfExists('push-to/file')
204+
205 def test_push_new_branch_revision_count(self):
206 # bzr push of a branch with revisions to a new location
207 # should print the number of revisions equal to the length of the