[Pkg-bazaar-commits] ./bzr-builddeb/trunk r242: Lock the tree before starting as remote trees are more strict about this,

James Westby jw+debian at jameswestby.net
Mon Jul 7 10:06:23 UTC 2008


------------------------------------------------------------
revno: 242
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: 241.1.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: 241.1.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
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2008-05-29 23:38:52 +0000
+++ b/__init__.py	2008-06-23 15:55:09 +0000
@@ -89,6 +89,28 @@
 default_orig_dir = '../tarballs'
 
 
+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.
 
@@ -201,134 +223,127 @@
       tree = branch.repository.revision_tree(revid)
       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")
-      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:
-      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:
-      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)
-
+    tree.lock_read()
     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()
+      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:
-        build.move_result(result)
+        result = os.path.realpath(result)
+      
+      if build_dir is None:
+        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:
+        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()
+        if result is not None:
+          build.move_result(result)
+    finally:
+      tree.unlock()
 
 
 register_command(cmd_builddeb)

=== modified file 'debian/changelog'
--- a/debian/changelog	2008-06-13 14:39:20 +0000
+++ b/debian/changelog	2008-07-07 10:06:23 +0000
@@ -2,6 +2,8 @@
 
   [ 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.
 
  -- James Westby <james.westby at canonical.com>  Fri, 13 Jun 2008 15:03:53 +0100
 



More information about the Pkg-bazaar-commits mailing list