[PATCH] localrepo: move extension loading to a separate method

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] localrepo: move extension loading to a separate method

Jun Wu
# HG changeset patch
# User Jun Wu <[hidden email]>
# Date 1487216474 28800
#      Wed Feb 15 19:41:14 2017 -0800
# Node ID dda2ebe89f50fcf3bf5a9b8d2266aa2dd5b106ea
# Parent  e5363cb96233861fc99f7e9b85d7884d3121558c
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r dda2ebe89f50
localrepo: move extension loading to a separate method

The stateful chg plan [1] requires a special repo object, where ideally all
side effects caused by loading the repo object could be reverted by just
dropping (gabbage collect) the loaded repo object.

Currently, that is impossible because repo.__init__ calls
"extensions.loadall", which may have unpredictable side-effects that cannot
be reverted by dropping the repo object.

This patch moves "extensions.loadall" to a separate method, so chg could
subclass localrepository and make extensions loading a no-op.

[1]: mercurial-scm.org/pipermail/mercurial-devel/2017-February/092547.html

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -271,5 +271,5 @@ class localrepository(object):
         try:
             self.ui.readconfig(self.join("hgrc"), self.root)
-            extensions.loadall(self.ui)
+            self._loadextensions()
         except IOError:
             pass
@@ -372,4 +372,7 @@ class localrepository(object):
         self._writecaches()
 
+    def _loadextensions(self):
+        extensions.loadall(self.ui)
+
     def _writecaches(self):
         if self._revbranchcache:
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] localrepo: move extension loading to a separate method

Augie Fackler-2
On Wed, Feb 15, 2017 at 07:42:40PM -0800, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <[hidden email]>
> # Date 1487216474 28800
> #      Wed Feb 15 19:41:14 2017 -0800
> # Node ID dda2ebe89f50fcf3bf5a9b8d2266aa2dd5b106ea
> # Parent  e5363cb96233861fc99f7e9b85d7884d3121558c
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r dda2ebe89f50
> localrepo: move extension loading to a separate method

Queued, thanks.

>
> The stateful chg plan [1] requires a special repo object, where ideally all
> side effects caused by loading the repo object could be reverted by just
> dropping (gabbage collect) the loaded repo object.
>
> Currently, that is impossible because repo.__init__ calls
> "extensions.loadall", which may have unpredictable side-effects that cannot
> be reverted by dropping the repo object.
>
> This patch moves "extensions.loadall" to a separate method, so chg could
> subclass localrepository and make extensions loading a no-op.
>
> [1]: mercurial-scm.org/pipermail/mercurial-devel/2017-February/092547.html
>
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -271,5 +271,5 @@ class localrepository(object):
>          try:
>              self.ui.readconfig(self.join("hgrc"), self.root)
> -            extensions.loadall(self.ui)
> +            self._loadextensions()
>          except IOError:
>              pass
> @@ -372,4 +372,7 @@ class localrepository(object):
>          self._writecaches()
>
> +    def _loadextensions(self):
> +        extensions.loadall(self.ui)
> +
>      def _writecaches(self):
>          if self._revbranchcache:
> _______________________________________________
> Mercurial-devel mailing list
> [hidden email]
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel