Show More
@@ -63,7 +63,7 b' def write(repo):' | |||
|
63 | 63 | refs = repo._bookmarks |
|
64 | 64 | if os.path.exists(repo.join('bookmarks')): |
|
65 | 65 | util.copyfile(repo.join('bookmarks'), repo.join('undo.bookmarks')) |
|
66 |
if |
|
|
66 | if repo._bookmarkcurrent not in refs: | |
|
67 | 67 | setcurrent(repo, None) |
|
68 | 68 | wlock = repo.wlock() |
|
69 | 69 | try: |
@@ -81,8 +81,6 b' def current(repo):' | |||
|
81 | 81 | we are on. This function returns the name of the bookmark. It |
|
82 | 82 | is stored in .hg/bookmarks.current |
|
83 | 83 | ''' |
|
84 | if repo._bookmarkcurrent: | |
|
85 | return repo._bookmarkcurrent | |
|
86 | 84 | mark = None |
|
87 | 85 | if os.path.exists(repo.join('bookmarks.current')): |
|
88 | 86 | file = repo.opener('bookmarks.current') |
@@ -91,7 +89,6 b' def current(repo):' | |||
|
91 | 89 | if mark == '': |
|
92 | 90 | mark = None |
|
93 | 91 | file.close() |
|
94 | repo._bookmarkcurrent = mark | |
|
95 | 92 | return mark |
|
96 | 93 | |
|
97 | 94 | def setcurrent(repo, mark): |
@@ -100,14 +97,15 b' def setcurrent(repo, mark):' | |||
|
100 | 97 | Set the name of the bookmark that we are on (hg update <bookmark>). |
|
101 | 98 | The name is recorded in .hg/bookmarks.current |
|
102 | 99 | ''' |
|
103 | if current(repo) == mark: | |
|
100 | current = repo._bookmarkcurrent | |
|
101 | if current == mark: | |
|
104 | 102 | return |
|
105 | 103 | |
|
106 | 104 | refs = repo._bookmarks |
|
107 | 105 | |
|
108 | 106 | # do not update if we do update to a rev equal to the current bookmark |
|
109 | 107 | if (mark and mark not in refs and |
|
110 |
current |
|
|
108 | current and refs[current] == repo.changectx('.').node()): | |
|
111 | 109 | return |
|
112 | 110 | if mark not in refs: |
|
113 | 111 | mark = '' |
@@ -146,7 +144,7 b' def bookmark(ui, repo, mark=None, rev=No' | |||
|
146 | 144 | raise util.Abort(_("new bookmark name required")) |
|
147 | 145 | marks[mark] = marks[rename] |
|
148 | 146 | del marks[rename] |
|
149 |
if |
|
|
147 | if repo._bookmarkcurrent == rename: | |
|
150 | 148 | setcurrent(repo, mark) |
|
151 | 149 | write(repo) |
|
152 | 150 | return |
@@ -156,7 +154,7 b' def bookmark(ui, repo, mark=None, rev=No' | |||
|
156 | 154 | raise util.Abort(_("bookmark name required")) |
|
157 | 155 | if mark not in marks: |
|
158 | 156 | raise util.Abort(_("a bookmark of this name does not exist")) |
|
159 |
if mark == |
|
|
157 | if mark == repo._bookmarkcurrent: | |
|
160 | 158 | setcurrent(repo, None) |
|
161 | 159 | del marks[mark] |
|
162 | 160 | write(repo) |
@@ -188,7 +186,8 b' def bookmark(ui, repo, mark=None, rev=No' | |||
|
188 | 186 | else: |
|
189 | 187 | for bmark, n in marks.iteritems(): |
|
190 | 188 | if ui.configbool('bookmarks', 'track.current'): |
|
191 | prefix = (bmark == current(repo) and n == cur) and '*' or ' ' | |
|
189 | current = repo._bookmarkcurrent | |
|
190 | prefix = (bmark == current and n == cur) and '*' or ' ' | |
|
192 | 191 | else: |
|
193 | 192 | prefix = (n == cur) and '*' or ' ' |
|
194 | 193 | |
@@ -233,16 +232,16 b' def reposetup(ui, repo):' | |||
|
233 | 232 | if not repo.local(): |
|
234 | 233 | return |
|
235 | 234 | |
|
236 | # init a bookmark cache as otherwise we would get a infinite reading | |
|
237 | # in lookup() | |
|
238 | repo._bookmarkcurrent = None | |
|
239 | ||
|
240 | 235 | class bookmark_repo(repo.__class__): |
|
241 | 236 | |
|
242 | 237 | @util.propertycache |
|
243 | 238 | def _bookmarks(self): |
|
244 | 239 | return parse(self) |
|
245 | 240 | |
|
241 | @util.propertycache | |
|
242 | def _bookmarkcurrent(self): | |
|
243 | return current(self) | |
|
244 | ||
|
246 | 245 | def rollback(self): |
|
247 | 246 | if os.path.exists(self.join('undo.bookmarks')): |
|
248 | 247 | util.rename(self.join('undo.bookmarks'), self.join('bookmarks')) |
@@ -267,7 +266,7 b' def reposetup(ui, repo):' | |||
|
267 | 266 | marks = self._bookmarks |
|
268 | 267 | update = False |
|
269 | 268 | if ui.configbool('bookmarks', 'track.current'): |
|
270 |
mark = |
|
|
269 | mark = self._bookmarkcurrent | |
|
271 | 270 | if mark and marks[mark] in parents: |
|
272 | 271 | marks[mark] = node |
|
273 | 272 | update = True |
@@ -294,7 +293,7 b' def reposetup(ui, repo):' | |||
|
294 | 293 | marks = self._bookmarks |
|
295 | 294 | update = False |
|
296 | 295 | if ui.configbool('bookmarks', 'track.current'): |
|
297 |
mark = |
|
|
296 | mark = self._bookmarkcurrent | |
|
298 | 297 | if mark and marks[mark] in parents: |
|
299 | 298 | marks[mark] = node |
|
300 | 299 | update = True |
General Comments 0
You need to be logged in to leave comments.
Login now