53 # Drop the leading '.' path component if present, so Windows can read the |
53 # Drop the leading '.' path component if present, so Windows can read the |
54 # zip files (issue4634) |
54 # zip files (issue4634) |
55 if prefix.startswith('./'): |
55 if prefix.startswith('./'): |
56 prefix = prefix[2:] |
56 prefix = prefix[2:] |
57 if prefix.startswith('../') or os.path.isabs(lpfx) or '/../' in prefix: |
57 if prefix.startswith('../') or os.path.isabs(lpfx) or '/../' in prefix: |
58 raise util.Abort(_('archive prefix contains illegal components')) |
58 raise error.Abort(_('archive prefix contains illegal components')) |
59 return prefix |
59 return prefix |
60 |
60 |
61 exts = { |
61 exts = { |
62 'tar': ['.tar'], |
62 'tar': ['.tar'], |
63 'tbz2': ['.tbz2', '.tar.bz2'], |
63 'tbz2': ['.tbz2', '.tar.bz2'], |
290 |
290 |
291 prefix is name of path to put before every archive member.''' |
291 prefix is name of path to put before every archive member.''' |
292 |
292 |
293 if kind == 'files': |
293 if kind == 'files': |
294 if prefix: |
294 if prefix: |
295 raise util.Abort(_('cannot give prefix when archiving to files')) |
295 raise error.Abort(_('cannot give prefix when archiving to files')) |
296 else: |
296 else: |
297 prefix = tidyprefix(dest, kind, prefix) |
297 prefix = tidyprefix(dest, kind, prefix) |
298 |
298 |
299 def write(name, mode, islink, getdata): |
299 def write(name, mode, islink, getdata): |
300 data = getdata() |
300 data = getdata() |
301 if decode: |
301 if decode: |
302 data = repo.wwritedata(name, data) |
302 data = repo.wwritedata(name, data) |
303 archiver.addfile(prefix + name, mode, islink, data) |
303 archiver.addfile(prefix + name, mode, islink, data) |
304 |
304 |
305 if kind not in archivers: |
305 if kind not in archivers: |
306 raise util.Abort(_("unknown archive type '%s'") % kind) |
306 raise error.Abort(_("unknown archive type '%s'") % kind) |
307 |
307 |
308 ctx = repo[node] |
308 ctx = repo[node] |
309 archiver = archivers[kind](dest, mtime or ctx.date()[0]) |
309 archiver = archivers[kind](dest, mtime or ctx.date()[0]) |
310 |
310 |
311 if repo.ui.configbool("ui", "archivemeta", True): |
311 if repo.ui.configbool("ui", "archivemeta", True): |