# HG changeset patch # User Martin Geisler # Date 1279131931 -7200 # Node ID 57bdc2239535aaddb7c00931d431d9d8507d35d5 # Parent c20c2c4c0c6380ebff26f08927a08ff91b73212c 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. diff -r c20c2c4c0c63 -r 57bdc2239535 mercurial/archival.py --- 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.''' diff -r c20c2c4c0c63 -r 57bdc2239535 mercurial/commands.py --- 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 == '-':