Merge lp:~jelmer/brz/remove-dpush into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/remove-dpush
Merge into: lp:brz
Diff against target: 352 lines (+0/-308)
5 files modified
breezy/builtins.py (+0/-1)
breezy/foreign.py (+0/-107)
breezy/tests/blackbox/__init__.py (+0/-1)
breezy/tests/blackbox/test_dpush.py (+0/-175)
breezy/tests/test_foreign.py (+0/-24)
To merge this branch: bzr merge lp:~jelmer/brz/remove-dpush
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+342553@code.launchpad.net

Commit message

Remove the dpush command, in favor of 'brz push --lossy'.

Description of the change

Remove the dpush command, in favor of 'brz push --lossy'.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/builtins.py'
2--- breezy/builtins.py 2018-05-05 01:50:26 +0000
3+++ breezy/builtins.py 2018-05-07 11:30:00 +0000
4@@ -6785,7 +6785,6 @@
5 ('cmd_bundle_info', [], 'breezy.bundle.commands'),
6 ('cmd_config', [], 'breezy.config'),
7 ('cmd_dump_btree', [], 'breezy.bzr.debug_commands'),
8- ('cmd_dpush', [], 'breezy.foreign'),
9 ('cmd_version_info', [], 'breezy.cmd_version_info'),
10 ('cmd_resolve', ['resolved'], 'breezy.conflicts'),
11 ('cmd_conflicts', [], 'breezy.conflicts'),
12
13=== modified file 'breezy/foreign.py'
14--- breezy/foreign.py 2017-08-26 14:03:58 +0000
15+++ breezy/foreign.py 2018-05-07 11:30:00 +0000
16@@ -236,110 +236,3 @@
17 self.mapping = mapping
18 super(ForeignBranch, self).__init__()
19
20-
21-def update_workingtree_fileids(wt, target_tree):
22- """Update the file ids in a working tree based on another tree.
23-
24- :param wt: Working tree in which to update file ids
25- :param target_tree: Tree to retrieve new file ids from, based on path
26- """
27- tt = transform.TreeTransform(wt)
28- try:
29- for f, p, c, v, d, n, k, e in target_tree.iter_changes(wt):
30- if v == (True, False):
31- trans_id = tt.trans_id_tree_path(p[0])
32- tt.unversion_file(trans_id)
33- elif v == (False, True):
34- trans_id = tt.trans_id_tree_path(p[1])
35- tt.version_file(f, trans_id)
36- tt.apply()
37- finally:
38- tt.finalize()
39- if len(wt.get_parent_ids()) == 1:
40- wt.set_parent_trees([(target_tree.get_revision_id(), target_tree)])
41- else:
42- wt.set_last_revision(target_tree.get_revision_id())
43-
44-
45-class cmd_dpush(Command):
46- __doc__ = """Push into a different VCS without any custom bzr metadata.
47-
48- This will afterwards rebase the local branch on the remote
49- branch unless the --no-rebase option is used, in which case
50- the two branches will be out of sync after the push.
51- """
52- takes_args = ['location?']
53- takes_options = [
54- 'remember',
55- Option('directory',
56- help='Branch to push from, '
57- 'rather than the one containing the working directory.',
58- short_name='d',
59- type=text_type,
60- ),
61- Option('no-rebase', help="Do not rebase after push."),
62- Option('strict',
63- help='Refuse to push if there are uncommitted changes in'
64- ' the working tree, --no-strict disables the check.'),
65- ]
66-
67- def run(self, location=None, remember=False, directory=None,
68- no_rebase=False, strict=None):
69- from breezy import urlutils
70- from breezy.controldir import ControlDir
71- from breezy.errors import BzrCommandError, NoWorkingTree
72- from breezy.workingtree import WorkingTree
73-
74- if directory is None:
75- directory = "."
76- try:
77- source_wt = WorkingTree.open_containing(directory)[0]
78- source_branch = source_wt.branch
79- except NoWorkingTree:
80- source_branch = Branch.open(directory)
81- source_wt = None
82- if source_wt is not None:
83- source_wt.check_changed_or_out_of_date(
84- strict, 'dpush_strict',
85- more_error='Use --no-strict to force the push.',
86- more_warning='Uncommitted changes will not be pushed.')
87- stored_loc = source_branch.get_push_location()
88- if location is None:
89- if stored_loc is None:
90- raise BzrCommandError(gettext("No push location known or specified."))
91- else:
92- display_url = urlutils.unescape_for_display(stored_loc,
93- self.outf.encoding)
94- self.outf.write(
95- gettext("Using saved location: %s\n") % display_url)
96- location = stored_loc
97-
98- controldir = ControlDir.open(location)
99- target_branch = controldir.open_branch()
100- target_branch.lock_write()
101- try:
102- try:
103- push_result = source_branch.push(target_branch, lossy=True)
104- except errors.LossyPushToSameVCS:
105- raise BzrCommandError(gettext("{0!r} and {1!r} are in the same VCS, lossy "
106- "push not necessary. Please use regular push.").format(
107- source_branch, target_branch))
108- # We successfully created the target, remember it
109- if source_branch.get_push_location() is None or remember:
110- # FIXME: Should be done only if we succeed ? -- vila 2012-01-18
111- source_branch.set_push_location(target_branch.base)
112- if not no_rebase:
113- old_last_revid = source_branch.last_revision()
114- source_branch.pull(target_branch, overwrite=True)
115- new_last_revid = source_branch.last_revision()
116- if source_wt is not None and old_last_revid != new_last_revid:
117- source_wt.lock_write()
118- try:
119- target = source_wt.branch.repository.revision_tree(
120- new_last_revid)
121- update_workingtree_fileids(source_wt, target)
122- finally:
123- source_wt.unlock()
124- push_result.report(self.outf)
125- finally:
126- target_branch.unlock()
127
128=== modified file 'breezy/tests/blackbox/__init__.py'
129--- breezy/tests/blackbox/__init__.py 2017-12-19 15:55:48 +0000
130+++ breezy/tests/blackbox/__init__.py 2018-05-07 11:30:00 +0000
131@@ -59,7 +59,6 @@
132 'test_deleted',
133 'test_diff',
134 'test_dump_btree',
135- 'test_dpush',
136 'test_exceptions',
137 'test_export',
138 'test_export_pot',
139
140=== removed file 'breezy/tests/blackbox/test_dpush.py'
141--- breezy/tests/blackbox/test_dpush.py 2018-03-26 00:54:10 +0000
142+++ breezy/tests/blackbox/test_dpush.py 1970-01-01 00:00:00 +0000
143@@ -1,175 +0,0 @@
144-# Copyright (C) 2009-2012, 2016 Canonical Ltd
145-#
146-# This program is free software; you can redistribute it and/or modify
147-# it under the terms of the GNU General Public License as published by
148-# the Free Software Foundation; either version 2 of the License, or
149-# (at your option) any later version.
150-#
151-# This program is distributed in the hope that it will be useful,
152-# but WITHOUT ANY WARRANTY; without even the implied warranty of
153-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
154-# GNU General Public License for more details.
155-#
156-# You should have received a copy of the GNU General Public License
157-# along with this program; if not, write to the Free Software
158-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
159-
160-
161-"""Black-box tests for brz dpush."""
162-
163-
164-from breezy import (
165- branch,
166- tests,
167- )
168-from breezy.tests import (
169- script,
170- test_foreign,
171- )
172-from breezy.tests.blackbox import test_push
173-from breezy.tests.scenarios import (
174- load_tests_apply_scenarios,
175- )
176-
177-
178-load_tests = load_tests_apply_scenarios
179-
180-
181-class TestDpush(tests.TestCaseWithTransport):
182-
183- def setUp(self):
184- super(TestDpush, self).setUp()
185- test_foreign.register_dummy_foreign_for_test(self)
186-
187- def make_dummy_builder(self, relpath):
188- builder = self.make_branch_builder(
189- relpath, format=test_foreign.DummyForeignVcsDirFormat())
190- builder.build_snapshot(None,
191- [('add', ('', 'TREE_ROOT', 'directory', None)),
192- ('add', ('foo', 'fooid', 'file', 'bar'))],
193- revision_id=b'revid')
194- return builder
195-
196- def test_dpush_native(self):
197- target_tree = self.make_branch_and_tree("dp")
198- source_tree = self.make_branch_and_tree("dc")
199- output, error = self.run_bzr("dpush -d dc dp", retcode=3)
200- self.assertEqual("", output)
201- self.assertContainsRe(error,
202- 'in the same VCS, lossy push not necessary. Please use regular '
203- 'push.')
204-
205- def test_dpush(self):
206- branch = self.make_dummy_builder('d').get_branch()
207-
208- dc = branch.controldir.sprout('dc', force_new_repo=True)
209- self.build_tree(("dc/foo", "blaaaa"))
210- dc.open_workingtree().commit('msg')
211-
212- script.run_script(self, """
213- $ brz dpush -d dc d
214- 2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
215- 2>This may take some time. Upgrade the repositories to the same format for better performance.
216- 2>Pushed up to revision 2.
217- $ brz status dc
218- """)
219-
220- def test_dpush_new(self):
221- b = self.make_dummy_builder('d').get_branch()
222-
223- dc = b.controldir.sprout('dc', force_new_repo=True)
224- self.build_tree_contents([("dc/foofile", b"blaaaa")])
225- dc_tree = dc.open_workingtree()
226- dc_tree.add("foofile")
227- dc_tree.commit("msg")
228-
229- script.run_script(self, '''
230- $ brz dpush -d dc d
231- 2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
232- 2>This may take some time. Upgrade the repositories to the same format for better performance.
233- 2>Pushed up to revision 2.
234- $ brz revno dc
235- 2
236- $ brz status dc
237- ''')
238-
239- def test_dpush_wt_diff(self):
240- b = self.make_dummy_builder('d').get_branch()
241-
242- dc = b.controldir.sprout('dc', force_new_repo=True)
243- self.build_tree_contents([("dc/foofile", b"blaaaa")])
244- dc_tree = dc.open_workingtree()
245- dc_tree.add("foofile")
246- newrevid = dc_tree.commit('msg')
247-
248- self.build_tree_contents([("dc/foofile", b"blaaaal")])
249- script.run_script(self, '''
250- $ brz dpush -d dc d --no-strict
251- 2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
252- 2>This may take some time. Upgrade the repositories to the same format for better performance.
253- 2>Pushed up to revision 2.
254- ''')
255- self.assertFileEqual("blaaaal", "dc/foofile")
256- # if the dummy vcs wasn't that dummy we could uncomment the line below
257- # self.assertFileEqual("blaaaa", "d/foofile")
258- script.run_script(self, '''
259- $ brz status dc
260- modified:
261- foofile
262- ''')
263-
264- def test_diverged(self):
265- builder = self.make_dummy_builder('d')
266-
267- b = builder.get_branch()
268-
269- dc = b.controldir.sprout('dc', force_new_repo=True)
270- dc_tree = dc.open_workingtree()
271-
272- self.build_tree_contents([("dc/foo", b"bar")])
273- dc_tree.commit('msg1')
274-
275- builder.build_snapshot(None,
276- [('modify', ('foo', b'blie'))], revision_id=b'revid2')
277-
278- output, error = self.run_bzr("dpush -d dc d", retcode=3)
279- self.assertEqual(output, "")
280- self.assertContainsRe(error, "have diverged")
281-
282-
283-class TestDpushStrictMixin(object):
284-
285- def setUp(self):
286- test_foreign.register_dummy_foreign_for_test(self)
287- # Create an empty branch where we will be able to push
288- self.foreign = self.make_branch(
289- 'to', format=test_foreign.DummyForeignVcsDirFormat())
290-
291- def set_config_push_strict(self, value):
292- br = branch.Branch.open('local')
293- br.get_config_stack().set('dpush_strict', value)
294-
295- _default_command = ['dpush', '../to']
296-
297-
298-class TestDpushStrictWithoutChanges(TestDpushStrictMixin,
299- test_push.TestPushStrictWithoutChanges):
300-
301- def setUp(self):
302- test_push.TestPushStrictWithoutChanges.setUp(self)
303- TestDpushStrictMixin.setUp(self)
304-
305-
306-class TestDpushStrictWithChanges(TestDpushStrictMixin,
307- test_push.TestPushStrictWithChanges):
308-
309- scenarios = test_push.strict_push_change_scenarios
310-
311- _changes_type = None # Set by load_tests
312-
313- def setUp(self):
314- test_push.TestPushStrictWithChanges.setUp(self)
315- TestDpushStrictMixin.setUp(self)
316-
317- def test_push_with_revision(self):
318- raise tests.TestNotApplicable('dpush does not handle --revision')
319
320=== modified file 'breezy/tests/test_foreign.py'
321--- breezy/tests/test_foreign.py 2018-02-18 15:21:06 +0000
322+++ breezy/tests/test_foreign.py 2018-05-07 11:30:00 +0000
323@@ -413,30 +413,6 @@
324 self.assertEqual(mapp, rev.mapping)
325
326
327-class WorkingTreeFileUpdateTests(tests.TestCaseWithTransport):
328- """Tests for update_workingtree_fileids()."""
329-
330- def test_update_workingtree(self):
331- wt = self.make_branch_and_tree('br1')
332- self.build_tree_contents([('br1/bla', b'original contents\n')])
333- wt.add('bla', 'bla-a')
334- wt.commit('bla-a')
335- root_id = wt.get_root_id()
336- target = wt.controldir.sprout('br2').open_workingtree()
337- target.unversion(['bla'])
338- target.add('bla', 'bla-b')
339- target.commit('bla-b')
340- target_basis = target.basis_tree()
341- target_basis.lock_read()
342- self.addCleanup(target_basis.unlock)
343- foreign.update_workingtree_fileids(wt, target_basis)
344- wt.lock_read()
345- try:
346- self.assertEqual({'', "bla"}, set(wt.all_versioned_paths()))
347- finally:
348- wt.unlock()
349-
350-
351 class DummyForeignVcsTests(tests.TestCaseWithTransport):
352 """Very basic test for DummyForeignVcs."""
353

Subscribers

People subscribed via source and target branches