[PATCH] bzr export --format uses incorrect directory names

Aaron Bentley aaron.bentley at utoronto.ca
Thu Sep 29 15:33:18 BST 2005


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

Wouter Bolsterlee wrote:
> P? Tue, Sep 27, 2005 at 11:33:49PM +0200, Wouter Bolsterlee skrev:
> 
>>So, I end up with files like "myproject-snapshot-revno-NNN.tar/README".
> 
> 
> Proposed patch attached.

I think it's better to treat .tar.gz as the extension.  Fewer special
cases that way.  Also, we should use just the basename, not the full
path.  And it looks like the --root option was getting clobbered, so I
fixed that too.

So something like this:

=== modified file 'bzrlib/builtins.py'
- --- bzrlib/builtins.py
+++ bzrlib/builtins.py
@@ -927,13 +927,20 @@
                 raise BzrError('bzr export --revision takes exactly 1
argument')
             rev_id = revision[0].in_history(b).rev_id
         t = b.revision_tree(rev_id)
- -        root, ext = os.path.splitext(dest)
+        arg_root, ext = os.path.splitext(os.path.basename(dest))
+        if ext in ('.gz', '.bz2'):
+            new_root, new_ext = os.path.splitext(arg_root)
+            if new_ext == '.tar':
+                arg_root = new_root
+                ext = new_ext + ext
+        if root is None:
+            root = arg_root
         if not format:
             if ext in (".tar",):
                 format = "tar"
- -            elif ext in (".gz", ".tgz"):
+            elif ext in (".tar.gz", ".tgz"):
                 format = "tgz"
- -            elif ext in (".bz2", ".tbz2"):
+            elif ext in (".tar.bz2", ".tbz2"):
                 format = "tbz2"
             else:
                 format = "dir"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDO/su0F+nu1YWqI0RAi6hAJ95ZccZOyslOpkoH/ssNouQ0mD6dwCfTrcI
6q0zrElul5J30lhe3dMRBD4=
=zVE1
-----END PGP SIGNATURE-----




More information about the bazaar mailing list