Mercurial > public > mercurial-scm > hg
comparison mercurial/hg.py @ 786:902b12d55751
Fix the directory and revlog collision problem
This adds escaping for directory names so that directory foo.i doesn't
collide with the revision data for file foo.
author | mpm@selenic.com |
---|---|
date | Wed, 27 Jul 2005 18:50:32 -0800 |
parents | 46a8dd3145cc |
children | 64d2a558c943 445970ccf57a 80fd2958235a |
comparison
equal
deleted
inserted
replaced
785:46a8dd3145cc | 786:902b12d55751 |
---|---|
14 demandload(globals(), "bisect select") | 14 demandload(globals(), "bisect select") |
15 | 15 |
16 class filelog(revlog): | 16 class filelog(revlog): |
17 def __init__(self, opener, path): | 17 def __init__(self, opener, path): |
18 revlog.__init__(self, opener, | 18 revlog.__init__(self, opener, |
19 os.path.join("data", path + ".i"), | 19 os.path.join("data", self.encodedir(path + ".i")), |
20 os.path.join("data", path + ".d")) | 20 os.path.join("data", self.encodedir(path + ".d"))) |
21 | |
22 # This avoids a collision between a file named foo and a dir named | |
23 # foo.i or foo.d | |
24 def encodedir(self, path): | |
25 path.replace(".hg/", ".hg.hg/") | |
26 path.replace(".i/", ".i.hg/") | |
27 path.replace(".d/", ".i.hg/") | |
28 return path | |
29 | |
30 def decodedir(self, path): | |
31 path.replace(".d.hg/", ".d/") | |
32 path.replace(".i.hg/", ".i/") | |
33 path.replace(".hg.hg/", ".hg/") | |
34 return path | |
21 | 35 |
22 def read(self, node): | 36 def read(self, node): |
23 t = self.revision(node) | 37 t = self.revision(node) |
24 if not t.startswith('\1\n'): | 38 if not t.startswith('\1\n'): |
25 return t | 39 return t |