mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
pull: update visibility efficiently via repo.pull API
Summary: With selectivepull we can tell visibility directly about which heads to add, instead of adding all nodes in a changegroup. Note: This does not affect the pull command, nor exclude public commits yet. Reviewed By: markbt Differential Revision: D25562090 fbshipit-source-id: aa5f346f33058dfdb3b2f23f175e35b5d3c30a1d
This commit is contained in:
parent
35094bad4e
commit
c9a701d104
@ -326,6 +326,7 @@ class bundleoperation(object):
|
||||
captureoutput=True,
|
||||
replaydata=None,
|
||||
respondlightly=False,
|
||||
extras=None,
|
||||
):
|
||||
self.repo = repo
|
||||
self.ui = repo.ui
|
||||
@ -340,6 +341,7 @@ class bundleoperation(object):
|
||||
self.respondlightly = respondlightly
|
||||
self.replaydata = replaydata
|
||||
self._addreplayhookargs()
|
||||
self.extras = extras or {}
|
||||
|
||||
def _addreplayhookargs(self):
|
||||
if self.replaydata is None:
|
||||
@ -516,6 +518,7 @@ def processparts(repo, op, unbundler):
|
||||
|
||||
@perftrace.tracefunc("Apply Changegroup")
|
||||
def _processchangegroup(op, cg, tr, source, url, **kwargs):
|
||||
kwargs["updatevisibility"] = op.extras.get("updatevisibility", True)
|
||||
ret = cg.apply(op.repo, tr, source, url, **kwargs)
|
||||
op.records.add("changegroup", {"return": ret})
|
||||
return ret
|
||||
|
@ -311,7 +311,14 @@ class cg1unpacker(object):
|
||||
return mfnodes
|
||||
|
||||
def apply(
|
||||
self, repo, tr, srctype, url, targetphase=phases.draft, expectedtotal=None
|
||||
self,
|
||||
repo,
|
||||
tr,
|
||||
srctype,
|
||||
url,
|
||||
targetphase=phases.draft,
|
||||
expectedtotal=None,
|
||||
updatevisibility=True,
|
||||
):
|
||||
# types: (Any, Any, str, str, int, Optional[int]) -> int
|
||||
"""Add the changegroup returned by source.read() to this repo.
|
||||
@ -433,7 +440,7 @@ class cg1unpacker(object):
|
||||
targetphase = phaseall = phases.draft
|
||||
if added:
|
||||
phases.registernew(repo, tr, targetphase, added)
|
||||
if targetphase > phases.public:
|
||||
if updatevisibility and targetphase > phases.public:
|
||||
visibility.add(repo, added)
|
||||
|
||||
if phaseall is not None:
|
||||
|
@ -1603,7 +1603,9 @@ def _pullbundle2(pullop):
|
||||
_pullbundle2extraprepare(pullop, kwargs)
|
||||
bundle = pullop.remote.getbundle("pull", **kwargs)
|
||||
try:
|
||||
op = bundle2.bundleoperation(pullop.repo, pullop.gettransaction)
|
||||
op = bundle2.bundleoperation(
|
||||
pullop.repo, pullop.gettransaction, extras=pullop.extras
|
||||
)
|
||||
op.modes["bookmarks"] = "records"
|
||||
bundle2.processbundle(pullop.repo, bundle, op=op)
|
||||
except bundle2.AbortFromPart as exc:
|
||||
|
@ -981,7 +981,13 @@ class localrepository(object):
|
||||
# information while the exchange.pull does not know about what
|
||||
# to delete. Consider also bypass phases if narrow-heads is
|
||||
# enabled everywhere.
|
||||
extras = {"bookmarks": False, "obsolete": False}
|
||||
# Bypass inefficient visibility updating as this function will
|
||||
# take care of them.
|
||||
extras = {
|
||||
"bookmarks": False,
|
||||
"obsolete": False,
|
||||
"updatevisibility": False,
|
||||
}
|
||||
opargs = {"extras": extras}
|
||||
heads = sorted(heads)
|
||||
exchange.pull(self, remote, heads, opargs=opargs)
|
||||
@ -995,6 +1001,10 @@ class localrepository(object):
|
||||
self, {remotename: remotenamechanges}, override=False
|
||||
)
|
||||
|
||||
# Update visibleheads:
|
||||
if heads:
|
||||
visibility.add(self, heads)
|
||||
|
||||
def conn(self, source="default", **opts):
|
||||
"""Create a connection from the connection pool"""
|
||||
from . import hg # avoid cycle
|
||||
|
Loading…
Reference in New Issue
Block a user