Mercurial > hg
view tests/test-custom-filters.t @ 39291:9f097214fbf3
index: embed nodetree in index object to avoid reference cycle
Since the index has a reference to a nodetree and the nodetree has a
reference back to the index, there is a reference cycle, so the index
(and its nodetree) can never be freed. This patch fixes that by making
"nodetree" a plan C struct that the index can embed, and also
introduces a new "nodetreeObject" that is a Python type wrapping the
nodetree struct.
Thanks to Yuya for noticing this and for suggesting the solution.
All tests passed on the first attempt once it compiled (I guess C is
like Haskell in this regard?).
Differential Revision: https://phab.mercurial-scm.org/D4372
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 24 Aug 2018 08:45:18 -0700 |
parents | 6e713711331b |
children | ee9981bc8b44 |
line wrap: on
line source
$ hg init $ cat > .hg/hgrc <<EOF > [extensions] > prefixfilter = prefix.py > [encode] > *.txt = stripprefix: Copyright 2046, The Masters > [decode] > *.txt = insertprefix: Copyright 2046, The Masters > EOF $ cat > prefix.py <<EOF > from mercurial import error > def stripprefix(s, cmd, filename, **kwargs): > header = b'%s\n' % cmd > if s[:len(header)] != header: > raise error.Abort(b'missing header "%s" in %s' % (cmd, filename)) > return s[len(header):] > def insertprefix(s, cmd): > return b'%s\n%s' % (cmd, s) > def reposetup(ui, repo): > repo.adddatafilter(b'stripprefix:', stripprefix) > repo.adddatafilter(b'insertprefix:', insertprefix) > EOF $ cat > .hgignore <<EOF > .hgignore > prefix.py > prefix.pyc > EOF $ cat > stuff.txt <<EOF > Copyright 2046, The Masters > Some stuff to ponder very carefully. > EOF $ hg add stuff.txt $ hg ci -m stuff Repository data: $ hg cat stuff.txt Some stuff to ponder very carefully. Fresh checkout: $ rm stuff.txt $ hg up -C 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cat stuff.txt Copyright 2046, The Masters Some stuff to ponder very carefully. $ echo "Very very carefully." >> stuff.txt $ hg stat M stuff.txt $ echo "Unauthorized material subject to destruction." > morestuff.txt Problem encoding: $ hg add morestuff.txt $ hg ci -m morestuff abort: missing header "Copyright 2046, The Masters" in morestuff.txt [255] $ hg stat M stuff.txt A morestuff.txt