Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hg.py @ 17922:7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Bookmarks persistence still showed a fair amount of its legacy as a
monkeypatching extension. This encapsulates all bookmarks
serialization and parsing in a single class, and offers a single
location where other bookmarks storage engines can be substituted
in. As a result, many files no longer import the bookmarks module,
which strikes me as an encapsulation win.
This doesn't do anything to the current bookmark state yet, but I'm
hoping put that in the bmstore class as well.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Wed, 07 Nov 2012 16:21:39 -0600 |
parents | 47fb48060e36 |
children | fd903f89e42b |
comparison
equal
deleted
inserted
replaced
17921:4ac9cf3d810c | 17922:7f5dab94e48c |
---|---|
389 | 389 |
390 # clone all bookmarks except divergent ones | 390 # clone all bookmarks except divergent ones |
391 destrepo = destpeer.local() | 391 destrepo = destpeer.local() |
392 if destrepo and srcpeer.capable("pushkey"): | 392 if destrepo and srcpeer.capable("pushkey"): |
393 rb = srcpeer.listkeys('bookmarks') | 393 rb = srcpeer.listkeys('bookmarks') |
394 marks = destrepo._bookmarks | |
394 for k, n in rb.iteritems(): | 395 for k, n in rb.iteritems(): |
395 try: | 396 try: |
396 m = destrepo.lookup(n) | 397 m = destrepo.lookup(n) |
397 destrepo._bookmarks[k] = m | 398 marks[k] = m |
398 except error.RepoLookupError: | 399 except error.RepoLookupError: |
399 pass | 400 pass |
400 if rb: | 401 if rb: |
401 bookmarks.write(destrepo) | 402 marks.write() |
402 elif srcrepo and destpeer.capable("pushkey"): | 403 elif srcrepo and destpeer.capable("pushkey"): |
403 for k, n in srcrepo._bookmarks.iteritems(): | 404 for k, n in srcrepo._bookmarks.iteritems(): |
404 destpeer.pushkey('bookmarks', k, '', hex(n)) | 405 destpeer.pushkey('bookmarks', k, '', hex(n)) |
405 | 406 |
406 if destrepo: | 407 if destrepo: |