diff options
Diffstat (limited to 'mercurial/archival.py')
-rw-r--r-- | mercurial/archival.py | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/mercurial/archival.py b/mercurial/archival.py index 8eddf29..3f92f4c 100644 --- a/mercurial/archival.py +++ b/mercurial/archival.py @@ -7,7 +7,6 @@ from i18n import _ from node import hex -import match as matchmod import cmdutil import scmutil, util, encoding import cStringIO, os, tarfile, time, zipfile @@ -196,7 +195,7 @@ class fileit(object): return f = self.opener(name, "w", atomictemp=True) f.write(data) - f.close() + f.rename() destfile = os.path.join(self.basedir, name) os.chmod(destfile, mode) @@ -235,6 +234,8 @@ def archive(repo, dest, node, kind, decode=True, matchfn=None, prefix = tidyprefix(dest, kind, prefix) def write(name, mode, islink, getdata): + if matchfn and not matchfn(name): + return data = getdata() if decode: data = repo.wwritedata(name, data) @@ -264,18 +265,11 @@ def archive(repo, dest, node, kind, decode=True, matchfn=None, return base + tags - name = '.hg_archival.txt' - if not matchfn or matchfn(name): - write(name, 0644, False, metadata) + write('.hg_archival.txt', 0644, False, metadata) - if matchfn: - files = [f for f in ctx.manifest().keys() if matchfn(f)] - else: - files = ctx.manifest().keys() - files.sort() - total = len(files) + total = len(ctx.manifest()) repo.ui.progress(_('archiving'), 0, unit=_('files'), total=total) - for i, f in enumerate(files): + for i, f in enumerate(ctx): ff = ctx.flags(f) write(f, 'x' in ff and 0755 or 0644, 'l' in ff, ctx[f].data) repo.ui.progress(_('archiving'), i + 1, item=f, @@ -285,7 +279,6 @@ def archive(repo, dest, node, kind, decode=True, matchfn=None, if subrepos: for subpath in ctx.substate: sub = ctx.sub(subpath) - submatch = matchmod.narrowmatcher(subpath, matchfn) - sub.archive(repo.ui, archiver, prefix, submatch) + sub.archive(repo.ui, archiver, prefix) archiver.done() |