5 # This software may be used and distributed according to the terms of the |
5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2, incorporated herein by reference. |
6 # GNU General Public License version 2, incorporated herein by reference. |
7 |
7 |
8 from i18n import _ |
8 from i18n import _ |
9 from node import hex |
9 from node import hex |
|
10 import cmdutil |
10 import util |
11 import util |
11 import cStringIO, os, stat, tarfile, time, zipfile |
12 import cStringIO, os, stat, tarfile, time, zipfile |
12 import zlib, gzip |
13 import zlib, gzip |
13 |
14 |
14 def tidyprefix(dest, prefix, suffixes): |
15 def tidyprefix(dest, prefix, suffixes): |
215 |
216 |
216 ctx = repo[node] |
217 ctx = repo[node] |
217 archiver = archivers[kind](dest, prefix, mtime or ctx.date()[0]) |
218 archiver = archivers[kind](dest, prefix, mtime or ctx.date()[0]) |
218 |
219 |
219 if repo.ui.configbool("ui", "archivemeta", True): |
220 if repo.ui.configbool("ui", "archivemeta", True): |
220 write('.hg_archival.txt', 0644, False, |
221 def metadata(): |
221 lambda: 'repo: %s\nnode: %s\n' % ( |
222 base = 'repo: %s\nnode: %s\nbranch: %s\n' % ( |
222 hex(repo.changelog.node(0)), hex(node))) |
223 hex(repo.changelog.node(0)), hex(node), ctx.branch()) |
|
224 |
|
225 tags = ''.join('tag: %s\n' % t for t in ctx.tags() |
|
226 if repo.tagtype(t) == 'global') |
|
227 if not tags: |
|
228 repo.ui.pushbuffer() |
|
229 opts = {'template': '{latesttag}\n{latesttagdistance}', |
|
230 'style': '', 'patch': None, 'git': None} |
|
231 cmdutil.show_changeset(repo.ui, repo, opts).show(ctx) |
|
232 ltags, dist = repo.ui.popbuffer().split('\n') |
|
233 tags = ''.join('latesttag: %s\n' % t for t in ltags.split(':')) |
|
234 tags += 'latesttagdistance: %s\n' % dist |
|
235 |
|
236 return base + tags |
|
237 |
|
238 write('.hg_archival.txt', 0644, False, metadata) |
|
239 |
223 for f in ctx: |
240 for f in ctx: |
224 ff = ctx.flags(f) |
241 ff = ctx.flags(f) |
225 write(f, 'x' in ff and 0755 or 0644, 'l' in ff, ctx[f].data) |
242 write(f, 'x' in ff and 0755 or 0644, 'l' in ff, ctx[f].data) |
226 archiver.done() |
243 archiver.done() |