Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.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 | 4484a7b661f2 |
children | 6dbdf5c5c5bd |
comparison
equal
deleted
inserted
replaced
11556:c20c2c4c0c63 | 11557:57bdc2239535 |
---|---|
194 node = ctx.node() | 194 node = ctx.node() |
195 dest = cmdutil.make_filename(repo, dest, node) | 195 dest = cmdutil.make_filename(repo, dest, node) |
196 if os.path.realpath(dest) == repo.root: | 196 if os.path.realpath(dest) == repo.root: |
197 raise util.Abort(_('repository root cannot be destination')) | 197 raise util.Abort(_('repository root cannot be destination')) |
198 | 198 |
199 def guess_type(): | 199 kind = opts.get('type') or archival.guesskind(dest) or 'files' |
200 exttypes = { | |
201 'tar': ['.tar'], | |
202 'tbz2': ['.tbz2', '.tar.bz2'], | |
203 'tgz': ['.tgz', '.tar.gz'], | |
204 'zip': ['.zip'], | |
205 } | |
206 | |
207 for type, extensions in exttypes.items(): | |
208 if util.any(dest.endswith(ext) for ext in extensions): | |
209 return type | |
210 return None | |
211 | |
212 kind = opts.get('type') or guess_type() or 'files' | |
213 prefix = opts.get('prefix') | 200 prefix = opts.get('prefix') |
214 | 201 |
215 if dest == '-': | 202 if dest == '-': |
216 if kind == 'files': | 203 if kind == 'files': |
217 raise util.Abort(_('cannot archive plain files to stdout')) | 204 raise util.Abort(_('cannot archive plain files to stdout')) |