##// END OF EJS Templates
phases: basic I/O logic...
Pierre-Yves David -
r15418:cf729af2 default
parent child Browse files
Show More
@@ -8,7 +8,7 b''
8 from node import bin, hex, nullid, nullrev, short
8 from node import bin, hex, nullid, nullrev, short
9 from i18n import _
9 from i18n import _
10 import repo, changegroup, subrepo, discovery, pushkey
10 import repo, changegroup, subrepo, discovery, pushkey
11 import changelog, dirstate, filelog, manifest, context, bookmarks
11 import changelog, dirstate, filelog, manifest, context, bookmarks, phases
12 import lock, transaction, store, encoding
12 import lock, transaction, store, encoding
13 import scmutil, util, extensions, hook, error, revset
13 import scmutil, util, extensions, hook, error, revset
14 import match as matchmod
14 import match as matchmod
@@ -170,6 +170,10 b' class localrepository(repo.repository):'
170 def _writebookmarks(self, marks):
170 def _writebookmarks(self, marks):
171 bookmarks.write(self)
171 bookmarks.write(self)
172
172
173 @filecache('phaseroots')
174 def _phaseroots(self):
175 return phases.readroots(self)
176
173 @filecache('00changelog.i', True)
177 @filecache('00changelog.i', True)
174 def changelog(self):
178 def changelog(self):
175 c = changelog.changelog(self.sopener)
179 c = changelog.changelog(self.sopener)
@@ -7,5 +7,33 b''
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()
General Comments 0
You need to be logged in to leave comments. Login now