8 import revlog |
8 import revlog |
9 |
9 |
10 class filelog(revlog.revlog): |
10 class filelog(revlog.revlog): |
11 def __init__(self, opener, path): |
11 def __init__(self, opener, path): |
12 revlog.revlog.__init__(self, opener, |
12 revlog.revlog.__init__(self, opener, |
13 "/".join(("data", self.encodedir(path + ".i")))) |
13 "/".join(("data", path + ".i"))) |
14 |
|
15 # This avoids a collision between a file named foo and a dir named |
|
16 # foo.i or foo.d |
|
17 def encodedir(self, path): |
|
18 return (path |
|
19 .replace(".hg/", ".hg.hg/") |
|
20 .replace(".i/", ".i.hg/") |
|
21 .replace(".d/", ".d.hg/")) |
|
22 |
|
23 def decodedir(self, path): |
|
24 return (path |
|
25 .replace(".d.hg/", ".d/") |
|
26 .replace(".i.hg/", ".i/") |
|
27 .replace(".hg.hg/", ".hg/")) |
|
28 |
14 |
29 def read(self, node): |
15 def read(self, node): |
30 t = self.revision(node) |
16 t = self.revision(node) |
31 if not t.startswith('\1\n'): |
17 if not t.startswith('\1\n'): |
32 return t |
18 return t |