135 The name is recorded in .hg/bookmarks.current |
135 The name is recorded in .hg/bookmarks.current |
136 """ |
136 """ |
137 if mark not in repo._bookmarks: |
137 if mark not in repo._bookmarks: |
138 raise AssertionError('bookmark %s does not exist!' % mark) |
138 raise AssertionError('bookmark %s does not exist!' % mark) |
139 |
139 |
140 current = repo._bookmarkcurrent |
140 current = repo._activebookmark |
141 if current == mark: |
141 if current == mark: |
142 return |
142 return |
143 |
143 |
144 wlock = repo.wlock() |
144 wlock = repo.wlock() |
145 try: |
145 try: |
146 file = repo.vfs('bookmarks.current', 'w', atomictemp=True) |
146 file = repo.vfs('bookmarks.current', 'w', atomictemp=True) |
147 file.write(encoding.fromlocal(mark)) |
147 file.write(encoding.fromlocal(mark)) |
148 file.close() |
148 file.close() |
149 finally: |
149 finally: |
150 wlock.release() |
150 wlock.release() |
151 repo._bookmarkcurrent = mark |
151 repo._activebookmark = mark |
152 |
152 |
153 def deactivate(repo): |
153 def deactivate(repo): |
154 """ |
154 """ |
155 Unset the active bookmark in this reposiotry. |
155 Unset the active bookmark in this reposiotry. |
156 """ |
156 """ |
157 wlock = repo.wlock() |
157 wlock = repo.wlock() |
158 try: |
158 try: |
159 try: |
159 try: |
160 repo.vfs.unlink('bookmarks.current') |
160 repo.vfs.unlink('bookmarks.current') |
161 repo._bookmarkcurrent = None |
161 repo._activebookmark = None |
162 except OSError, inst: |
162 except OSError, inst: |
163 if inst.errno != errno.ENOENT: |
163 if inst.errno != errno.ENOENT: |
164 raise |
164 raise |
165 finally: |
165 finally: |
166 wlock.release() |
166 wlock.release() |
170 |
170 |
171 I.e., the bookmark listed in .hg/bookmarks.current also points to a |
171 I.e., the bookmark listed in .hg/bookmarks.current also points to a |
172 parent of the working directory. |
172 parent of the working directory. |
173 ''' |
173 ''' |
174 if not mark: |
174 if not mark: |
175 mark = repo._bookmarkcurrent |
175 mark = repo._activebookmark |
176 if not parents: |
176 if not parents: |
177 parents = [p.node() for p in repo[None].parents()] |
177 parents = [p.node() for p in repo[None].parents()] |
178 marks = repo._bookmarks |
178 marks = repo._bookmarks |
179 return (mark in marks and marks[mark] in parents) |
179 return (mark in marks and marks[mark] in parents) |
180 |
180 |
207 def calculateupdate(ui, repo, checkout): |
207 def calculateupdate(ui, repo, checkout): |
208 '''Return a tuple (targetrev, movemarkfrom) indicating the rev to |
208 '''Return a tuple (targetrev, movemarkfrom) indicating the rev to |
209 check out and where to move the active bookmark from, if needed.''' |
209 check out and where to move the active bookmark from, if needed.''' |
210 movemarkfrom = None |
210 movemarkfrom = None |
211 if checkout is None: |
211 if checkout is None: |
212 curmark = repo._bookmarkcurrent |
212 curmark = repo._activebookmark |
213 if iscurrent(repo): |
213 if iscurrent(repo): |
214 movemarkfrom = repo['.'].node() |
214 movemarkfrom = repo['.'].node() |
215 elif curmark: |
215 elif curmark: |
216 ui.status(_("updating to active bookmark %s\n") % curmark) |
216 ui.status(_("updating to active bookmark %s\n") % curmark) |
217 checkout = curmark |
217 checkout = curmark |