D664: changegroup: replace getsubset with makechangegroup
durham (Durham Goode)
phabricator at mercurial-scm.org
Mon Sep 11 02:07:09 UTC 2017
durham created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
The current changegroup APIs are a bit of a mess. Currently you can use
getsubsetraw, getsubset, changegroupsubset, getlocalchangegroupraw,
getchangegroup, and getlocalchangroup to produce changegroups. This patch is the
beginning of a refactor to boil all of that away to just makechangegroup and
makestream.
The first step adds the new functions and replaces getsubset function with them.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D664
AFFECTED FILES
mercurial/changegroup.py
mercurial/exchange.py
CHANGE DETAILS
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -963,12 +963,8 @@
or pushop.repo.changelog.filteredrevs):
# push everything,
# use the fast path, no race possible on push
- bundler = changegroup.cg1packer(pushop.repo, bundlecaps)
- cg = changegroup.getsubset(pushop.repo,
- outgoing,
- bundler,
- 'push',
- fastpath=True)
+ cg = changegroup.makechangegroup(pushop.repo, outgoing, '01', 'push',
+ fastpath=True, bundlecaps=bundlecaps)
else:
cg = changegroup.getchangegroup(pushop.repo, 'push', outgoing,
bundlecaps=bundlecaps)
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -899,6 +899,18 @@
for node in nodes:
repo.ui.debug("%s\n" % hex(node))
+def makestream(repo, outgoing, version, source, fastpath=False,
+ bundlecaps=None):
+ bundler = getbundler(version, repo, bundlecaps=bundlecaps)
+ return getsubsetraw(repo, outgoing, bundler, source, fastpath=fastpath)
+
+def makechangegroup(repo, outgoing, version, source, fastpath=False,
+ bundlecaps=None):
+ cgstream = makestream(repo, outgoing, version, source,
+ fastpath=fastpath, bundlecaps=bundlecaps)
+ return getunbundler(version, util.chunkbuffer(cgstream), None,
+ {'clcount': len(outgoing.missing) })
+
def getsubsetraw(repo, outgoing, bundler, source, fastpath=False):
repo = repo.unfiltered()
commonrevs = outgoing.common
@@ -915,11 +927,6 @@
_changegroupinfo(repo, csets, source)
return bundler.generate(commonrevs, csets, fastpathlinkrev, source)
-def getsubset(repo, outgoing, bundler, source, fastpath=False):
- gengroup = getsubsetraw(repo, outgoing, bundler, source, fastpath)
- return getunbundler(bundler.version, util.chunkbuffer(gengroup), None,
- {'clcount': len(outgoing.missing)})
-
def changegroupsubset(repo, roots, heads, source, version='01'):
"""Compute a changegroup consisting of all the nodes that are
descendants of any of the roots and ancestors of any of the heads.
@@ -934,8 +941,7 @@
the changegroup a particular filenode or manifestnode belongs to.
"""
outgoing = discovery.outgoing(repo, missingroots=roots, missingheads=heads)
- bundler = getbundler(version, repo)
- return getsubset(repo, outgoing, bundler, source)
+ return makechangegroup(repo, outgoing, version, source)
def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None,
version='01'):
@@ -956,8 +962,8 @@
precomputed sets in outgoing."""
if not outgoing.missing:
return None
- bundler = getbundler(version, repo, bundlecaps)
- return getsubset(repo, outgoing, bundler, source)
+ return makechangegroup(repo, outgoing, version, source,
+ bundlecaps=bundlecaps)
def getlocalchangegroup(repo, *args, **kwargs):
repo.ui.deprecwarn('getlocalchangegroup is deprecated, use getchangegroup',
To: durham, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list