comparison mercurial/filelog.py @ 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 f1a39128da95
children 6a917075535a
comparison
equal deleted inserted replaced
40388:5cb72229f0e9 40389:1b183edbb68e
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 from .i18n import _
10 from .node import ( 11 from .node import (
11 nullid, 12 nullid,
12 nullrev, 13 nullrev,
13 ) 14 )
14 from . import ( 15 from . import (
102 cachedelta=None): 103 cachedelta=None):
103 return self._revlog.addrevision(revisiondata, transaction, linkrev, 104 return self._revlog.addrevision(revisiondata, transaction, linkrev,
104 p1, p2, node=node, flags=flags, 105 p1, p2, node=node, flags=flags,
105 cachedelta=cachedelta) 106 cachedelta=cachedelta)
106 107
107 def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None): 108 def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None,
109 maybemissingparents=False):
110 if maybemissingparents:
111 raise error.Abort(_('revlog storage does not support missing '
112 'parents write mode'))
113
108 return self._revlog.addgroup(deltas, linkmapper, transaction, 114 return self._revlog.addgroup(deltas, linkmapper, transaction,
109 addrevisioncb=addrevisioncb) 115 addrevisioncb=addrevisioncb)
110 116
111 def getstrippoint(self, minlink): 117 def getstrippoint(self, minlink):
112 return self._revlog.getstrippoint(minlink) 118 return self._revlog.getstrippoint(minlink)
113 119
114 def strip(self, minlink, transaction): 120 def strip(self, minlink, transaction):