All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clark Williams <clark.williams@gmail.com>
To: "Karl Hasselström" <kha@treskal.com>
Cc: Catalin Marinas <catalin.marinas@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH - stgit] Patch to allow import of compressed files
Date: Tue, 10 Jun 2008 08:54:58 -0500	[thread overview]
Message-ID: <484E87B2.2090506@gmail.com> (raw)
In-Reply-To: <20080610063328.GB26965@diana.vm.bytemark.co.uk>

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

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

Karl Hasselström wrote:
> 
> Some comments here:
> 
>   * By my reading of the docs, the second argument to BZ2File defaults
>     to 'r' anyway, so you could omit it.
> 
>   * We try to use single quotes wherever possible (except when triple
>     quoting). You're using a mix ...
> 
>   * .replace() will happily replace anywhere in the string. Please
>     consider using stgit.util.strip_suffix() instead.
> 
> And last but not least, it'd be terrific if you'd let me bully you
> into adding .gz and .bz2 test cases for t1800-import. :-)
> 

Sigh. Never reply before your second cup of coffee.

Updated patch attached.

Clark

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

iEYEARECAAYFAkhOh7EACgkQqA4JVb61b9c4BgCeJH0GUzQJCDdJ8gx5287KE/KO
uTwAoKD7V4JMqHnYmFCg01ij5aBbLDbq
=Yy/n
-----END PGP SIGNATURE-----

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

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

From: Clark Williams <williams@redhat.com>

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..050301a 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 = strip_suffix('.gz', filename)
+        elif filename.endswith('.bz2'):
+            import bz2
+            f = bz2.BZ2File(filename)
+            pname = strip_suffic('.bz2', filename)
+        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)
 

  parent reply	other threads:[~2008-06-10 13:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=484E87B2.2090506@gmail.com \
    --to=clark.williams@gmail.com \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=kha@treskal.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.