Patchwork [1,of,4,V2] clone: move file stream walk to a separate function

login
register
mail settings
Submitter Durham Goode
Date May 7, 2013, 3:14 a.m.
Message ID <672183bf736b04570576.1367896487@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1578/
State Superseded, archived
Commit aae14b3d0a9c4c95db7e9073b828516ed9152c9b
Delegated to: Augie Fackler
Headers show

Comments

Durham Goode - May 7, 2013, 3:14 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1367429921 25200
#      Wed May 01 10:38:41 2013 -0700
# Node ID 672183bf736b045705760066ef102a0a4cb52cca
# Parent  a718a0ba6787ae9546d0aa453c8a7dae25d4405b
clone: move file stream walk to a separate function

Moves the file walk out of the stream method so that extensions can override it.
Also adds store.topfiles() that only walks the non data/ files.

This allows an extension to decide what files should be streamed, and in
particular allows a stream without filelogs.

Patch

diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -322,13 +322,16 @@ 
     def datafiles(self):
         return self._walk('data', True)
 
+    def topfiles(self):
+        return reversed(self._walk('', False))
+
     def walk(self):
         '''yields (unencoded, encoded, size)'''
         # yield data files first
         for x in self.datafiles():
             yield x
         # yield manifest before changelog
-        for x in reversed(self._walk('', False)):
+        for x in self.topfiles():
             yield x
 
     def copylist(self):
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -523,6 +523,10 @@ 
 def _allowstream(ui):
     return ui.configbool('server', 'uncompressed', True, untrusted=True)
 
+def _walkstreamfiles(repo):
+    # this is it's own function so extensions can override it
+    return repo.store.walk()
+
 def stream(repo, proto):
     '''If the server supports streaming clone, it advertises the "stream"
     capability with a value representing the version and flags of the repo
@@ -544,7 +548,7 @@ 
         lock = repo.lock()
         try:
             repo.ui.debug('scanning\n')
-            for name, ename, size in repo.store.walk():
+            for name, ename, size in _walkstreamfiles(repo):
                 if size:
                     entries.append((name, size))
                     total_bytes += size