Mercurial > hgsubversion
view README @ 1550:67b28d657f62
sqliterevmap: break ".hashes()" cycle in a safer way
The `fromsvn()` revset implementation could cause weakref error when using
sqliterevmap like:
File "hgsubversion/util.py", line 357, in <lambda>
return subset.filter(lambda r: tonode(r) in hashes)
File "hgsubversion/maps.py", line 542, in __contains__
return self.get(key) != None
File "hgsubversion/maps.py", line 533, in get
for row in self.revmap._query(
ReferenceError: weakly-referenced object no longer exists
Basically the seemingly harmless assignment could break surprisingly:
# dangerous: `hashes` does not have a reference of `meta.revmap` and may
# become unavailable after `meta`, `revmap` being released by refcount.
hashes = meta.revmap.hashes()
The above syntax is nice to support while avoiding cycles is also nice.
This patch removes `revmap._hashes` so the revmap no longer owns a reference
of a `ReverseRevMap` object so the `ReverseRevMap` object no longer needs to
use weakref for `self.revmap`.
This could actually be caught by `comprehensive/test_sqlite_revmap.py`.
I was not careful enough verifying the "fromsvn()" patch.
author | Jun Wu <quark@fb.com> |
---|---|
date | Thu, 21 Dec 2017 17:39:52 -0800 |
parents | 3df6ed4e7561 |
children | b06be5815692 |
line wrap: on
line source
.. -*-restructuredtext-*- ============ hgsubversion ============ hgsubversion is an extension for Mercurial that allows using Mercurial as a Subversion client. At this point, hgsubversion is usable by users reasonably familiar with Mercurial as a VCS. It's not recommended to dive into hgsubversion as an introduction to Mercurial, since hgsubversion "bends the rules" a little and violates some of the typical assumptions of early Mercurial users. Installation ------------ You need to have either have Subversion 1.5 (or later) installed along with either Subvertpy 0.7.4 (or later) or the Subversion SWIG Python bindings. You need Mercurial 2.0 or later. .. _mercurial: http://selenic.com/repo/hg .. _mercurial-stable: http://selenic.com/repo/hg-stable .. _crew: http://hg.intevation.org/mercurial/crew .. _crew-stable: http://hg.intevation.org/mercurial/crew-stable If you are unfamiliar with installing Mercurial extensions, please see the UsingExtensions_ page in the Mercurial wiki. Look at the example for specifying an absolute path near the bottom of the page. You want to give the path to the top level of your clone of this repository. .. _UsingExtensions: http://mercurial.selenic.com/wiki/UsingExtensions Before using hgsubversion, I *strongly* encourage you to run the automated tests. Just use nose_ if you have it (or ``easy_install nose`` if you want it), or use ``python tests/run.py`` to run the suite with the conventional test runner. Note that because I use nose, there's a lot of stdout spew in the tests right now. The important part is that all the tests pass. .. _nose: http://code.google.com/p/python-nose/ You can check that hgsubversion is installed and properly activated using the following command:: $ hg version --svn Mercurial Distributed SCM (version ...) Copyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. hgsubversion: ... Subversion: ... bindings: Subvertpy ... If your bindings are listed as `SWIG`, please consider installing Subvertpy_. .. _Subvertpy: http://pypi.python.org/pypi/subvertpy Further Reading --------------- More information on how to use hgsubversion is available from within Mercurial in the `subversion` help topic. To view it, use:: $ hg help subversion The Restructured Text source for this topic is also available in the file ``hgsubverson/help/subversion.rst``.