Mercurial > hg-stable
changeset 40389:1b183edbb68e
repository: teach addgroup() to receive data with missing parents
The way the narrow extension works today, the server rewrites
outgoing changegroup data to lie about parents when the parents
data is missing. It adds the ellipsis flag to the revision so
it can be recorded as such in the revlog.
In the new wire protocol, such rewriting does not occur on
the server (at least not yet anyway). Instead, it is up to the
client to recognize when it has received a revision without its
parents. This means rewriting will be performed on the client.
Furthermore, the mechanism for storing a shallow revision may
differ from store to store. For example, the revlog store uses
the ellipsis flag to denote a revision's parents have been
rewritten. But a non-revlog store may wish to store things
differently. And, some stores may not even support receiving
shallow revision data!
Therefore, it makes sense for the store itself to be making
decisions about what to do when they receive revision data
without their parents.
This commit teaches the addgroup() bulk insert method to accept
a boolean argument that indicates whether the incoming data may
lack parent revisions. This flag can be set when receiving
"shallow" data from a remote.
The revlog implementation of this method has been taught to rewrite
the missing parent(s) to nullid and to add the ellipsis flag to
the revision when a missing parent is encountered. But it only
does this if ellipsis flags are enabled on the repo and the
incoming data is marked as possibly shallow. An error occurs
otherwise.
Differential Revision: https://phab.mercurial-scm.org/D5165
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 26 Sep 2018 14:41:15 -0700 |
parents | 5cb72229f0e9 |
children | 7e3b6c4f01a2 |
files | hgext/sqlitestore.py mercurial/filelog.py mercurial/repository.py tests/simplestorerepo.py |
diffstat | 4 files changed, 27 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/sqlitestore.py Fri Oct 19 13:44:25 2018 +0200 +++ b/hgext/sqlitestore.py Wed Sep 26 14:41:15 2018 -0700 @@ -615,7 +615,12 @@ self._revisioncache[node] = revisiondata return node - def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None): + def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None, + maybemissingparents=False): + if maybemissingparents: + raise error.Abort(_('SQLite storage does not support missing ' + 'parents write mode')) + nodes = [] for node, p1, p2, linknode, deltabase, delta, wireflags in deltas:
--- a/mercurial/filelog.py Fri Oct 19 13:44:25 2018 +0200 +++ b/mercurial/filelog.py Wed Sep 26 14:41:15 2018 -0700 @@ -7,6 +7,7 @@ from __future__ import absolute_import +from .i18n import _ from .node import ( nullid, nullrev, @@ -104,9 +105,14 @@ p1, p2, node=node, flags=flags, cachedelta=cachedelta) - def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None): + def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None, + maybemissingparents=False): + if maybemissingparents: + raise error.Abort(_('revlog storage does not support missing ' + 'parents write mode')) + return self._revlog.addgroup(deltas, linkmapper, transaction, - addrevisioncb=addrevisioncb) + addrevisioncb=addrevisioncb) def getstrippoint(self, minlink): return self._revlog.getstrippoint(minlink)
--- a/mercurial/repository.py Fri Oct 19 13:44:25 2018 +0200 +++ b/mercurial/repository.py Wed Sep 26 14:41:15 2018 -0700 @@ -693,7 +693,8 @@ applying raw data from a peer repo. """ - def addgroup(deltas, linkmapper, transaction, addrevisioncb=None): + def addgroup(deltas, linkmapper, transaction, addrevisioncb=None, + maybemissingparents=False): """Process a series of deltas for storage. ``deltas`` is an iterable of 7-tuples of @@ -707,6 +708,11 @@ ``addrevisioncb`` should be called for each node as it is committed. + ``maybemissingparents`` is a bool indicating whether the incoming + data may reference parents/ancestor revisions that aren't present. + This flag is set when receiving data into a "shallow" store that + doesn't hold all history. + Returns a list of nodes that were processed. A node will be in the list even if it existed in the store previously. """
--- a/tests/simplestorerepo.py Fri Oct 19 13:44:25 2018 +0200 +++ b/tests/simplestorerepo.py Wed Sep 26 14:41:15 2018 -0700 @@ -459,7 +459,12 @@ self._refreshindex() self._svfs.write(self._indexpath, cbor.dumps(self._indexdata)) - def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None): + def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None, + maybemissingparents=False): + if maybemissingparents: + raise error.Abort(_('simple store does not support missing parents ' + 'write mode')) + nodes = [] transaction.addbackup(self._indexpath)