mercurial/archival.py
changeset 11557 57bdc2239535
parent 10282 08a0f04b56bd
child 11558 d8f6458434ec
equal deleted inserted replaced
11556:c20c2c4c0c63 11557:57bdc2239535
    33         prefix += '/'
    33         prefix += '/'
    34     if prefix.startswith('../') or os.path.isabs(lpfx) or '/../' in prefix:
    34     if prefix.startswith('../') or os.path.isabs(lpfx) or '/../' in prefix:
    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.'''
    41 
    55 
    42     class GzipFileWithTime(gzip.GzipFile):
    56     class GzipFileWithTime(gzip.GzipFile):