##// END OF EJS Templates
narrow: remove unused "cacheprop" stuff...
Martin von Zweigbergk -
r37398:c3c76194 default
parent child Browse files
Show More
@@ -1,75 +1,65 b''
1 # narrowrepo.py - repository which supports narrow revlogs, lazy loading
1 # narrowrepo.py - repository which supports narrow revlogs, lazy loading
2 #
2 #
3 # Copyright 2017 Google, Inc.
3 # Copyright 2017 Google, Inc.
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 from mercurial import (
10 from mercurial import (
11 bundlerepo,
12 changegroup,
11 changegroup,
13 hg,
12 hg,
14 localrepo,
15 narrowspec,
13 narrowspec,
16 scmutil,
14 scmutil,
17 )
15 )
18
16
19 from . import (
17 from . import (
20 narrowrevlog,
18 narrowrevlog,
21 )
19 )
22
20
23 def wrappostshare(orig, sourcerepo, destrepo, **kwargs):
21 def wrappostshare(orig, sourcerepo, destrepo, **kwargs):
24 orig(sourcerepo, destrepo, **kwargs)
22 orig(sourcerepo, destrepo, **kwargs)
25 if changegroup.NARROW_REQUIREMENT in sourcerepo.requirements:
23 if changegroup.NARROW_REQUIREMENT in sourcerepo.requirements:
26 with destrepo.wlock():
24 with destrepo.wlock():
27 with destrepo.vfs('shared', 'a') as fp:
25 with destrepo.vfs('shared', 'a') as fp:
28 fp.write(narrowspec.FILENAME + '\n')
26 fp.write(narrowspec.FILENAME + '\n')
29
27
30 def unsharenarrowspec(orig, ui, repo, repopath):
28 def unsharenarrowspec(orig, ui, repo, repopath):
31 if (changegroup.NARROW_REQUIREMENT in repo.requirements
29 if (changegroup.NARROW_REQUIREMENT in repo.requirements
32 and repo.path == repopath and repo.shared()):
30 and repo.path == repopath and repo.shared()):
33 srcrepo = hg.sharedreposource(repo)
31 srcrepo = hg.sharedreposource(repo)
34 with srcrepo.vfs(narrowspec.FILENAME) as f:
32 with srcrepo.vfs(narrowspec.FILENAME) as f:
35 spec = f.read()
33 spec = f.read()
36 with repo.vfs(narrowspec.FILENAME, 'w') as f:
34 with repo.vfs(narrowspec.FILENAME, 'w') as f:
37 f.write(spec)
35 f.write(spec)
38 return orig(ui, repo, repopath)
36 return orig(ui, repo, repopath)
39
37
40 def wraprepo(repo):
38 def wraprepo(repo):
41 """Enables narrow clone functionality on a single local repository."""
39 """Enables narrow clone functionality on a single local repository."""
42
40
43 cacheprop = localrepo.storecache
44 if isinstance(repo, bundlerepo.bundlerepository):
45 # We have to use a different caching property decorator for
46 # bundlerepo because storecache blows up in strange ways on a
47 # bundlerepo. Fortunately, there's no risk of data changing in
48 # a bundlerepo.
49 cacheprop = lambda name: localrepo.unfilteredpropertycache
50
51 class narrowrepository(repo.__class__):
41 class narrowrepository(repo.__class__):
52
42
53 def file(self, f):
43 def file(self, f):
54 fl = super(narrowrepository, self).file(f)
44 fl = super(narrowrepository, self).file(f)
55 narrowrevlog.makenarrowfilelog(fl, self.narrowmatch())
45 narrowrevlog.makenarrowfilelog(fl, self.narrowmatch())
56 return fl
46 return fl
57
47
58 # I'm not sure this is the right place to do this filter.
48 # I'm not sure this is the right place to do this filter.
59 # context._manifestmatches() would probably be better, or perhaps
49 # context._manifestmatches() would probably be better, or perhaps
60 # move it to a later place, in case some of the callers do want to know
50 # move it to a later place, in case some of the callers do want to know
61 # which directories changed. This seems to work for now, though.
51 # which directories changed. This seems to work for now, though.
62 def status(self, *args, **kwargs):
52 def status(self, *args, **kwargs):
63 s = super(narrowrepository, self).status(*args, **kwargs)
53 s = super(narrowrepository, self).status(*args, **kwargs)
64 narrowmatch = self.narrowmatch()
54 narrowmatch = self.narrowmatch()
65 modified = list(filter(narrowmatch, s.modified))
55 modified = list(filter(narrowmatch, s.modified))
66 added = list(filter(narrowmatch, s.added))
56 added = list(filter(narrowmatch, s.added))
67 removed = list(filter(narrowmatch, s.removed))
57 removed = list(filter(narrowmatch, s.removed))
68 deleted = list(filter(narrowmatch, s.deleted))
58 deleted = list(filter(narrowmatch, s.deleted))
69 unknown = list(filter(narrowmatch, s.unknown))
59 unknown = list(filter(narrowmatch, s.unknown))
70 ignored = list(filter(narrowmatch, s.ignored))
60 ignored = list(filter(narrowmatch, s.ignored))
71 clean = list(filter(narrowmatch, s.clean))
61 clean = list(filter(narrowmatch, s.clean))
72 return scmutil.status(modified, added, removed, deleted, unknown,
62 return scmutil.status(modified, added, removed, deleted, unknown,
73 ignored, clean)
63 ignored, clean)
74
64
75 repo.__class__ = narrowrepository
65 repo.__class__ = narrowrepository
General Comments 0
You need to be logged in to leave comments. Login now