[Pkg-bazaar-maint] Bug#451248: bzr-builddeb: patch for import_dsc.py

Jamie Wilkinson jaq at debian.org
Fri Nov 16 13:27:05 UTC 2007


Package: bzr-builddeb
Version: 0.92
Tags: patch
Followup-For: Bug #451248

Hi!

I've poked around in import_dsc.py and found that the reason it was
hanging was due to the buffering between python, filterdiff, and patch.
I've refactored it so there's no loop reading the output of one and the
other, and glued the two subprocesses together directly.  I think this
will also have the sideeffect of making it faster because Python won't
be using any CPU.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-3-686 (SMP w/1 CPU core)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages bzr-builddeb depends on:
ii  bzr                           0.92-1     Bazaar, the next-generation distri
ii  bzrtools                      0.92.0-1   Collection of tools for bzr
ii  devscripts                    2.10.10    Scripts to make the life of a Debi
ii  dpkg-dev                      1.14.7     package building tools for Debian
ii  fakeroot                      1.8.4      Gives a fake root environment
ii  patchutils                    0.2.31-4   Utilities to work with patches
ii  python                        2.4.4-6    An interactive high-level object-o
ii  python-apt                    0.7.3.1+b1 Python interface to libapt-pkg
ii  python-central                0.5.15     register and build utility for Pyt
ii  python-debian                 0.1.6      python modules to work with Debian

bzr-builddeb recommends no packages.

-- no debconf information
-------------- next part --------------
--- import_dsc.py.new	2007-11-17 00:17:34.000000000 +1100
+++ import_dsc.py.bak	2007-11-17 00:13:40.000000000 +1100
@@ -339,41 +339,39 @@
     """Create a filterdiff subprocess."""  
     filter_cmd = ['filterdiff', '-x', '*/.bzr/*']
     filter_proc = Popen(filter_cmd, stdin=PIPE, stdout=PIPE)
-    for line in patch:
-      filter_proc.stdin.write(line)
-    filter_proc.stdin.close()
-    r = filter_proc.wait()
-    if r != 0:
-      raise BzrError('filtering patch failed')
-    filtered_patch = filter_proc.stdout.readlines()
-    return filtered_patch
-
+    return filter_proc
 
   def _patch_tree(self, patch, basedir):
+    """Patch a tree located at basedir."""
+    filter_proc = self._make_filter_proc()
     patch_cmd =  ['patch', '--strip', '1', '--quiet', '-f', '--directory',
                   basedir]
-    patch_proc = Popen(patch_cmd, stdin=PIPE)
-    for line in self._filter_patch(patch):
-      patch_proc.stdin.write(line)
-    patch_proc.stdin.close()
+    patch_proc = Popen(patch_cmd, stdin=filter_proc.stdout, close_fds=True)
+    for line in patch:
+      filter_proc.stdin.write(line)
+      filter_proc.stdin.flush()
+    filter_proc.stdin.close()
     r = patch_proc.wait()
     if r != 0:
       raise BzrError('patch failed')
 
   def _get_touched_paths(self, patch):
+    filter_proc = self._make_filter_proc()
     cmd = ['lsdiff', '--strip', '1']
-    child_proc = Popen(cmd, stdin=PIPE, stdout=PIPE)
-    for line in self._filter_patch(patch):
-      child_proc.stdin.write(line)
-    child_proc.stdin.close()
-    r = child_proc.wait()
-    if r != 0:
-      raise BzrError('lsdiff failed')
+    child_proc = Popen(cmd, stdin=filter_proc.stdout, stdout=PIPE,
+                       close_fds=True)
+    for line in patch:
+      filter_proc.stdin.write(line)
+      filter_proc.stdin.flush()
+    filter_proc.stdin.close()
     touched_paths = []
     for filename in child_proc.stdout.readlines():
       if filename.endswith('\n'):
         filename = filename[:-1]
       touched_paths.append(filename)
+    r = child_proc.wait()
+    if r != 0:
+      raise BzrError('lsdiff failed')
     return touched_paths
 
   def _add_implied_parents(self, tree, implied_parents, path,


More information about the Pkg-bazaar-maint mailing list