##// END OF EJS Templates
phases: handle errors other than ENOENT appropriately
Matt Mackall -
r15419:ccb7de21 default
parent child Browse files
Show More
@@ -1,39 +1,41 b''
1 1 # Mercurial phases support code
2 2 #
3 3 # Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
4 4 # Logilab SA <contact@logilab.fr>
5 5 # Augie Fackler <durin42@gmail.com>
6 6 #
7 7 # This software may be used and distributed according to the terms of the
8 8 # GNU General Public License version 2 or any later version.
9 9
10 import errno
10 11 from node import nullid, bin, hex
11 12
12 13 allphases = range(2)
13 14 trackedphases = allphases[1:]
14 15
15 16 def readroots(repo):
16 17 """Read phase roots from disk"""
17 18 roots = [set() for i in allphases]
18 19 roots[0].add(nullid)
19 20 try:
20 21 f = repo.sopener('phaseroots')
21 22 try:
22 23 for line in f:
23 24 phase, nh = line.strip().split()
24 25 roots[int(phase)].add(bin(nh))
25 26 finally:
26 27 f.close()
27 except IOError:
28 pass # default value are enough
28 except IOError, inst:
29 if inst.errno != errno.ENOENT:
30 raise
29 31 return roots
30 32
31 33 def writeroots(repo):
32 34 """Write phase roots from disk"""
33 35 f = repo.sopener('phaseroots', 'w', atomictemp=True)
34 36 try:
35 37 for phase, roots in enumerate(repo._phaseroots):
36 38 for h in roots:
37 39 f.write('%i %s\n' % (phase, hex(h)))
38 40 finally:
39 41 f.close()
General Comments 0
You need to be logged in to leave comments. Login now