Mercurial > hg
comparison tests/test-issue2137.t @ 17802:a421459b83c0
test: use proper subclassing in `test-issue2137.t`.
To use changelog filtering on the repository, we plan to use "proxy" object that
perfectly mock a repository but with a filtered changelog.
Altering the `repo.commit` function using `extensions.wrapfunction` will prevent
the logic to propagate to the proxy class by the mean of inheritance.
We changes the extension to use subclassing as expectable.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 16 Oct 2012 23:12:07 +0200 |
parents | f2719b387380 |
children | 2fc86d92c4a9 |
comparison
equal
deleted
inserted
replaced
17801:03554dfc7ced | 17802:a421459b83c0 |
---|---|
10 | 10 |
11 $ cat > commitwrapper.py <<EOF | 11 $ cat > commitwrapper.py <<EOF |
12 > from mercurial import extensions, node, revlog | 12 > from mercurial import extensions, node, revlog |
13 > | 13 > |
14 > def reposetup(ui, repo): | 14 > def reposetup(ui, repo): |
15 > def wrapcommit(orig, *args, **kwargs): | 15 > class wraprepo(repo.__class__): |
16 > result = orig(*args, **kwargs) | 16 > def commit(self, *args, **kwargs): |
17 > tip1 = node.short(repo.changelog.tip()) | 17 > result = super(wraprepo, self).commit(*args, **kwargs) |
18 > tip2 = node.short(repo.lookup(tip1)) | 18 > tip1 = node.short(repo.changelog.tip()) |
19 > assert tip1 == tip2 | 19 > tip2 = node.short(repo.lookup(tip1)) |
20 > ui.write('new tip: %s\n' % tip1) | 20 > assert tip1 == tip2 |
21 > return result | 21 > ui.write('new tip: %s\n' % tip1) |
22 > | 22 > return result |
23 > extensions.wrapfunction(repo, 'commit', wrapcommit) | 23 > repo.__class__ = wraprepo |
24 > | 24 > |
25 > def extsetup(ui): | 25 > def extsetup(ui): |
26 > revlog._maxinline = 8 # split out 00changelog.d early | 26 > revlog._maxinline = 8 # split out 00changelog.d early |
27 > revlog._prereadsize = 8 # use revlog.lazyparser | 27 > revlog._prereadsize = 8 # use revlog.lazyparser |
28 > EOF | 28 > EOF |