4 # |
4 # |
5 # This software may be used and distributed according to the terms of the |
5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. |
6 # GNU General Public License version 2 or any later version. |
7 from node import hex, nullid, short |
7 from node import hex, nullid, short |
8 from i18n import _ |
8 from i18n import _ |
9 import peer, changegroup, subrepo, discovery, pushkey, obsolete, repoview |
9 import peer, changegroup, subrepo, pushkey, obsolete, repoview |
10 import changelog, dirstate, filelog, manifest, context, bookmarks, phases |
10 import changelog, dirstate, filelog, manifest, context, bookmarks, phases |
11 import lock as lockmod |
11 import lock as lockmod |
12 import transaction, store, encoding, exchange |
12 import transaction, store, encoding, exchange |
13 import scmutil, util, extensions, hook, error, revset |
13 import scmutil, util, extensions, hook, error, revset |
14 import match as matchmod |
14 import match as matchmod |
102 |
102 |
103 def known(self, nodes): |
103 def known(self, nodes): |
104 return self._repo.known(nodes) |
104 return self._repo.known(nodes) |
105 |
105 |
106 def getbundle(self, source, heads=None, common=None, bundlecaps=None): |
106 def getbundle(self, source, heads=None, common=None, bundlecaps=None): |
107 return self._repo.getbundle(source, heads=heads, common=common, |
107 return changegroup.getbundle(self._repo, source, heads=heads, |
108 bundlecaps=None) |
108 common=common, bundlecaps=None) |
109 |
109 |
110 # TODO We might want to move the next two calls into legacypeer and add |
110 # TODO We might want to move the next two calls into legacypeer and add |
111 # unbundle instead. |
111 # unbundle instead. |
112 |
112 |
113 def lock(self): |
113 def lock(self): |
1681 pass |
1681 pass |
1682 |
1682 |
1683 def push(self, remote, force=False, revs=None, newbranch=False): |
1683 def push(self, remote, force=False, revs=None, newbranch=False): |
1684 return exchange.push(self, remote, force, revs, newbranch) |
1684 return exchange.push(self, remote, force, revs, newbranch) |
1685 |
1685 |
1686 def getbundle(self, source, heads=None, common=None, bundlecaps=None): |
|
1687 """Like changegroupsubset, but returns the set difference between the |
|
1688 ancestors of heads and the ancestors common. |
|
1689 |
|
1690 If heads is None, use the local heads. If common is None, use [nullid]. |
|
1691 |
|
1692 The nodes in common might not all be known locally due to the way the |
|
1693 current discovery protocol works. |
|
1694 """ |
|
1695 cl = self.changelog |
|
1696 if common: |
|
1697 hasnode = cl.hasnode |
|
1698 common = [n for n in common if hasnode(n)] |
|
1699 else: |
|
1700 common = [nullid] |
|
1701 if not heads: |
|
1702 heads = cl.heads() |
|
1703 outgoing = discovery.outgoing(cl, common, heads) |
|
1704 return changegroup.getlocalbundle(self, source, outgoing, |
|
1705 bundlecaps=bundlecaps) |
|
1706 |
|
1707 def changegroup(self, basenodes, source): |
1686 def changegroup(self, basenodes, source): |
1708 # to avoid a race we use changegroupsubset() (issue1320) |
1687 # to avoid a race we use changegroupsubset() (issue1320) |
1709 return changegroup.changegroupsubset(self, basenodes, self.heads(), |
1688 return changegroup.changegroupsubset(self, basenodes, self.heads(), |
1710 source) |
1689 source) |
1711 |
1690 |