[kernel] r16454 - in dists/sid/linux-2.6/debian: . lib/python/debian_linux

Ben Hutchings benh at alioth.debian.org
Sun Oct 17 02:07:18 UTC 2010


Author: benh
Date: Sun Oct 17 02:07:09 2010
New Revision: 16454

Log:
debian/.../patches.py: Open files as needed, rather than all at once (Closes: #600423)

Modified:
   dists/sid/linux-2.6/debian/changelog
   dists/sid/linux-2.6/debian/lib/python/debian_linux/patches.py

Modified: dists/sid/linux-2.6/debian/changelog
==============================================================================
--- dists/sid/linux-2.6/debian/changelog	Sun Oct 17 00:58:47 2010	(r16453)
+++ dists/sid/linux-2.6/debian/changelog	Sun Oct 17 02:07:09 2010	(r16454)
@@ -16,6 +16,8 @@
     possible with 'plain' IV on devices larger than 2TB (Closes: #600384)
   * [x86] ahci,ata_generic: let ata_generic handle new MBP w/ MCP89
     (Closes: #600305)
+  * debian/.../patches.py: Open files as needed, rather than all at once
+    (Closes: #600423)
 
  -- dann frazier <dannf at debian.org>  Fri, 15 Oct 2010 16:03:12 +0100
 

Modified: dists/sid/linux-2.6/debian/lib/python/debian_linux/patches.py
==============================================================================
--- dists/sid/linux-2.6/debian/lib/python/debian_linux/patches.py	Sun Oct 17 00:58:47 2010	(r16453)
+++ dists/sid/linux-2.6/debian/lib/python/debian_linux/patches.py	Sun Oct 17 02:07:09 2010	(r16454)
@@ -29,14 +29,14 @@
         raise NotImplementedError
 
 class OperationPatch(Operation):
-    def __init__(self, name, fp, data):
+    def __init__(self, name, fopen, data):
         super(OperationPatch, self).__init__(name, data)
-        self.fp = fp
+        self.fopen = fopen
 
     def _call(self, dir, extraargs):
         cmdline = "cd %s; patch -p1 -f -s -t --no-backup-if-mismatch %s" % (dir, extraargs)
         f = os.popen(cmdline, 'wb')
-        shutil.copyfileobj(self.fp, f)
+        shutil.copyfileobj(self.fopen(), f)
         if f.close():
             raise RuntimeError("Patch failed")
 
@@ -103,12 +103,12 @@
         'unifdef': SubOperationFilesUnifdef,
     }
 
-    def __init__(self, name, fp, data):
+    def __init__(self, name, fopen, data):
         super(OperationFiles, self).__init__(name, data)
 
         ops = []
 
-        for line in fp:
+        for line in fopen():
             line = line.strip()
             if not line or line[0] == '#':
                 continue
@@ -156,14 +156,15 @@
                 for suffix, cls in (('', file), ('.bz2', BZ2File), ('.gz', GzipFile)):
                     f1 = f + suffix
                     if os.path.exists(f1):
-                        fp = cls(f1)
+                        # Must copy current bindings into the lambda-function
+                        fopen = lambda cls=cls, f1=f1: cls(f1)
                         break
                 else:
                     raise RuntimeError("Can't find patch %s for series %s" % (filename, self.name))
             else:
                 raise RuntimeError('Undefined operation "%s" in series %s' % (operation, name))
 
-            self.append(self.operations[operation](filename, fp, data))
+            self.append(self.operations[operation](filename, fopen, data))
 
     def __call__(self, cond = bool, dir = '.', reverse = False):
         if not reverse:



More information about the Kernel-svn-changes mailing list