Rev 55: Map dput specs to ppa url fragments. in http://people.canonical.com/~robertc/baz2.0/plugins/builder/blocking

Robert Collins robertc at robertcollins.net
Fri Oct 23 01:14:15 BST 2009


At http://people.canonical.com/~robertc/baz2.0/plugins/builder/blocking

------------------------------------------------------------
revno: 55
revision-id: robertc at robertcollins.net-20091023001410-g7zoncjp4vv7jg3b
parent: robertc at robertcollins.net-20091022051701-3i7ob17on0uaadds
committer: Robert Collins <robertc at robertcollins.net>
branch nick: blocking
timestamp: Fri 2009-10-23 11:14:10 +1100
message:
  Map dput specs to ppa url fragments.
=== modified file '__init__.py'
--- a/__init__.py	2009-10-22 05:17:01 +0000
+++ b/__init__.py	2009-10-23 00:14:10 +0000
@@ -266,6 +266,8 @@
         if not dput and watch_ppa:
             raise errors.BzrCommandError(
                 "cannot watch a ppa without doing dput.")
+        elif dput:
+            target_from_dput(dput)
 
         base_branch = self._get_branch_from_recipe_file(recipe_file)
         time = datetime.datetime.utcnow()
@@ -303,15 +305,16 @@
                 self._sign_source_package(package_dir, key_id)
             if dput is not None:
                 self._dput_source_package(package_dir, dput)
-                if watch_ppa:
-                    from bzrlib.plugins.builder.ppa import watch
-                    watch(dput, package or recipe_name,
-                        base_branch.deb_version)
             if manifest is not None:
                 self._write_manifest_to_path(manifest, base_branch)
         finally:
             if temp_dir is not None:
                 shutil.rmtree(temp_dir)
+        if watch_ppa:
+            from bzrlib.plugins.builder.ppa import watch
+            target = target_from_dput(dput)
+            return watch(target, package or recipe_name,
+                base_branch.deb_version)
 
 
     def _add_changelog_entry(self, base_branch, basedir, distribution=None,
@@ -466,6 +469,20 @@
 register_command(cmd_dailydeb)
 
 
+def target_from_dput(dput):
+    """Convert a dput specification to a LP API specification.
+
+    :param dput: A dput command spec like ppa:team-name.
+    :return: A LP API target like team-name/ppa.
+    """
+    if not dput.startswith('ppa:'):
+        raise errors.BzrCommandError('not a ppa %s' % dput)
+    base, _, suffix = dput[4:].partition('/')
+    if not suffix:
+        suffix = 'ppa'
+    return base + '/' + suffix
+
+
 def test_suite():
     from unittest import TestSuite
     from bzrlib.plugins.builder import tests

=== modified file 'tests/__init__.py'
--- a/tests/__init__.py	2009-04-16 20:23:39 +0000
+++ b/tests/__init__.py	2009-10-23 00:14:10 +0000
@@ -20,9 +20,10 @@
     loader = TestUtil.TestLoader()
     suite = TestSuite()
     testmod_names = [
-            'test_blackbox',
-            'test_recipe',
+            'blackbox',
+            'ppa',
+            'recipe',
             ]
-    suite.addTest(loader.loadTestsFromModuleNames(["%s.%s" % (__name__, i)
+    suite.addTest(loader.loadTestsFromModuleNames(["%s.test_%s" % (__name__, i)
                                             for i in testmod_names]))
     return suite

=== added file 'tests/test_ppa.py'
--- a/tests/test_ppa.py	1970-01-01 00:00:00 +0000
+++ b/tests/test_ppa.py	2009-10-23 00:14:10 +0000
@@ -0,0 +1,31 @@
+# bzr-builder: a bzr plugin to construct trees based on recipes
+# Copyright 2009 Canonical Ltd.
+
+# This program is free software: you can redistribute it and/or modify it 
+# under the terms of the GNU General Public License version 3, as published 
+# by the Free Software Foundation.
+
+# This program is distributed in the hope that it will be useful, but 
+# WITHOUT ANY WARRANTY; without even the implied warranties of 
+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
+# PURPOSE.  See the GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License along 
+# with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+import os
+
+from bzrlib import workingtree
+from bzrlib.plugins.builder import target_from_dput
+from bzrlib.tests import (
+        TestCase,
+        )
+
+
+class TestTargetFromDPut(TestCase):
+
+    def test_default_ppa(self):
+        self.assertEqual('team-name/ppa', target_from_dput('ppa:team-name'))
+
+    def test_named_ppa(self):
+        self.assertEqual('team/ppa2', target_from_dput('ppa:team/ppa2'))




More information about the bazaar-commits mailing list