comparison hgext/simple4server.py @ 1067:5d063fed9e3d

evolve: yield to relevant markers handling in core The handling of obsolescence marker is now performed in core. If we detect a mercurial with such power we skip the wrapping from evolve. This changeset also suffer from massive diff from the change in display of obsolescence marker with parent information introduced at the same time in core.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 20 Aug 2014 20:49:48 -0700
parents f80e8e3c3726
children f15f02007a0b
comparison
equal deleted inserted replaced
1066:045f7de9e4d3 1067:5d063fed9e3d
106 obsdata = StringIO() 106 obsdata = StringIO()
107 _encodemarkersstream(obsdata, markers) 107 _encodemarkersstream(obsdata, markers)
108 obsdata.seek(0) 108 obsdata.seek(0)
109 return obsdata 109 return obsdata
110 110
111 # from evolve extension: 1a23c7c52a43 111 if not util.safehasattr(obsolete.obsstore, 'relevantmarkers'):
112 class pruneobsstore(obsolete.obsstore): 112 # from evolve extension: 1a23c7c52a43
113 """And extended obsstore class that read parent information from v1 format 113 class pruneobsstore(obsolete.obsstore):
114 114 """And extended obsstore class that read parent information from v1 format
115 Evolve extension adds parent information in prune marker. We use it to make 115
116 markers relevant to pushed changeset.""" 116 Evolve extension adds parent information in prune marker. We use it to make
117 117 markers relevant to pushed changeset."""
118 def __init__(self, *args, **kwargs): 118
119 self.prunedchildren = {} 119 def __init__(self, *args, **kwargs):
120 return super(pruneobsstore, self).__init__(*args, **kwargs) 120 self.prunedchildren = {}
121 121 return super(pruneobsstore, self).__init__(*args, **kwargs)
122 def _load(self, markers): 122
123 markers = self._prunedetectingmarkers(markers) 123 def _load(self, markers):
124 return super(pruneobsstore, self)._load(markers) 124 markers = self._prunedetectingmarkers(markers)
125 125 return super(pruneobsstore, self)._load(markers)
126 126
127 def _prunedetectingmarkers(self, markers): 127
128 for m in markers: 128 def _prunedetectingmarkers(self, markers):
129 if not m[1]: # no successors 129 for m in markers:
130 meta = obsolete.decodemeta(m[3]) 130 if not m[1]: # no successors
131 if 'p1' in meta: 131 meta = obsolete.decodemeta(m[3])
132 p1 = node.bin(meta['p1']) 132 if 'p1' in meta:
133 self.prunedchildren.setdefault(p1, set()).add(m) 133 p1 = node.bin(meta['p1'])
134 if 'p2' in meta: 134 self.prunedchildren.setdefault(p1, set()).add(m)
135 p2 = node.bin(meta['p2']) 135 if 'p2' in meta:
136 self.prunedchildren.setdefault(p2, set()).add(m) 136 p2 = node.bin(meta['p2'])
137 yield m 137 self.prunedchildren.setdefault(p2, set()).add(m)
138 138 yield m
139 # from evolve extension: 1a23c7c52a43 139
140 def relevantmarkers(self, nodes): 140 # from evolve extension: 1a23c7c52a43
141 """return a set of all obsolescence marker relevant to a set of node. 141 def relevantmarkers(self, nodes):
142 142 """return a set of all obsolescence marker relevant to a set of node.
143 "relevant" to a set of node mean: 143
144 144 "relevant" to a set of node mean:
145 - marker that use this changeset as successors 145
146 - prune marker of direct children on this changeset. 146 - marker that use this changeset as successors
147 - recursive application of the two rules on precursors of these markers 147 - prune marker of direct children on this changeset.
148 148 - recursive application of the two rules on precursors of these markers
149 It is a set so you cannot rely on order""" 149
150 seennodes = set(nodes) 150 It is a set so you cannot rely on order"""
151 seenmarkers = set() 151 seennodes = set(nodes)
152 pendingnodes = set(nodes) 152 seenmarkers = set()
153 precursorsmarkers = self.precursors 153 pendingnodes = set(nodes)
154 prunedchildren = self.prunedchildren 154 precursorsmarkers = self.precursors
155 while pendingnodes: 155 prunedchildren = self.prunedchildren
156 direct = set() 156 while pendingnodes:
157 for current in pendingnodes: 157 direct = set()
158 direct.update(precursorsmarkers.get(current, ())) 158 for current in pendingnodes:
159 direct.update(prunedchildren.get(current, ())) 159 direct.update(precursorsmarkers.get(current, ()))
160 direct -= seenmarkers 160 direct.update(prunedchildren.get(current, ()))
161 pendingnodes = set([m[0] for m in direct]) 161 direct -= seenmarkers
162 seenmarkers |= direct 162 pendingnodes = set([m[0] for m in direct])
163 pendingnodes -= seennodes 163 seenmarkers |= direct
164 seennodes |= pendingnodes 164 pendingnodes -= seennodes
165 return seenmarkers 165 seennodes |= pendingnodes
166 return seenmarkers
166 167
167 # from evolve extension: cf35f38d6a10 168 # from evolve extension: cf35f38d6a10
168 def srv_pullobsmarkers(repo, proto, others): 169 def srv_pullobsmarkers(repo, proto, others):
169 """serves a binary stream of markers. 170 """serves a binary stream of markers.
170 171
257 gboptsmap['evo_obsheads'] = 'plain' 258 gboptsmap['evo_obsheads'] = 'plain'
258 else: 259 else:
259 gboptslist.append('evo_obsheads') 260 gboptslist.append('evo_obsheads')
260 gboptslist.append('evo_obscommon') 261 gboptslist.append('evo_obscommon')
261 gboptslist.append('evo_obsmarker') 262 gboptslist.append('evo_obsmarker')
262 obsolete.obsstore = pruneobsstore 263 if not util.safehasattr(obsolete.obsstore, 'relevantmarkers'):
263 obsolete.obsstore.relevantmarkers = relevantmarkers 264 obsolete.obsstore = pruneobsstore
265 obsolete.obsstore.relevantmarkers = relevantmarkers
264 hgweb_mod.perms['evoext_pushobsmarkers_0'] = 'push' 266 hgweb_mod.perms['evoext_pushobsmarkers_0'] = 'push'
265 hgweb_mod.perms['evoext_pullobsmarkers_0'] = 'pull' 267 hgweb_mod.perms['evoext_pullobsmarkers_0'] = 'pull'
266 hgweb_mod.perms['evoext_obshash'] = 'pull' 268 hgweb_mod.perms['evoext_obshash'] = 'pull'
267 wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '') 269 wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '')
268 wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*') 270 wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*')