[Pkg-bazaar-commits] ./bzr/unstable r857: - If export filename ends in .tar, etc, then make a tarball instead of a directory

Martin Pool mbp at sourcefrog.net
Fri Apr 10 08:21:16 UTC 2009


------------------------------------------------------------
revno: 857
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Thu 2005-07-07 20:56:27 +1000
message:
  - If export filename ends in .tar, etc, then make a tarball instead of a directory
modified:
  bzrlib/commands.py
-------------- next part --------------
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2005-07-07 02:07:03 +0000
+++ b/bzrlib/commands.py	2005-07-07 10:56:27 +0000
@@ -1042,19 +1042,32 @@
     If no revision is specified this exports the last committed revision.
 
     Format may be an "exporter" name, such as tar, tgz, tbz2.  If none is
-    given, exports to a directory (equivalent to --format=dir).
+    given, try to find the format with the extension. If no extension
+    is found exports to a directory (equivalent to --format=dir).
 
-    Root may be the top directory for tar, tgz and tbz2 formats."""
+    Root may be the top directory for tar, tgz and tbz2 formats. If none
+    is given, the top directory will be the root name of the file."""
     # TODO: list known exporters
     takes_args = ['dest']
     takes_options = ['revision', 'format', 'root']
-    def run(self, dest, revision=None, format='dir', root=None):
+    def run(self, dest, revision=None, format=None, root=None):
+        import os.path
         b = find_branch('.')
         if revision == None:
             rh = b.revision_history()[-1]
         else:
             rh = b.lookup_revision(int(revision))
         t = b.revision_tree(rh)
+        root, ext = os.path.splitext(dest)
+        if not format:
+            if ext in (".tar",):
+                format = "tar"
+            elif ext in (".gz", ".tgz"):
+                format = "tgz"
+            elif ext in (".bz2", ".tbz2"):
+                format = "tbz2"
+            else:
+                format = "dir"
         t.export(dest, format, root)
 
 



More information about the Pkg-bazaar-commits mailing list