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 i18n import _ |
8 from i18n import _ |
9 import osutil, scmutil, util |
9 import osutil, scmutil, util, parsers |
10 import os, stat, errno |
10 import os, stat, errno |
11 |
11 |
12 _sha = util.sha1 |
12 _sha = util.sha1 |
13 |
13 |
14 # This avoids a collision between a file named foo and a dir named |
14 # This avoids a collision between a file named foo and a dir named |
15 # foo.i or foo.d |
15 # foo.i or foo.d |
16 def encodedir(path): |
16 def _encodedir(path): |
17 ''' |
17 ''' |
18 >>> encodedir('data/foo.i') |
18 >>> _encodedir('data/foo.i') |
19 'data/foo.i' |
19 'data/foo.i' |
20 >>> encodedir('data/foo.i/bla.i') |
20 >>> _encodedir('data/foo.i/bla.i') |
21 'data/foo.i.hg/bla.i' |
21 'data/foo.i.hg/bla.i' |
22 >>> encodedir('data/foo.i.hg/bla.i') |
22 >>> _encodedir('data/foo.i.hg/bla.i') |
23 'data/foo.i.hg.hg/bla.i' |
23 'data/foo.i.hg.hg/bla.i' |
24 >>> encodedir('data/foo.i\\ndata/foo.i/bla.i\\ndata/foo.i.hg/bla.i\\n') |
24 >>> _encodedir('data/foo.i\\ndata/foo.i/bla.i\\ndata/foo.i.hg/bla.i\\n') |
25 'data/foo.i\\ndata/foo.i.hg/bla.i\\ndata/foo.i.hg.hg/bla.i\\n' |
25 'data/foo.i\\ndata/foo.i.hg/bla.i\\ndata/foo.i.hg.hg/bla.i\\n' |
26 ''' |
26 ''' |
27 return (path |
27 return (path |
28 .replace(".hg/", ".hg.hg/") |
28 .replace(".hg/", ".hg.hg/") |
29 .replace(".i/", ".i.hg/") |
29 .replace(".i/", ".i.hg/") |
30 .replace(".d/", ".d.hg/")) |
30 .replace(".d/", ".d.hg/")) |
|
31 |
|
32 encodedir = getattr(parsers, 'encodedir', _encodedir) |
31 |
33 |
32 def decodedir(path): |
34 def decodedir(path): |
33 ''' |
35 ''' |
34 >>> decodedir('data/foo.i') |
36 >>> decodedir('data/foo.i') |
35 'data/foo.i' |
37 'data/foo.i' |