The main emitrevisions() uses nodes. So it makes sense to use
nodes for the helper API.
Not bothering with API since this function was introduced a few
commits ago.
hg-reviewers |
The main emitrevisions() uses nodes. So it makes sense to use
nodes for the helper API.
Not bothering with API since this function was introduced a few
commits ago.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/revlog.py (13 lines) | |||
M | mercurial/utils/storageutil.py (19 lines) |
assumehaveparentrevisions=False, deltaprevious=False): | assumehaveparentrevisions=False, deltaprevious=False): | ||||
if nodesorder not in ('nodes', 'storage', None): | if nodesorder not in ('nodes', 'storage', None): | ||||
raise error.ProgrammingError('unhandled value for nodesorder: %s' % | raise error.ProgrammingError('unhandled value for nodesorder: %s' % | ||||
nodesorder) | nodesorder) | ||||
if nodesorder is None and not self._generaldelta: | if nodesorder is None and not self._generaldelta: | ||||
nodesorder = 'storage' | nodesorder = 'storage' | ||||
frev = self.rev | |||||
if nodesorder == 'nodes': | |||||
revs = [frev(n) for n in nodes] | |||||
elif nodesorder == 'storage': | |||||
revs = sorted(frev(n) for n in nodes) | |||||
else: | |||||
assert self._generaldelta | |||||
revs = set(frev(n) for n in nodes) | |||||
revs = dagop.linearize(revs, self.parentrevs) | |||||
return storageutil.emitrevisions( | return storageutil.emitrevisions( | ||||
self, revs, revlogrevisiondelta, | self, nodes, nodesorder, revlogrevisiondelta, | ||||
deltaparentfn=self.deltaparent, | deltaparentfn=self.deltaparent, | ||||
candeltafn=self.candelta, | candeltafn=self.candelta, | ||||
rawsizefn=self.rawsize, | rawsizefn=self.rawsize, | ||||
revdifffn=self.revdiff, | revdifffn=self.revdiff, | ||||
flagsfn=self.flags, | flagsfn=self.flags, | ||||
sendfulltext=not self._storedeltachains, | sendfulltext=not self._storedeltachains, | ||||
revisiondata=revisiondata, | revisiondata=revisiondata, | ||||
assumehaveparentrevisions=assumehaveparentrevisions, | assumehaveparentrevisions=assumehaveparentrevisions, |
from ..i18n import _ | from ..i18n import _ | ||||
from ..node import ( | from ..node import ( | ||||
bin, | bin, | ||||
nullid, | nullid, | ||||
nullrev, | nullrev, | ||||
) | ) | ||||
from .. import ( | from .. import ( | ||||
dagop, | |||||
error, | error, | ||||
mdiff, | mdiff, | ||||
pycompat, | pycompat, | ||||
) | ) | ||||
_nullhash = hashlib.sha1(nullid) | _nullhash = hashlib.sha1(nullid) | ||||
def hashrevisionsha1(text, p1, p2): | def hashrevisionsha1(text, p1, p2): | ||||
if p != nullrev: | if p != nullrev: | ||||
plinkrev = linkrevfn(p) | plinkrev = linkrevfn(p) | ||||
heads[p] = plinkrev | heads[p] = plinkrev | ||||
if plinkrev >= minlinkrev: | if plinkrev >= minlinkrev: | ||||
futurelargelinkrevs.add(plinkrev) | futurelargelinkrevs.add(plinkrev) | ||||
return strippoint, brokenrevs | return strippoint, brokenrevs | ||||
def emitrevisions(store, revs, resultcls, deltaparentfn=None, candeltafn=None, | def emitrevisions(store, nodes, nodesorder, resultcls, deltaparentfn=None, | ||||
rawsizefn=None, revdifffn=None, flagsfn=None, | candeltafn=None, rawsizefn=None, revdifffn=None, flagsfn=None, | ||||
sendfulltext=False, | sendfulltext=False, | ||||
revisiondata=False, assumehaveparentrevisions=False, | revisiondata=False, assumehaveparentrevisions=False, | ||||
deltaprevious=False): | deltaprevious=False): | ||||
"""Generic implementation of ifiledata.emitrevisions(). | """Generic implementation of ifiledata.emitrevisions(). | ||||
Emitting revision data is subtly complex. This function attempts to | Emitting revision data is subtly complex. This function attempts to | ||||
encapsulate all the logic for doing so in a backend-agnostic way. | encapsulate all the logic for doing so in a backend-agnostic way. | ||||
``store`` | ``store`` | ||||
Object conforming to ``ifilestorage`` interface. | Object conforming to ``ifilestorage`` interface. | ||||
``revs`` | ``nodes`` | ||||
List of integer revision numbers whose data to emit. | List of revision nodes whose data to emit. | ||||
``resultcls`` | ``resultcls`` | ||||
A type implementing the ``irevisiondelta`` interface that will be | A type implementing the ``irevisiondelta`` interface that will be | ||||
constructed and returned. | constructed and returned. | ||||
``deltaparentfn`` (optional) | ``deltaparentfn`` (optional) | ||||
Callable receiving a revision number and returning the revision number | Callable receiving a revision number and returning the revision number | ||||
of a revision that the internal delta is stored against. This delta | of a revision that the internal delta is stored against. This delta | ||||
``flagsfn`` (optional) | ``flagsfn`` (optional) | ||||
Callable receiving a revision number and returns the integer flags | Callable receiving a revision number and returns the integer flags | ||||
value for it. If not defined, flags value will be 0. | value for it. If not defined, flags value will be 0. | ||||
``sendfulltext`` | ``sendfulltext`` | ||||
Whether to send fulltext revisions instead of deltas, if allowed. | Whether to send fulltext revisions instead of deltas, if allowed. | ||||
``nodesorder`` | |||||
``revisiondata`` | ``revisiondata`` | ||||
``assumehaveparentrevisions`` | ``assumehaveparentrevisions`` | ||||
``deltaprevious`` | ``deltaprevious`` | ||||
See ``ifiledata.emitrevisions()`` interface documentation. | See ``ifiledata.emitrevisions()`` interface documentation. | ||||
""" | """ | ||||
fnode = store.node | fnode = store.node | ||||
frev = store.rev | |||||
if nodesorder == 'nodes': | |||||
revs = [frev(n) for n in nodes] | |||||
elif nodesorder == 'storage': | |||||
revs = sorted(frev(n) for n in nodes) | |||||
else: | |||||
revs = set(frev(n) for n in nodes) | |||||
revs = dagop.linearize(revs, store.parentrevs) | |||||
prevrev = None | prevrev = None | ||||
if deltaprevious or assumehaveparentrevisions: | if deltaprevious or assumehaveparentrevisions: | ||||
prevrev = store.parentrevs(revs[0])[0] | prevrev = store.parentrevs(revs[0])[0] | ||||
# Set of revs available to delta against. | # Set of revs available to delta against. | ||||
available = set() | available = set() |