← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Jelmer Vernooij has proposed merging lp:~jelmer/launchpad/import-colocated-branches into lp:launchpad with lp:~jelmer/launchpad/bzr-2.4b4 as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jelmer/launchpad/import-colocated-branches/+merge/72127

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. 

-- 
https://code.launchpad.net/~jelmer/launchpad/import-colocated-branches/+merge/72127
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jelmer/launchpad/import-colocated-branches into lp:launchpad.
=== modified file 'lib/lp/code/bzr.py'
--- lib/lp/code/bzr.py	2011-06-02 19:27:36 +0000
+++ lib/lp/code/bzr.py	2011-08-19 01:59:55 +0000
@@ -20,39 +20,39 @@
 
 from bzrlib.branch import (
     BranchReferenceFormat,
-    BzrBranchFormat4,
     BzrBranchFormat5,
     BzrBranchFormat6,
     BzrBranchFormat7,
     )
-from bzrlib.bzrdir import (
+from bzrlib.bzrdir import BzrDirMetaFormat1
+from bzrlib.plugins.loom.branch import (
+    BzrBranchLoomFormat1,
+    BzrBranchLoomFormat6,
+    )
+from bzrlib.plugins.weave_fmt.branch import BzrBranchFormat4
+from bzrlib.plugins.weave_fmt.bzrdir import (
     BzrDirFormat4,
     BzrDirFormat5,
     BzrDirFormat6,
-    BzrDirMetaFormat1,
     )
-from bzrlib.plugins.loom.branch import (
-    BzrBranchLoomFormat1,
-    BzrBranchLoomFormat6,
+from bzrlib.plugins.weave_fmt.repository import (
+    RepositoryFormat4,
+    RepositoryFormat5,
+    RepositoryFormat6,
+    RepositoryFormat7,
     )
 from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
+from bzrlib.repofmt.knitpack_repo import (
+    RepositoryFormatKnitPack1,
+    RepositoryFormatKnitPack3,
+    RepositoryFormatKnitPack4,
+    RepositoryFormatKnitPack5,
+    )
 from bzrlib.repofmt.knitrepo import (
     RepositoryFormatKnit1,
     RepositoryFormatKnit3,
     RepositoryFormatKnit4,
     )
-from bzrlib.repofmt.pack_repo import (
-    RepositoryFormatKnitPack1,
-    RepositoryFormatKnitPack3,
-    RepositoryFormatKnitPack4,
-    RepositoryFormatKnitPack5,
-    )
-from bzrlib.repofmt.weaverepo import (
-    RepositoryFormat4,
-    RepositoryFormat5,
-    RepositoryFormat6,
-    RepositoryFormat7,
-    )
 from lazr.enum import (
     DBEnumeratedType,
     DBItem,

=== modified file 'lib/lp/code/interfaces/tests/test_branch.py'
--- lib/lp/code/interfaces/tests/test_branch.py	2011-08-12 11:37:08 +0000
+++ lib/lp/code/interfaces/tests/test_branch.py	2011-08-19 01:59:55 +0000
@@ -5,7 +5,11 @@
 
 __metaclass__ = type
 
-from bzrlib.branch import BranchFormat as BzrBranchFormat
+import lp.codehosting # For plugins
+
+from bzrlib.branch import (
+    format_registry as branch_format_registry,
+    )
 from bzrlib.bzrdir import BzrProber
 from bzrlib.repository import format_registry as repo_format_registry
 
@@ -26,10 +30,10 @@
     """
 
     def test_control_format_complement(self):
-        self.bzrlib_is_subset(BzrProber._formats.keys(), ControlFormat)
+        self.bzrlib_is_subset(BzrProber.formats.keys(), ControlFormat)
 
     def test_branch_format_complement(self):
-        self.bzrlib_is_subset(BzrBranchFormat._formats.keys(), BranchFormat)
+        self.bzrlib_is_subset(branch_format_registry.keys(), BranchFormat)
 
     def test_repository_format_complement(self):
         self.bzrlib_is_subset(repo_format_registry.keys(), RepositoryFormat)

=== modified file 'lib/lp/code/model/tests/test_branchjob.py'
--- lib/lp/code/model/tests/test_branchjob.py	2011-08-12 11:37:08 +0000
+++ lib/lp/code/model/tests/test_branchjob.py	2011-08-19 01:59:55 +0000
@@ -16,7 +16,7 @@
     BzrBranchFormat7,
     )
 from bzrlib.bzrdir import BzrDirMetaFormat1
-from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack6
+from bzrlib.repofmt.knitpack_repo import RepositoryFormatKnitPack6
 from bzrlib.revision import NULL_REVISION
 from bzrlib.transport import get_transport
 import pytz

=== modified file 'lib/lp/codehosting/__init__.py'
--- lib/lp/codehosting/__init__.py	2011-03-30 15:16:35 +0000
+++ lib/lp/codehosting/__init__.py	2011-08-19 01:59:55 +0000
@@ -70,15 +70,13 @@
     __import__("bzrlib.plugins.%s" % plugin_name)
 
 
-def remove_hook(self, hook):
-    """Remove the hook from the HookPoint"""
-    self._callbacks.remove(hook)
-    for name, value in self._callback_names.iteritems():
-        if value is hook:
-            del self._callback_names[name]
-
-
-# XXX: JonathanLange 2011-03-30 bug=301472: Monkeypatch: Branch.hooks is a
-# list in bzr 1.13, so it supports remove.  It is a HookPoint in bzr 1.14, so
-# add HookPoint.remove.
-hooks.HookPoint.remove = remove_hook
+def load_bundled_plugin(plugin_name):
+    """Load a plugin bundled with Bazaar."""
+    from bzrlib.plugin import get_core_plugin_path
+    from bzrlib import plugins
+    if get_core_plugin_path() not in plugins.__path__:
+        plugins.__path__.append(get_core_plugin_path())
+    __import__("bzrlib.plugins.%s" % plugin_name)
+
+
+load_bundled_plugin("weave_fmt")

=== modified file 'lib/lp/codehosting/codeimport/tests/servers.py'
--- lib/lp/codehosting/codeimport/tests/servers.py	2011-06-02 10:48:54 +0000
+++ lib/lp/codehosting/codeimport/tests/servers.py	2011-08-19 01:59:55 +0000
@@ -206,14 +206,17 @@
 
 class GitServer(Server):
 
-    def __init__(self, repo_url):
+    def __init__(self, repo_path):
         super(GitServer, self).__init__()
-        self.repo_url = repo_url
+        self.repo_path = repo_path
+
+    def get_url(self):
+        return local_path_to_url(self.repo_path)
 
     def makeRepo(self, tree_contents):
         wd = os.getcwd()
         try:
-            os.chdir(self.repo_url)
+            os.chdir(self.repo_path)
             repo = GitRepo.init(".")
             blobs = [
                 (Blob.from_string(contents), filename) for (filename, contents)

=== modified file 'lib/lp/codehosting/codeimport/tests/test_worker.py'
--- lib/lp/codehosting/codeimport/tests/test_worker.py	2011-08-12 11:37:08 +0000
+++ lib/lp/codehosting/codeimport/tests/test_worker.py	2011-08-19 01:59:55 +0000
@@ -12,6 +12,7 @@
 import tempfile
 import time
 
+from bzrlib import urlutils
 from bzrlib.branch import (
     Branch,
     BranchReferenceFormat,
@@ -26,7 +27,10 @@
     )
 from bzrlib.tests import TestCaseWithTransport
 from bzrlib import trace
-from bzrlib.transport import get_transport
+from bzrlib.transport import (
+    get_transport,
+    get_transport_from_url,
+    )
 from bzrlib.urlutils import (
     join as urljoin,
     local_path_from_url,
@@ -1068,11 +1072,15 @@
             source_details, self.get_transport('import_data'),
             self.bazaar_store, logging.getLogger())
 
-    def makeForeignCommit(self, source_details):
+    def makeForeignCommit(self, source_details, message=None,
+            ref="refs/heads/master"):
         """Change the foreign tree, generating exactly one commit."""
-        repo = GitRepo(source_details.url)
-        repo.do_commit(message=self.factory.getUniqueString(),
-            committer="Joe Random Hacker <joe@xxxxxxxxxxx>")
+        repo = GitRepo(
+            os.path.abspath(local_path_from_url(source_details.url)))
+        if message is None:
+            message = self.factory.getUniqueString()
+        repo.do_commit(message=message,
+            committer="Joe Random Hacker <joe@xxxxxxxxxxx>", ref=ref)
         self.foreign_commit_count += 1
 
     def makeSourceDetails(self, branch_name, files):
@@ -1087,8 +1095,29 @@
         self.foreign_commit_count = 1
 
         return self.factory.makeCodeImportSourceDetails(
-            rcstype='git', url=repository_path)
+            rcstype='git', url=git_server.get_url())
 
+    def test_non_master(self):
+        # non-master branches can be specified in the import URL.
+        source_details = self.makeSourceDetails(
+            'trunk', [('README', 'Original contents')])
+        self.makeForeignCommit(source_details, ref="refs/heads/other",
+            message="Message for other")
+        self.makeForeignCommit(source_details, ref="refs/heads/master",
+            message="Message for master")
+        source_details.url = urlutils.join_segment_parameters(
+                source_details.url, { "branch": "other" })
+        source_transport = get_transport_from_url(source_details.url)
+        self.assertEquals(
+            { "branch": "other" },
+            source_transport.get_segment_parameters())
+        worker = self.makeImportWorker(source_details)
+        self.assertTrue(self.foreign_commit_count > 1)
+        self.assertEqual(
+            CodeImportWorkerExitCode.SUCCESS, worker.run())
+        branch = worker.getBazaarBranch()
+        lastrev = branch.repository.get_revision(branch.last_revision())
+        self.assertEquals(lastrev.message, "Message for other")
 
 
 class TestMercurialImport(WorkerTest, TestActualImportMixin,

=== modified file 'lib/lp/codehosting/codeimport/tests/test_workermonitor.py'
--- lib/lp/codehosting/codeimport/tests/test_workermonitor.py	2011-08-12 11:37:08 +0000
+++ lib/lp/codehosting/codeimport/tests/test_workermonitor.py	2011-08-19 01:59:55 +0000
@@ -667,7 +667,8 @@
         self.git_server.makeRepo([('README', 'contents')])
         self.foreign_commit_count = 1
 
-        return self.factory.makeCodeImport(git_repo_url=self.repo_path)
+        return self.factory.makeCodeImport(
+            git_repo_url=self.git_server.get_url())
 
     def makeHgCodeImport(self):
         """Make a `CodeImport` that points to a real Mercurial repository."""

=== modified file 'lib/lp/codehosting/codeimport/worker.py'
--- lib/lp/codehosting/codeimport/worker.py	2011-08-02 11:28:46 +0000
+++ lib/lp/codehosting/codeimport/worker.py	2011-08-19 01:59:55 +0000
@@ -32,13 +32,13 @@
 from bzrlib.errors import (
     ConnectionError,
     InvalidEntryName,
+    NoRepositoryPresent,
     NoSuchFile,
-    NoRepositoryPresent,
     NotBranchError,
     )
 from bzrlib.transport import get_transport
+from bzrlib.upgrade import upgrade
 import bzrlib.ui
-from bzrlib.upgrade import upgrade
 from bzrlib.urlutils import (
     join as urljoin,
     local_path_from_url,

=== modified file 'lib/lp/codehosting/puller/tests/test_scheduler.py'
--- lib/lp/codehosting/puller/tests/test_scheduler.py	2011-08-17 04:56:56 +0000
+++ lib/lp/codehosting/puller/tests/test_scheduler.py	2011-08-19 01:59:55 +0000
@@ -767,7 +767,7 @@
         branch.lock_write()
         protocol.mirrorFailed('a', 'b')
         protocol.sendEvent(
-            'lock_id', branch.control_files._lock.peek()['user'])
+            'lock_id', branch.control_files._lock.peek().get('user'))
         sys.stdout.flush()
         branch.unlock()
         """

=== modified file 'lib/lp/codehosting/puller/tests/test_worker_formats.py'
--- lib/lp/codehosting/puller/tests/test_worker_formats.py	2011-08-17 01:04:36 +0000
+++ lib/lp/codehosting/puller/tests/test_worker_formats.py	2011-08-19 01:59:55 +0000
@@ -5,17 +5,17 @@
 
 __metaclass__ = type
 
+import lp.codehosting # for bzr plugins
+
 from bzrlib.branch import Branch
-from bzrlib.bzrdir import (
-    BzrDirFormat6,
-    BzrDirMetaFormat1,
-    )
-from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
-from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack5
-from bzrlib.repofmt.weaverepo import (
+from bzrlib.bzrdir import BzrDirMetaFormat1
+from bzrlib.plugins.weave_fmt.bzrdir import BzrDirFormat6
+from bzrlib.plugins.weave_fmt.repository import (
     RepositoryFormat6,
     RepositoryFormat7,
     )
+from bzrlib.repofmt.knitpack_repo import RepositoryFormatKnitPack5
+from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
 from bzrlib.tests.per_repository import TestCaseWithRepository
 
 from lp.codehosting.puller.tests import PullerWorkerMixin

=== modified file 'lib/lp/codehosting/puller/worker.py'
--- lib/lp/codehosting/puller/worker.py	2011-08-06 18:13:13 +0000
+++ lib/lp/codehosting/puller/worker.py	2011-08-19 01:59:55 +0000
@@ -8,15 +8,16 @@
 import sys
 import urllib2
 
+import lp.codehosting # to load bzr plugins
+
 from bzrlib import (
     errors,
     urlutils,
     )
-from bzrlib.branch import (
-    Branch,
-    BzrBranchFormat4,
-    )
-from bzrlib.repofmt.weaverepo import (
+from bzrlib.branch import Branch
+from bzrlib.bzrdir import BzrDir
+from bzrlib.plugins.weave_fmt.branch import BzrBranchFormat4
+from bzrlib.plugins.weave_fmt.repository import (
     RepositoryFormat4,
     RepositoryFormat5,
     RepositoryFormat6,

=== modified file 'lib/lp/codehosting/tests/test_safe_open.py'
--- lib/lp/codehosting/tests/test_safe_open.py	2011-08-16 11:41:40 +0000
+++ lib/lp/codehosting/tests/test_safe_open.py	2011-08-19 01:59:55 +0000
@@ -27,7 +27,7 @@
 from bzrlib.bzrdir import (
     BzrDirMetaFormat1,
     )
-from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack1
+from bzrlib.repofmt.knitpack_repo import RepositoryFormatKnitPack1
 from bzrlib.tests import (
     TestCaseWithTransport,
     )

=== modified file 'lib/lp/translations/scripts/translations_to_branch.py'
--- lib/lp/translations/scripts/translations_to_branch.py	2011-05-27 13:36:02 +0000
+++ lib/lp/translations/scripts/translations_to_branch.py	2011-08-19 01:59:55 +0000
@@ -14,6 +14,7 @@
 import os.path
 
 from bzrlib.errors import NotBranchError
+from bzrlib.revision import NULL_REVISION
 import pytz
 from storm.expr import (
     And,
@@ -157,7 +158,9 @@
 
         revno, current_rev = branch.last_revision_info()
         repository = branch.repository
-        for rev_id in repository.iter_reverse_revision_history(current_rev):
+        graph = repository.get_graph()
+        for rev_id in graph.iter_lefthand_ancestry(
+                current_rev, (NULL_REVISION, )):
             revision = repository.get_revision(rev_id)
             revision_date = self._getRevisionTime(revision)
             if self._isTranslationsCommit(revision):

=== modified file 'utilities/sourcedeps.cache'
--- utilities/sourcedeps.cache	2011-08-16 18:22:19 +0000
+++ utilities/sourcedeps.cache	2011-08-19 01:59:55 +0000
@@ -1,8 +1,4 @@
 {
-    "bzr-builder": [
-        68, 
-        "launchpad@xxxxxxxxxxxxxxxxx-20101123183213-777lz46xgagn1deg"
-    ], 
     "testresources": [
         16, 
         "robertc@xxxxxxxxxxxxxxxxx-20050911111209-ee5da49011cf936a"
@@ -31,40 +27,44 @@
         24, 
         "launchpad@xxxxxxxxxxxxxxxxx-20100601182722-wo7h2fh0fvyw3aaq"
     ], 
-    "lpreview": [
-        23, 
-        "launchpad@xxxxxxxxxxxxxxxxx-20090720061538-euyh68ifavhy0pi8"
-    ], 
     "bzr-git": [
-        259, 
-        "launchpad@xxxxxxxxxxxxxxxxx-20110601140035-gl5merbechngjw5s"
+        261, 
+        "launchpad@xxxxxxxxxxxxxxxxx-20110818195215-bdxw09lp94p4p26o"
+    ], 
+    "loggerhead": [
+        452, 
+        "andrew.bennetts@xxxxxxxxxxxxx-20110628173100-owrifrnckvoi60af"
+    ], 
+    "bzr-builder": [
+        68, 
+        "launchpad@xxxxxxxxxxxxxxxxx-20101123183213-777lz46xgagn1deg"
     ], 
     "bzr-loom": [
-        49, 
-        "launchpad@xxxxxxxxxxxxxxxxx-20110601122412-54vo3k8yae9i2zve"
+        50, 
+        "launchpad@xxxxxxxxxxxxxxxxx-20110722102404-hl1z8uzhhwiol34l"
     ], 
     "old_xmlplus": [
         4, 
         "sinzui-20090526164636-1swugzupwvjgomo4"
     ], 
-    "loggerhead": [
-        452, 
-        "andrew.bennetts@xxxxxxxxxxxxx-20110628173100-owrifrnckvoi60af"
+    "lpreview": [
+        23, 
+        "launchpad@xxxxxxxxxxxxxxxxx-20090720061538-euyh68ifavhy0pi8"
     ], 
     "difftacular": [
         6, 
         "aaron@xxxxxxxxxxxxxxxx-20100715135013-uoi3q430urx9gwb8"
     ], 
     "bzr-svn": [
-        2715, 
-        "launchpad@xxxxxxxxxxxxxxxxx-20110810144016-m5f5pbnrpkbz04v3"
+        2716, 
+        "launchpad@xxxxxxxxxxxxxxxxx-20110813142415-1izlitsieztuzkly"
     ], 
     "bzr-hg": [
-        286, 
-        "launchpad@xxxxxxxxxxxxxxxxx-20110608121012-ukbfdj6izm8n72tp"
+        287, 
+        "launchpad@xxxxxxxxxxxxxxxxx-20110722151205-zvse1g7ghie2snt2"
     ], 
     "dulwich": [
-        426, 
-        "launchpad@xxxxxxxxxxxxxxxxx-20110520175715-e90dzs8os0kotbm9"
+        428, 
+        "launchpad@xxxxxxxxxxxxxxxxx-20110818211213-mnz3lehaoxyyys7x"
     ]
 }
\ No newline at end of file

=== modified file 'utilities/sourcedeps.conf'
--- utilities/sourcedeps.conf	2011-08-14 07:53:08 +0000
+++ utilities/sourcedeps.conf	2011-08-19 01:59:55 +0000
@@ -1,10 +1,10 @@
 bzr-builder lp:~launchpad-pqm/bzr-builder/trunk;revno=68
-bzr-git lp:~launchpad-pqm/bzr-git/devel;revno=259
-bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=286
-bzr-loom lp:~launchpad-pqm/bzr-loom/trunk;revno=49
-bzr-svn lp:~launchpad-pqm/bzr-svn/devel;revno=2715
+bzr-git lp:~launchpad-pqm/bzr-git/devel;revno=261
+bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=287
+bzr-loom lp:~launchpad-pqm/bzr-loom/trunk;revno=50
+bzr-svn lp:~launchpad-pqm/bzr-svn/devel;revno=2716
 cscvs lp:~launchpad-pqm/launchpad-cscvs/devel;revno=432
-dulwich lp:~launchpad-pqm/dulwich/devel;revno=426
+dulwich lp:~launchpad-pqm/dulwich/devel;revno=428
 difftacular lp:difftacular;revno=6
 loggerhead lp:~loggerhead-team/loggerhead/trunk-rich;revno=452
 lpreview lp:~launchpad-pqm/bzr-lpreview/devel;revno=23

=== modified file 'versions.cfg'
--- versions.cfg	2011-08-18 16:46:41 +0000
+++ versions.cfg	2011-08-19 01:59:55 +0000
@@ -7,7 +7,7 @@
 ampoule = 0.2.0
 amqplib = 0.6.1
 BeautifulSoup = 3.1.0.1
-bzr = 2.3.3
+bzr = 2.5.0dev1-r6082
 chameleon.core = 1.0b35
 chameleon.zpt = 1.0b17
 ClientForm = 0.2.10