hgext/git/index.py
changeset 52628 3865451a5fab
parent 52627 4dadaf300fe0
child 52630 70b523d7a60d
--- a/hgext/git/index.py	Fri Oct 04 10:51:44 2024 -0400
+++ b/hgext/git/index.py	Fri Oct 04 10:25:24 2024 -0400
@@ -18,7 +18,7 @@
 
 pygit2 = gitutil.get_pygit2()
 
-_CURRENT_SCHEMA_VERSION = 4
+_CURRENT_SCHEMA_VERSION = 5
 _SCHEMA = (
     """
 CREATE TABLE refs (
@@ -72,6 +72,12 @@
 CREATE INDEX changedfiles_nodes_idx
   ON changedfiles(node);
 
+-- Cached values to improve performance
+CREATE TABLE cache (
+  ncommits INTEGER
+);
+INSERT INTO cache (ncommits) VALUES (NULL);
+
 PRAGMA user_version=%d
 """
     % _CURRENT_SCHEMA_VERSION
@@ -398,6 +404,13 @@
             prog.update(pos)
         _index_repo_commit(gitrepo, db, h)
 
+    db.execute(
+        '''
+    UPDATE cache SET
+        ncommits = (SELECT COUNT(1) FROM changelog)
+    '''
+    )
+
     db.commit()
     if prog is not None:
         prog.complete()