Patchwork [11,of,13,sparse,V2] sparse: variable to track if sparse is enabled

login
register
mail settings
Submitter Gregory Szorc
Date July 6, 2017, 7:36 p.m.
Message ID <debc65849276c8a8df45.1499369797@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/22039/
State Accepted
Headers show

Comments

Gregory Szorc - July 6, 2017, 7:36 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1499367997 25200
#      Thu Jul 06 12:06:37 2017 -0700
# Node ID debc65849276c8a8df457a9e67ad7328f22d13c0
# Parent  bbca7c059359f585f8bb3b6ab1276769dbf1fc98
sparse: variable to track if sparse is enabled

Currently, the sparse extension sniffs repo instances for
attributes defined by the sparse extension to determine if
sparse is enabled. As we move code away from repo instances,
these checks will be a bit more brittle.

We introduce a module-level variable to track whether sparse is
enabled as a temporary workaround.

Patch

diff --git a/hgext/sparse.py b/hgext/sparse.py
--- a/hgext/sparse.py
+++ b/hgext/sparse.py
@@ -110,6 +110,8 @@  def uisetup(ui):
     _setupcommit(ui)
 
 def extsetup(ui):
+    sparse.enabled = True
+
     _setupclone(ui)
     _setuplog(ui)
     _setupadd(ui)
diff --git a/mercurial/sparse.py b/mercurial/sparse.py
--- a/mercurial/sparse.py
+++ b/mercurial/sparse.py
@@ -12,6 +12,11 @@  from . import (
     error,
 )
 
+# Whether sparse features are enabled. This variable is intended to be
+# temporary to facilitate porting sparse to core. It should eventually be
+# a per-repo option, possibly a repo requirement.
+enabled = False
+
 def parseconfig(ui, raw):
     """Parse sparse config file content.