[Pkg-bazaar-commits] r167 ./bzr-builddeb/trunk: * Support exporting the working tree when it contains symlinks. Thanks

James Westby jw+debian at jameswestby.net
Wed Aug 22 21:18:19 UTC 2007


------------------------------------------------------------
revno: 167
committer: James Westby <jw+debian at jameswestby.net>
branch nick: trunk
timestamp: Wed 2007-08-22 22:18:19 +0100
message:
  * Support exporting the working tree when it contains symlinks. Thanks
    to John Arbash Meinel for help on fixing it. (LP: #132391)
modified:
  __init__.py
  builder.py
  debian/changelog
  tests/test_builder.py
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2007-07-10 22:01:56 +0000
+++ b/__init__.py	2007-08-22 21:18:19 +0000
@@ -244,20 +244,21 @@
 
     if merge:
       if export_upstream is None:
-        build = DebMergeBuild(properties, t)
+        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)
+                                            stop_on_no_change,
+                                            _is_working_tree=working_tree)
     elif native:
-      build = DebNativeBuild(properties, t)
+      build = DebNativeBuild(properties, t, _is_working_tree=working_tree)
     elif split:
-      build = DebSplitBuild(properties, t)
+      build = DebSplitBuild(properties, t, _is_working_tree=working_tree)
     else:
-      build = DebBuild(properties, t)
+      build = DebBuild(properties, t, _is_working_tree=working_tree)
 
     build.prepare(use_existing)
 

=== modified file 'builder.py'
--- a/builder.py	2007-07-10 21:04:28 +0000
+++ b/builder.py	2007-08-22 21:18:19 +0000
@@ -60,7 +60,7 @@
 class DebBuild(object):
   """The object that does the building work."""
 
-  def __init__(self, properties, tree):
+  def __init__(self, properties, tree, _is_working_tree=False):
     """Create a builder.
 
     properties:
@@ -71,6 +71,12 @@
     """
     self._properties = properties
     self._tree = tree
+    self._is_working_tree = _is_working_tree
+
+  def _prepare_working_tree(self):
+    if self._is_working_tree:
+      for (dp, ie) in self._tree.inventory.iter_entries():
+        ie._read_tree_state(dp, self._tree)
 
   def prepare(self, keep_source_dir=False):
     """Do any preparatory steps that should be run before the build.
@@ -191,6 +197,7 @@
     tree = self._tree
     tree.lock_read()
     try:
+      self._prepare_working_tree()
       export(tree,source_dir,None,None)
     finally:
       tree.unlock()
@@ -297,6 +304,7 @@
     tree = self._tree
     tree.lock_read()
     try:
+      self._prepare_working_tree()
       export(tree,export_dir,None,None)
     finally:
       tree.unlock()
@@ -317,6 +325,7 @@
     tree = self._tree
     tree.lock_read()
     try:
+      self._prepare_working_tree()
       export(tree,source_dir,None,None)
     finally:
       tree.unlock()
@@ -335,6 +344,7 @@
     tree = self._tree
     tree.lock_read()
     try:
+      self._prepare_working_tree()
       export(tree,source_dir,None,None)
       info("Creating .orig.tar.gz: %s", tarball)
       remove_bzrbuilddeb_dir(source_dir)
@@ -347,6 +357,7 @@
         tar.close()
       shutil.rmtree(source_dir)
       info("Exporting to %s", source_dir)
+      self._prepare_working_tree()
       export(tree,source_dir,None,None)
     finally:
       tree.unlock()
@@ -357,12 +368,13 @@
      .orig.tar.gz before building."""
 
   def __init__(self, properties, tree, export_upstream, export_revision,
-               export_prepull, stop_on_no_change):
+               export_prepull, stop_on_no_change, _is_working_tree=False):
     DebMergeBuild.__init__(self, properties, tree)
     self._export_upstream = export_upstream
     self._export_revision = export_revision
     self._export_prepull = export_prepull
     self._stop_on_no_change = stop_on_no_change
+    self._is_working_tree = _is_working_tree
 
   def _export_upstream_branch(self):
     build_dir = self._properties.build_dir()

=== modified file 'debian/changelog'
--- a/debian/changelog	2007-08-13 21:12:10 +0000
+++ b/debian/changelog	2007-08-22 21:18:19 +0000
@@ -1,3 +1,10 @@
+bzr-builddeb (0.90) unstable; urgency=low
+
+  * Support exporting the working tree when it contains symlinks. Thanks
+    to John Arbash Meinel for help on fixing it. (LP: #132391)
+
+ -- James Westby <jw+debian at jameswestby.net>  Wed, 22 Aug 2007 22:13:24 +0100
+
 bzr-builddeb (0.19) unstable; urgency=low
 
   * Allow empty author information in the changelog for those that like to

=== modified file 'tests/test_builder.py'
--- a/tests/test_builder.py	2007-07-10 21:02:32 +0000
+++ b/tests/test_builder.py	2007-08-22 21:18:19 +0000
@@ -298,7 +298,7 @@
       wt = self._make_branch()
     changelog = self.make_changelog(version=version)
     properties = self.make_properties(changelog, larstiq)
-    return DebBuild(properties, wt)
+    return DebBuild(properties, wt, _is_working_tree=True)
 
   def test_prepare_creates_build_dir(self):
     """Test that the build dir is created correctly."""
@@ -413,7 +413,8 @@
     wt.add(['a', 'b'])
     wt.commit('commit one')
     self.build_branch_tree(['c', 'd'])
-    wt.add(['c'])
+    os.symlink(join(self.branch_dir, 'e'), join(self.branch_dir, 'f'))
+    wt.add(['c', 'f'])
     wt.remove(['b'])
     builder = self.get_builder(wt=wt)
     self.make_orig_tarball()
@@ -423,6 +424,8 @@
     self.failIfExists(join(self.source_dir, 'b'))
     self.failUnlessExists(join(self.source_dir, 'c'))
     self.failIfExists(join(self.source_dir, 'd'))
+    self.failIfExists(join(self.source_dir, 'e'))
+    self.assertTrue(os.path.lexists(join(self.source_dir, 'f')))
 
   def test_export_removes_builddeb_dir(self):
     """Test that the builddeb dir is removed from the export."""
@@ -520,7 +523,7 @@
       wt = self._make_branch()
     changelog = self.make_changelog(version=version)
     properties = self.make_properties(changelog, larstiq)
-    return DebNativeBuild(properties, wt)
+    return DebNativeBuild(properties, wt, _is_working_tree=True)
 
   def test_export_creates_source_dir(self):
     """Test that the source dir is created by export."""
@@ -567,7 +570,7 @@
       wt = self._make_branch()
     changelog = self.make_changelog(version=version)
     properties = self.make_properties(changelog, larstiq)
-    return DebSplitBuild(properties, wt)
+    return DebSplitBuild(properties, wt, _is_working_tree=True)
 
   def test_export_creates_source_dir(self):
     """Test that the source dir is created by export."""
@@ -637,7 +640,7 @@
       wt = self._make_branch()
     changelog = self.make_changelog(version=version)
     properties = self.make_properties(changelog, larstiq)
-    return DebMergeBuild(properties, wt)
+    return DebMergeBuild(properties, wt, _is_working_tree=True)
 
   upstream_files = ['a', 'b', 'dir/', 'dir/c']
   debian_files = ['control', 'changelog', 'patches/', 'patches/patch']
@@ -810,7 +813,8 @@
     properties = self.make_properties(changelog, larstiq)
     return DebMergeExportUpstreamBuild(properties, wt, self.upstream_branch,
                                        export_revision, export_prepull,
-                                       stop_on_no_change)
+                                       stop_on_no_change,
+                                       _is_working_tree=True)
 
   def make_upstream_branch(self, parent=None):
     """Make the upstream branch that will be exported."""



More information about the Pkg-bazaar-commits mailing list