Mercurial > hg
comparison mercurial/exchange.py @ 20487:f715cc0b5107
pull: make pulled subset a propertycache of the pull object
The computation of the subset is simple operation using two useful pull
information (1) the set of common changeset before the pull (2) the set of
pulled changeset. We move this data into the `pulloperation` object since some
phase will need them. And we turn the pulled subset computation behind a
property case as multiple pull phase will need it.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Fri, 31 Jan 2014 01:34:00 -0800 |
parents | 0c469df6e914 |
children | 76e66654f74e |
comparison
equal
deleted
inserted
replaced
20486:0c469df6e914 | 20487:f715cc0b5107 |
---|---|
393 self.force = force | 393 self.force = force |
394 # the name the pull transaction | 394 # the name the pull transaction |
395 self._trname = 'pull\n' + util.hidepassword(remote.url()) | 395 self._trname = 'pull\n' + util.hidepassword(remote.url()) |
396 # hold the transaction once created | 396 # hold the transaction once created |
397 self._tr = None | 397 self._tr = None |
398 # heads of the set of changeset target by the pull | 398 # set of common changeset between local and remote before pull |
399 self.pulledsubset = None | 399 self.common = None |
400 # set of pulled head | |
401 self.rheads = None | |
402 | |
403 @util.propertycache | |
404 def pulledsubset(self): | |
405 """heads of the set of changeset target by the pull""" | |
406 # compute target subset | |
407 if self.heads is None: | |
408 # We pulled every thing possible | |
409 # sync on everything common | |
410 return self.common + self.rheads | |
411 else: | |
412 # We pulled a specific subset | |
413 # sync on this subset | |
414 return self.heads | |
400 | 415 |
401 def gettransaction(self): | 416 def gettransaction(self): |
402 """get appropriate pull transaction, creating it if needed""" | 417 """get appropriate pull transaction, creating it if needed""" |
403 if self._tr is None: | 418 if self._tr is None: |
404 self._tr = self.repo.transaction(self._trname) | 419 self._tr = self.repo.transaction(self._trname) |
428 try: | 443 try: |
429 tmp = discovery.findcommonincoming(pullop.repo.unfiltered(), | 444 tmp = discovery.findcommonincoming(pullop.repo.unfiltered(), |
430 pullop.remote, | 445 pullop.remote, |
431 heads=pullop.heads, | 446 heads=pullop.heads, |
432 force=force) | 447 force=force) |
433 common, fetch, rheads = tmp | 448 pullop.common, fetch, pullop.rheads = tmp |
434 if not fetch: | 449 if not fetch: |
435 pullop.repo.ui.status(_("no changes found\n")) | 450 pullop.repo.ui.status(_("no changes found\n")) |
436 result = 0 | 451 result = 0 |
437 else: | 452 else: |
438 # We delay the open of the transaction as late as possible so we | 453 # We delay the open of the transaction as late as possible so we |
439 # don't open transaction for nothing or you break future useful | 454 # don't open transaction for nothing or you break future useful |
440 # rollback call | 455 # rollback call |
441 pullop.gettransaction() | 456 pullop.gettransaction() |
442 if pullop.heads is None and list(common) == [nullid]: | 457 if pullop.heads is None and list(pullop.common) == [nullid]: |
443 pullop.repo.ui.status(_("requesting all changes\n")) | 458 pullop.repo.ui.status(_("requesting all changes\n")) |
444 elif (pullop.heads is None | 459 elif (pullop.heads is None |
445 and pullop.remote.capable('changegroupsubset')): | 460 and pullop.remote.capable('changegroupsubset')): |
446 # issue1320, avoid a race if remote changed after discovery | 461 # issue1320, avoid a race if remote changed after discovery |
447 pullop.heads = rheads | 462 pullop.heads = pullop.rheads |
448 | 463 |
449 if pullop.remote.capable('getbundle'): | 464 if pullop.remote.capable('getbundle'): |
450 # TODO: get bundlecaps from remote | 465 # TODO: get bundlecaps from remote |
451 cg = pullop.remote.getbundle('pull', common=common, | 466 cg = pullop.remote.getbundle('pull', |
452 heads=pullop.heads or rheads) | 467 common=pullop.common, |
468 heads=(pullop.heads | |
469 or pullop.rheads)) | |
453 elif pullop.heads is None: | 470 elif pullop.heads is None: |
454 cg = pullop.remote.changegroup(fetch, 'pull') | 471 cg = pullop.remote.changegroup(fetch, 'pull') |
455 elif not pullop.remote.capable('changegroupsubset'): | 472 elif not pullop.remote.capable('changegroupsubset'): |
456 raise util.Abort(_("partial pull cannot be done because " | 473 raise util.Abort(_("partial pull cannot be done because " |
457 "other repository doesn't support " | 474 "other repository doesn't support " |
459 else: | 476 else: |
460 cg = pullop.remote.changegroupsubset(fetch, pullop.heads, | 477 cg = pullop.remote.changegroupsubset(fetch, pullop.heads, |
461 'pull') | 478 'pull') |
462 result = pullop.repo.addchangegroup(cg, 'pull', | 479 result = pullop.repo.addchangegroup(cg, 'pull', |
463 pullop.remote.url()) | 480 pullop.remote.url()) |
464 | |
465 # compute target subset | |
466 if pullop.heads is None: | |
467 # We pulled every thing possible | |
468 # sync on everything common | |
469 subset = common + rheads | |
470 else: | |
471 # We pulled a specific subset | |
472 # sync on this subset | |
473 subset = pullop.heads | |
474 pullop.pulledsubset = subset | |
475 | 481 |
476 _pullphase(pullop) | 482 _pullphase(pullop) |
477 _pullobsolete(pullop) | 483 _pullobsolete(pullop) |
478 pullop.closetransaction() | 484 pullop.closetransaction() |
479 finally: | 485 finally: |