##// END OF EJS Templates
transaction: allow running file generators after finalizers...
transaction: allow running file generators after finalizers Previously, transaction.close would run the file generators before running the finalizers (see the list below for what is in each). Since file generators contain the bookmarks and the dirstate, this meant we made the dirstate and bookmarks visible to external readers before we actually wrote the commits into the changelog, which could result in missing bookmarks and missing working copy parents (especially on servers with high commit throughput, since pulls might fail to see certain bookmarks in this situation). By moving the changelog writing to be before the bookmark/dirstate writing, we ensure the commits are present before they are referenced. This implementation allows certain file generators to be after the finalizers. We didn't want to move all of the generators, since it's important that things like phases actually run before the finalizers (otherwise you could expose commits as public when they really shouldn't be). For reference, file generators currently consist of: bookmarks, dirstate, and phases. Finalizers currently consist of: changelog, revbranchcache, and fncache.

File last commit:

r28213:93b5c540 default
r28830:a5009789 default
Show More
test-template-engine.t
47 lines | 1.3 KiB | text/troff | Tads3Lexer
/ tests / test-template-engine.t
$ cat > engine.py << EOF
>
> from mercurial import templater
>
> class mytemplater(object):
> def __init__(self, loader, filters, defaults):
> self.loader = loader
>
> def process(self, t, map):
> tmpl = self.loader(t)
> for k, v in map.iteritems():
> if k in ('templ', 'ctx', 'repo', 'revcache', 'cache'):
> continue
> if hasattr(v, '__call__'):
> v = v(**map)
> v = templater.stringify(v)
> tmpl = tmpl.replace('{{%s}}' % k, v)
> yield tmpl
>
> templater.engines['my'] = mytemplater
> EOF
$ hg init test
$ echo '[extensions]' > test/.hg/hgrc
$ echo "engine = `pwd`/engine.py" >> test/.hg/hgrc
$ cd test
$ cat > mymap << EOF
> changeset = my:changeset.txt
> EOF
$ cat > changeset.txt << EOF
> {{rev}} {{node}} {{author}}
> EOF
$ hg ci -Ama
adding changeset.txt
adding mymap
$ hg log --style=./mymap
0 97e5f848f0936960273bbf75be6388cd0350a32b test
$ cat > changeset.txt << EOF
> {{p1rev}} {{p1node}} {{p2rev}} {{p2node}}
> EOF
$ hg ci -Ama
$ hg log --style=./mymap
0 97e5f848f0936960273bbf75be6388cd0350a32b -1 0000000000000000000000000000000000000000
-1 0000000000000000000000000000000000000000 -1 0000000000000000000000000000000000000000
$ cd ..