##// END OF EJS Templates
bookmarks: make sure we close the bookmark file after reading...
marmoute -
r32794:6f775d10 default
parent child Browse files
Show More
@@ -56,25 +56,25 class bmstore(dict):
56 tonode = bin # force local lookup
56 tonode = bin # force local lookup
57 setitem = dict.__setitem__
57 setitem = dict.__setitem__
58 try:
58 try:
59 bkfile = _getbkfile(repo)
59 with _getbkfile(repo) as bkfile:
60 for line in bkfile:
60 for line in bkfile:
61 line = line.strip()
61 line = line.strip()
62 if not line:
62 if not line:
63 continue
63 continue
64 try:
64 try:
65 sha, refspec = line.split(' ', 1)
65 sha, refspec = line.split(' ', 1)
66 node = tonode(sha)
66 node = tonode(sha)
67 if node in nm:
67 if node in nm:
68 refspec = encoding.tolocal(refspec)
68 refspec = encoding.tolocal(refspec)
69 setitem(self, refspec, node)
69 setitem(self, refspec, node)
70 except (TypeError, ValueError):
70 except (TypeError, ValueError):
71 # TypeError:
71 # TypeError:
72 # - bin(...)
72 # - bin(...)
73 # ValueError:
73 # ValueError:
74 # - node in nm, for non-20-bytes entry
74 # - node in nm, for non-20-bytes entry
75 # - split(...), for string without ' '
75 # - split(...), for string without ' '
76 repo.ui.warn(_('malformed line in .hg/bookmarks: %r\n')
76 repo.ui.warn(_('malformed line in .hg/bookmarks: %r\n')
77 % line)
77 % line)
78 except IOError as inst:
78 except IOError as inst:
79 if inst.errno != errno.ENOENT:
79 if inst.errno != errno.ENOENT:
80 raise
80 raise
General Comments 0
You need to be logged in to leave comments. Login now