Mercurial > public > mercurial-scm > hg-stable
diff mercurial/archival.py @ 11557:57bdc2239535
archival: move commands.archive.guess_type to archival.guesskind
The list of suffixes for each kind of archive belongs in archival.
Renamed function to fit with out code style.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Wed, 14 Jul 2010 20:25:31 +0200 |
parents | 08a0f04b56bd |
children | d8f6458434ec |
line wrap: on
line diff
--- a/mercurial/archival.py Wed Jul 14 20:41:01 2010 +0200 +++ b/mercurial/archival.py Wed Jul 14 20:25:31 2010 +0200 @@ -35,6 +35,20 @@ raise util.Abort(_('archive prefix contains illegal components')) return prefix +exts = { + 'tar': ['.tar'], + 'tbz2': ['.tbz2', '.tar.bz2'], + 'tgz': ['.tgz', '.tar.gz'], + 'zip': ['.zip'], + } + +def guesskind(dest): + for kind, extensions in exts.iteritems(): + if util.any(dest.endswith(ext) for ext in extensions): + return kind + return None + + class tarit(object): '''write archive to tar file or stream. can write uncompressed, or compress with gzip or bzip2.'''