Patchwork mq: use an unfiltered property cache for the queue object

login
register
mail settings
Submitter Pierre-Yves David
Date July 14, 2013, 3:29 p.m.
Message ID <d4fa058cf19f09424bbc.1373815747@yamac.lan>
Download mbox | patch
Permalink /patch/1891/
State Accepted
Commit 19622224559bc68fb6b32b1cc0d5920aa77b4c40
Headers show

Comments

Pierre-Yves David - July 14, 2013, 3:29 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1373815387 -7200
#      Sun Jul 14 17:23:07 2013 +0200
# Node ID d4fa058cf19f09424bbc274825724fb78682b0f5
# Parent  41c4bdd1d585a9196bd6c668fd9fce5e67a1028a
mq: use an unfiltered property cache for the queue object

The same `queue` object should be used in all situations. This allows to store
global states on the object (like the reworked shelve extension plans to).  The
queue object does not need to be distinct for all possible views (no reference
to the repo/view used at creation time) it's even a bit surprising that mq still
works with the current code.
Augie Fackler - July 16, 2013, 3:20 p.m.
On Sun, Jul 14, 2013 at 05:29:07PM +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1373815387 -7200
> #      Sun Jul 14 17:23:07 2013 +0200
> # Node ID d4fa058cf19f09424bbc274825724fb78682b0f5
> # Parent  41c4bdd1d585a9196bd6c668fd9fce5e67a1028a
> mq: use an unfiltered property cache for the queue object

Queued, with regret that I had to read mq.py.

>
> The same `queue` object should be used in all situations. This allows to store
> global states on the object (like the reworked shelve extension plans to).  The
> queue object does not need to be distinct for all possible views (no reference
> to the repo/view used at creation time) it's even a bit surprising that mq still
> works with the current code.
>
> diff --git a/hgext/mq.py b/hgext/mq.py
> --- a/hgext/mq.py
> +++ b/hgext/mq.py
> @@ -63,10 +63,11 @@ from mercurial.i18n import _
>  from mercurial.node import bin, hex, short, nullid, nullrev
>  from mercurial.lock import release
>  from mercurial import commands, cmdutil, hg, scmutil, util, revset
>  from mercurial import repair, extensions, error, phases
>  from mercurial import patch as patchmod
> +from mercurial import localrepo
>  import os, re, errno, shutil
>
>  commands.norepo += " qclone"
>
>  seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
> @@ -3408,11 +3409,11 @@ def mqphasedefaults(repo, roots):
>          roots[mqphase].add(qbase.node())
>      return roots
>
>  def reposetup(ui, repo):
>      class mqrepo(repo.__class__):
> -        @util.propertycache
> +        @localrepo.unfilteredpropertycache
>          def mq(self):
>              return queue(self.ui, self.baseui, self.path)
>
>          def abortifwdirpatched(self, errmsg, force=False):
>              if self.mq.applied and not force:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Bryan O'Sullivan - July 19, 2013, 4 p.m.
On Sun, Jul 14, 2013 at 8:29 AM, Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

> The same `queue` object should be used in all situations. This allows to
> store
> global states on the object (like the reworked shelve extension plans to).
>

I tried the shelve extension after this commit, and while it might be "more
correct", it made no difference to the underlying bug: I still see the mq
object getting recreated on every access.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -63,10 +63,11 @@  from mercurial.i18n import _
 from mercurial.node import bin, hex, short, nullid, nullrev
 from mercurial.lock import release
 from mercurial import commands, cmdutil, hg, scmutil, util, revset
 from mercurial import repair, extensions, error, phases
 from mercurial import patch as patchmod
+from mercurial import localrepo
 import os, re, errno, shutil
 
 commands.norepo += " qclone"
 
 seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
@@ -3408,11 +3409,11 @@  def mqphasedefaults(repo, roots):
         roots[mqphase].add(qbase.node())
     return roots
 
 def reposetup(ui, repo):
     class mqrepo(repo.__class__):
-        @util.propertycache
+        @localrepo.unfilteredpropertycache
         def mq(self):
             return queue(self.ui, self.baseui, self.path)
 
         def abortifwdirpatched(self, errmsg, force=False):
             if self.mq.applied and not force: