[Pkg-bazaar-commits] ./bzr-builddeb/trunk r238: Default to doing everything in ./build-area/ when building a remote branch

James Westby jw+debian at jameswestby.net
Thu May 29 23:38:52 UTC 2008


------------------------------------------------------------
revno: 238
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
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2008-05-29 22:51:16 +0000
+++ b/__init__.py	2008-05-29 23:38:52 +0000
@@ -24,9 +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,
@@ -172,6 +174,11 @@
     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
@@ -195,14 +202,17 @@
       working_tree = False
 
     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)
 
     if reuse:
       info("Reusing existing build dir")
@@ -227,11 +237,6 @@
         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
@@ -257,15 +262,25 @@
     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 = config.build_dir
-      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
+      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)
 

=== modified file 'config.py'
--- a/config.py	2008-05-18 01:34:44 +0000
+++ b/config.py	2008-05-29 23:38:52 +0000
@@ -70,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."""
@@ -156,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 'doc/user_manual/building.rst'
--- a/doc/user_manual/building.rst	2008-05-29 23:01:55 +0000
+++ b/doc/user_manual/building.rst	2008-05-29 23:38:52 +0000
@@ -82,18 +82,9 @@
 This doesn't require you to have any of the branch history locally, and will
 just download what is needed to build the branch.
 
-Note however that it may create the files in a suprising location. It will still
-default to ``../build-area/`` and will in fact use the
-``.bzr-builddeb/default.conf`` file from the remote branch, which may alter this.
-
-To avoid this you may want to override these things on the command line,
-e.g.::
-
-  $ bzr builddeb --build-dir=. --orig-dir=. \
-        http://bzr.debian.org/pkg-bazaar/bzr-builddeb/trunk/
-
-which will use the current directory as a working area, and leave the resulting
-packages in the current directory.
+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 :
 



More information about the Pkg-bazaar-commits mailing list