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
=== modified file 'lib/lp/codehosting/bzrutils.py'
--- lib/lp/codehosting/bzrutils.py 2011-08-16 11:33:00 +0000
+++ lib/lp/codehosting/bzrutils.py 2011-09-13 09:42:55 +0000
@@ -101,11 +101,11 @@
101 # BzrDir.find_branch_format()), then the branch is not stackable. Bazaar101 # BzrDir.find_branch_format()), then the branch is not stackable. Bazaar
102 # post-1.6 has added 'get_branch_format' to the pre-split-out formats,102 # post-1.6 has added 'get_branch_format' to the pre-split-out formats,
103 # which we could use instead.103 # which we could use instead.
104 find_branch_format = getattr(a_bzrdir, 'find_branch_format', None)104 try:
105 if find_branch_format is None:105 format = a_bzrdir.find_branch_format(None)
106 except NotImplementedError:
106 raise UnstackableBranchFormat(107 raise UnstackableBranchFormat(
107 a_bzrdir._format, a_bzrdir.root_transport.base)108 a_bzrdir._format, a_bzrdir.root_transport.base)
108 format = find_branch_format()
109 if not format.supports_stacking():109 if not format.supports_stacking():
110 raise UnstackableBranchFormat(format, a_bzrdir.root_transport.base)110 raise UnstackableBranchFormat(format, a_bzrdir.root_transport.base)
111 branch_transport = a_bzrdir.get_branch_transport(None)111 branch_transport = a_bzrdir.get_branch_transport(None)
112112
=== modified file 'lib/lp/codehosting/codeimport/tests/test_worker.py'
--- lib/lp/codehosting/codeimport/tests/test_worker.py 2011-08-28 08:36:14 +0000
+++ lib/lp/codehosting/codeimport/tests/test_worker.py 2011-09-13 09:42:55 +0000
@@ -12,7 +12,10 @@
12import tempfile12import tempfile
13import time13import time
1414
15from bzrlib import trace15from bzrlib import (
16 trace,
17 urlutils,
18 )
16from bzrlib.branch import (19from bzrlib.branch import (
17 Branch,20 Branch,
18 BranchReferenceFormat,21 BranchReferenceFormat,
@@ -25,7 +28,10 @@
25 )28 )
26from bzrlib.errors import NoSuchFile29from bzrlib.errors import NoSuchFile
27from bzrlib.tests import TestCaseWithTransport30from bzrlib.tests import TestCaseWithTransport
28from bzrlib.transport import get_transport31from bzrlib.transport import (
32 get_transport,
33 get_transport_from_url,
34 )
29from bzrlib.urlutils import (35from bzrlib.urlutils import (
30 join as urljoin,36 join as urljoin,
31 local_path_from_url,37 local_path_from_url,
@@ -1112,11 +1118,13 @@
1112 self.bazaar_store, logging.getLogger(),1118 self.bazaar_store, logging.getLogger(),
1113 opener_policy=opener_policy)1119 opener_policy=opener_policy)
11141120
1115 def makeForeignCommit(self, source_details):1121 def makeForeignCommit(self, source_details, message=None, ref="HEAD"):
1116 """Change the foreign tree, generating exactly one commit."""1122 """Change the foreign tree, generating exactly one commit."""
1117 repo = GitRepo(local_path_from_url(source_details.url))1123 repo = GitRepo(local_path_from_url(source_details.url))
1118 repo.do_commit(message=self.factory.getUniqueString(),1124 if message is None:
1119 committer="Joe Random Hacker <joe@example.com>")1125 message = self.factory.getUniqueString()
1126 repo.do_commit(message=message,
1127 committer="Joe Random Hacker <joe@example.com>", ref=ref)
1120 self.foreign_commit_count += 11128 self.foreign_commit_count += 1
11211129
1122 def makeSourceDetails(self, branch_name, files):1130 def makeSourceDetails(self, branch_name, files):
@@ -1133,6 +1141,29 @@
1133 return self.factory.makeCodeImportSourceDetails(1141 return self.factory.makeCodeImportSourceDetails(
1134 rcstype='git', url=git_server.get_url())1142 rcstype='git', url=git_server.get_url())
11351143
1144 def test_non_master(self):
1145 # non-master branches can be specified in the import URL.
1146 source_details = self.makeSourceDetails(
1147 'trunk', [('README', 'Original contents')])
1148 self.makeForeignCommit(source_details, ref="refs/heads/other",
1149 message="Message for other")
1150 self.makeForeignCommit(source_details, ref="refs/heads/master",
1151 message="Message for master")
1152 source_details.url = urlutils.join_segment_parameters(
1153 source_details.url, { "branch": "other" })
1154 source_transport = get_transport_from_url(source_details.url)
1155 self.assertEquals(
1156 { "branch": "other" },
1157 source_transport.get_segment_parameters())
1158 worker = self.makeImportWorker(source_details,
1159 opener_policy=AcceptAnythingPolicy())
1160 self.assertTrue(self.foreign_commit_count > 1)
1161 self.assertEqual(
1162 CodeImportWorkerExitCode.SUCCESS, worker.run())
1163 branch = worker.getBazaarBranch()
1164 lastrev = branch.repository.get_revision(branch.last_revision())
1165 self.assertEquals(lastrev.message, "Message for other")
1166
11361167
1137class TestMercurialImport(WorkerTest, TestActualImportMixin,1168class TestMercurialImport(WorkerTest, TestActualImportMixin,
1138 PullingImportWorkerTests):1169 PullingImportWorkerTests):
@@ -1163,12 +1194,18 @@
1163 self.bazaar_store, logging.getLogger(),1194 self.bazaar_store, logging.getLogger(),
1164 opener_policy=opener_policy)1195 opener_policy=opener_policy)
11651196
1166 def makeForeignCommit(self, source_details):1197 def makeForeignCommit(self, source_details, message=None, branch=None):
1167 """Change the foreign tree, generating exactly one commit."""1198 """Change the foreign tree, generating exactly one commit."""
1168 from mercurial.ui import ui1199 from mercurial.ui import ui
1169 from mercurial.localrepo import localrepository1200 from mercurial.localrepo import localrepository
1170 repo = localrepository(ui(), local_path_from_url(source_details.url))1201 repo = localrepository(ui(), local_path_from_url(source_details.url))
1171 repo.commit(text="hello world!", user="Jane Random Hacker", force=1)1202 extra = {}
1203 if branch is not None:
1204 extra = { "branch": branch }
1205 if message is None:
1206 message = self.factory.getUniqueString()
1207 repo.commit(text=message, user="Jane Random Hacker", force=1,
1208 extra=extra)
1172 self.foreign_commit_count += 11209 self.foreign_commit_count += 1
11731210
1174 def makeSourceDetails(self, branch_name, files):1211 def makeSourceDetails(self, branch_name, files):
@@ -1185,6 +1222,29 @@
1185 return self.factory.makeCodeImportSourceDetails(1222 return self.factory.makeCodeImportSourceDetails(
1186 rcstype='hg', url=hg_server.get_url())1223 rcstype='hg', url=hg_server.get_url())
11871224
1225 def test_non_default(self):
1226 # non-default branches can be specified in the import URL.
1227 source_details = self.makeSourceDetails(
1228 'trunk', [('README', 'Original contents')])
1229 self.makeForeignCommit(source_details, branch="other",
1230 message="Message for other")
1231 self.makeForeignCommit(source_details, branch="default",
1232 message="Message for default")
1233 source_details.url = urlutils.join_segment_parameters(
1234 source_details.url, { "branch": "other" })
1235 source_transport = get_transport_from_url(source_details.url)
1236 self.assertEquals(
1237 { "branch": "other" },
1238 source_transport.get_segment_parameters())
1239 worker = self.makeImportWorker(source_details,
1240 opener_policy=AcceptAnythingPolicy())
1241 self.assertTrue(self.foreign_commit_count > 1)
1242 self.assertEqual(
1243 CodeImportWorkerExitCode.SUCCESS, worker.run())
1244 branch = worker.getBazaarBranch()
1245 lastrev = branch.repository.get_revision(branch.last_revision())
1246 self.assertEquals(lastrev.message, "Message for other")
1247
11881248
1189class TestBzrSvnImport(WorkerTest, SubversionImportHelpers,1249class TestBzrSvnImport(WorkerTest, SubversionImportHelpers,
1190 TestActualImportMixin, PullingImportWorkerTests):1250 TestActualImportMixin, PullingImportWorkerTests):
11911251
=== modified file 'lib/lp/codehosting/codeimport/uifactory.py'
--- lib/lp/codehosting/codeimport/uifactory.py 2011-08-03 00:35:38 +0000
+++ lib/lp/codehosting/codeimport/uifactory.py 2011-09-13 09:42:55 +0000
@@ -206,7 +206,3 @@
206 self._bytes_since_update = 0206 self._bytes_since_update = 0
207 self._last_transport_msg = msg207 self._last_transport_msg = msg
208 self._repaint()208 self._repaint()
209
210 # bzr 1.17 renamed _show_transport_activity to show_transport_activity.
211 # When we have upgraded to bzr 1.17, this compatibility hack can go away.
212 _show_transport_activity = show_transport_activity
213209
=== modified file 'utilities/sourcedeps.cache'
--- utilities/sourcedeps.cache 2011-09-06 19:40:50 +0000
+++ utilities/sourcedeps.cache 2011-09-13 09:42:55 +0000
@@ -4,12 +4,12 @@
4 "launchpad@pqm.canonical.com-20101123183213-777lz46xgagn1deg"4 "launchpad@pqm.canonical.com-20101123183213-777lz46xgagn1deg"
5 ], 5 ],
6 "bzr-git": [6 "bzr-git": [
7 259, 7 264,
8 "launchpad@pqm.canonical.com-20110601140035-gl5merbechngjw5s"8 "launchpad@pqm.canonical.com-20110913022112-2x3wgyj2mqof74uy"
9 ], 9 ],
10 "bzr-hg": [10 "bzr-hg": [
11 290, 11 291,
12 "launchpad@pqm.canonical.com-20110808175904-4gj24x3y21kxepcj"12 "launchpad@pqm.canonical.com-20110822162405-m5xrb9p3ahzddmcm"
13 ], 13 ],
14 "bzr-loom": [14 "bzr-loom": [
15 50, 15 50,
@@ -28,8 +28,8 @@
28 "aaron@aaronbentley.com-20100715135013-uoi3q430urx9gwb8"28 "aaron@aaronbentley.com-20100715135013-uoi3q430urx9gwb8"
29 ], 29 ],
30 "dulwich": [30 "dulwich": [
31 426, 31 430,
32 "launchpad@pqm.canonical.com-20110520175715-e90dzs8os0kotbm9"32 "launchpad@pqm.canonical.com-20110913014713-3l8j2zva6pgor5uw"
33 ], 33 ],
34 "loggerhead": [34 "loggerhead": [
35 456, 35 456,
3636
=== modified file 'utilities/sourcedeps.conf'
--- utilities/sourcedeps.conf 2011-09-03 02:58:43 +0000
+++ utilities/sourcedeps.conf 2011-09-13 09:42:55 +0000
@@ -1,10 +1,10 @@
1bzr-builder lp:~launchpad-pqm/bzr-builder/trunk;revno=681bzr-builder lp:~launchpad-pqm/bzr-builder/trunk;revno=68
2bzr-git lp:~launchpad-pqm/bzr-git/devel;revno=2592bzr-git lp:~launchpad-pqm/bzr-git/devel;revno=264
3bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=2903bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=291
4bzr-loom lp:~launchpad-pqm/bzr-loom/trunk;revno=504bzr-loom lp:~launchpad-pqm/bzr-loom/trunk;revno=50
5bzr-svn lp:~launchpad-pqm/bzr-svn/devel;revno=27175bzr-svn lp:~launchpad-pqm/bzr-svn/devel;revno=2717
6cscvs lp:~launchpad-pqm/launchpad-cscvs/devel;revno=4326cscvs lp:~launchpad-pqm/launchpad-cscvs/devel;revno=432
7dulwich lp:~launchpad-pqm/dulwich/devel;revno=4267dulwich lp:~launchpad-pqm/dulwich/devel;revno=430
8difftacular lp:difftacular;revno=68difftacular lp:difftacular;revno=6
9loggerhead lp:~loggerhead-team/loggerhead/trunk-rich;revno=4569loggerhead lp:~loggerhead-team/loggerhead/trunk-rich;revno=456
10lpreview lp:~launchpad-pqm/bzr-lpreview/devel;revno=2310lpreview lp:~launchpad-pqm/bzr-lpreview/devel;revno=23
1111
=== modified file 'versions.cfg'
--- versions.cfg 2011-09-12 23:52:19 +0000
+++ versions.cfg 2011-09-13 09:42:55 +0000
@@ -7,7 +7,7 @@
7ampoule = 0.2.07ampoule = 0.2.0
8amqplib = 0.6.18amqplib = 0.6.1
9BeautifulSoup = 3.1.0.19BeautifulSoup = 3.1.0.1
10bzr = 2.4.1dev-r604510bzr = 2.5.0dev1-r6082
11Chameleon = 2.4.011Chameleon = 2.4.0
12ClientForm = 0.2.1012ClientForm = 0.2.10
13cssutils = 0.9.613cssutils = 0.9.6