##// END OF EJS Templates
bookmarks: move update into core
Matt Mackall -
r13352:f9cd37fc default
parent child Browse files
Show More
@@ -164,7 +164,6 b' def reposetup(ui, repo):'
164 return
164 return
165
165
166 class bookmark_repo(repo.__class__):
166 class bookmark_repo(repo.__class__):
167
168 @util.propertycache
167 @util.propertycache
169 def _bookmarks(self):
168 def _bookmarks(self):
170 return bookmarks.read(self)
169 return bookmarks.read(self)
@@ -187,22 +186,6 b' def reposetup(ui, repo):'
187 key = self._bookmarks[key]
186 key = self._bookmarks[key]
188 return super(bookmark_repo, self).lookup(key)
187 return super(bookmark_repo, self).lookup(key)
189
188
190 def _bookmarksupdate(self, parents, node):
191 marks = self._bookmarks
192 update = False
193 if ui.configbool('bookmarks', 'track.current'):
194 mark = self._bookmarkcurrent
195 if mark and marks[mark] in parents:
196 marks[mark] = node
197 update = True
198 else:
199 for mark, n in marks.items():
200 if n in parents:
201 marks[mark] = node
202 update = True
203 if update:
204 bookmarks.write(self)
205
206 def commitctx(self, ctx, error=False):
189 def commitctx(self, ctx, error=False):
207 """Add a revision to the repository and
190 """Add a revision to the repository and
208 move the bookmark"""
191 move the bookmark"""
@@ -215,7 +198,7 b' def reposetup(ui, repo):'
215 if parents[1] == nullid:
198 if parents[1] == nullid:
216 parents = (parents[0],)
199 parents = (parents[0],)
217
200
218 self._bookmarksupdate(parents, node)
201 bookmarks.update(self, parents, node)
219 return node
202 return node
220 finally:
203 finally:
221 wlock.release()
204 wlock.release()
@@ -275,7 +258,7 b' def reposetup(ui, repo):'
275 return result
258 return result
276 node = self.changelog.tip()
259 node = self.changelog.tip()
277 parents = self.dirstate.parents()
260 parents = self.dirstate.parents()
278 self._bookmarksupdate(parents, node)
261 bookmarks.update(self, parents, node)
279 return result
262 return result
280
263
281 def _findtags(self):
264 def _findtags(self):
@@ -105,3 +105,19 b' def setcurrent(repo, mark):'
105 finally:
105 finally:
106 wlock.release()
106 wlock.release()
107 repo._bookmarkcurrent = mark
107 repo._bookmarkcurrent = mark
108
109 def update(repo, parents, node):
110 marks = repo._bookmarks
111 update = False
112 if repo.ui.configbool('bookmarks', 'track.current'):
113 mark = repo._bookmarkcurrent
114 if mark and marks[mark] in parents:
115 marks[mark] = node
116 update = True
117 else:
118 for mark, n in marks.items():
119 if n in parents:
120 marks[mark] = node
121 update = True
122 if update:
123 write(repo)
General Comments 0
You need to be logged in to leave comments. Login now