Show More
@@ -0,0 +1,43 b'' | |||||
|
1 | #!/usr/bin/env python | |||
|
2 | import sys, os, sha, base64, re | |||
|
3 | from mercurial import hg | |||
|
4 | ||||
|
5 | ui = hg.ui() | |||
|
6 | repo = hg.repository(ui=ui) | |||
|
7 | known = {} | |||
|
8 | ||||
|
9 | def encodepath(path): | |||
|
10 | s = sha.sha(path).digest() | |||
|
11 | s = base64.encodestring(s)[:-3] | |||
|
12 | s = re.sub("\+", "%", s) | |||
|
13 | s = re.sub("/", "_", s) | |||
|
14 | return s | |||
|
15 | ||||
|
16 | for i in range(repo.changelog.count()): | |||
|
17 | n = repo.changelog.node(i) | |||
|
18 | changes = repo.changelog.read(n) | |||
|
19 | for f in changes[3]: | |||
|
20 | known[f] = 1 | |||
|
21 | ||||
|
22 | try: | |||
|
23 | os.mkdir(".hg/data-new") | |||
|
24 | except: | |||
|
25 | pass | |||
|
26 | ||||
|
27 | files = known.keys() | |||
|
28 | files.sort() | |||
|
29 | for f in files: | |||
|
30 | pb = ".hg/data/" + encodepath(f) | |||
|
31 | pn = ".hg/data-new/" + f | |||
|
32 | print f | |||
|
33 | try: | |||
|
34 | file(pn+".i", "w").write(file(pb+"i").read()) | |||
|
35 | except: | |||
|
36 | os.makedirs(os.path.dirname(pn)) | |||
|
37 | # we actually copy the files to get nice disk layout | |||
|
38 | file(pn+".i", "w").write(file(pb+"i").read()) | |||
|
39 | ||||
|
40 | file(pn+".d", "w").write(file(pb).read()) | |||
|
41 | ||||
|
42 | os.rename(".hg/data", ".hg/data-old") | |||
|
43 | os.rename(".hg/data-new", ".hg/data") |
General Comments 0
You need to be logged in to leave comments.
Login now