Show More
@@ -7,8 +7,8 b'' | |||||
7 |
|
7 | |||
8 | from mercurial.i18n import _ |
|
8 | from mercurial.i18n import _ | |
9 | from mercurial.node import nullid, nullrev, bin, hex, short |
|
9 | from mercurial.node import nullid, nullrev, bin, hex, short | |
10 | from mercurial import encoding, util |
|
10 | from mercurial import encoding, error, util | |
11 | import os |
|
11 | import errno, os | |
12 |
|
12 | |||
13 | def valid(mark): |
|
13 | def valid(mark): | |
14 | for c in (':', '\0', '\n', '\r'): |
|
14 | for c in (':', '\0', '\n', '\r'): | |
@@ -23,14 +23,18 b' def read(repo):' | |||||
23 | in the .hg/bookmarks file. |
|
23 | in the .hg/bookmarks file. | |
24 | Read the file and return a (name=>nodeid) dictionary |
|
24 | Read the file and return a (name=>nodeid) dictionary | |
25 | ''' |
|
25 | ''' | |
|
26 | bookmarks = {} | |||
26 | try: |
|
27 | try: | |
27 | bookmarks = {} |
|
|||
28 | for line in repo.opener('bookmarks'): |
|
28 | for line in repo.opener('bookmarks'): | |
29 | sha, refspec = line.strip().split(' ', 1) |
|
29 | sha, refspec = line.strip().split(' ', 1) | |
30 | refspec = encoding.tolocal(refspec) |
|
30 | refspec = encoding.tolocal(refspec) | |
31 | bookmarks[refspec] = repo.changelog.lookup(sha) |
|
31 | try: | |
32 | except IOError: |
|
32 | bookmarks[refspec] = repo.changelog.lookup(sha) | |
33 | pass |
|
33 | except error.RepoLookupError: | |
|
34 | pass | |||
|
35 | except IOError, inst: | |||
|
36 | if inst.errno != errno.ENOENT: | |||
|
37 | raise | |||
34 | return bookmarks |
|
38 | return bookmarks | |
35 |
|
39 | |||
36 | def readcurrent(repo): |
|
40 | def readcurrent(repo): | |
@@ -41,12 +45,18 b' def readcurrent(repo):' | |||||
41 | is stored in .hg/bookmarks.current |
|
45 | is stored in .hg/bookmarks.current | |
42 | ''' |
|
46 | ''' | |
43 | mark = None |
|
47 | mark = None | |
44 | if os.path.exists(repo.join('bookmarks.current')): |
|
48 | try: | |
45 | file = repo.opener('bookmarks.current') |
|
49 | file = repo.opener('bookmarks.current') | |
|
50 | except IOError, inst: | |||
|
51 | if inst.errno != errno.ENOENT: | |||
|
52 | raise | |||
|
53 | return None | |||
|
54 | try: | |||
46 | # No readline() in posixfile_nt, reading everything is cheap |
|
55 | # No readline() in posixfile_nt, reading everything is cheap | |
47 | mark = encoding.tolocal((file.readlines() or [''])[0]) |
|
56 | mark = encoding.tolocal((file.readlines() or [''])[0]) | |
48 | if mark == '' or mark not in repo._bookmarks: |
|
57 | if mark == '' or mark not in repo._bookmarks: | |
49 | mark = None |
|
58 | mark = None | |
|
59 | finally: | |||
50 | file.close() |
|
60 | file.close() | |
51 | return mark |
|
61 | return mark | |
52 |
|
62 |
General Comments 0
You need to be logged in to leave comments.
Login now