changeset 1471:6bc2a2f61923

svnmeta: add a config option to use sqlite revmap This patch adds a config option to choose the revmap implementation. It's "plain" by default and can be set to "sqlite". The sqlite implementation will migrate data from the plain revmap while the "plain" implementation will complain if it sees the sqlite revmap. A class variable is added for setting the default revmap implementation, which is useful for testing.
author Jun Wu <quark@fb.com>
date Wed, 15 Jun 2016 17:17:56 +0100
parents b6e2bc962536
children cf79525f507c
files hgsubversion/help/subversion.rst hgsubversion/svnmeta.py
diffstat 2 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/help/subversion.rst
+++ b/hgsubversion/help/subversion.rst
@@ -352,6 +352,16 @@ settings:
 
         Password stores are only supported with the SWIG bindings.
 
+  ``hgsubversion.revmapimpl``
+
+    Set the revision map implementation. ``plain`` which is simple and works
+    well for small repos. ``sqlite`` is a sqlite based implementation that
+    works better for large repos with a lot of revisions. The default is
+    ``plain``.
+
+    If it is set to an implementation different from what the repo is using,
+    a migration will run automatically when the revision map is accessed.
+
   ``hgsubversion.stupid``
     Setting this boolean option to true will force using a slower method for
     pulling revisions from Subversion. This method is compatible with servers
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -345,7 +345,7 @@ class SVNMeta(object):
     @property
     def revmap(self):
         if self._revmap is None:
-            self._revmap = maps.RevMap(
+            self._revmap = self.revmapclass(
                 self.revmap_file, os.path.join(self.metapath, 'lastpulled'))
         return self._revmap
 
@@ -353,6 +353,20 @@ class SVNMeta(object):
     def revmapexists(self):
         return os.path.exists(self.revmap_file)
 
+    _defaultrevmapclass = maps.RevMap
+
+    @property
+    def revmapclass(self):
+        impl = self.ui.config('hgsubversion', 'revmapimpl')
+        if impl == 'plain':
+            return maps.RevMap
+        elif impl == 'sqlite':
+            return maps.SqliteRevMap
+        elif impl is None:
+            return self._defaultrevmapclass
+        else:
+            raise hgutil.Abort('unknown revmapimpl: %s' % impl)
+
     def fixdate(self, date):
         if date is not None:
             date = date.replace('T', ' ').replace('Z', '').split('.')[0]