##// END OF EJS Templates
computeoutgoing: move the function from 'changegroup' to 'exchange'...
Pierre-Yves David -
r29808:8d226db3 default
parent child Browse files
Show More
@@ -15,7 +15,6 b' import weakref'
15 from .i18n import _
15 from .i18n import _
16 from .node import (
16 from .node import (
17 hex,
17 hex,
18 nullid,
19 nullrev,
18 nullrev,
20 short,
19 short,
21 )
20 )
@@ -968,25 +967,6 b' def getlocalchangegroup(repo, source, ou'
968 bundler = getbundler(version, repo, bundlecaps)
967 bundler = getbundler(version, repo, bundlecaps)
969 return getsubset(repo, outgoing, bundler, source)
968 return getsubset(repo, outgoing, bundler, source)
970
969
971 def computeoutgoing(repo, heads, common):
972 """Computes which revs are outgoing given a set of common
973 and a set of heads.
974
975 This is a separate function so extensions can have access to
976 the logic.
977
978 Returns a discovery.outgoing object.
979 """
980 cl = repo.changelog
981 if common:
982 hasnode = cl.hasnode
983 common = [n for n in common if hasnode(n)]
984 else:
985 common = [nullid]
986 if not heads:
987 heads = cl.heads()
988 return discovery.outgoing(repo, common, heads)
989
990 def getchangegroup(repo, source, outgoing, bundlecaps=None,
970 def getchangegroup(repo, source, outgoing, bundlecaps=None,
991 version='01'):
971 version='01'):
992 """Like changegroupsubset, but returns the set difference between the
972 """Like changegroupsubset, but returns the set difference between the
@@ -257,6 +257,25 b' def buildobsmarkerspart(bundler, markers'
257 return bundler.newpart('obsmarkers', data=stream)
257 return bundler.newpart('obsmarkers', data=stream)
258 return None
258 return None
259
259
260 def _computeoutgoing(repo, heads, common):
261 """Computes which revs are outgoing given a set of common
262 and a set of heads.
263
264 This is a separate function so extensions can have access to
265 the logic.
266
267 Returns a discovery.outgoing object.
268 """
269 cl = repo.changelog
270 if common:
271 hasnode = cl.hasnode
272 common = [n for n in common if hasnode(n)]
273 else:
274 common = [nullid]
275 if not heads:
276 heads = cl.heads()
277 return discovery.outgoing(repo, common, heads)
278
260 def _forcebundle1(op):
279 def _forcebundle1(op):
261 """return true if a pull/push must use bundle1
280 """return true if a pull/push must use bundle1
262
281
@@ -1536,7 +1555,7 b' def getbundle(repo, source, heads=None, '
1536 if kwargs:
1555 if kwargs:
1537 raise ValueError(_('unsupported getbundle arguments: %s')
1556 raise ValueError(_('unsupported getbundle arguments: %s')
1538 % ', '.join(sorted(kwargs.keys())))
1557 % ', '.join(sorted(kwargs.keys())))
1539 outgoing = changegroup.computeoutgoing(repo, heads, common)
1558 outgoing = _computeoutgoing(repo, heads, common)
1540 return changegroup.getchangegroup(repo, source, outgoing,
1559 return changegroup.getchangegroup(repo, source, outgoing,
1541 bundlecaps=bundlecaps)
1560 bundlecaps=bundlecaps)
1542
1561
@@ -1573,7 +1592,7 b' def _getbundlechangegrouppart(bundler, r'
1573 if not cgversions:
1592 if not cgversions:
1574 raise ValueError(_('no common changegroup version'))
1593 raise ValueError(_('no common changegroup version'))
1575 version = max(cgversions)
1594 version = max(cgversions)
1576 outgoing = changegroup.computeoutgoing(repo, heads, common)
1595 outgoing = _computeoutgoing(repo, heads, common)
1577 cg = changegroup.getlocalchangegroupraw(repo, source, outgoing,
1596 cg = changegroup.getlocalchangegroupraw(repo, source, outgoing,
1578 bundlecaps=bundlecaps,
1597 bundlecaps=bundlecaps,
1579 version=version)
1598 version=version)
@@ -1626,7 +1645,7 b' def _getbundletagsfnodes(bundler, repo, '
1626 if not (kwargs.get('cg', True) and 'hgtagsfnodes' in b2caps):
1645 if not (kwargs.get('cg', True) and 'hgtagsfnodes' in b2caps):
1627 return
1646 return
1628
1647
1629 outgoing = changegroup.computeoutgoing(repo, heads, common)
1648 outgoing = _computeoutgoing(repo, heads, common)
1630
1649
1631 if not outgoing.missingheads:
1650 if not outgoing.missingheads:
1632 return
1651 return
General Comments 0
You need to be logged in to leave comments. Login now