comparison mercurial/exchange.py @ 20476:1180c6ec5695

pull: move obsolescence marker exchange in the exchange module The obsolescence marker exchange code was already extracted during a previous cycle. We are moving the extracted functio in this module. This function will read and write data in the `pulloperation` object and I prefer to have all core function collaborating through this object in the same place. This changeset is pure code movement only. Code change for direct consumption of the `pulloperation` object will come later.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Thu, 30 Jan 2014 17:38:41 -0800
parents b79b405583af
children 2607a21bb40b
comparison
equal deleted inserted replaced
20475:b79b405583af 20476:1180c6ec5695
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from i18n import _ 8 from i18n import _
9 from node import hex, nullid 9 from node import hex, nullid
10 import errno 10 import errno
11 import util, scmutil, changegroup 11 import util, scmutil, changegroup, base85
12 import discovery, phases, obsolete, bookmarks 12 import discovery, phases, obsolete, bookmarks
13 13
14 14
15 class pushoperation(object): 15 class pushoperation(object):
16 """A object that represent a single push operation 16 """A object that represent a single push operation
391 self.heads = heads 391 self.heads = heads
392 # do we force pull? 392 # do we force pull?
393 self.force = force 393 self.force = force
394 394
395 def pull(repo, remote, heads=None, force=False): 395 def pull(repo, remote, heads=None, force=False):
396 pullop = pulloperation(repo, remote, heads) 396 pullop = pulloperation(repo, remote, heads, force)
397 if pullop.remote.local(): 397 if pullop.remote.local():
398 missing = set(pullop.remote.requirements) - pullop.repo.supported 398 missing = set(pullop.remote.requirements) - pullop.repo.supported
399 if missing: 399 if missing:
400 msg = _("required features are not" 400 msg = _("required features are not"
401 " supported in the destination:" 401 " supported in the destination:"
468 def gettransaction(): 468 def gettransaction():
469 if tr is None: 469 if tr is None:
470 return pullop.repo.transaction(trname) 470 return pullop.repo.transaction(trname)
471 return tr 471 return tr
472 472
473 obstr = obsolete.syncpull(pullop.repo, pullop.remote, gettransaction) 473 obstr = _pullobsolete(pullop.repo, pullop.remote, gettransaction)
474 if obstr is not None: 474 if obstr is not None:
475 tr = obstr 475 tr = obstr
476 476
477 if tr is not None: 477 if tr is not None:
478 tr.close() 478 tr.close()
480 if tr is not None: 480 if tr is not None:
481 tr.release() 481 tr.release()
482 lock.release() 482 lock.release()
483 483
484 return result 484 return result
485
486 def _pullobsolete(repo, remote, gettransaction):
487 """utility function to pull obsolete markers from a remote
488
489 The `gettransaction` is function that return the pull transaction, creating
490 one if necessary. We return the transaction to inform the calling code that
491 a new transaction have been created (when applicable).
492
493 Exists mostly to allow overriding for experimentation purpose"""
494 tr = None
495 if obsolete._enabled:
496 repo.ui.debug('fetching remote obsolete markers\n')
497 remoteobs = remote.listkeys('obsolete')
498 if 'dump0' in remoteobs:
499 tr = gettransaction()
500 for key in sorted(remoteobs, reverse=True):
501 if key.startswith('dump'):
502 data = base85.b85decode(remoteobs[key])
503 repo.obsstore.mergemarkers(tr, data)
504 repo.invalidatevolatilesets()
505 return tr
506