Kiln » Kiln Extensions
Clone URL:  
kilnfilecache.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright (C) 2011, 2012 Fog Creek Software. All rights reserved. # # This extension is used internally by Kiln Importer. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. '''fix a _filecache invalidation bug so hg convert works See * http://our.fogbugz.com/f/cases/2338914/importer-does-not-work-with-hg-2-3-1 and * http://www.selenic.com/pipermail/mercurial-devel/2012-November/046159.html for more details. Until Mercurial fixes this bug or accepts my patch, this bug affects any tags in this revset: * hg log -r 'descendants(9f94358) and tag()' --template '{tags}\n' As of writing, that's every 2.3 release and 2.4-rc and 2.4. ''' from mercurial import util def reposetup(ui, repo): if util.version()[:3] < '2.3': # This bug was first introduced in 9f94358f9f93, which # occurred between 2.3-rc and 2.3. return from mercurial import localrepo if not issubclass(repo.__class__, localrepo.localrepository): return class kilnfilecacherepo(repo.__class__): def destroyed(self, *args, **kwargs): # By saving _filecache before it's cleared, we can # restore it and then call invalidate() afterward so # localrepo can delattr() the relevant attributes off # the repo object. See my mercurial-devel patch for # more details. oldfilecache = dict(self._filecache) super(kilnfilecacherepo, self).destroyed(*args, **kwargs) self._filecache = oldfilecache self.invalidate() repo.__class__ = kilnfilecacherepo