In the name of readability.
Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGcc957b9dc335: changegroup: rename mfs to manifests
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
hg-reviewers |
In the name of readability.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/changegroup.py (26 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Gregory Szorc | Aug 10 2018, 3:44 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg |
close = closechunk() | close = closechunk() | ||||
size += len(close) | size += len(close) | ||||
yield closechunk() | yield closechunk() | ||||
self._verbosenote(_('%8.i (changelog)\n') % size) | self._verbosenote(_('%8.i (changelog)\n') % size) | ||||
clrevorder = clstate['clrevorder'] | clrevorder = clstate['clrevorder'] | ||||
mfs = clstate['mfs'] | manifests = clstate['manifests'] | ||||
changedfiles = clstate['changedfiles'] | changedfiles = clstate['changedfiles'] | ||||
# We need to make sure that the linkrev in the changegroup refers to | # We need to make sure that the linkrev in the changegroup refers to | ||||
# the first changeset that introduced the manifest or file revision. | # the first changeset that introduced the manifest or file revision. | ||||
# The fastpath is usually safer than the slowpath, because the filelogs | # The fastpath is usually safer than the slowpath, because the filelogs | ||||
# are walked in revlog order. | # are walked in revlog order. | ||||
# | # | ||||
# When taking the slowpath with reorder=None and the manifest revlog | # When taking the slowpath with reorder=None and the manifest revlog | ||||
# send along with files. This could probably be fixed. | # send along with files. This could probably be fixed. | ||||
fastpathlinkrev = fastpathlinkrev and ( | fastpathlinkrev = fastpathlinkrev and ( | ||||
'treemanifest' not in repo.requirements) | 'treemanifest' not in repo.requirements) | ||||
fnodes = {} # needed file nodes | fnodes = {} # needed file nodes | ||||
size = 0 | size = 0 | ||||
it = self.generatemanifests( | it = self.generatemanifests( | ||||
commonrevs, clrevorder, fastpathlinkrev, mfs, fnodes, source, | commonrevs, clrevorder, fastpathlinkrev, manifests, fnodes, source, | ||||
clstate['clrevtomanifestrev']) | clstate['clrevtomanifestrev']) | ||||
for tree, deltas in it: | for tree, deltas in it: | ||||
if tree: | if tree: | ||||
assert self.version == b'03' | assert self.version == b'03' | ||||
chunk = _fileheader(tree) | chunk = _fileheader(tree) | ||||
size += len(chunk) | size += len(chunk) | ||||
yield chunk | yield chunk | ||||
yield close | yield close | ||||
self._verbosenote(_('%8.i (manifests)\n') % size) | self._verbosenote(_('%8.i (manifests)\n') % size) | ||||
yield self._manifestsend | yield self._manifestsend | ||||
mfdicts = None | mfdicts = None | ||||
if self._ellipses and self._isshallow: | if self._ellipses and self._isshallow: | ||||
mfdicts = [(self._repo.manifestlog[n].read(), lr) | mfdicts = [(self._repo.manifestlog[n].read(), lr) | ||||
for (n, lr) in mfs.iteritems()] | for (n, lr) in manifests.iteritems()] | ||||
mfs.clear() | manifests.clear() | ||||
clrevs = set(cl.rev(x) for x in clnodes) | clrevs = set(cl.rev(x) for x in clnodes) | ||||
it = self.generatefiles(changedfiles, commonrevs, | it = self.generatefiles(changedfiles, commonrevs, | ||||
source, mfdicts, fastpathlinkrev, | source, mfdicts, fastpathlinkrev, | ||||
fnodes, clrevs) | fnodes, clrevs) | ||||
for path, deltas in it: | for path, deltas in it: | ||||
h = _fileheader(path) | h = _fileheader(path) | ||||
def _generatechangelog(self, cl, nodes): | def _generatechangelog(self, cl, nodes): | ||||
"""Generate data for changelog chunks. | """Generate data for changelog chunks. | ||||
Returns a 2-tuple of a dict containing state and an iterable of | Returns a 2-tuple of a dict containing state and an iterable of | ||||
byte chunks. The state will not be fully populated until the | byte chunks. The state will not be fully populated until the | ||||
chunk stream has been fully consumed. | chunk stream has been fully consumed. | ||||
""" | """ | ||||
clrevorder = {} | clrevorder = {} | ||||
mfs = {} # needed manifests | manifests = {} | ||||
mfl = self._repo.manifestlog | mfl = self._repo.manifestlog | ||||
changedfiles = set() | changedfiles = set() | ||||
clrevtomanifestrev = {} | clrevtomanifestrev = {} | ||||
# Callback for the changelog, used to collect changed files and | # Callback for the changelog, used to collect changed files and | ||||
# manifest nodes. | # manifest nodes. | ||||
# Returns the linkrev node (identity in the changelog case). | # Returns the linkrev node (identity in the changelog case). | ||||
def lookupcl(x): | def lookupcl(x): | ||||
c = cl.changelogrevision(x) | c = cl.changelogrevision(x) | ||||
clrevorder[x] = len(clrevorder) | clrevorder[x] = len(clrevorder) | ||||
if self._ellipses: | if self._ellipses: | ||||
# Only update mfs if x is going to be sent. Otherwise we | # Only update manifests if x is going to be sent. Otherwise we | ||||
# end up with bogus linkrevs specified for manifests and | # end up with bogus linkrevs specified for manifests and | ||||
# we skip some manifest nodes that we should otherwise | # we skip some manifest nodes that we should otherwise | ||||
# have sent. | # have sent. | ||||
if (x in self._fullclnodes | if (x in self._fullclnodes | ||||
or cl.rev(x) in self._precomputedellipsis): | or cl.rev(x) in self._precomputedellipsis): | ||||
manifestnode = c.manifest | manifestnode = c.manifest | ||||
# Record the first changeset introducing this manifest | # Record the first changeset introducing this manifest | ||||
# version. | # version. | ||||
mfs.setdefault(manifestnode, x) | manifests.setdefault(manifestnode, x) | ||||
# Set this narrow-specific dict so we have the lowest | # Set this narrow-specific dict so we have the lowest | ||||
# manifest revnum to look up for this cl revnum. (Part of | # manifest revnum to look up for this cl revnum. (Part of | ||||
# mapping changelog ellipsis parents to manifest ellipsis | # mapping changelog ellipsis parents to manifest ellipsis | ||||
# parents) | # parents) | ||||
clrevtomanifestrev.setdefault( | clrevtomanifestrev.setdefault( | ||||
cl.rev(x), mfl.rev(manifestnode)) | cl.rev(x), mfl.rev(manifestnode)) | ||||
# We can't trust the changed files list in the changeset if the | # We can't trust the changed files list in the changeset if the | ||||
# client requested a shallow clone. | # client requested a shallow clone. | ||||
if self._isshallow: | if self._isshallow: | ||||
changedfiles.update(mfl[c.manifest].read().keys()) | changedfiles.update(mfl[c.manifest].read().keys()) | ||||
else: | else: | ||||
changedfiles.update(c.files) | changedfiles.update(c.files) | ||||
else: | else: | ||||
# record the first changeset introducing this manifest version | # record the first changeset introducing this manifest version | ||||
mfs.setdefault(c.manifest, x) | manifests.setdefault(c.manifest, x) | ||||
# Record a complete list of potentially-changed files in | # Record a complete list of potentially-changed files in | ||||
# this manifest. | # this manifest. | ||||
changedfiles.update(c.files) | changedfiles.update(c.files) | ||||
return x | return x | ||||
state = { | state = { | ||||
'clrevorder': clrevorder, | 'clrevorder': clrevorder, | ||||
'mfs': mfs, | 'manifests': manifests, | ||||
'changedfiles': changedfiles, | 'changedfiles': changedfiles, | ||||
'clrevtomanifestrev': clrevtomanifestrev, | 'clrevtomanifestrev': clrevtomanifestrev, | ||||
} | } | ||||
gen = deltagroup( | gen = deltagroup( | ||||
self._repo, cl, nodes, True, lookupcl, | self._repo, cl, nodes, True, lookupcl, | ||||
self._forcedeltaparentprev, | self._forcedeltaparentprev, | ||||
# Reorder settings are currently ignored for changelog. | # Reorder settings are currently ignored for changelog. | ||||
True, | True, | ||||
ellipses=self._ellipses, | ellipses=self._ellipses, | ||||
units=_('changesets'), | units=_('changesets'), | ||||
clrevtolocalrev={}, | clrevtolocalrev={}, | ||||
fullclnodes=self._fullclnodes, | fullclnodes=self._fullclnodes, | ||||
precomputedellipsis=self._precomputedellipsis) | precomputedellipsis=self._precomputedellipsis) | ||||
return state, gen | return state, gen | ||||
def generatemanifests(self, commonrevs, clrevorder, fastpathlinkrev, mfs, | def generatemanifests(self, commonrevs, clrevorder, fastpathlinkrev, | ||||
fnodes, source, clrevtolocalrev): | manifests, fnodes, source, clrevtolocalrev): | ||||
"""Returns an iterator of changegroup chunks containing manifests. | """Returns an iterator of changegroup chunks containing manifests. | ||||
`source` is unused here, but is used by extensions like remotefilelog to | `source` is unused here, but is used by extensions like remotefilelog to | ||||
change what is sent based in pulls vs pushes, etc. | change what is sent based in pulls vs pushes, etc. | ||||
""" | """ | ||||
repo = self._repo | repo = self._repo | ||||
mfl = repo.manifestlog | mfl = repo.manifestlog | ||||
dirlog = mfl._revlog.dirlog | dirlog = mfl._revlog.dirlog | ||||
tmfnodes = {'': mfs} | tmfnodes = {'': manifests} | ||||
# Callback for the manifest, used to collect linkrevs for filelog | # Callback for the manifest, used to collect linkrevs for filelog | ||||
# revisions. | # revisions. | ||||
# Returns the linkrev node (collected in lookupcl). | # Returns the linkrev node (collected in lookupcl). | ||||
def makelookupmflinknode(tree, nodes): | def makelookupmflinknode(tree, nodes): | ||||
if fastpathlinkrev: | if fastpathlinkrev: | ||||
assert not tree | assert not tree | ||||
return mfs.__getitem__ | return manifests.__getitem__ | ||||
def lookupmflinknode(x): | def lookupmflinknode(x): | ||||
"""Callback for looking up the linknode for manifests. | """Callback for looking up the linknode for manifests. | ||||
Returns the linkrev node for the specified manifest. | Returns the linkrev node for the specified manifest. | ||||
SIDE EFFECT: | SIDE EFFECT: | ||||