Provide an option to disable the SQLite database
authorGregory Szorc <gps@mozilla.com>
Wed, 08 Jan 2014 19:09:31 -0800
changeset 91 3605ab6652f4
parent 90 59159168b2c9
child 92 45ce73b8f29e
push id66
push usergszorc@mozilla.com
push date2014-01-09 03:09 +0000
Provide an option to disable the SQLite database It is a hacky implementation and isn't complete.
__init__.py
--- a/__init__.py
+++ b/__init__.py
@@ -254,16 +254,20 @@ mozext.ircnick
 mozext.noautocritic
    When this boolean flag is true, the code critic hook will not run
    during commit and qrefresh operations.
 
 mozext.critic_merges
    When this boolean flag is true, the code critic hook will run on merges.
    By default, the hook does not run on merges.
 
+mozext.disable_local_database
+   When this boolean flag is true, the local SQLite database indexing
+   useful lookups (such as bugs and pushlog info) is not enabled.
+
 mozext.reject_pushes_with_repo_names
    This boolean is used to enable a ``prepushkey`` hook that prevents
    pushes to keys (bookmarks, tags, etc) whose name is prefixed with that
    of an official Mozilla repository.
 
    This hook is useful for servers exposing a monolithic repository where
    each separate Mozilla repository is exposed through bookmarks and where
    the server does not want to allow external users from changing the
@@ -585,24 +589,32 @@ def syncpushinfo(ui, repo, tree=None, **
     """Synchronize the pushlog information for all known Gecko trees.
 
     The pushlog info contains who, when, and where individual changesets were
     pushed.
 
     After running this command, you can query for push information for specific
     changesets.
     """
+    if not repo.changetracker:
+        ui.warn('Local database appears to be disabled.')
+        return 1
+
     for i, tree in enumerate(sorted(REPOS)):
         repo.changetracker.load_pushlog(tree)
         ui.progress('pushlogsync', i, total=len(REPOS))
 
     ui.progress('pushlogsync', None)
 
 
 def print_changeset_pushes(ui, repo, rev, all=False):
+    if not repo.changetracker:
+        ui.warn('Local database appears to be disabled.')
+        return 1
+
     ctx = repo[rev]
     node = ctx.node()
 
     pushes = repo.changetracker.pushes_for_changeset(node)
     pushes = [p for p in pushes if all or p[0] in RELEASE_TREES]
     if not pushes:
         ui.warn('No pushes recorded for changeset: ', str(ctx), '\n')
         return 1
@@ -651,16 +663,20 @@ def changesetpushes(ui, repo, rev, all=F
 
 
 @command('buginfo', [
     ('a', 'all', False, _('Show all trees, not just release trees.'), ''),
     ('', 'reset', False, _('Wipe and repopulate the bug database.'), ''),
     ('', 'sync', False, _('Synchronize the bug database.'), ''),
     ], _('hg buginfo [BUG] ...'))
 def buginfo(ui, repo, *bugs, **opts):
+    if not repo.changetracker:
+        ui.warning('Local database appears to be disabled')
+        return 1
+
     if opts['sync']:
         repo.sync_bug_database()
         return
 
     if opts['reset']:
         repo.reset_bug_database()
         return
 
@@ -1261,16 +1277,18 @@ def reposetup(ui, repo):
 
     class remotestrackingrepo(repo.__class__):
         @repofilecache('remoterefs')
         def remoterefs(self):
             return remoterefs(self)
 
         @util.propertycache
         def changetracker(self):
+            if ui.configbool('mozext', 'disable_local_database'):
+                return None
             try:
                 return ChangeTracker(self.join('changetracker.db'))
             except Exception as e:
                 raise util.Abort(e.message)
 
         # Resolve remote ref symbols. For some reason, we need both lookup
         # and findtags implemented.
         def lookup(self, key):
@@ -1293,23 +1311,24 @@ def reposetup(ui, repo):
             old_rev = len(self)
             res = orig_pull(remote, *args, **kwargs)
             lock = self.wlock()
             try:
                 tree = resolve_uri_to_tree(remote.url())
 
                 if tree:
                     self._update_remote_refs(remote, tree)
-                    self.changetracker.load_pushlog(tree)
+                    if self.changetracker:
+                        self.changetracker.load_pushlog(tree)
 
                 # Sync bug info.
                 for rev in self.changelog.revs(old_rev + 1):
                     ctx = self[rev]
                     bugs = parse_bugs(ctx.description())
-                    if bugs:
+                    if bugs and self.changetracker:
                         self.changetracker.associate_bugs_with_changeset(bugs,
                             ctx.node())
 
             finally:
                 lock.release()
 
             return res
 
@@ -1444,20 +1463,26 @@ def reposetup(ui, repo):
                 ancestors = set(self.changelog.findmissingrevs(
                     common=seen, heads=[version_rev]))
                 d[version] = ancestors
                 seen |= ancestors
 
             return d
 
         def reset_bug_database(self):
+            if not self.changetracker:
+                return
+
             self.changetracker.wipe_bugs()
             self.sync_bug_database()
 
         def sync_bug_database(self):
+            if not self.changetracker:
+                return
+
             for rev in self:
                 ui.progress('changeset', rev, total=len(self))
                 ctx = self[rev]
                 bugs = parse_bugs(ctx.description())
                 if bugs:
                     self.changetracker.associate_bugs_with_changeset(bugs,
                         ctx.node())