git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH - stgit] Patch to allow import of compressed files
@ 2008-06-09 18:38 Clark Williams
  2008-06-10  6:33 ` Karl Hasselström
  0 siblings, 1 reply; 18+ messages in thread
From: Clark Williams @ 2008-06-09 18:38 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 764 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This patch allows StGit to directly import compressed (.gz and .bz2) files with
reasonable patch names.

I do a lot of work on modified kernel trees and usually the first two things imported
are a stable update patch followed immediately by an -rt patch, both of which are
compressed. With this patch I can just copy the files down directly from kernel.org
and import them, rather than having to keep uncompressed copies around.

Hey, I'm lazy... :)

Clark

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkhNeL4ACgkQqA4JVb61b9cu0ACdH/Z71xh4gaD5euF3BgYnIhiO
AkUAnipyN/dsTBQDyhc6uzFhxdxPeYvJ
=2G71
-----END PGP SIGNATURE-----

[-- Attachment #2: compressed-input.patch --]
[-- Type: text/plain, Size: 1437 bytes --]

From: Clark Williams <williams@redhat.com>

Patch to allow import from compressed (.gz and .bz2) files

Signed-off-by: Clark Williams <williams@redhat.com>
---

 stgit/commands/imprt.py |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py
index 4a4b792..83dae2f 100644
--- a/stgit/commands/imprt.py
+++ b/stgit/commands/imprt.py
@@ -178,8 +178,22 @@ def __create_patch(filename, message, author_name, author_email,
 def __import_file(filename, options, patch = None):
     """Import a patch from a file or standard input
     """
+    if patch:
+        pname = patch
+    else:
+        pname = filename
+
     if filename:
-        f = file(filename)
+        if filename.endswith(".gz"):
+            import gzip
+            f = gzip.open(filename)
+            pname = filename.replace(".gz", "")
+        elif filename.endswith(".bz2"):
+            import bz2
+            f = bz2.BZ2File(filename, 'r')
+            pname = filename.replace(".bz2", "")
+        else:
+            f = file(filename)
     else:
         f = sys.stdin
 
@@ -197,11 +211,6 @@ def __import_file(filename, options, patch = None):
     if filename:
         f.close()
 
-    if patch:
-        pname = patch
-    else:
-        pname = filename
-
     __create_patch(pname, message, author_name, author_email,
                    author_date, diff, options)
 

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2008-06-19 21:37 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-09 18:38 [PATCH - stgit] Patch to allow import of compressed files Clark Williams
2008-06-10  6:33 ` Karl Hasselström
2008-06-10  6:38   ` Asheesh Laroia
2008-06-10  8:07     ` Sverre Rabbelier
2008-06-10  9:53       ` Karl Hasselström
2008-06-10  9:57         ` Sverre Rabbelier
2008-06-10 10:28           ` Karl Hasselström
2008-06-10 10:33             ` Sverre Rabbelier
2008-06-10 14:06               ` Clark Williams
2008-06-10 14:01       ` Clark Williams
2008-06-10 13:57     ` Clark Williams
2008-06-10 14:04       ` Asheesh Laroia
2008-06-10 13:54   ` Clark Williams
2008-06-10 13:54   ` Clark Williams
2008-06-11  6:27     ` Karl Hasselström
2008-06-11 17:28       ` Clark Williams
2008-06-11 19:14         ` Karl Hasselström
2008-06-19 14:17   ` David Kågedal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).