Merge lp:~jelmer/launchpad/import-colocated-branches into lp:launchpad

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 13941
Proposed branch: lp:~jelmer/launchpad/import-colocated-branches
Merge into: lp:launchpad
Prerequisite: lp:~jelmer/launchpad/bzr-2.4b4
Diff against target: 219 lines (+80/-24)
6 files modified
lib/lp/codehosting/bzrutils.py (+3/-3)
lib/lp/codehosting/codeimport/tests/test_worker.py (+67/-7)
lib/lp/codehosting/codeimport/uifactory.py (+0/-4)
utilities/sourcedeps.cache (+6/-6)
utilities/sourcedeps.conf (+3/-3)
versions.cfg (+1/-1)
To merge this branch: bzr merge lp:~jelmer/launchpad/import-colocated-branches
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+72127@code.launchpad.net

This proposal supersedes a proposal from 2011-08-19.

Commit message

Import newer versions of bzr, bzr-git and dulwich which have support for addressing colocated branches.

Description of the change

Import newer versions of bzr, bzr-git and dulwich which have support for addressing colocated branches.

This makes it possible to import non-HEAD branches from Git repositories (bug 380871).

There already is a branch pending which updates Bazaar in launchpad to version 2.4.0. Rather than cherrypicking the patches that add support for colocated branches from bzr.dev, I have chosen to simply go to a recent snapshot of bzr.dev. The reason for this is that there have only been a few revisions since 2.4.0 in bzr.dev, and backporting a relatively large change like colocated branch support also has its risks.

This does not yet add any extra UI to make it easier for a user to import non-master branch paths - users have to know about the syntax in the Bazaar URL format.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/codehosting/bzrutils.py'
2--- lib/lp/codehosting/bzrutils.py 2011-08-16 11:33:00 +0000
3+++ lib/lp/codehosting/bzrutils.py 2011-09-13 09:42:55 +0000
4@@ -101,11 +101,11 @@
5 # BzrDir.find_branch_format()), then the branch is not stackable. Bazaar
6 # post-1.6 has added 'get_branch_format' to the pre-split-out formats,
7 # which we could use instead.
8- find_branch_format = getattr(a_bzrdir, 'find_branch_format', None)
9- if find_branch_format is None:
10+ try:
11+ format = a_bzrdir.find_branch_format(None)
12+ except NotImplementedError:
13 raise UnstackableBranchFormat(
14 a_bzrdir._format, a_bzrdir.root_transport.base)
15- format = find_branch_format()
16 if not format.supports_stacking():
17 raise UnstackableBranchFormat(format, a_bzrdir.root_transport.base)
18 branch_transport = a_bzrdir.get_branch_transport(None)
19
20=== modified file 'lib/lp/codehosting/codeimport/tests/test_worker.py'
21--- lib/lp/codehosting/codeimport/tests/test_worker.py 2011-08-28 08:36:14 +0000
22+++ lib/lp/codehosting/codeimport/tests/test_worker.py 2011-09-13 09:42:55 +0000
23@@ -12,7 +12,10 @@
24 import tempfile
25 import time
26
27-from bzrlib import trace
28+from bzrlib import (
29+ trace,
30+ urlutils,
31+ )
32 from bzrlib.branch import (
33 Branch,
34 BranchReferenceFormat,
35@@ -25,7 +28,10 @@
36 )
37 from bzrlib.errors import NoSuchFile
38 from bzrlib.tests import TestCaseWithTransport
39-from bzrlib.transport import get_transport
40+from bzrlib.transport import (
41+ get_transport,
42+ get_transport_from_url,
43+ )
44 from bzrlib.urlutils import (
45 join as urljoin,
46 local_path_from_url,
47@@ -1112,11 +1118,13 @@
48 self.bazaar_store, logging.getLogger(),
49 opener_policy=opener_policy)
50
51- def makeForeignCommit(self, source_details):
52+ def makeForeignCommit(self, source_details, message=None, ref="HEAD"):
53 """Change the foreign tree, generating exactly one commit."""
54 repo = GitRepo(local_path_from_url(source_details.url))
55- repo.do_commit(message=self.factory.getUniqueString(),
56- committer="Joe Random Hacker <joe@example.com>")
57+ if message is None:
58+ message = self.factory.getUniqueString()
59+ repo.do_commit(message=message,
60+ committer="Joe Random Hacker <joe@example.com>", ref=ref)
61 self.foreign_commit_count += 1
62
63 def makeSourceDetails(self, branch_name, files):
64@@ -1133,6 +1141,29 @@
65 return self.factory.makeCodeImportSourceDetails(
66 rcstype='git', url=git_server.get_url())
67
68+ def test_non_master(self):
69+ # non-master branches can be specified in the import URL.
70+ source_details = self.makeSourceDetails(
71+ 'trunk', [('README', 'Original contents')])
72+ self.makeForeignCommit(source_details, ref="refs/heads/other",
73+ message="Message for other")
74+ self.makeForeignCommit(source_details, ref="refs/heads/master",
75+ message="Message for master")
76+ source_details.url = urlutils.join_segment_parameters(
77+ source_details.url, { "branch": "other" })
78+ source_transport = get_transport_from_url(source_details.url)
79+ self.assertEquals(
80+ { "branch": "other" },
81+ source_transport.get_segment_parameters())
82+ worker = self.makeImportWorker(source_details,
83+ opener_policy=AcceptAnythingPolicy())
84+ self.assertTrue(self.foreign_commit_count > 1)
85+ self.assertEqual(
86+ CodeImportWorkerExitCode.SUCCESS, worker.run())
87+ branch = worker.getBazaarBranch()
88+ lastrev = branch.repository.get_revision(branch.last_revision())
89+ self.assertEquals(lastrev.message, "Message for other")
90+
91
92 class TestMercurialImport(WorkerTest, TestActualImportMixin,
93 PullingImportWorkerTests):
94@@ -1163,12 +1194,18 @@
95 self.bazaar_store, logging.getLogger(),
96 opener_policy=opener_policy)
97
98- def makeForeignCommit(self, source_details):
99+ def makeForeignCommit(self, source_details, message=None, branch=None):
100 """Change the foreign tree, generating exactly one commit."""
101 from mercurial.ui import ui
102 from mercurial.localrepo import localrepository
103 repo = localrepository(ui(), local_path_from_url(source_details.url))
104- repo.commit(text="hello world!", user="Jane Random Hacker", force=1)
105+ extra = {}
106+ if branch is not None:
107+ extra = { "branch": branch }
108+ if message is None:
109+ message = self.factory.getUniqueString()
110+ repo.commit(text=message, user="Jane Random Hacker", force=1,
111+ extra=extra)
112 self.foreign_commit_count += 1
113
114 def makeSourceDetails(self, branch_name, files):
115@@ -1185,6 +1222,29 @@
116 return self.factory.makeCodeImportSourceDetails(
117 rcstype='hg', url=hg_server.get_url())
118
119+ def test_non_default(self):
120+ # non-default branches can be specified in the import URL.
121+ source_details = self.makeSourceDetails(
122+ 'trunk', [('README', 'Original contents')])
123+ self.makeForeignCommit(source_details, branch="other",
124+ message="Message for other")
125+ self.makeForeignCommit(source_details, branch="default",
126+ message="Message for default")
127+ source_details.url = urlutils.join_segment_parameters(
128+ source_details.url, { "branch": "other" })
129+ source_transport = get_transport_from_url(source_details.url)
130+ self.assertEquals(
131+ { "branch": "other" },
132+ source_transport.get_segment_parameters())
133+ worker = self.makeImportWorker(source_details,
134+ opener_policy=AcceptAnythingPolicy())
135+ self.assertTrue(self.foreign_commit_count > 1)
136+ self.assertEqual(
137+ CodeImportWorkerExitCode.SUCCESS, worker.run())
138+ branch = worker.getBazaarBranch()
139+ lastrev = branch.repository.get_revision(branch.last_revision())
140+ self.assertEquals(lastrev.message, "Message for other")
141+
142
143 class TestBzrSvnImport(WorkerTest, SubversionImportHelpers,
144 TestActualImportMixin, PullingImportWorkerTests):
145
146=== modified file 'lib/lp/codehosting/codeimport/uifactory.py'
147--- lib/lp/codehosting/codeimport/uifactory.py 2011-08-03 00:35:38 +0000
148+++ lib/lp/codehosting/codeimport/uifactory.py 2011-09-13 09:42:55 +0000
149@@ -206,7 +206,3 @@
150 self._bytes_since_update = 0
151 self._last_transport_msg = msg
152 self._repaint()
153-
154- # bzr 1.17 renamed _show_transport_activity to show_transport_activity.
155- # When we have upgraded to bzr 1.17, this compatibility hack can go away.
156- _show_transport_activity = show_transport_activity
157
158=== modified file 'utilities/sourcedeps.cache'
159--- utilities/sourcedeps.cache 2011-09-06 19:40:50 +0000
160+++ utilities/sourcedeps.cache 2011-09-13 09:42:55 +0000
161@@ -4,12 +4,12 @@
162 "launchpad@pqm.canonical.com-20101123183213-777lz46xgagn1deg"
163 ],
164 "bzr-git": [
165- 259,
166- "launchpad@pqm.canonical.com-20110601140035-gl5merbechngjw5s"
167+ 264,
168+ "launchpad@pqm.canonical.com-20110913022112-2x3wgyj2mqof74uy"
169 ],
170 "bzr-hg": [
171- 290,
172- "launchpad@pqm.canonical.com-20110808175904-4gj24x3y21kxepcj"
173+ 291,
174+ "launchpad@pqm.canonical.com-20110822162405-m5xrb9p3ahzddmcm"
175 ],
176 "bzr-loom": [
177 50,
178@@ -28,8 +28,8 @@
179 "aaron@aaronbentley.com-20100715135013-uoi3q430urx9gwb8"
180 ],
181 "dulwich": [
182- 426,
183- "launchpad@pqm.canonical.com-20110520175715-e90dzs8os0kotbm9"
184+ 430,
185+ "launchpad@pqm.canonical.com-20110913014713-3l8j2zva6pgor5uw"
186 ],
187 "loggerhead": [
188 456,
189
190=== modified file 'utilities/sourcedeps.conf'
191--- utilities/sourcedeps.conf 2011-09-03 02:58:43 +0000
192+++ utilities/sourcedeps.conf 2011-09-13 09:42:55 +0000
193@@ -1,10 +1,10 @@
194 bzr-builder lp:~launchpad-pqm/bzr-builder/trunk;revno=68
195-bzr-git lp:~launchpad-pqm/bzr-git/devel;revno=259
196-bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=290
197+bzr-git lp:~launchpad-pqm/bzr-git/devel;revno=264
198+bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=291
199 bzr-loom lp:~launchpad-pqm/bzr-loom/trunk;revno=50
200 bzr-svn lp:~launchpad-pqm/bzr-svn/devel;revno=2717
201 cscvs lp:~launchpad-pqm/launchpad-cscvs/devel;revno=432
202-dulwich lp:~launchpad-pqm/dulwich/devel;revno=426
203+dulwich lp:~launchpad-pqm/dulwich/devel;revno=430
204 difftacular lp:difftacular;revno=6
205 loggerhead lp:~loggerhead-team/loggerhead/trunk-rich;revno=456
206 lpreview lp:~launchpad-pqm/bzr-lpreview/devel;revno=23
207
208=== modified file 'versions.cfg'
209--- versions.cfg 2011-09-12 23:52:19 +0000
210+++ versions.cfg 2011-09-13 09:42:55 +0000
211@@ -7,7 +7,7 @@
212 ampoule = 0.2.0
213 amqplib = 0.6.1
214 BeautifulSoup = 3.1.0.1
215-bzr = 2.4.1dev-r6045
216+bzr = 2.5.0dev1-r6082
217 Chameleon = 2.4.0
218 ClientForm = 0.2.10
219 cssutils = 0.9.6