Mercurial > hg
comparison hgext/bookmarks.py @ 8944:dda4ad7c9ea9
bookmarks: Change references to "repo" by references to "self" (issue1611)
Using "repo" instead of "self" inside bookmark_repo methods was causing a
circular reference and, thus, a memory leak. It has been detected because the
method bundlerepository.__del__ is never called, therefore leaving dangling
uncompressed bundles inside .hg subdirectory.
author | Isaac Jurado <diptongo@gmail.com> |
---|---|
date | Wed, 24 Jun 2009 19:20:59 +0200 |
parents | 868670dbc237 |
children | 6d0b5d76e76d |
comparison
equal
deleted
inserted
replaced
8943:09ff905cdc86 | 8944:dda4ad7c9ea9 |
---|---|
255 wlock = self.wlock() # do both commit and bookmark with lock held | 255 wlock = self.wlock() # do both commit and bookmark with lock held |
256 try: | 256 try: |
257 node = super(bookmark_repo, self).commit(*k, **kw) | 257 node = super(bookmark_repo, self).commit(*k, **kw) |
258 if node is None: | 258 if node is None: |
259 return None | 259 return None |
260 parents = repo.changelog.parents(node) | 260 parents = self.changelog.parents(node) |
261 if parents[1] == nullid: | 261 if parents[1] == nullid: |
262 parents = (parents[0],) | 262 parents = (parents[0],) |
263 marks = parse(repo) | 263 marks = parse(self) |
264 update = False | 264 update = False |
265 for mark, n in marks.items(): | 265 for mark, n in marks.items(): |
266 if ui.configbool('bookmarks', 'track.current'): | 266 if ui.configbool('bookmarks', 'track.current'): |
267 if mark == current(repo) and n in parents: | 267 if mark == current(self) and n in parents: |
268 marks[mark] = node | 268 marks[mark] = node |
269 update = True | 269 update = True |
270 else: | 270 else: |
271 if n in parents: | 271 if n in parents: |
272 marks[mark] = node | 272 marks[mark] = node |
273 update = True | 273 update = True |
274 if update: | 274 if update: |
275 write(repo, marks) | 275 write(self, marks) |
276 return node | 276 return node |
277 finally: | 277 finally: |
278 wlock.release() | 278 wlock.release() |
279 | 279 |
280 def addchangegroup(self, source, srctype, url, emptyok=False): | 280 def addchangegroup(self, source, srctype, url, emptyok=False): |
281 parents = repo.dirstate.parents() | 281 parents = self.dirstate.parents() |
282 | 282 |
283 result = super(bookmark_repo, self).addchangegroup( | 283 result = super(bookmark_repo, self).addchangegroup( |
284 source, srctype, url, emptyok) | 284 source, srctype, url, emptyok) |
285 if result > 1: | 285 if result > 1: |
286 # We have more heads than before | 286 # We have more heads than before |
287 return result | 287 return result |
288 node = repo.changelog.tip() | 288 node = self.changelog.tip() |
289 marks = parse(repo) | 289 marks = parse(self) |
290 update = False | 290 update = False |
291 for mark, n in marks.items(): | 291 for mark, n in marks.items(): |
292 if n in parents: | 292 if n in parents: |
293 marks[mark] = node | 293 marks[mark] = node |
294 update = True | 294 update = True |
295 if update: | 295 if update: |
296 write(repo, marks) | 296 write(self, marks) |
297 return result | 297 return result |
298 | 298 |
299 def tags(self): | 299 def tags(self): |
300 """Merge bookmarks with normal tags""" | 300 """Merge bookmarks with normal tags""" |
301 if self.tagscache: | 301 if self.tagscache: |
302 return self.tagscache | 302 return self.tagscache |
303 | 303 |
304 tagscache = super(bookmark_repo, self).tags() | 304 tagscache = super(bookmark_repo, self).tags() |
305 tagscache.update(parse(repo)) | 305 tagscache.update(parse(self)) |
306 return tagscache | 306 return tagscache |
307 | 307 |
308 repo.__class__ = bookmark_repo | 308 repo.__class__ = bookmark_repo |
309 | 309 |
310 def uisetup(ui): | 310 def uisetup(ui): |