Mercurial > public > mercurial-scm > hg
comparison mercurial/exchange.py @ 39629:a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Wire protocol version 2 will take a substantially different
approach to exchange than version 1 (at least as far as pulling
is concerned).
This commit establishes a new exchangev2 module for holding
code related to exchange using wire protocol v2. I could have
added things to the existing exchange module. But it is already
quite big. And doing things inline isn't in question because
the existing code is already littered with conditional code
for various states of support for the existing wire protocol
as it evolved over 10+ years. A new module gives us a chance
to make a clean break.
This approach does mean we'll end up writing some duplicate
code. And there's a significant chance we'll miss functionality
as code is ported. The plan is to eventually add #testcase's
to existing tests so the new wire protocol is tested side-by-side
with the existing one. This will hopefully tease out any
features that weren't ported properly. But before we get there,
we need to build up support for the new exchange methods.
Our journey towards implementing a new exchange begins with pulling.
And pulling begins with discovery.
The discovery code added to exchangev2 is heavily drawn from
the following functions:
* exchange._pulldiscoverychangegroup
* discovery.findcommonincoming
For now, we build on top of existing discovery mechanisms. The
new wire protocol should be capable of doing things more efficiently.
But I'd rather defer on this problem.
To foster the transition, we invent a fake capability on the HTTPv2
peer and have the main pull code in exchange.py call into exchangev2
when the new wire protocol is being used.
Differential Revision: https://phab.mercurial-scm.org/D4480
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 12 Sep 2018 09:58:23 -0700 |
parents | 130e5df346d5 |
children | 9c2c77c73f23 |
comparison
equal
deleted
inserted
replaced
39628:a5de21c9e370 | 39629:a86d21e70b2b |
---|---|
24 bookmarks as bookmod, | 24 bookmarks as bookmod, |
25 bundle2, | 25 bundle2, |
26 changegroup, | 26 changegroup, |
27 discovery, | 27 discovery, |
28 error, | 28 error, |
29 exchangev2, | |
29 lock as lockmod, | 30 lock as lockmod, |
30 logexchange, | 31 logexchange, |
31 narrowspec, | 32 narrowspec, |
32 obsolete, | 33 obsolete, |
33 phases, | 34 phases, |
1504 " %s") % (', '.join(sorted(missing))) | 1505 " %s") % (', '.join(sorted(missing))) |
1505 raise error.Abort(msg) | 1506 raise error.Abort(msg) |
1506 | 1507 |
1507 pullop.trmanager = transactionmanager(repo, 'pull', remote.url()) | 1508 pullop.trmanager = transactionmanager(repo, 'pull', remote.url()) |
1508 with repo.wlock(), repo.lock(), pullop.trmanager: | 1509 with repo.wlock(), repo.lock(), pullop.trmanager: |
1509 # This should ideally be in _pullbundle2(). However, it needs to run | 1510 # Use the modern wire protocol, if available. |
1510 # before discovery to avoid extra work. | 1511 if remote.capable('exchangev2'): |
1511 _maybeapplyclonebundle(pullop) | 1512 exchangev2.pull(pullop) |
1512 streamclone.maybeperformlegacystreamclone(pullop) | 1513 else: |
1513 _pulldiscovery(pullop) | 1514 # This should ideally be in _pullbundle2(). However, it needs to run |
1514 if pullop.canusebundle2: | 1515 # before discovery to avoid extra work. |
1515 _fullpullbundle2(repo, pullop) | 1516 _maybeapplyclonebundle(pullop) |
1516 _pullchangeset(pullop) | 1517 streamclone.maybeperformlegacystreamclone(pullop) |
1517 _pullphase(pullop) | 1518 _pulldiscovery(pullop) |
1518 _pullbookmarks(pullop) | 1519 if pullop.canusebundle2: |
1519 _pullobsolete(pullop) | 1520 _fullpullbundle2(repo, pullop) |
1521 _pullchangeset(pullop) | |
1522 _pullphase(pullop) | |
1523 _pullbookmarks(pullop) | |
1524 _pullobsolete(pullop) | |
1520 | 1525 |
1521 # storing remotenames | 1526 # storing remotenames |
1522 if repo.ui.configbool('experimental', 'remotenames'): | 1527 if repo.ui.configbool('experimental', 'remotenames'): |
1523 logexchange.pullremotenames(repo, remote) | 1528 logexchange.pullremotenames(repo, remote) |
1524 | 1529 |