equal
deleted
inserted
replaced
5 # Augie Fackler <durin42@gmail.com> |
5 # Augie Fackler <durin42@gmail.com> |
6 # |
6 # |
7 # This software may be used and distributed according to the terms of the |
7 # This software may be used and distributed according to the terms of the |
8 # GNU General Public License version 2 or any later version. |
8 # GNU General Public License version 2 or any later version. |
9 |
9 |
|
10 from node import nullid, bin, hex |
|
11 |
10 allphases = range(2) |
12 allphases = range(2) |
11 trackedphases = allphases[1:] |
13 trackedphases = allphases[1:] |
|
14 |
|
15 def readroots(repo): |
|
16 """Read phase roots from disk""" |
|
17 roots = [set() for i in allphases] |
|
18 roots[0].add(nullid) |
|
19 try: |
|
20 f = repo.sopener('phaseroots') |
|
21 try: |
|
22 for line in f: |
|
23 phase, nh = line.strip().split() |
|
24 roots[int(phase)].add(bin(nh)) |
|
25 finally: |
|
26 f.close() |
|
27 except IOError: |
|
28 pass # default value are enough |
|
29 return roots |
|
30 |
|
31 def writeroots(repo): |
|
32 """Write phase roots from disk""" |
|
33 f = repo.sopener('phaseroots', 'w', atomictemp=True) |
|
34 try: |
|
35 for phase, roots in enumerate(repo._phaseroots): |
|
36 for h in roots: |
|
37 f.write('%i %s\n' % (phase, hex(h))) |
|
38 finally: |
|
39 f.close() |