archive: delay extraction of file revisions
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Thu, 19 Jul 2007 19:43:25 -0300
changeset 4951 667290b6c95e
parent 4950 93b7e2fa7ee3
child 4952 a11921d24ec4
archive: delay extraction of file revisions This allows us to look only at the filelogs we're interested in, providing a nice speedup if we're archiving only part of a repository.
mercurial/archival.py
--- a/mercurial/archival.py	Thu Jul 19 19:43:25 2007 -0300
+++ b/mercurial/archival.py	Thu Jul 19 19:43:25 2007 -0300
@@ -200,8 +200,9 @@
 
     prefix is name of path to put before every archive member.'''
 
-    def write(name, mode, islink, data):
+    def write(name, mode, islink, getdata):
         if matchfn and not matchfn(name): return
+        data = getdata()
         if decode:
             data = repo.wwritedata(name, data)
         archiver.addfile(name, mode, islink, data)
@@ -212,8 +213,8 @@
     items = m.items()
     items.sort()
     write('.hg_archival.txt', 0644, False,
-          'repo: %s\nnode: %s\n' % (hex(repo.changelog.node(0)), hex(node)))
+          lambda: 'repo: %s\nnode: %s\n' % (hex(repo.changelog.node(0)), hex(node)))
     for filename, filenode in items:
         write(filename, m.execf(filename) and 0755 or 0644, m.linkf(filename),
-              repo.file(filename).read(filenode))
+              lambda: repo.file(filename).read(filenode))
     archiver.done()