[Pkg-bazaar-commits] ./bzr-builddeb/trunk.old r252: Merge trunk features.

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


------------------------------------------------------------
revno: 252
committer: James Westby <jw+debian at jameswestby.net>
branch nick: 2.0
timestamp: Wed 2008-08-27 13:13:34 +0100
message:
  Merge trunk features.
modified:
  __init__.py
  builder.py
  config.py
  debian/changelog
  debian/control
  debian/rules
  doc/user_manual/building.rst
  doc/user_manual/export_upstream.rst
  doc/user_manual/hooks.rst
  hooks.py
  setup.py
  tests/blackbox/test_builddeb.py
  tests/test_config.py
  tests/test_hooks.py
  tests/test_util.py
  util.py
  version.py
    ------------------------------------------------------------
    revno: 226.1.1
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: usebranch
    timestamp: Thu 2008-05-15 15:39:55 +0200
    message:
      Use branch-specific configuration when possible.
    modified:
      __init__.py
    ------------------------------------------------------------
    revno: 226.2.1
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Thu 2008-05-15 16:04:12 +0100
    message:
      Merge patch from Jelmer to use the branch config as well.
      
      This allows bzr-builddeb to use the mergeWithUpstream property
      from svn-buildpackage if a recent enough bzr-svn is used.
    modified:
      __init__.py
    ------------------------------------------------------------
    revno: 226.2.2
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Thu 2008-05-15 16:11:55 +0100
    message:
      Merge Jelmer's change to make ~svn123 version numbers grab the corresponding revision
      
      I have added support for ~svnX as well.
    modified:
      debian/changelog
      tests/test_config.py
      tests/test_util.py
      util.py
        ------------------------------------------------------------
        revno: 193.1.4
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: trunk
        timestamp: Mon 2007-12-03 14:10:13 +0100
        message:
          Support building svn snapshots.
        modified:
          tests/test_config.py
          tests/test_util.py
          util.py
        ------------------------------------------------------------
        revno: 226.3.1
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: upstream
        timestamp: Thu 2008-05-15 15:04:43 +0200
        message:
          Merge support for svn snapshots.
        modified:
          debian/changelog
          tests/test_config.py
          tests/test_util.py
          util.py
    ------------------------------------------------------------
    revno: 226.2.3
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Thu 2008-05-15 16:13:23 +0100
    message:
      Merge Jelmer's addition to the docs on snapshot handling.
    modified:
      doc/user_manual/export_upstream.rst
        ------------------------------------------------------------
        revno: 226.4.1
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: doc
        timestamp: Thu 2008-05-15 16:57:41 +0200
        message:
          Document ~bzr and ~svn.
        modified:
          doc/user_manual/export_upstream.rst
    ------------------------------------------------------------
    revno: 226.2.4
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Thu 2008-05-15 16:21:17 +0100
    message:
      Fix the FTBFS by disabling the testsuite. Thanks Sebastian Bober.
    modified:
      debian/changelog
      debian/control
      debian/rules
    ------------------------------------------------------------
    revno: 226.2.5
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Thu 2008-05-15 16:40:58 +0100
    message:
      Update the version number.
    modified:
      setup.py
      version.py
    ------------------------------------------------------------
    revno: 226.2.6
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Thu 2008-05-15 16:54:50 +0100
    message:
      Use DEB_BUILD_OPTIONS instead of DEBBUILDOPTS as the former is correct.
    modified:
      debian/rules
    ------------------------------------------------------------
    revno: 226.2.7
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Thu 2008-05-15 16:59:32 +0100
    message:
      Create the tarball dir before trying to download from the archive in to it.
    modified:
      builder.py
      debian/changelog
    ------------------------------------------------------------
    revno: 226.2.8
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Fri 2008-05-16 12:24:46 +0100
    message:
      * Suggest bzr-svn to hint that you can work with svn. The version
        is the one that exports the svn-buildpackage mergeWithUpstream
        property as "merge = True", so that bzr-builddeb will seamlessly
        build these branches.
    modified:
      debian/changelog
      debian/control
        ------------------------------------------------------------
        revno: 226.5.1
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: upstream
        timestamp: Fri 2008-05-16 03:08:08 +0200
        message:
          Suggests bzr-svn
        modified:
          debian/control
    ------------------------------------------------------------
    revno: 226.2.9
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Fri 2008-05-16 12:29:16 +0100
    message:
      Post release version bump.
    modified:
      debian/changelog
      setup.py
      version.py
    ------------------------------------------------------------
    revno: 226.2.10
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Thu 2008-05-29 23:51:16 +0100
    message:
      Support building remote branches, thanks Jelmer!
    modified:
      __init__.py
      config.py
      debian/changelog
      hooks.py
      tests/blackbox/test_builddeb.py
      tests/test_hooks.py
      tests/test_util.py
      util.py
        ------------------------------------------------------------
        revno: 226.3.2
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: remote
        timestamp: Sun 2008-05-18 01:07:18 +0200
        message:
          Support building from remote branch.
        modified:
          __init__.py
        ------------------------------------------------------------
        revno: 226.3.3
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: remote
        timestamp: Sun 2008-05-18 01:38:07 +0200
        message:
          Use Tree functions for accessing link properties.
        modified:
          util.py
        ------------------------------------------------------------
        revno: 226.3.4
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: remote
        timestamp: Sun 2008-05-18 01:45:09 +0200
        message:
          Specify tree to use to hooks explicitly so we notice when trying to run the pre-export one without a local working tree.
        modified:
          __init__.py
          debian/changelog
          hooks.py
        ------------------------------------------------------------
        revno: 226.3.5
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: remote
        timestamp: Sun 2008-05-18 01:48:32 +0200
        message:
          Remove unused utility function goto_branch.
        modified:
          util.py
        ------------------------------------------------------------
        revno: 226.3.6
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: remote
        timestamp: Sun 2008-05-18 02:04:21 +0200
        message:
          Fix some broken tests.
        modified:
          hooks.py
          tests/test_hooks.py
          tests/test_util.py
        ------------------------------------------------------------
        revno: 226.3.7
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: remote
        timestamp: Sun 2008-05-18 03:34:44 +0200
        message:
          Support loading .bzr-builddeb/default.conf when not building from a 
          working tree.
          
          Also avoid loading .bzr-builddeb/local.conf when it is versioned to avoid 
          security problems when pulling in changes from somebody else.
        modified:
          __init__.py
          config.py
          tests/blackbox/test_builddeb.py
    ------------------------------------------------------------
    revno: 226.2.11
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Fri 2008-05-30 00:01:55 +0100
    message:
      Add documentation on building remote branches.
      
      The documentation warns the user about the strange directories that
      may be used.
    modified:
      doc/user_manual/building.rst
      doc/user_manual/hooks.rst
    ------------------------------------------------------------
    revno: 226.2.12
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Fri 2008-05-30 00:38:52 +0100
    message:
      Default to doing everything in ./build-area/ when building a remote branch
    modified:
      __init__.py
      config.py
      doc/user_manual/building.rst
    ------------------------------------------------------------
    revno: 226.2.13
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Fri 2008-05-30 00:51:32 +0100
    message:
      Fix target of release.
    modified:
      debian/changelog
    ------------------------------------------------------------
    revno: 226.2.14
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Fri 2008-05-30 00:52:48 +0100
    message:
      Post release version bump.
    modified:
      debian/changelog
      setup.py
      version.py
    ------------------------------------------------------------
    revno: 226.2.15
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Fri 2008-06-13 15:39:20 +0100
    message:
      Support +bzr for snapshots as well as ~bzr.
    modified:
      debian/changelog
      tests/test_util.py
      util.py
        ------------------------------------------------------------
        revno: 226.6.1
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: trunk
        timestamp: Mon 2008-06-09 13:40:13 +0200
        message:
          Allow use of + before snapshot revisions.
        modified:
          tests/test_util.py
          util.py
    ------------------------------------------------------------
    revno: 226.2.16
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Mon 2008-07-07 11:06:23 +0100
    message:
      Lock the tree before starting as remote trees are more strict about this,
      meaning there were problems with remote branches.
    modified:
      __init__.py
      debian/changelog
        ------------------------------------------------------------
        revno: 226.7.1
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: trunk
        timestamp: Mon 2008-06-23 17:44:02 +0200
        message:
          Move determination of configuration into a separate function.
        modified:
          __init__.py
        ------------------------------------------------------------
        revno: 226.7.2
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: trunk
        timestamp: Mon 2008-06-23 17:55:09 +0200
        message:
          Lock the tree in cmd_builddeb() to allow reading the configuration from a RevisionTree.
        modified:
          __init__.py
    ------------------------------------------------------------
    revno: 226.2.17
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: trunk
    timestamp: Mon 2008-07-07 11:07:42 +0100
    message:
      Import apt_pkg only when used, as it is used rarely and importing it
      has an overhead, and also leads to increased memory usage.
    modified:
      builder.py
      debian/changelog
        ------------------------------------------------------------
        revno: 226.7.3
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: trunk
        timestamp: Tue 2008-06-24 13:04:53 +0200
        message:
          Import apt_pkg only when it's needed. Saves the allocation of about 1.3Mb worth of 
          data every time bzr is run.
        modified:
          builder.py
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2008-08-27 11:57:30 +0000
+++ b/__init__.py	2008-08-27 12:13:34 +0000
@@ -24,8 +24,11 @@
 
 import os
 import subprocess
+import urlparse
 
+from bzrlib.branch import Branch
 from bzrlib.commands import Command, register_command
+from bzrlib.config import ConfigObj
 from bzrlib.errors import (BzrCommandError,
                            NoWorkingTree,
                            NotBranchError,
@@ -50,10 +53,9 @@
 from bzrlib.plugins.builddeb.hooks import run_hook
 from bzrlib.plugins.builddeb.import_dsc import DistributionBranch
 from bzrlib.plugins.builddeb.properties import BuildProperties
-from bzrlib.plugins.builddeb.util import (goto_branch,
-        find_changelog,
+from bzrlib.plugins.builddeb.util import (find_changelog,
+        lookup_distribution,
         tarball_name,
-        lookup_distribution,
         )
 from bzrlib.plugins.builddeb.version import version_info
 
@@ -92,15 +94,38 @@
 default_result_dir = '..'
 
 
+def debuild_config(tree, working_tree, no_user_config):
+  """Obtain the Debuild configuration object.
+
+  :param tree: A Tree object, can be a WorkingTree or RevisionTree.
+  :param working_tree: Whether the tree is a working tree.
+  :param no_user_config: Whether to skip the user configuration
+  """
+  config_files = []
+  user_config = None
+  if (working_tree and 
+      tree.has_filename(local_conf) and tree.path2id(local_conf) is None):
+    config_files.append((tree.get_file_byname(local_conf), True))
+  if not no_user_config:
+    config_files.append((global_conf, True))
+    user_config = global_conf
+  if tree.path2id(default_conf):
+    config_files.append((tree.get_file(tree.path2id(default_conf)), False))
+  config = DebBuildConfig(config_files)
+  config.set_user_config(user_config)
+  return config
+
+
 class cmd_builddeb(Command):
   """Builds a Debian package from a branch.
 
   If BRANCH is specified it is assumed that the branch you wish to build is
   located there. If it is not specified then the current directory is used.
 
-  By default the working tree is used to build. If you wish to build the
-  last committed revision use --revision -1. You can specify any other
-  revision using the --revision option.
+  By default the if a working tree is found it is used to build and otherwise
+  the last committed revision was used. To force building the last committed 
+  revision use --revision -1. You can specify any other revision using the 
+  --revision option.
 
   If you only wish to export the package, and not build it (especially useful
   for merge mode), use --export-only.
@@ -173,146 +198,162 @@
           export_upstream=None, export_upstream_revision=None,
           source=False, revision=None, no_user_config=False):
 
-    goto_branch(branch)
-
-    tree, relpath = WorkingTree.open_containing('.')
-    
-    if no_user_config:
-        config_files = [(local_conf, True), (default_conf, False)]
-    else:
-        config_files = [(local_conf, True), (global_conf, True),
-                             (default_conf, False)]
-    config = DebBuildConfig(config_files)
-
-    if reuse:
-      info("Reusing existing build dir")
-      dont_purge = True
-      use_existing = True
-
-    if not merge:
-      merge = config.merge
-
-    if merge:
-      info("Running in merge mode")
-    else:
-      if not native:
-        native = config.native
-
-      if native:
-        info("Running in native mode")
-      else:
-        if not split:
-          split = config.split
-
-        if split:
-          info("Running in split mode")
-
-    if result is None:
-      result = config.result_dir
-    if result is not None:
-      result = os.path.realpath(result)
-
-    if builder is None:
-      if quick:
-        builder = config.quick_builder
-        if builder is None:
-          builder = "fakeroot debian/rules binary"
-      else:
-        if source:
-          builder = config.source_builder
-          if builder is None:
-            builder = "dpkg-buildpackage -rfakeroot -uc -us -S"
-        else:
-          builder = config.builder
-          if builder is None:
-            builder = "dpkg-buildpackage -uc -us -rfakeroot"
-
-    if revision is None:
+    if branch is None:
+      branch = "."
+
+    # Find out if we were passed a local or remote branch
+    is_local = urlparse.urlsplit(branch)[0] in ('', 'file')
+    if is_local:
+      os.chdir(branch)
+
+    try:
+      tree, _ = WorkingTree.open_containing(branch)
+      branch = tree.branch
+    except NoWorkingTree:
+      tree = None
+      branch, _ = Branch.open_containing(branch)
+
+    if revision is None and tree is not None:
       info("Building using working tree")
-      t = tree
       working_tree = True
     else:
-      if len(revision) != 1:
+      if revision is None:
+        revid = branch.last_revision()
+      elif len(revision) == 1:
+        revid = revision[0].in_history(branch).rev_id
+      else:
         raise BzrCommandError('bzr builddeb --revision takes exactly one '
                               'revision specifier.')
-      b = tree.branch
-      rev = revision[0].in_history(b)
-      info("Building branch from revision %s", rev.rev_id)
-      t = b.repository.revision_tree(rev.rev_id)
+      info("Building branch from revision %s", revid)
+      tree = branch.repository.revision_tree(revid)
       working_tree = False
 
-    (changelog, larstiq) = find_changelog(t, merge)
-
-    config.set_version(changelog.version)
-
-    if export_upstream is None:
-      export_upstream = config.export_upstream
-
-    if export_upstream_revision is None:
-      export_upstream_revision = config.export_upstream_revision
-
-    if build_dir is None:
-      build_dir = config.build_dir
+    tree.lock_read()
+    try:
+      config = debuild_config(tree, working_tree, no_user_config)
+
+      if reuse:
+        info("Reusing existing build dir")
+        dont_purge = True
+        use_existing = True
+
+      if not merge:
+        merge = config.merge
+
+      if merge:
+        info("Running in merge mode")
+      else:
+        if not native:
+          native = config.native
+
+        if native:
+          info("Running in native mode")
+        else:
+          if not split:
+            split = config.split
+
+          if split:
+            info("Running in split mode")
+
+      if builder is None:
+        if quick:
+          builder = config.quick_builder
+          if builder is None:
+            builder = "fakeroot debian/rules binary"
+        else:
+          if source:
+            builder = config.source_builder
+            if builder is None:
+              builder = "dpkg-buildpackage -rfakeroot -uc -us -S"
+          else:
+            builder = config.builder
+            if builder is None:
+              builder = "dpkg-buildpackage -uc -us -rfakeroot"
+
+      (changelog, larstiq) = find_changelog(tree, merge)
+
+      config.set_version(changelog.version)
+
+      if export_upstream is None:
+        export_upstream = config.export_upstream
+
+      if export_upstream_revision is None:
+        export_upstream_revision = config.export_upstream_revision
+
+      if result is None:
+        if is_local:
+          result = config.result_dir
+        else:
+          result = config.user_result_dir
+      if result is not None:
+        result = os.path.realpath(result)
+      
       if build_dir is None:
-        build_dir = default_build_dir
+        if is_local:
+          build_dir = config.build_dir or default_build_dir
+        else:
+          build_dir = config.user_build_dir or 'build-area'
 
-    if orig_dir is None:
-      orig_dir = config.orig_dir
       if orig_dir is None:
-        orig_dir = default_orig_dir
-    
-    properties = BuildProperties(changelog,build_dir,orig_dir,larstiq)
-
-    if merge:
-      if export_upstream is None:
-        build = DebMergeBuild(properties, t, _is_working_tree=working_tree)
-      else:
-        prepull_upstream = config.prepull_upstream
-        stop_on_no_change = config.prepull_upstream_stop
-        build = DebMergeExportUpstreamBuild(properties, t, export_upstream,
-                                            export_upstream_revision,
-                                            prepull_upstream,
-                                            stop_on_no_change,
-                                            _is_working_tree=working_tree)
-    elif native:
-      build = DebNativeBuild(properties, t, _is_working_tree=working_tree)
-    elif split:
-      build = DebSplitBuild(properties, t, _is_working_tree=working_tree)
-    else:
-      if export_upstream is None:
-        build = DebBuild(properties, t, _is_working_tree=working_tree)
-      else:
-        prepull_upstream = config.prepull_upstream
-        stop_on_no_change = config.prepull_upstream_stop
-        build = DebExportUpstreamBuild(properties, t, export_upstream,
-                                       export_upstream_revision,
-                                       prepull_upstream,
-                                       stop_on_no_change,
-                                       _is_working_tree=working_tree)
-
-    build.prepare(use_existing)
-
-    run_hook('pre-export', config)
-
-    try:
-      build.export(use_existing)
-    except StopBuild, e:
-      warning('Stopping the build: %s.', e.reason)
-      return
-
-    if not export_only:
-      run_hook('pre-build', config, wd=properties.source_dir())
-      build.build(builder)
-      run_hook('post-build', config, wd=properties.source_dir())
-      if not dont_purge:
-        build.clean()
-      arch = None
-      if source:
-        arch = "source"
-      if result is not None:
-        build.move_result(result, arch=arch)
-      else:
-        build.move_result(default_result_dir, allow_missing=True, arch=arch)
+        if is_local:
+          orig_dir = config.orig_dir or default_orig_dir
+        else:
+          orig_dir = config.user_orig_dir or 'build-area'
+      
+      properties = BuildProperties(changelog, build_dir, orig_dir, larstiq)
+
+      if merge:
+        if export_upstream is None:
+          build = DebMergeBuild(properties, tree, _is_working_tree=working_tree)
+        else:
+          prepull_upstream = config.prepull_upstream
+          stop_on_no_change = config.prepull_upstream_stop
+          build = DebMergeExportUpstreamBuild(properties, tree, export_upstream,
+                                              export_upstream_revision,
+                                              prepull_upstream,
+                                              stop_on_no_change,
+                                              _is_working_tree=working_tree)
+      elif native:
+        build = DebNativeBuild(properties, tree, _is_working_tree=working_tree)
+      elif split:
+        build = DebSplitBuild(properties, tree, _is_working_tree=working_tree)
+      else:
+        if export_upstream is None:
+          build = DebBuild(properties, tree, _is_working_tree=working_tree)
+        else:
+          prepull_upstream = config.prepull_upstream
+          stop_on_no_change = config.prepull_upstream_stop
+          build = DebExportUpstreamBuild(properties, tree, export_upstream,
+                                         export_upstream_revision,
+                                         prepull_upstream,
+                                         stop_on_no_change,
+                                         _is_working_tree=working_tree)
+
+      build.prepare(use_existing)
+
+      run_hook(tree, 'pre-export', config)
+
+      try:
+        build.export(use_existing)
+      except StopBuild, e:
+        warning('Stopping the build: %s.', e.reason)
+        return
+
+      if not export_only:
+        run_hook(tree, 'pre-build', config, wd=properties.source_dir())
+        build.build(builder)
+        run_hook(tree, 'post-build', config, wd=properties.source_dir())
+        if not dont_purge:
+          build.clean()
+        arch = None
+        if source:
+          arch = "source"
+        if result is not None:
+          build.move_result(result, arch=arch)
+        else:
+          build.move_result(default_result_dir, allow_missing=True, arch=arch)
+    finally:
+      tree.unlock()
 
 
 register_command(cmd_builddeb)
@@ -354,7 +395,7 @@
     if version is None:
       raise BzrCommandError("You must supply the --version argument.")
 
-    tree, relpath = WorkingTree.open_containing('.')
+    tree, _ = WorkingTree.open_containing('.')
 
     config = DebBuildConfig([(local_conf, True), (global_conf, True),
                              (default_conf, False)])

=== modified file 'builder.py'
--- a/builder.py	2008-08-27 01:13:12 +0000
+++ b/builder.py	2008-08-27 12:13:34 +0000
@@ -25,8 +25,6 @@
 import tempfile
 import os
 
-import apt_pkg
-
 from debian_bundle.changelog import Version
 
 from bzrlib.branch import Branch
@@ -211,6 +209,7 @@
     os.unlink(fetched_tarball)
 
   def _get_upstream_from_archive(self):
+    import apt_pkg
     apt_pkg.init()
     sources = apt_pkg.GetPkgSrcRecords()
     sources.Restart()
@@ -220,6 +219,8 @@
     while sources.Lookup(package):
       if version == Version(sources.Version).upstream_version:
         tarball_dir = self._properties.tarball_dir()
+        if not os.path.exists(tarball_dir):
+            os.makedirs(tarball_dir)
         command = 'apt-get source -y --tar-only %s=%s' % \
             (package, sources.Version)
         proc = subprocess.Popen(command, shell=True, cwd=tarball_dir)

=== modified file 'config.py'
--- a/config.py	2008-03-05 17:00:51 +0000
+++ b/config.py	2008-05-29 23:38:52 +0000
@@ -63,7 +63,6 @@
     """
     self._config_files = []
     self.version = version
-    assert(len(files) > 0)
     for input in files:
       config = ConfigObj(input[0])
       self._config_files.append((config, input[1]))
@@ -71,6 +70,19 @@
       self._branch_config = TreeConfig(branch)
     else:
       self._branch_config = None
+    self.user_config = None
+
+  def set_user_config(self, user_conf):
+    if user_conf is not None:
+      self.user_config = ConfigObj(user_conf)
+
+  def _user_config_value(self, key):
+    if self.user_config is not None:
+      try:
+        return self.user_config.get_value(self.section, key)
+      except KeyError:
+        pass
+    return None
 
   def set_version(self, version):
     """Set the version used for substitution."""
@@ -157,12 +169,21 @@
 
   build_dir = _opt_property('build-dir', "The dir to build in")
 
+  user_build_dir = property(
+          lambda self: self._user_config_value('build-dir'))
+
   orig_dir = _opt_property('orig-dir', "The dir to get upstream tarballs from")
 
+  user_orig_dir = property(
+          lambda self: self._user_config_value('orig-dir'))
+
   builder = _opt_property('builder', "The command to build with", True)
 
   result_dir = _opt_property('result-dir', "The dir to put the results in")
 
+  user_result_dir = property(
+          lambda self: self._user_config_value('result-dir'))
+
   merge = _bool_property('merge', "Run in merge mode")
 
   quick_builder = _opt_property('quick-builder',

=== modified file 'debian/changelog'
--- a/debian/changelog	2008-03-19 21:33:05 +0000
+++ b/debian/changelog	2008-07-07 10:07:42 +0000
@@ -1,3 +1,45 @@
+bzr-builddeb (1.0) UNRELEASED; urgency=low
+
+  [ Jelmer Vernooij ]
+  * Support +bzr for snapshots as well as ~bzr.
+  * Lock the tree before starting as remote trees are more strict about this,
+    meaning there were problems with remote branches.
+  * Import apt_pkg only when used, as it is used rarely and importing it
+    has an overhead, and also leads to increased memory usage.
+
+ -- James Westby <james.westby at canonical.com>  Fri, 13 Jun 2008 15:03:53 +0100
+
+bzr-builddeb (0.95) unstable; urgency=low
+
+  [ Jelmer Vernooij ]
+  * Support building from remote branches,
+    "bzr builddeb http://wherever/package.debian" will now work.
+
+ -- James Westby <james.westby at canonical.com>  Fri, 16 May 2008 12:29:08 +0100
+
+bzr-builddeb (0.94) unstable; urgency=low
+
+  [ Jelmer Vernooij ]
+  * Support building against snapshots from Subversion branches.
+  * Suggest bzr-svn to hint that you can work with svn. The version
+    is the one that exports the svn-buildpackage mergeWithUpstream
+    property as "merge = True", so that bzr-builddeb will seamlessly
+    build these branches.
+
+  [ Sebastian Bober ]
+  * Disable the testsuite during build as we can't be sure that
+    /etc/apt/sources.list has a deb-src line. "check" or "test"
+    in DEB_BUILD_OPTIONS will turn it back on again. (Closes: #472543)
+  * Build-Depend and Depend on python-apt, as it is used directly
+    now.
+  * Tweaks to stamp handling in debian/rules.
+
+  [ James Westby ]
+  * Make the tarball dir before trying to download from the archive in
+    to it. (LP: #223948)
+
+ -- James Westby <james.westby at canonical.com>  Thu, 15 May 2008 16:59:00 +0100
+
 bzr-builddeb (0.93) unstable; urgency=low
 
   [ Arnaud Fontaine ]

=== modified file 'debian/control'
--- a/debian/control	2008-03-19 20:33:17 +0000
+++ b/debian/control	2008-05-16 01:08:08 +0000
@@ -4,14 +4,15 @@
 Maintainer: Debian Bazaar Maintainers <pkg-bazaar-maint at lists.alioth.debian.org>
 Uploaders: Reinhard Tartler <siretart at tauware.de>, James Westby <jw+debian at jameswestby.net>
 Build-Depends: debhelper (>= 5.0.37.2), python-all (>= 2.3.5-11)
-Build-Depends-Indep: bzr (>= 1.2~), python-central (>= 0.5.8), python-docutils, python-debian (>= 0.1.4), bzrtools (>= 1.2~), patchutils
+Build-Depends-Indep: bzr (>= 1.2~), python-central (>= 0.5.8), python-docutils, python-debian (>= 0.1.4), python-apt, bzrtools (>= 1.2~), patchutils
 Vcs-Bzr: http://bazaar.launchpad.net/~james-w/bzr-builddeb/trunk
 XS-Python-Version: >= 2.4
 Standards-Version: 3.7.2
 
 Package: bzr-builddeb
 Architecture: all
-Depends: bzr (>= 1.2~), python-debian (>= 0.1.4), ${python:Depends}, dpkg-dev, fakeroot, bzrtools (>= 1.2), devscripts, patchutils
+Depends: bzr (>= 1.2~), python-debian (>= 0.1.4), python-apt, ${python:Depends}, dpkg-dev, fakeroot, bzrtools (>= 1.2), devscripts, patchutils
+Suggests: bzr-svn (>= 0.4.10)
 Provides: bzr-buildpackage
 XB-Python-Version: ${python:Versions}
 Description: bzr plugin for Debian package management

=== modified file 'debian/rules'
--- a/debian/rules	2008-03-19 22:02:39 +0000
+++ b/debian/rules	2008-05-15 15:54:50 +0000
@@ -21,17 +21,15 @@
 
 build-python%:
 	python$* setup.py build
-ifeq (,$(findstring nocheck,$(DEBBUILDOPTS)))
-ifeq (,$(findstring notest,$(DEBBUILDOPTS)))
+ifneq (,$(filter test check,$(DEB_BUILD_OPTIONS)))
 	BZR_PLUGIN_PATH="$(CURDIR)/build/lib/bzrlib/plugins/" python$* /usr/bin/bzr test-builddeb
 endif
-endif
-	touch $@
+	touch $@-stamp
 
 clean:
 	dh_testdir
 	dh_testroot
-	rm -f build-stamp install-all-stamp
+	rm -f build-stamp install-all-stamp build-python*-stamp
 	rm -f $(html_docs)
 	rm -f README.html
 

=== modified file 'doc/user_manual/building.rst'
--- a/doc/user_manual/building.rst	2007-10-23 21:25:20 +0000
+++ b/doc/user_manual/building.rst	2008-05-29 23:38:52 +0000
@@ -72,5 +72,19 @@
 
 lists them all.
 
+Remote Branches
+---------------
+
+It is possible to build directly from remote branches, e.g.::
+
+  $ bzr builddeb http://bzr.debian.org/pkg-bazaar/bzr-builddeb/trunk/
+
+This doesn't require you to have any of the branch history locally, and will
+just download what is needed to build the branch.
+
+If you do not have different directories set in ``~/.bazaar/builddeb.conf``
+then all actions will take place within ``./build-area/``, which should
+avoid overwriting any files that you wish to keep.
+
 .. vim: set ft=rst tw=76 :
 

=== modified file 'doc/user_manual/export_upstream.rst'
--- a/doc/user_manual/export_upstream.rst	2007-10-23 21:25:20 +0000
+++ b/doc/user_manual/export_upstream.rst	2008-05-15 14:57:41 +0000
@@ -121,5 +121,11 @@
 Note that this variable substitution only occurs from the configuration file,
 and does not work if this option is passed on the command line.
 
+It is possible to export a snapshot of the upstream by appending ``~bzr``
+and a revision number to the upstream version. For example, using version 
+``0.1~bzr42-1`` in the changelog would export revision 42 in the upstream
+branch. A similar directive exists for Subversion revision numbers. E.g. 
+``0.1~svn42-1`` would export Subversion revision 42.
+
 .. vim: set ft=rst tw=76 :
 

=== modified file 'doc/user_manual/hooks.rst'
--- a/doc/user_manual/hooks.rst	2007-09-16 19:40:35 +0000
+++ b/doc/user_manual/hooks.rst	2008-05-29 23:01:55 +0000
@@ -49,6 +49,8 @@
 run all necessary commands from the default hooks that are necessary to build
 the package.
 
+.. _configuration: configuration.html
+
 The hooks are set in a ``[HOOKS]`` section of the configuration file. The
 key is the hook point that the hook is set for, the value is the command(s)
 to run. For instance to run autoconf before building you would set the

=== modified file 'hooks.py'
--- a/hooks.py	2008-03-05 17:00:51 +0000
+++ b/hooks.py	2008-05-18 00:04:21 +0000
@@ -25,15 +25,13 @@
 from bzrlib.plugins.builddeb.errors import HookFailedError
 
 
-def run_hook(hook_name, config, wd=None):
+def run_hook(tree, hook_name, config, wd="."):
   hook = config.get_hook(hook_name)
   if hook is None:
     return
   info("Running %s as %s hook" % (hook, hook_name))
-  kwargs = {}
-  if wd is not None:
-    kwargs['cwd'] = wd
-  proc = subprocess.Popen(hook, shell=True, **kwargs)
+  proc = subprocess.Popen(hook, shell=True, 
+                          cwd=tree.abspath(wd))
   proc.wait()
   if proc.returncode != 0:
     raise HookFailedError(hook_name)

=== modified file 'setup.py'
--- a/setup.py	2008-03-19 22:23:13 +0000
+++ b/setup.py	2008-05-29 23:52:48 +0000
@@ -23,7 +23,7 @@
 from distutils.core import setup
 
 setup(name="bzr-builddeb",
-      version="0.1.0",
+      version="0.96",
       description="Build a .deb from a bzr branch",
       author="James Westby",
       author_email="jw+debian at jameswestby.net",

=== modified file 'tests/blackbox/test_builddeb.py'
--- a/tests/blackbox/test_builddeb.py	2008-08-26 15:41:59 +0000
+++ b/tests/blackbox/test_builddeb.py	2008-08-27 12:13:34 +0000
@@ -137,6 +137,7 @@
       f.write('pre-build = touch pre-build\npost-build = touch post-build\n')
     finally:
       f.close()
+    self.run_bzr('add .bzr-builddeb/default.conf')
     self.run_bzr('bd --no-user-conf --dont-purge --builder true')
     self.failUnlessExists('pre-export')
     self.assertInBuildDir(['pre-build', 'post-build'])
@@ -159,6 +160,7 @@
       f.write('export-upstream-revision = tag:test-$UPSTREAM_VERSION\n')
     finally:
       f.close()
+    self.run_bzr('add .bzr-builddeb/default.conf')
     self.run_bzr('bd --no-user-conf --dont-purge --builder true')
     self.assertInBuildDir(['a'])
     self.assertNotInBuildDir(['b'])

=== modified file 'tests/test_config.py'
--- a/tests/test_config.py	2008-03-05 17:00:51 +0000
+++ b/tests/test_config.py	2008-05-15 13:04:43 +0000
@@ -87,5 +87,7 @@
     self.assertEqual(self.config.export_upstream_revision, 'tag:upstream-0.2')
     self.config.set_version(Version('0.2~bzr300'))
     self.assertEqual(self.config.export_upstream_revision, '300')
+    self.config.set_version(Version('0.2~svn200'))
+    self.assertEqual(self.config.export_upstream_revision, 'svn:200')
 
 # vim: ts=2 sts=2 sw=2

=== modified file 'tests/test_hooks.py'
--- a/tests/test_hooks.py	2008-03-05 17:00:51 +0000
+++ b/tests/test_hooks.py	2008-05-18 00:04:21 +0000
@@ -26,6 +26,9 @@
 from bzrlib.plugins.builddeb.errors import HookFailedError
 from bzrlib.plugins.builddeb.hooks import run_hook
 
+class MockTree:
+  def abspath(self, relpath):
+    return os.path.abspath(relpath)
 
 class HookTests(TestCaseInTempDir):
 
@@ -36,7 +39,7 @@
     f = open(self.default_conf, 'wb')
     f.close()
     config = DebBuildConfig([(self.default_conf, False)])
-    run_hook('pre-build', config)
+    run_hook(MockTree(), 'pre-build', config)
 
   def test_run_hook_raises_when_hook_fails(self):
     f = open(self.default_conf, 'wb')
@@ -45,7 +48,7 @@
     finally:
       f.close()
     config = DebBuildConfig([(self.default_conf, False)])
-    self.assertRaises(HookFailedError, run_hook, 'pre-build', config)
+    self.assertRaises(HookFailedError, run_hook, MockTree(), 'pre-build', config)
 
   def test_run_hook_when_hook_passes(self):
     f = open(self.default_conf, 'wb')
@@ -54,7 +57,7 @@
     finally:
       f.close()
     config = DebBuildConfig([(self.default_conf, False)])
-    run_hook('pre-build', config)
+    run_hook(MockTree(), 'pre-build', config)
 
   def test_run_hook_uses_cwd_by_default(self):
     f = open(self.default_conf, 'wb')
@@ -63,7 +66,7 @@
     finally:
       f.close()
     config = DebBuildConfig([(self.default_conf, False)])
-    run_hook('pre-build', config)
+    run_hook(MockTree(), 'pre-build', config)
     self.failUnlessExists('a')
 
   def test_run_hook_uses_passed_wd(self):
@@ -74,7 +77,7 @@
     finally:
       f.close()
     config = DebBuildConfig([(self.default_conf, False)])
-    run_hook('pre-build', config, wd='dir')
+    run_hook(MockTree(), 'pre-build', config, wd='dir')
     self.failUnlessExists('dir/a')
 
   def test_run_hook_uses_shell(self):
@@ -84,7 +87,7 @@
     finally:
       f.close()
     config = DebBuildConfig([(self.default_conf, False)])
-    run_hook('post-build', config)
+    run_hook(MockTree(), 'post-build', config)
     self.failUnlessExists('a')
     self.failUnlessExists('b')
 
@@ -101,7 +104,7 @@
       f.close()
     config = DebBuildConfig([(self.local_conf, False),
                              (self.default_conf, False)])
-    run_hook('post-build', config)
+    run_hook(MockTree(), 'post-build', config)
     self.failIfExists('a')
     self.failUnlessExists('b')
 

=== modified file 'tests/test_util.py'
--- a/tests/test_util.py	2008-08-27 11:57:30 +0000
+++ b/tests/test_util.py	2008-08-27 12:13:34 +0000
@@ -138,6 +138,7 @@
     self.write_changelog('changelog')
     tree.add(['changelog'])
     os.symlink('.', 'debian')
+    tree.add(['debian'])
     (cl, lq) = find_changelog(tree, True)
     self.assertEqual(str(cl), cl_block1)
     self.assertEqual(lq, True)
@@ -168,12 +169,21 @@
   def test_with_snapshot(self):
     self.assertEquals("30", get_snapshot_revision("0.4.4~bzr30"))
 
+  def test_with_snapshot_plus(self):
+    self.assertEquals("30", get_snapshot_revision("0.4.4+bzr30"))
+
   def test_without_snapshot(self):
     self.assertEquals(None, get_snapshot_revision("0.4.4"))
 
   def test_non_numeric_snapshot(self):
     self.assertEquals(None, get_snapshot_revision("0.4.4~bzra"))
 
+  def test_with_svn_snapshot(self):
+    self.assertEquals("svn:4242", get_snapshot_revision("0.4.4~svn4242"))
+
+  def test_with_svn_snapshot_plus(self):
+    self.assertEquals("svn:2424", get_snapshot_revision("0.4.4+svn2424"))
+
 
 class LookupDistributionTests(TestCase):
 

=== modified file 'util.py'
--- a/util.py	2008-08-27 11:57:30 +0000
+++ b/util.py	2008-08-27 12:13:34 +0000
@@ -47,12 +47,6 @@
       shutil.copy(path, todir)
 
 
-def goto_branch(branch):
-  """Changes to the specified branch dir if it is not None"""
-  if branch is not None:
-    info("Building using branch at %s", branch)
-    os.chdir(branch)
-
 def find_changelog(t, merge):
     changelog_file = 'debian/changelog'
     larstiq = False
@@ -69,7 +63,8 @@
           raise MissingChangelogError("debian/changelog")
       else:
         if merge and t.has_filename('changelog'):
-          if os.path.islink('debian') and os.readlink('debian') == '.':
+          if (t.kind(t.path2id('debian')) == 'symlink' and 
+              t.get_symlink_target(t.path2id('debian')) == '.'):
             changelog_file = 'changelog'
             larstiq = True
       mutter("Using '%s' to get package information", changelog_file)
@@ -84,16 +79,19 @@
     return changelog, larstiq
 
 def tarball_name(package, version):
-  """Return the name of the .orig.tar.gz for the given pakcage and version."""
+  """Return the name of the .orig.tar.gz for the given package and version."""
 
   return "%s_%s.orig.tar.gz" % (package, str(version))
 
 def get_snapshot_revision(upstream_version):
   """Return the upstream revision specifier if specified in the upstream version or None. """
-  match = re.search("~bzr([0-9]+)$", upstream_version)
-  if match is None:
-    return None
-  return match.groups()[0]
+  match = re.search("(?:~|\\+)bzr([0-9]+)$", upstream_version)
+  if match is not None:
+    return match.groups()[0]
+  match = re.search("(?:~|\\+)svn([0-9]+)$", upstream_version)
+  if match is not None:
+    return "svn:%s" % match.groups()[0]
+  return None
 
 
 def lookup_distribution(target_dist):

=== modified file 'version.py'
--- a/version.py	2007-10-29 18:00:52 +0000
+++ b/version.py	2008-05-29 23:52:48 +0000
@@ -26,7 +26,7 @@
 # releaselevel of 'dev' for unreleased under-development code.
 #
 # Please set this to 'final' before upload.
-version_info = (0, 92, 0, 'dev', 0)
+version_info = (0, 96, 0, 'dev', 0)
 
 # vim: ts=2 sts=2 sw=2
 



More information about the Pkg-bazaar-commits mailing list