[Pkg-bazaar-commits] ./bzr-builddeb/trunk.old r271: Add a deb: directory service that uses Vcs-* headers to get the branch.

James Westby jw+debian at jameswestby.net
Wed Dec 10 08:33:03 UTC 2008


------------------------------------------------------------
revno: 271
committer: James Westby <jw+debian at jameswestby.net>
branch nick: trunk
timestamp: Fri 2008-08-29 14:22:48 +0100
message:
  Add a deb: directory service that uses Vcs-* headers to get the branch.
added:
  directory.py
modified:
  __init__.py
  debian/changelog
  debian/copyright
    ------------------------------------------------------------
    revno: 226.2.18
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: directoryservice
    timestamp: Fri 2008-07-18 16:35:24 +0200
    message:
      Add simple directory service.
    added:
      directory.py
    modified:
      __init__.py
      debian/changelog
    ------------------------------------------------------------
    revno: 226.2.19
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: directoryservice
    timestamp: Fri 2008-07-18 17:15:31 +0200
    message:
      Use apt_pkg rather than parsing the output of apt-cache.
    modified:
      directory.py
    ------------------------------------------------------------
    revno: 226.2.20
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: directoryservice
    timestamp: Thu 2008-08-28 16:07:53 +0200
    message:
      Merge James.
    added:
      tests/blackbox/test_mark_uploaded.py
    modified:
      README
      TODO
      __init__.py
      builder.py
      changes.py
      debian/NEWS
      debian/changelog
      debian/copyright
      doc/user_manual/configuration.rst
      doc/user_manual/merge.rst
      doc/user_manual/native.rst
      doc/user_manual/normal.rst
      errors.py
      import_dsc.py
      merge_upstream.py
      properties.py
      setup.py
      tests/__init__.py
      tests/blackbox/__init__.py
      tests/blackbox/test_builddeb.py
      tests/blackbox/test_do.py
      tests/blackbox/test_import_dsc.py
      tests/test_builder.py
      tests/test_import_dsc.py
      tests/test_merge_upstream.py
      tests/test_util.py
      util.py
      version.py
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2008-08-29 13:06:37 +0000
+++ b/__init__.py	2008-08-29 13:22:48 +0000
@@ -35,6 +35,7 @@
 from bzrlib.branch import Branch
 from bzrlib.commands import Command, register_command
 from bzrlib.config import ConfigObj
+from bzrlib.directory_service import directories
 from bzrlib.errors import (BzrCommandError,
                            NoWorkingTree,
                            NotBranchError,
@@ -783,6 +784,9 @@
 
 register_command(cmd_test_builddeb)
 
+directories.register_lazy("deb:", 'bzrlib.plugins.builddeb.directory', 
+        'VcsDirectory', 
+        "Directory that uses Debian Vcs-* control fields to look up branches")
 
 if __name__ == '__main__':
   print ("This is a Bazaar plugin. Copy this directory to ~/.bazaar/plugins "

=== modified file 'debian/changelog'
--- a/debian/changelog	2008-08-29 13:06:37 +0000
+++ b/debian/changelog	2008-08-29 13:22:48 +0000
@@ -1,5 +1,9 @@
 bzr-builddeb (2.1) UNRELEASED; urgency=low
 
+  [ Jelmer Vernooij ]
+  * Add simple deb: directory service for Bazaar that uses the dpkg Vcs-* fields.
+
+  [ James Westby ]
   * Support repacking of .zips. Thanks Daniel Hahler.
 
  -- James Westby <james.westby at canonical.com>  Thu, 28 Aug 2008 11:41:35 +0100

=== modified file 'debian/copyright'
--- a/debian/copyright	2008-08-27 21:06:59 +0000
+++ b/debian/copyright	2008-08-29 13:22:48 +0000
@@ -10,6 +10,7 @@
            2006, 2007 James Westby <jw+debian at jameswestby.net>
            2007 Reinhard Tartler <siretart at tauware.de>
            2008 Canonical Ltd.
+           2008 Jelmer Vernooij <jelmer at samba.org>
 
 License:
 

=== added file 'directory.py'
--- a/directory.py	1970-01-01 00:00:00 +0000
+++ b/directory.py	2008-08-29 13:22:48 +0000
@@ -0,0 +1,72 @@
+#    directory.py -- Directory service that uses Debian Vcs-* fields
+#    Copyright (C) 2008 Jelmer Vernooij <jelmer at samba.org>
+#    
+#    This file is part of bzr-builddeb.
+#
+#    bzr-builddeb is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    bzr-builddeb is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY 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 bzr-builddeb; if not, write to the Free Software
+#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+from bzrlib import errors
+from bzrlib.trace import info
+
+import apt_pkg
+
+
+class VcsDirectory(object):
+    """Simple Bazaar directory service which uses dpkg Vcs-* fields."""
+
+    def look_up(self, name, url):
+        if "/" in name:
+            (name, version) = name.split("/", 1)
+        else:
+            version = None
+
+        apt_pkg.init()
+
+        sources = apt_pkg.GetPkgSrcRecords()
+
+        urls = {}
+        while sources.Lookup(name):
+            for l in sources.Record.splitlines():
+                if not ": " in l:
+                    continue
+                (field, value) = l.strip("\n").split(": ", 1)
+
+                if field == "Version":
+                    pkg_version = value
+                elif field.startswith("X-Vcs-") or field.startswith("Vcs-"):
+                    vcs = field.split("-")[-1]
+                    urls.setdefault(pkg_version,{})[vcs] = value
+
+        if len(urls) == 0:
+            raise errors.InvalidURL(path=url, extra='no URLs found')
+
+        if version is None:
+            # Try the latest version
+            version = sorted(urls,cmp=apt_pkg.VersionCompare)[0]
+
+        if not version in urls:
+            raise errors.InvalidURL(path=url, extra='version %s not found' % version)
+        
+        info("Retrieving Vcs locating from %s Debian version %s", name, version)
+
+        if "Bzr" in urls[version]:
+            return urls[version]["Bzr"]
+
+        if "Svn" in urls[version]:
+            return urls[version]["Svn"]
+
+        raise errors.InvalidURL(path=url,
+            extra='unsupported VCSes %r found' % urls[version].keys())



More information about the Pkg-bazaar-commits mailing list