[PATCH] Work around weird mq interaction with debugsetparents.

Alexis S. L. Carvalho alexis at cecm.usp.br
Sun Jul 16 04:11:57 UTC 2006


Hi

Right now if you enable mq and try to use debugsetparents, the command
fails and gives you an interesting:

Exception exceptions.ImportError: 'No module named tempfile' in <bound method dirstate.__del__ of <mercurial.dirstate.dirstate object at 0xb7aefe2c>> ignored

>From the mq side of things, the problem is the reference to the repo
that is kept in the repomap dict.

I'm not sure what's the correct way to fix this.  The patch below
changes repomap from a dict into a weakref.WeakKeyDictionary.  It's
slower than a regular dict, but since it's used only once per command it
shouldn't make much difference.

Another option would be to add an explicit repo.dirstate.write() to the
end of the debugsetparents function in commands.py .

Alexis

# HG changeset patch
# User Alexis S. L. Carvalho <alexis at cecm.usp.br>
# Date 1153022399 10800
# Node ID 9bdd38645cde56de88cbf6b2980f862668d6216e
# Parent  00fc88b0b256ab2117f10bddf4c5aeadd0f4aab2
Work around weird mq interaction with debugsetparents.

With mq enabled, debugsetparents was failing and printing something like:

Exception exceptions.ImportError: 'No module named tempfile' in <bound method dirstate.__del__ of <mercurial.dirstate.dirstate object at 0xb7aefe2c>> ignored

>From the mq side of things, the problem is the reference kept in the
repomap dictionary.  Change it to a WeakKeyDictionary.

diff -r 00fc88b0b256 -r 9bdd38645cde hgext/mq.py
--- a/hgext/mq.py	Wed Jul 12 08:59:20 2006 -0700
+++ b/hgext/mq.py	Sun Jul 16 00:59:59 2006 -0300
@@ -30,13 +30,13 @@ refresh contents of top applied patch   
 '''
 
 from mercurial.demandload import *
-demandload(globals(), "os sys re struct traceback errno bz2")
+demandload(globals(), "os sys re struct traceback errno bz2 weakref")
 from mercurial.i18n import gettext as _
 from mercurial import ui, hg, revlog, commands, util
 
 versionstr = "0.45"
 
-repomap = {}
+repomap = None
 
 commands.norepo += " qversion"
 class queue:
@@ -1271,6 +1271,9 @@ def version(ui, q=None):
     return 0
 
 def reposetup(ui, repo):
+    global repomap
+    if not repomap:
+        repomap = weakref.WeakKeyDictionary()
     repomap[repo] = queue(ui, repo.join(""))
 
 cmdtable = {



More information about the Mercurial mailing list