Package: bzr-builddeb Version: 0.92 Tags: patch Followup-For: Bug #451248 Hi again,
I messed up the diff last time, so it won't apply properly and it'll generate bad code if it does. Instead here's some inline code you can copy and paste into import_dsc.py, replacing _filter_patch(), _patch_tree(), and _get_touched_paths(). This version also handles large patches going through _get_touched_paths better, by selecting on lsdiff's stdout each time we write to filterdiff's stdin, so these processes don't fill up their own buffers and stop reading. The read(1) can probably be made more efficient, but for now this works pretty well! Thanks! def _make_filter_proc(self): """Create a filterdiff subprocess.""" filter_cmd = ['filterdiff', '-x', '*/.bzr/*'] filter_proc = Popen(filter_cmd, stdin=PIPE, stdout=PIPE) 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=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=filter_proc.stdout, stdout=PIPE, close_fds=True) output = '' for line in patch: filter_proc.stdin.write(line) filter_proc.stdin.flush() while select.select([child_proc.stdout], [], [], 0)[0]: output += child_proc.stdout.read(1) filter_proc.stdin.close() output += child_proc.stdout.read() touched_paths = [] for filename in output.split('\n'): 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 -- 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 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]