Show More
@@ -9,7 +9,6 b' from __future__ import absolute_import' | |||
|
9 | 9 | |
|
10 | 10 | from . import ( |
|
11 | 11 | narrowdirstate, |
|
12 | narrowrevlog, | |
|
13 | 12 | narrowwirepeer, |
|
14 | 13 | ) |
|
15 | 14 | |
@@ -18,11 +17,6 b' def wraprepo(repo):' | |||
|
18 | 17 | |
|
19 | 18 | class narrowrepository(repo.__class__): |
|
20 | 19 | |
|
21 | def file(self, f): | |
|
22 | fl = super(narrowrepository, self).file(f) | |
|
23 | narrowrevlog.makenarrowfilelog(fl, self.narrowmatch()) | |
|
24 | return fl | |
|
25 | ||
|
26 | 20 | def _makedirstate(self): |
|
27 | 21 | dirstate = super(narrowrepository, self)._makedirstate() |
|
28 | 22 | return narrowdirstate.wrapdirstate(self, dirstate) |
@@ -9,7 +9,6 b' from __future__ import absolute_import' | |||
|
9 | 9 | |
|
10 | 10 | from mercurial import ( |
|
11 | 11 | revlog, |
|
12 | util, | |
|
13 | 12 | ) |
|
14 | 13 | |
|
15 | 14 | def readtransform(self, text): |
@@ -28,53 +27,3 b' def setup():' | |||
|
28 | 27 | # We just wanted to add the flag processor, which is done at module |
|
29 | 28 | # load time. |
|
30 | 29 | pass |
|
31 | ||
|
32 | def makenarrowfilelog(fl, narrowmatch): | |
|
33 | class narrowfilelog(fl.__class__): | |
|
34 | def renamed(self, node): | |
|
35 | # Renames that come from outside the narrowspec are | |
|
36 | # problematic at least for git-diffs, because we lack the | |
|
37 | # base text for the rename. This logic was introduced in | |
|
38 | # 3cd72b1 of narrowhg (authored by martinvonz, reviewed by | |
|
39 | # adgar), but that revision doesn't have any additional | |
|
40 | # commentary on what problems we can encounter. | |
|
41 | m = super(narrowfilelog, self).renamed(node) | |
|
42 | if m and not narrowmatch(m[0]): | |
|
43 | return None | |
|
44 | return m | |
|
45 | ||
|
46 | def size(self, rev): | |
|
47 | # We take advantage of the fact that remotefilelog | |
|
48 | # lacks a node() method to just skip the | |
|
49 | # rename-checking logic when on remotefilelog. This | |
|
50 | # might be incorrect on other non-revlog-based storage | |
|
51 | # engines, but for now this seems to be fine. | |
|
52 | # | |
|
53 | # TODO: when remotefilelog is in core, improve this to | |
|
54 | # explicitly look for remotefilelog instead of cheating | |
|
55 | # with a hasattr check. | |
|
56 | if util.safehasattr(self, 'node'): | |
|
57 | node = self.node(rev) | |
|
58 | # Because renamed() is overridden above to | |
|
59 | # sometimes return None even if there is metadata | |
|
60 | # in the revlog, size can be incorrect for | |
|
61 | # copies/renames, so we need to make sure we call | |
|
62 | # the super class's implementation of renamed() | |
|
63 | # for the purpose of size calculation. | |
|
64 | if super(narrowfilelog, self).renamed(node): | |
|
65 | return len(self.read(node)) | |
|
66 | return super(narrowfilelog, self).size(rev) | |
|
67 | ||
|
68 | def cmp(self, node, text): | |
|
69 | different = super(narrowfilelog, self).cmp(node, text) | |
|
70 | if different: | |
|
71 | # Similar to size() above, if the file was copied from | |
|
72 | # a file outside the narrowspec, the super class's | |
|
73 | # would have returned True because we tricked it into | |
|
74 | # thinking that the file was not renamed. | |
|
75 | if super(narrowfilelog, self).renamed(node): | |
|
76 | t2 = self.read(node) | |
|
77 | return t2 != text | |
|
78 | return different | |
|
79 | ||
|
80 | fl.__class__ = narrowfilelog |
General Comments 0
You need to be logged in to leave comments.
Login now