diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -8,7 +8,7 @@ from node import hex, nullid, short from i18n import _ import peer, changegroup, subrepo, discovery, pushkey, obsolete, repoview import changelog, dirstate, filelog, manifest, context, bookmarks, phases -import lock, transaction, store, encoding, base85 +import lock, transaction, store, encoding import scmutil, util, extensions, hook, error, revset import match as matchmod import merge as mergemod @@ -1717,17 +1717,15 @@ class localrepository(object): # should be seen as public phases.advanceboundary(self, phases.public, subset) - if obsolete._enabled: - self.ui.debug('fetching remote obsolete markers\n') - remoteobs = remote.listkeys('obsolete') - if 'dump0' in remoteobs: - if tr is None: - tr = self.transaction(trname) - for key in sorted(remoteobs, reverse=True): - if key.startswith('dump'): - data = base85.b85decode(remoteobs[key]) - self.obsstore.mergemarkers(tr, data) - self.invalidatevolatilesets() + def gettransaction(): + if tr is None: + return self.transaction(trname) + return tr + + obstr = obsolete.syncpull(self, remote, gettransaction) + if obstr is not None: + tr = obstr + if tr is not None: tr.close() finally: diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py --- a/mercurial/obsolete.py +++ b/mercurial/obsolete.py @@ -386,6 +386,27 @@ def syncpush(repo, remote): msg = _('failed to push some obsolete markers!\n') repo.ui.warn(msg) +def syncpull(repo, remote, gettransaction): + """utility function to pull bookmark to a remote + + The `gettransaction` is function that return the pull transaction, creating + one if necessary. We return the transaction to inform the calling code that + a new transaction have been created (when applicable). + + Exists mostly to allow overridding for experimentation purpose""" + tr = None + if _enabled: + repo.ui.debug('fetching remote obsolete markers\n') + remoteobs = remote.listkeys('obsolete') + if 'dump0' in remoteobs: + tr = gettransaction() + for key in sorted(remoteobs, reverse=True): + if key.startswith('dump'): + data = base85.b85decode(remoteobs[key]) + repo.obsstore.mergemarkers(tr, data) + repo.invalidatevolatilesets() + return tr + def allmarkers(repo): """all obsolete markers known in a repository""" for markerdata in repo.obsstore: