Show More
@@ -2178,15 +2178,16 b' class localrepository(object):' | |||||
2178 | ) |
|
2178 | ) | |
2179 | if hook.hashook(repo.ui, b'pretxnclose-phase'): |
|
2179 | if hook.hashook(repo.ui, b'pretxnclose-phase'): | |
2180 | cl = repo.unfiltered().changelog |
|
2180 | cl = repo.unfiltered().changelog | |
2181 |
for rev, (old, new) in tr.changes[b'phases'] |
|
2181 | for revs, (old, new) in tr.changes[b'phases']: | |
2182 | args = tr.hookargs.copy() |
|
2182 | for rev in revs: | |
2183 | node = hex(cl.node(rev)) |
|
2183 | args = tr.hookargs.copy() | |
2184 | args.update(phases.preparehookargs(node, old, new)) |
|
2184 | node = hex(cl.node(rev)) | |
2185 | repo.hook( |
|
2185 | args.update(phases.preparehookargs(node, old, new)) | |
2186 |
|
|
2186 | repo.hook( | |
2187 |
|
|
2187 | b'pretxnclose-phase', | |
2188 | **pycompat.strkwargs(args) |
|
2188 | throw=True, | |
2189 | ) |
|
2189 | **pycompat.strkwargs(args) | |
|
2190 | ) | |||
2190 |
|
2191 | |||
2191 | repo.hook( |
|
2192 | repo.hook( | |
2192 | b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs) |
|
2193 | b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs) | |
@@ -2231,7 +2232,7 b' class localrepository(object):' | |||||
2231 | ) |
|
2232 | ) | |
2232 | tr.changes[b'origrepolen'] = len(self) |
|
2233 | tr.changes[b'origrepolen'] = len(self) | |
2233 | tr.changes[b'obsmarkers'] = set() |
|
2234 | tr.changes[b'obsmarkers'] = set() | |
2234 |
tr.changes[b'phases'] = |
|
2235 | tr.changes[b'phases'] = [] | |
2235 | tr.changes[b'bookmarks'] = {} |
|
2236 | tr.changes[b'bookmarks'] = {} | |
2236 |
|
2237 | |||
2237 | tr.hookargs[b'txnid'] = txnid |
|
2238 | tr.hookargs[b'txnid'] = txnid | |
@@ -2265,16 +2266,19 b' class localrepository(object):' | |||||
2265 |
|
2266 | |||
2266 | if hook.hashook(repo.ui, b'txnclose-phase'): |
|
2267 | if hook.hashook(repo.ui, b'txnclose-phase'): | |
2267 | cl = repo.unfiltered().changelog |
|
2268 | cl = repo.unfiltered().changelog | |
2268 |
phasemv = sorted( |
|
2269 | phasemv = sorted( | |
2269 | for rev, (old, new) in phasemv: |
|
2270 | tr.changes[b'phases'], key=lambda r: r[0][0] | |
2270 |
|
|
2271 | ) | |
2271 | node = hex(cl.node(rev)) |
|
2272 | for revs, (old, new) in phasemv: | |
2272 | args.update(phases.preparehookargs(node, old, new)) |
|
2273 | for rev in revs: | |
2273 |
|
|
2274 | args = tr.hookargs.copy() | |
2274 |
|
|
2275 | node = hex(cl.node(rev)) | |
2275 | throw=False, |
|
2276 | args.update(phases.preparehookargs(node, old, new)) | |
2276 |
|
|
2277 | repo.hook( | |
2277 |
|
|
2278 | b'txnclose-phase', | |
|
2279 | throw=False, | |||
|
2280 | **pycompat.strkwargs(args) | |||
|
2281 | ) | |||
2278 |
|
2282 | |||
2279 | repo.hook( |
|
2283 | repo.hook( | |
2280 | b'txnclose', throw=False, **pycompat.strkwargs(hookargs) |
|
2284 | b'txnclose', throw=False, **pycompat.strkwargs(hookargs) |
@@ -216,17 +216,101 b' def binarydecode(stream):' | |||||
216 | return headsbyphase |
|
216 | return headsbyphase | |
217 |
|
217 | |||
218 |
|
218 | |||
|
219 | def _sortedrange_insert(data, idx, rev, t): | |||
|
220 | merge_before = False | |||
|
221 | if idx: | |||
|
222 | r1, t1 = data[idx - 1] | |||
|
223 | merge_before = r1[-1] + 1 == rev and t1 == t | |||
|
224 | merge_after = False | |||
|
225 | if idx < len(data): | |||
|
226 | r2, t2 = data[idx] | |||
|
227 | merge_after = r2[0] == rev + 1 and t2 == t | |||
|
228 | ||||
|
229 | if merge_before and merge_after: | |||
|
230 | data[idx - 1] = (pycompat.xrange(r1[0], r2[-1] + 1), t) | |||
|
231 | data.pop(idx) | |||
|
232 | elif merge_before: | |||
|
233 | data[idx - 1] = (pycompat.xrange(r1[0], rev + 1), t) | |||
|
234 | elif merge_after: | |||
|
235 | data[idx] = (pycompat.xrange(rev, r2[-1] + 1), t) | |||
|
236 | else: | |||
|
237 | data.insert(idx, (pycompat.xrange(rev, rev + 1), t)) | |||
|
238 | ||||
|
239 | ||||
|
240 | def _sortedrange_split(data, idx, rev, t): | |||
|
241 | r1, t1 = data[idx] | |||
|
242 | if t == t1: | |||
|
243 | return | |||
|
244 | t = (t1[0], t[1]) | |||
|
245 | if len(r1) == 1: | |||
|
246 | data.pop(idx) | |||
|
247 | _sortedrange_insert(data, idx, rev, t) | |||
|
248 | elif r1[0] == rev: | |||
|
249 | data[idx] = (pycompat.xrange(rev + 1, r1[-1] + 1), t1) | |||
|
250 | _sortedrange_insert(data, idx, rev, t) | |||
|
251 | elif r1[-1] == rev: | |||
|
252 | data[idx] = (pycompat.xrange(r1[0], rev), t1) | |||
|
253 | _sortedrange_insert(data, idx + 1, rev, t) | |||
|
254 | else: | |||
|
255 | data[idx : idx + 1] = [ | |||
|
256 | (pycompat.xrange(r1[0], rev), t1), | |||
|
257 | (pycompat.xrange(rev, rev + 1), t), | |||
|
258 | (pycompat.xrange(rev + 1, r1[-1] + 1), t1), | |||
|
259 | ] | |||
|
260 | ||||
|
261 | ||||
219 | def _trackphasechange(data, rev, old, new): |
|
262 | def _trackphasechange(data, rev, old, new): | |
220 |
"""add a phase move the <data> |
|
263 | """add a phase move to the <data> list of ranges | |
221 |
|
264 | |||
222 | If data is None, nothing happens. |
|
265 | If data is None, nothing happens. | |
223 | """ |
|
266 | """ | |
224 | if data is None: |
|
267 | if data is None: | |
225 | return |
|
268 | return | |
226 | existing = data.get(rev) |
|
269 | ||
227 | if existing is not None: |
|
270 | # If data is empty, create a one-revision range and done | |
228 | old = existing[0] |
|
271 | if not data: | |
229 | data[rev] = (old, new) |
|
272 | data.insert(0, (pycompat.xrange(rev, rev + 1), (old, new))) | |
|
273 | return | |||
|
274 | ||||
|
275 | low = 0 | |||
|
276 | high = len(data) | |||
|
277 | t = (old, new) | |||
|
278 | while low < high: | |||
|
279 | mid = (low + high) // 2 | |||
|
280 | revs = data[mid][0] | |||
|
281 | ||||
|
282 | if rev in revs: | |||
|
283 | _sortedrange_split(data, mid, rev, t) | |||
|
284 | return | |||
|
285 | ||||
|
286 | if revs[0] == rev + 1: | |||
|
287 | if mid and data[mid - 1][0][-1] == rev: | |||
|
288 | _sortedrange_split(data, mid - 1, rev, t) | |||
|
289 | else: | |||
|
290 | _sortedrange_insert(data, mid, rev, t) | |||
|
291 | return | |||
|
292 | ||||
|
293 | if revs[-1] == rev - 1: | |||
|
294 | if mid + 1 < len(data) and data[mid + 1][0][0] == rev: | |||
|
295 | _sortedrange_split(data, mid + 1, rev, t) | |||
|
296 | else: | |||
|
297 | _sortedrange_insert(data, mid + 1, rev, t) | |||
|
298 | return | |||
|
299 | ||||
|
300 | if revs[0] > rev: | |||
|
301 | high = mid | |||
|
302 | else: | |||
|
303 | low = mid + 1 | |||
|
304 | ||||
|
305 | if low == len(data): | |||
|
306 | data.append((pycompat.xrange(rev, rev + 1), t)) | |||
|
307 | return | |||
|
308 | ||||
|
309 | r1, t1 = data[low] | |||
|
310 | if r1[0] > rev: | |||
|
311 | data.insert(low, (pycompat.xrange(rev, rev + 1), t)) | |||
|
312 | else: | |||
|
313 | data.insert(low + 1, (pycompat.xrange(rev, rev + 1), t)) | |||
230 |
|
314 | |||
231 |
|
315 | |||
232 | class phasecache(object): |
|
316 | class phasecache(object): | |
@@ -400,8 +484,9 b' class phasecache(object):' | |||||
400 | phasetracking = tr.changes[b'phases'] |
|
484 | phasetracking = tr.changes[b'phases'] | |
401 | torev = repo.changelog.rev |
|
485 | torev = repo.changelog.rev | |
402 | phase = self.phase |
|
486 | phase = self.phase | |
403 |
for n in nodes |
|
487 | revs = [torev(node) for node in nodes] | |
404 |
|
|
488 | revs.sort() | |
|
489 | for rev in revs: | |||
405 | revphase = phase(repo, rev) |
|
490 | revphase = phase(repo, rev) | |
406 | _trackphasechange(phasetracking, rev, None, revphase) |
|
491 | _trackphasechange(phasetracking, rev, None, revphase) | |
407 | repo.invalidatevolatilesets() |
|
492 | repo.invalidatevolatilesets() | |
@@ -485,7 +570,7 b' class phasecache(object):' | |||||
485 | affected -= revs |
|
570 | affected -= revs | |
486 | else: # public phase |
|
571 | else: # public phase | |
487 | revs = affected |
|
572 | revs = affected | |
488 | for r in revs: |
|
573 | for r in sorted(revs): | |
489 | _trackphasechange(phasetracking, r, phase, targetphase) |
|
574 | _trackphasechange(phasetracking, r, phase, targetphase) | |
490 | repo.invalidatevolatilesets() |
|
575 | repo.invalidatevolatilesets() | |
491 |
|
576 |
@@ -2058,14 +2058,11 b' def registersummarycallback(repo, otr, t' | |||||
2058 | pull/unbundle. |
|
2058 | pull/unbundle. | |
2059 | """ |
|
2059 | """ | |
2060 | origrepolen = tr.changes.get(b'origrepolen', len(repo)) |
|
2060 | origrepolen = tr.changes.get(b'origrepolen', len(repo)) | |
2061 | phasetracking = tr.changes.get(b'phases', {}) |
|
2061 | published = [] | |
2062 | if not phasetracking: |
|
2062 | for revs, (old, new) in tr.changes.get(b'phases', []): | |
2063 | return |
|
2063 | if new != phases.public: | |
2064 | published = [ |
|
2064 | continue | |
2065 | rev |
|
2065 | published.extend(rev for rev in revs if rev < origrepolen) | |
2066 | for rev, (old, new) in pycompat.iteritems(phasetracking) |
|
|||
2067 | if new == phases.public and rev < origrepolen |
|
|||
2068 | ] |
|
|||
2069 | if not published: |
|
2066 | if not published: | |
2070 | return |
|
2067 | return | |
2071 | msg = _(b'%d local changesets published\n') |
|
2068 | msg = _(b'%d local changesets published\n') |
@@ -5,21 +5,22 b' from __future__ import absolute_import' | |||||
5 |
|
5 | |||
6 | def reposetup(ui, repo): |
|
6 | def reposetup(ui, repo): | |
7 | def reportphasemove(tr): |
|
7 | def reportphasemove(tr): | |
8 |
for rev, move in sorted(tr.changes[b |
|
8 | for revs, move in sorted(tr.changes[b"phases"], key=lambda r: r[0][0]): | |
9 |
|
|
9 | for rev in revs: | |
10 |
|
|
10 | if move[0] is None: | |
11 | ( |
|
11 | ui.write( | |
12 | b'test-debug-phase: new rev %d: x -> %d\n' |
|
12 | ( | |
13 | % (rev, move[1]) |
|
13 | b'test-debug-phase: new rev %d: x -> %d\n' | |
|
14 | % (rev, move[1]) | |||
|
15 | ) | |||
14 | ) |
|
16 | ) | |
15 |
|
|
17 | else: | |
16 | else: |
|
18 | ui.write( | |
17 |
|
|
19 | ( | |
18 | ( |
|
20 | b'test-debug-phase: move rev %d: %d -> %d\n' | |
19 | b'test-debug-phase: move rev %d: %d -> %d\n' |
|
21 | % (rev, move[0], move[1]) | |
20 |
|
|
22 | ) | |
21 | ) |
|
23 | ) | |
22 | ) |
|
|||
23 |
|
24 | |||
24 | class reportphaserepo(repo.__class__): |
|
25 | class reportphaserepo(repo.__class__): | |
25 | def transaction(self, *args, **kwargs): |
|
26 | def transaction(self, *args, **kwargs): |
General Comments 0
You need to be logged in to leave comments.
Login now