##// END OF EJS Templates
archival: move commands.archive.guess_type to archival.guesskind...
Martin Geisler -
r11557:57bdc223 default
parent child Browse files
Show More
@@ -35,6 +35,20 b' def tidyprefix(dest, prefix, suffixes):'
35 raise util.Abort(_('archive prefix contains illegal components'))
35 raise util.Abort(_('archive prefix contains illegal components'))
36 return prefix
36 return prefix
37
37
38 exts = {
39 'tar': ['.tar'],
40 'tbz2': ['.tbz2', '.tar.bz2'],
41 'tgz': ['.tgz', '.tar.gz'],
42 'zip': ['.zip'],
43 }
44
45 def guesskind(dest):
46 for kind, extensions in exts.iteritems():
47 if util.any(dest.endswith(ext) for ext in extensions):
48 return kind
49 return None
50
51
38 class tarit(object):
52 class tarit(object):
39 '''write archive to tar file or stream. can write uncompressed,
53 '''write archive to tar file or stream. can write uncompressed,
40 or compress with gzip or bzip2.'''
54 or compress with gzip or bzip2.'''
@@ -196,20 +196,7 b' def archive(ui, repo, dest, **opts):'
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 == '-':
General Comments 0
You need to be logged in to leave comments. Login now