Mercurial > hg
comparison mercurial/bookmarks.py @ 24947:a02d293a1079
bookmarks: rename bookmarkcurrent to activebookmark (API)
Today, the terms 'active' and 'current' are interchangeably used throughout the
codebase in reference to the active bookmark (the bookmark that will be updated
with the next commit). This leads to confusion among developers and users.
This patch is part of a series to standardize the usage to 'active' throughout
the mercurial codebase and user interface.
author | Ryan McElroy <rmcelroy@fb.com> |
---|---|
date | Tue, 14 Apr 2015 13:17:33 -0700 |
parents | c44534209a0a |
children | eecd48369caa |
comparison
equal
deleted
inserted
replaced
24946:c44534209a0a | 24947:a02d293a1079 |
---|---|
81 repo = self._repo | 81 repo = self._repo |
82 self._writerepo(repo) | 82 self._writerepo(repo) |
83 | 83 |
84 def _writerepo(self, repo): | 84 def _writerepo(self, repo): |
85 """Factored out for extensibility""" | 85 """Factored out for extensibility""" |
86 if repo._bookmarkcurrent not in self: | 86 if repo._activebookmark not in self: |
87 deactivate(repo) | 87 deactivate(repo) |
88 | 88 |
89 wlock = repo.wlock() | 89 wlock = repo.wlock() |
90 try: | 90 try: |
91 | 91 |
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 |
219 | 219 |
220 def update(repo, parents, node): | 220 def update(repo, parents, node): |
221 deletefrom = parents | 221 deletefrom = parents |
222 marks = repo._bookmarks | 222 marks = repo._bookmarks |
223 update = False | 223 update = False |
224 cur = repo._bookmarkcurrent | 224 cur = repo._activebookmark |
225 if not cur: | 225 if not cur: |
226 return False | 226 return False |
227 | 227 |
228 if marks[cur] in parents: | 228 if marks[cur] in parents: |
229 new = repo[node] | 229 new = repo[node] |