Mercurial > hg
changeset 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 | c20c2c4c0c63 |
children | d8f6458434ec |
files | mercurial/archival.py mercurial/commands.py |
diffstat | 2 files changed, 15 insertions(+), 14 deletions(-) [+] |
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.'''
--- a/mercurial/commands.py Wed Jul 14 20:41:01 2010 +0200 +++ b/mercurial/commands.py Wed Jul 14 20:25:31 2010 +0200 @@ -196,20 +196,7 @@ if os.path.realpath(dest) == repo.root: raise util.Abort(_('repository root cannot be destination')) - def guess_type(): - exttypes = { - 'tar': ['.tar'], - 'tbz2': ['.tbz2', '.tar.bz2'], - 'tgz': ['.tgz', '.tar.gz'], - 'zip': ['.zip'], - } - - for type, extensions in exttypes.items(): - if util.any(dest.endswith(ext) for ext in extensions): - return type - return None - - kind = opts.get('type') or guess_type() or 'files' + kind = opts.get('type') or archival.guesskind(dest) or 'files' prefix = opts.get('prefix') if dest == '-':