Patchwork [evolve-ext-V2] inhibit: move transaction wrapping outside of repo setup

login
register
mail settings
Submitter Laurent Charignon
Date June 16, 2015, 6:17 p.m.
Message ID <c203f07c665e960f348b.1434478622@lcharignon-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/9680/
State Accepted
Headers show

Comments

Laurent Charignon - June 16, 2015, 6:17 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1434474471 25200
#      Tue Jun 16 10:07:51 2015 -0700
# Node ID c203f07c665e960f348b7b4f0a947565f15a8c22
# Parent  5c13945b32fc4bcb4998a1bdd0b669ac43c26574
inhibit: move transaction wrapping outside of repo setup

Before this patch, transaction wrapping code was done in reposetup. It happened
to cause stackoverflows in repos with a lot of subreps.

This patch moves the wrapping to extsetup and avoids this problem.
Pierre-Yves David - June 16, 2015, 6:30 p.m.
On 06/16/2015 11:17 AM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1434474471 25200
> #      Tue Jun 16 10:07:51 2015 -0700
> # Node ID c203f07c665e960f348b7b4f0a947565f15a8c22
> # Parent  5c13945b32fc4bcb4998a1bdd0b669ac43c26574
> inhibit: move transaction wrapping outside of repo setup
>
> Before this patch, transaction wrapping code was done in reposetup. It happened
> to cause stackoverflows in repos with a lot of subreps.
>
> This patch moves the wrapping to extsetup and avoids this problem.

Actually the issue here is that we are hackily wrapper the base class 
method instead of adding a repo class as other extensions do.

eg: https://selenic.com/hg/file/a69983942fb4/hgext/keyword.py#l594

In addition of fixing this bug, it will properly restrict the feature to 
the repository it is enabled for.

I've pushed this patch to make the topic move forward. (buit we should 
do the above)

Patch

diff --git a/hgext/inhibit.py b/hgext/inhibit.py
--- a/hgext/inhibit.py
+++ b/hgext/inhibit.py
@@ -48,9 +48,6 @@  def reposetup(ui, repo):
             return newnode
 
     repo.__class__ = obsinhibitedrepo
-    # Wrapping this to inhibit obsolete revs resulting from a transaction
-    extensions.wrapfunction(localrepo.localrepository,
-                            'transaction', transactioncallback)
 
 def _update(orig, ui, repo, *args, **kwargs):
     """
@@ -199,6 +196,11 @@  def extsetup(ui):
     except KeyError:
         errormsg = _('Cannot use inhibit without the direct access extension')
         raise error.Abort(errormsg)
+
+    # Wrapping this to inhibit obsolete revs resulting from a transaction
+    extensions.wrapfunction(localrepo.localrepository,
+                            'transaction', transactioncallback)
+
     obsolete.cachefuncs['obsolete'] = _computeobsoleteset
     # wrap create marker to make it able to lift the inhibition
     extensions.wrapfunction(obsolete, 'createmarkers', _createmarkers)