##// END OF EJS Templates
effectflag: detect when date changed...
Boris Feld -
r34418:54af8de9 default
parent child Browse files
Show More
@@ -1,682 +1,687 b''
1 # obsutil.py - utility functions for obsolescence
1 # obsutil.py - utility functions for obsolescence
2 #
2 #
3 # Copyright 2017 Boris Feld <boris.feld@octobus.net>
3 # Copyright 2017 Boris Feld <boris.feld@octobus.net>
4 #
4 #
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 . import (
10 from . import (
11 phases,
11 phases,
12 util
12 util
13 )
13 )
14
14
15 class marker(object):
15 class marker(object):
16 """Wrap obsolete marker raw data"""
16 """Wrap obsolete marker raw data"""
17
17
18 def __init__(self, repo, data):
18 def __init__(self, repo, data):
19 # the repo argument will be used to create changectx in later version
19 # the repo argument will be used to create changectx in later version
20 self._repo = repo
20 self._repo = repo
21 self._data = data
21 self._data = data
22 self._decodedmeta = None
22 self._decodedmeta = None
23
23
24 def __hash__(self):
24 def __hash__(self):
25 return hash(self._data)
25 return hash(self._data)
26
26
27 def __eq__(self, other):
27 def __eq__(self, other):
28 if type(other) != type(self):
28 if type(other) != type(self):
29 return False
29 return False
30 return self._data == other._data
30 return self._data == other._data
31
31
32 def precnode(self):
32 def precnode(self):
33 msg = ("'marker.precnode' is deprecated, "
33 msg = ("'marker.precnode' is deprecated, "
34 "use 'marker.prednode'")
34 "use 'marker.prednode'")
35 util.nouideprecwarn(msg, '4.4')
35 util.nouideprecwarn(msg, '4.4')
36 return self.prednode()
36 return self.prednode()
37
37
38 def prednode(self):
38 def prednode(self):
39 """Predecessor changeset node identifier"""
39 """Predecessor changeset node identifier"""
40 return self._data[0]
40 return self._data[0]
41
41
42 def succnodes(self):
42 def succnodes(self):
43 """List of successor changesets node identifiers"""
43 """List of successor changesets node identifiers"""
44 return self._data[1]
44 return self._data[1]
45
45
46 def parentnodes(self):
46 def parentnodes(self):
47 """Parents of the predecessors (None if not recorded)"""
47 """Parents of the predecessors (None if not recorded)"""
48 return self._data[5]
48 return self._data[5]
49
49
50 def metadata(self):
50 def metadata(self):
51 """Decoded metadata dictionary"""
51 """Decoded metadata dictionary"""
52 return dict(self._data[3])
52 return dict(self._data[3])
53
53
54 def date(self):
54 def date(self):
55 """Creation date as (unixtime, offset)"""
55 """Creation date as (unixtime, offset)"""
56 return self._data[4]
56 return self._data[4]
57
57
58 def flags(self):
58 def flags(self):
59 """The flags field of the marker"""
59 """The flags field of the marker"""
60 return self._data[2]
60 return self._data[2]
61
61
62 def getmarkers(repo, nodes=None, exclusive=False):
62 def getmarkers(repo, nodes=None, exclusive=False):
63 """returns markers known in a repository
63 """returns markers known in a repository
64
64
65 If <nodes> is specified, only markers "relevant" to those nodes are are
65 If <nodes> is specified, only markers "relevant" to those nodes are are
66 returned"""
66 returned"""
67 if nodes is None:
67 if nodes is None:
68 rawmarkers = repo.obsstore
68 rawmarkers = repo.obsstore
69 elif exclusive:
69 elif exclusive:
70 rawmarkers = exclusivemarkers(repo, nodes)
70 rawmarkers = exclusivemarkers(repo, nodes)
71 else:
71 else:
72 rawmarkers = repo.obsstore.relevantmarkers(nodes)
72 rawmarkers = repo.obsstore.relevantmarkers(nodes)
73
73
74 for markerdata in rawmarkers:
74 for markerdata in rawmarkers:
75 yield marker(repo, markerdata)
75 yield marker(repo, markerdata)
76
76
77 def closestpredecessors(repo, nodeid):
77 def closestpredecessors(repo, nodeid):
78 """yield the list of next predecessors pointing on visible changectx nodes
78 """yield the list of next predecessors pointing on visible changectx nodes
79
79
80 This function respect the repoview filtering, filtered revision will be
80 This function respect the repoview filtering, filtered revision will be
81 considered missing.
81 considered missing.
82 """
82 """
83
83
84 precursors = repo.obsstore.predecessors
84 precursors = repo.obsstore.predecessors
85 stack = [nodeid]
85 stack = [nodeid]
86 seen = set(stack)
86 seen = set(stack)
87
87
88 while stack:
88 while stack:
89 current = stack.pop()
89 current = stack.pop()
90 currentpreccs = precursors.get(current, ())
90 currentpreccs = precursors.get(current, ())
91
91
92 for prec in currentpreccs:
92 for prec in currentpreccs:
93 precnodeid = prec[0]
93 precnodeid = prec[0]
94
94
95 # Basic cycle protection
95 # Basic cycle protection
96 if precnodeid in seen:
96 if precnodeid in seen:
97 continue
97 continue
98 seen.add(precnodeid)
98 seen.add(precnodeid)
99
99
100 if precnodeid in repo:
100 if precnodeid in repo:
101 yield precnodeid
101 yield precnodeid
102 else:
102 else:
103 stack.append(precnodeid)
103 stack.append(precnodeid)
104
104
105 def allprecursors(*args, **kwargs):
105 def allprecursors(*args, **kwargs):
106 """ (DEPRECATED)
106 """ (DEPRECATED)
107 """
107 """
108 msg = ("'obsutil.allprecursors' is deprecated, "
108 msg = ("'obsutil.allprecursors' is deprecated, "
109 "use 'obsutil.allpredecessors'")
109 "use 'obsutil.allpredecessors'")
110 util.nouideprecwarn(msg, '4.4')
110 util.nouideprecwarn(msg, '4.4')
111
111
112 return allpredecessors(*args, **kwargs)
112 return allpredecessors(*args, **kwargs)
113
113
114 def allpredecessors(obsstore, nodes, ignoreflags=0):
114 def allpredecessors(obsstore, nodes, ignoreflags=0):
115 """Yield node for every precursors of <nodes>.
115 """Yield node for every precursors of <nodes>.
116
116
117 Some precursors may be unknown locally.
117 Some precursors may be unknown locally.
118
118
119 This is a linear yield unsuited to detecting folded changesets. It includes
119 This is a linear yield unsuited to detecting folded changesets. It includes
120 initial nodes too."""
120 initial nodes too."""
121
121
122 remaining = set(nodes)
122 remaining = set(nodes)
123 seen = set(remaining)
123 seen = set(remaining)
124 while remaining:
124 while remaining:
125 current = remaining.pop()
125 current = remaining.pop()
126 yield current
126 yield current
127 for mark in obsstore.predecessors.get(current, ()):
127 for mark in obsstore.predecessors.get(current, ()):
128 # ignore marker flagged with specified flag
128 # ignore marker flagged with specified flag
129 if mark[2] & ignoreflags:
129 if mark[2] & ignoreflags:
130 continue
130 continue
131 suc = mark[0]
131 suc = mark[0]
132 if suc not in seen:
132 if suc not in seen:
133 seen.add(suc)
133 seen.add(suc)
134 remaining.add(suc)
134 remaining.add(suc)
135
135
136 def allsuccessors(obsstore, nodes, ignoreflags=0):
136 def allsuccessors(obsstore, nodes, ignoreflags=0):
137 """Yield node for every successor of <nodes>.
137 """Yield node for every successor of <nodes>.
138
138
139 Some successors may be unknown locally.
139 Some successors may be unknown locally.
140
140
141 This is a linear yield unsuited to detecting split changesets. It includes
141 This is a linear yield unsuited to detecting split changesets. It includes
142 initial nodes too."""
142 initial nodes too."""
143 remaining = set(nodes)
143 remaining = set(nodes)
144 seen = set(remaining)
144 seen = set(remaining)
145 while remaining:
145 while remaining:
146 current = remaining.pop()
146 current = remaining.pop()
147 yield current
147 yield current
148 for mark in obsstore.successors.get(current, ()):
148 for mark in obsstore.successors.get(current, ()):
149 # ignore marker flagged with specified flag
149 # ignore marker flagged with specified flag
150 if mark[2] & ignoreflags:
150 if mark[2] & ignoreflags:
151 continue
151 continue
152 for suc in mark[1]:
152 for suc in mark[1]:
153 if suc not in seen:
153 if suc not in seen:
154 seen.add(suc)
154 seen.add(suc)
155 remaining.add(suc)
155 remaining.add(suc)
156
156
157 def _filterprunes(markers):
157 def _filterprunes(markers):
158 """return a set with no prune markers"""
158 """return a set with no prune markers"""
159 return set(m for m in markers if m[1])
159 return set(m for m in markers if m[1])
160
160
161 def exclusivemarkers(repo, nodes):
161 def exclusivemarkers(repo, nodes):
162 """set of markers relevant to "nodes" but no other locally-known nodes
162 """set of markers relevant to "nodes" but no other locally-known nodes
163
163
164 This function compute the set of markers "exclusive" to a locally-known
164 This function compute the set of markers "exclusive" to a locally-known
165 node. This means we walk the markers starting from <nodes> until we reach a
165 node. This means we walk the markers starting from <nodes> until we reach a
166 locally-known precursors outside of <nodes>. Element of <nodes> with
166 locally-known precursors outside of <nodes>. Element of <nodes> with
167 locally-known successors outside of <nodes> are ignored (since their
167 locally-known successors outside of <nodes> are ignored (since their
168 precursors markers are also relevant to these successors).
168 precursors markers are also relevant to these successors).
169
169
170 For example:
170 For example:
171
171
172 # (A0 rewritten as A1)
172 # (A0 rewritten as A1)
173 #
173 #
174 # A0 <-1- A1 # Marker "1" is exclusive to A1
174 # A0 <-1- A1 # Marker "1" is exclusive to A1
175
175
176 or
176 or
177
177
178 # (A0 rewritten as AX; AX rewritten as A1; AX is unkown locally)
178 # (A0 rewritten as AX; AX rewritten as A1; AX is unkown locally)
179 #
179 #
180 # <-1- A0 <-2- AX <-3- A1 # Marker "2,3" are exclusive to A1
180 # <-1- A0 <-2- AX <-3- A1 # Marker "2,3" are exclusive to A1
181
181
182 or
182 or
183
183
184 # (A0 has unknown precursors, A0 rewritten as A1 and A2 (divergence))
184 # (A0 has unknown precursors, A0 rewritten as A1 and A2 (divergence))
185 #
185 #
186 # <-2- A1 # Marker "2" is exclusive to A0,A1
186 # <-2- A1 # Marker "2" is exclusive to A0,A1
187 # /
187 # /
188 # <-1- A0
188 # <-1- A0
189 # \
189 # \
190 # <-3- A2 # Marker "3" is exclusive to A0,A2
190 # <-3- A2 # Marker "3" is exclusive to A0,A2
191 #
191 #
192 # in addition:
192 # in addition:
193 #
193 #
194 # Markers "2,3" are exclusive to A1,A2
194 # Markers "2,3" are exclusive to A1,A2
195 # Markers "1,2,3" are exclusive to A0,A1,A2
195 # Markers "1,2,3" are exclusive to A0,A1,A2
196
196
197 See test/test-obsolete-bundle-strip.t for more examples.
197 See test/test-obsolete-bundle-strip.t for more examples.
198
198
199 An example usage is strip. When stripping a changeset, we also want to
199 An example usage is strip. When stripping a changeset, we also want to
200 strip the markers exclusive to this changeset. Otherwise we would have
200 strip the markers exclusive to this changeset. Otherwise we would have
201 "dangling"" obsolescence markers from its precursors: Obsolescence markers
201 "dangling"" obsolescence markers from its precursors: Obsolescence markers
202 marking a node as obsolete without any successors available locally.
202 marking a node as obsolete without any successors available locally.
203
203
204 As for relevant markers, the prune markers for children will be followed.
204 As for relevant markers, the prune markers for children will be followed.
205 Of course, they will only be followed if the pruned children is
205 Of course, they will only be followed if the pruned children is
206 locally-known. Since the prune markers are relevant to the pruned node.
206 locally-known. Since the prune markers are relevant to the pruned node.
207 However, while prune markers are considered relevant to the parent of the
207 However, while prune markers are considered relevant to the parent of the
208 pruned changesets, prune markers for locally-known changeset (with no
208 pruned changesets, prune markers for locally-known changeset (with no
209 successors) are considered exclusive to the pruned nodes. This allows
209 successors) are considered exclusive to the pruned nodes. This allows
210 to strip the prune markers (with the rest of the exclusive chain) alongside
210 to strip the prune markers (with the rest of the exclusive chain) alongside
211 the pruned changesets.
211 the pruned changesets.
212 """
212 """
213 # running on a filtered repository would be dangerous as markers could be
213 # running on a filtered repository would be dangerous as markers could be
214 # reported as exclusive when they are relevant for other filtered nodes.
214 # reported as exclusive when they are relevant for other filtered nodes.
215 unfi = repo.unfiltered()
215 unfi = repo.unfiltered()
216
216
217 # shortcut to various useful item
217 # shortcut to various useful item
218 nm = unfi.changelog.nodemap
218 nm = unfi.changelog.nodemap
219 precursorsmarkers = unfi.obsstore.predecessors
219 precursorsmarkers = unfi.obsstore.predecessors
220 successormarkers = unfi.obsstore.successors
220 successormarkers = unfi.obsstore.successors
221 childrenmarkers = unfi.obsstore.children
221 childrenmarkers = unfi.obsstore.children
222
222
223 # exclusive markers (return of the function)
223 # exclusive markers (return of the function)
224 exclmarkers = set()
224 exclmarkers = set()
225 # we need fast membership testing
225 # we need fast membership testing
226 nodes = set(nodes)
226 nodes = set(nodes)
227 # looking for head in the obshistory
227 # looking for head in the obshistory
228 #
228 #
229 # XXX we are ignoring all issues in regard with cycle for now.
229 # XXX we are ignoring all issues in regard with cycle for now.
230 stack = [n for n in nodes if not _filterprunes(successormarkers.get(n, ()))]
230 stack = [n for n in nodes if not _filterprunes(successormarkers.get(n, ()))]
231 stack.sort()
231 stack.sort()
232 # nodes already stacked
232 # nodes already stacked
233 seennodes = set(stack)
233 seennodes = set(stack)
234 while stack:
234 while stack:
235 current = stack.pop()
235 current = stack.pop()
236 # fetch precursors markers
236 # fetch precursors markers
237 markers = list(precursorsmarkers.get(current, ()))
237 markers = list(precursorsmarkers.get(current, ()))
238 # extend the list with prune markers
238 # extend the list with prune markers
239 for mark in successormarkers.get(current, ()):
239 for mark in successormarkers.get(current, ()):
240 if not mark[1]:
240 if not mark[1]:
241 markers.append(mark)
241 markers.append(mark)
242 # and markers from children (looking for prune)
242 # and markers from children (looking for prune)
243 for mark in childrenmarkers.get(current, ()):
243 for mark in childrenmarkers.get(current, ()):
244 if not mark[1]:
244 if not mark[1]:
245 markers.append(mark)
245 markers.append(mark)
246 # traverse the markers
246 # traverse the markers
247 for mark in markers:
247 for mark in markers:
248 if mark in exclmarkers:
248 if mark in exclmarkers:
249 # markers already selected
249 # markers already selected
250 continue
250 continue
251
251
252 # If the markers is about the current node, select it
252 # If the markers is about the current node, select it
253 #
253 #
254 # (this delay the addition of markers from children)
254 # (this delay the addition of markers from children)
255 if mark[1] or mark[0] == current:
255 if mark[1] or mark[0] == current:
256 exclmarkers.add(mark)
256 exclmarkers.add(mark)
257
257
258 # should we keep traversing through the precursors?
258 # should we keep traversing through the precursors?
259 prec = mark[0]
259 prec = mark[0]
260
260
261 # nodes in the stack or already processed
261 # nodes in the stack or already processed
262 if prec in seennodes:
262 if prec in seennodes:
263 continue
263 continue
264
264
265 # is this a locally known node ?
265 # is this a locally known node ?
266 known = prec in nm
266 known = prec in nm
267 # if locally-known and not in the <nodes> set the traversal
267 # if locally-known and not in the <nodes> set the traversal
268 # stop here.
268 # stop here.
269 if known and prec not in nodes:
269 if known and prec not in nodes:
270 continue
270 continue
271
271
272 # do not keep going if there are unselected markers pointing to this
272 # do not keep going if there are unselected markers pointing to this
273 # nodes. If we end up traversing these unselected markers later the
273 # nodes. If we end up traversing these unselected markers later the
274 # node will be taken care of at that point.
274 # node will be taken care of at that point.
275 precmarkers = _filterprunes(successormarkers.get(prec))
275 precmarkers = _filterprunes(successormarkers.get(prec))
276 if precmarkers.issubset(exclmarkers):
276 if precmarkers.issubset(exclmarkers):
277 seennodes.add(prec)
277 seennodes.add(prec)
278 stack.append(prec)
278 stack.append(prec)
279
279
280 return exclmarkers
280 return exclmarkers
281
281
282 def foreground(repo, nodes):
282 def foreground(repo, nodes):
283 """return all nodes in the "foreground" of other node
283 """return all nodes in the "foreground" of other node
284
284
285 The foreground of a revision is anything reachable using parent -> children
285 The foreground of a revision is anything reachable using parent -> children
286 or precursor -> successor relation. It is very similar to "descendant" but
286 or precursor -> successor relation. It is very similar to "descendant" but
287 augmented with obsolescence information.
287 augmented with obsolescence information.
288
288
289 Beware that possible obsolescence cycle may result if complex situation.
289 Beware that possible obsolescence cycle may result if complex situation.
290 """
290 """
291 repo = repo.unfiltered()
291 repo = repo.unfiltered()
292 foreground = set(repo.set('%ln::', nodes))
292 foreground = set(repo.set('%ln::', nodes))
293 if repo.obsstore:
293 if repo.obsstore:
294 # We only need this complicated logic if there is obsolescence
294 # We only need this complicated logic if there is obsolescence
295 # XXX will probably deserve an optimised revset.
295 # XXX will probably deserve an optimised revset.
296 nm = repo.changelog.nodemap
296 nm = repo.changelog.nodemap
297 plen = -1
297 plen = -1
298 # compute the whole set of successors or descendants
298 # compute the whole set of successors or descendants
299 while len(foreground) != plen:
299 while len(foreground) != plen:
300 plen = len(foreground)
300 plen = len(foreground)
301 succs = set(c.node() for c in foreground)
301 succs = set(c.node() for c in foreground)
302 mutable = [c.node() for c in foreground if c.mutable()]
302 mutable = [c.node() for c in foreground if c.mutable()]
303 succs.update(allsuccessors(repo.obsstore, mutable))
303 succs.update(allsuccessors(repo.obsstore, mutable))
304 known = (n for n in succs if n in nm)
304 known = (n for n in succs if n in nm)
305 foreground = set(repo.set('%ln::', known))
305 foreground = set(repo.set('%ln::', known))
306 return set(c.node() for c in foreground)
306 return set(c.node() for c in foreground)
307
307
308 # logic around storing and using effect flags
308 # logic around storing and using effect flags
309 EFFECTFLAGFIELD = "ef1"
309 EFFECTFLAGFIELD = "ef1"
310
310
311 DESCCHANGED = 1 << 0 # action changed the description
311 DESCCHANGED = 1 << 0 # action changed the description
312 USERCHANGED = 1 << 4 # the user changed
312 USERCHANGED = 1 << 4 # the user changed
313 DATECHANGED = 1 << 5 # the date changed
313
314
314 def geteffectflag(relation):
315 def geteffectflag(relation):
315 """ From an obs-marker relation, compute what changed between the
316 """ From an obs-marker relation, compute what changed between the
316 predecessor and the successor.
317 predecessor and the successor.
317 """
318 """
318 effects = 0
319 effects = 0
319
320
320 source = relation[0]
321 source = relation[0]
321
322
322 for changectx in relation[1]:
323 for changectx in relation[1]:
323 # Check if description has changed
324 # Check if description has changed
324 if changectx.description() != source.description():
325 if changectx.description() != source.description():
325 effects |= DESCCHANGED
326 effects |= DESCCHANGED
326
327
327 # Check if user has changed
328 # Check if user has changed
328 if changectx.user() != source.user():
329 if changectx.user() != source.user():
329 effects |= USERCHANGED
330 effects |= USERCHANGED
330
331
332 # Check if date has changed
333 if changectx.date() != source.date():
334 effects |= DATECHANGED
335
331 return effects
336 return effects
332
337
333 def getobsoleted(repo, tr):
338 def getobsoleted(repo, tr):
334 """return the set of pre-existing revisions obsoleted by a transaction"""
339 """return the set of pre-existing revisions obsoleted by a transaction"""
335 torev = repo.unfiltered().changelog.nodemap.get
340 torev = repo.unfiltered().changelog.nodemap.get
336 phase = repo._phasecache.phase
341 phase = repo._phasecache.phase
337 succsmarkers = repo.obsstore.successors.get
342 succsmarkers = repo.obsstore.successors.get
338 public = phases.public
343 public = phases.public
339 addedmarkers = tr.changes.get('obsmarkers')
344 addedmarkers = tr.changes.get('obsmarkers')
340 addedrevs = tr.changes.get('revs')
345 addedrevs = tr.changes.get('revs')
341 seenrevs = set(addedrevs)
346 seenrevs = set(addedrevs)
342 obsoleted = set()
347 obsoleted = set()
343 for mark in addedmarkers:
348 for mark in addedmarkers:
344 node = mark[0]
349 node = mark[0]
345 rev = torev(node)
350 rev = torev(node)
346 if rev is None or rev in seenrevs:
351 if rev is None or rev in seenrevs:
347 continue
352 continue
348 seenrevs.add(rev)
353 seenrevs.add(rev)
349 if phase(repo, rev) == public:
354 if phase(repo, rev) == public:
350 continue
355 continue
351 if set(succsmarkers(node) or []).issubset(addedmarkers):
356 if set(succsmarkers(node) or []).issubset(addedmarkers):
352 obsoleted.add(rev)
357 obsoleted.add(rev)
353 return obsoleted
358 return obsoleted
354
359
355 class _succs(list):
360 class _succs(list):
356 """small class to represent a successors with some metadata about it"""
361 """small class to represent a successors with some metadata about it"""
357
362
358 def __init__(self, *args, **kwargs):
363 def __init__(self, *args, **kwargs):
359 super(_succs, self).__init__(*args, **kwargs)
364 super(_succs, self).__init__(*args, **kwargs)
360 self.markers = set()
365 self.markers = set()
361
366
362 def copy(self):
367 def copy(self):
363 new = _succs(self)
368 new = _succs(self)
364 new.markers = self.markers.copy()
369 new.markers = self.markers.copy()
365 return new
370 return new
366
371
367 @util.propertycache
372 @util.propertycache
368 def _set(self):
373 def _set(self):
369 # immutable
374 # immutable
370 return set(self)
375 return set(self)
371
376
372 def canmerge(self, other):
377 def canmerge(self, other):
373 return self._set.issubset(other._set)
378 return self._set.issubset(other._set)
374
379
375 def successorssets(repo, initialnode, closest=False, cache=None):
380 def successorssets(repo, initialnode, closest=False, cache=None):
376 """Return set of all latest successors of initial nodes
381 """Return set of all latest successors of initial nodes
377
382
378 The successors set of a changeset A are the group of revisions that succeed
383 The successors set of a changeset A are the group of revisions that succeed
379 A. It succeeds A as a consistent whole, each revision being only a partial
384 A. It succeeds A as a consistent whole, each revision being only a partial
380 replacement. By default, the successors set contains non-obsolete
385 replacement. By default, the successors set contains non-obsolete
381 changesets only, walking the obsolescence graph until reaching a leaf. If
386 changesets only, walking the obsolescence graph until reaching a leaf. If
382 'closest' is set to True, closest successors-sets are return (the
387 'closest' is set to True, closest successors-sets are return (the
383 obsolescence walk stops on known changesets).
388 obsolescence walk stops on known changesets).
384
389
385 This function returns the full list of successor sets which is why it
390 This function returns the full list of successor sets which is why it
386 returns a list of tuples and not just a single tuple. Each tuple is a valid
391 returns a list of tuples and not just a single tuple. Each tuple is a valid
387 successors set. Note that (A,) may be a valid successors set for changeset A
392 successors set. Note that (A,) may be a valid successors set for changeset A
388 (see below).
393 (see below).
389
394
390 In most cases, a changeset A will have a single element (e.g. the changeset
395 In most cases, a changeset A will have a single element (e.g. the changeset
391 A is replaced by A') in its successors set. Though, it is also common for a
396 A is replaced by A') in its successors set. Though, it is also common for a
392 changeset A to have no elements in its successor set (e.g. the changeset
397 changeset A to have no elements in its successor set (e.g. the changeset
393 has been pruned). Therefore, the returned list of successors sets will be
398 has been pruned). Therefore, the returned list of successors sets will be
394 [(A',)] or [], respectively.
399 [(A',)] or [], respectively.
395
400
396 When a changeset A is split into A' and B', however, it will result in a
401 When a changeset A is split into A' and B', however, it will result in a
397 successors set containing more than a single element, i.e. [(A',B')].
402 successors set containing more than a single element, i.e. [(A',B')].
398 Divergent changesets will result in multiple successors sets, i.e. [(A',),
403 Divergent changesets will result in multiple successors sets, i.e. [(A',),
399 (A'')].
404 (A'')].
400
405
401 If a changeset A is not obsolete, then it will conceptually have no
406 If a changeset A is not obsolete, then it will conceptually have no
402 successors set. To distinguish this from a pruned changeset, the successor
407 successors set. To distinguish this from a pruned changeset, the successor
403 set will contain itself only, i.e. [(A,)].
408 set will contain itself only, i.e. [(A,)].
404
409
405 Finally, final successors unknown locally are considered to be pruned
410 Finally, final successors unknown locally are considered to be pruned
406 (pruned: obsoleted without any successors). (Final: successors not affected
411 (pruned: obsoleted without any successors). (Final: successors not affected
407 by markers).
412 by markers).
408
413
409 The 'closest' mode respect the repoview filtering. For example, without
414 The 'closest' mode respect the repoview filtering. For example, without
410 filter it will stop at the first locally known changeset, with 'visible'
415 filter it will stop at the first locally known changeset, with 'visible'
411 filter it will stop on visible changesets).
416 filter it will stop on visible changesets).
412
417
413 The optional `cache` parameter is a dictionary that may contains
418 The optional `cache` parameter is a dictionary that may contains
414 precomputed successors sets. It is meant to reuse the computation of a
419 precomputed successors sets. It is meant to reuse the computation of a
415 previous call to `successorssets` when multiple calls are made at the same
420 previous call to `successorssets` when multiple calls are made at the same
416 time. The cache dictionary is updated in place. The caller is responsible
421 time. The cache dictionary is updated in place. The caller is responsible
417 for its life span. Code that makes multiple calls to `successorssets`
422 for its life span. Code that makes multiple calls to `successorssets`
418 *should* use this cache mechanism or risk a performance hit.
423 *should* use this cache mechanism or risk a performance hit.
419
424
420 Since results are different depending of the 'closest' most, the same cache
425 Since results are different depending of the 'closest' most, the same cache
421 cannot be reused for both mode.
426 cannot be reused for both mode.
422 """
427 """
423
428
424 succmarkers = repo.obsstore.successors
429 succmarkers = repo.obsstore.successors
425
430
426 # Stack of nodes we search successors sets for
431 # Stack of nodes we search successors sets for
427 toproceed = [initialnode]
432 toproceed = [initialnode]
428 # set version of above list for fast loop detection
433 # set version of above list for fast loop detection
429 # element added to "toproceed" must be added here
434 # element added to "toproceed" must be added here
430 stackedset = set(toproceed)
435 stackedset = set(toproceed)
431 if cache is None:
436 if cache is None:
432 cache = {}
437 cache = {}
433
438
434 # This while loop is the flattened version of a recursive search for
439 # This while loop is the flattened version of a recursive search for
435 # successors sets
440 # successors sets
436 #
441 #
437 # def successorssets(x):
442 # def successorssets(x):
438 # successors = directsuccessors(x)
443 # successors = directsuccessors(x)
439 # ss = [[]]
444 # ss = [[]]
440 # for succ in directsuccessors(x):
445 # for succ in directsuccessors(x):
441 # # product as in itertools cartesian product
446 # # product as in itertools cartesian product
442 # ss = product(ss, successorssets(succ))
447 # ss = product(ss, successorssets(succ))
443 # return ss
448 # return ss
444 #
449 #
445 # But we can not use plain recursive calls here:
450 # But we can not use plain recursive calls here:
446 # - that would blow the python call stack
451 # - that would blow the python call stack
447 # - obsolescence markers may have cycles, we need to handle them.
452 # - obsolescence markers may have cycles, we need to handle them.
448 #
453 #
449 # The `toproceed` list act as our call stack. Every node we search
454 # The `toproceed` list act as our call stack. Every node we search
450 # successors set for are stacked there.
455 # successors set for are stacked there.
451 #
456 #
452 # The `stackedset` is set version of this stack used to check if a node is
457 # The `stackedset` is set version of this stack used to check if a node is
453 # already stacked. This check is used to detect cycles and prevent infinite
458 # already stacked. This check is used to detect cycles and prevent infinite
454 # loop.
459 # loop.
455 #
460 #
456 # successors set of all nodes are stored in the `cache` dictionary.
461 # successors set of all nodes are stored in the `cache` dictionary.
457 #
462 #
458 # After this while loop ends we use the cache to return the successors sets
463 # After this while loop ends we use the cache to return the successors sets
459 # for the node requested by the caller.
464 # for the node requested by the caller.
460 while toproceed:
465 while toproceed:
461 # Every iteration tries to compute the successors sets of the topmost
466 # Every iteration tries to compute the successors sets of the topmost
462 # node of the stack: CURRENT.
467 # node of the stack: CURRENT.
463 #
468 #
464 # There are four possible outcomes:
469 # There are four possible outcomes:
465 #
470 #
466 # 1) We already know the successors sets of CURRENT:
471 # 1) We already know the successors sets of CURRENT:
467 # -> mission accomplished, pop it from the stack.
472 # -> mission accomplished, pop it from the stack.
468 # 2) Stop the walk:
473 # 2) Stop the walk:
469 # default case: Node is not obsolete
474 # default case: Node is not obsolete
470 # closest case: Node is known at this repo filter level
475 # closest case: Node is known at this repo filter level
471 # -> the node is its own successors sets. Add it to the cache.
476 # -> the node is its own successors sets. Add it to the cache.
472 # 3) We do not know successors set of direct successors of CURRENT:
477 # 3) We do not know successors set of direct successors of CURRENT:
473 # -> We add those successors to the stack.
478 # -> We add those successors to the stack.
474 # 4) We know successors sets of all direct successors of CURRENT:
479 # 4) We know successors sets of all direct successors of CURRENT:
475 # -> We can compute CURRENT successors set and add it to the
480 # -> We can compute CURRENT successors set and add it to the
476 # cache.
481 # cache.
477 #
482 #
478 current = toproceed[-1]
483 current = toproceed[-1]
479
484
480 # case 2 condition is a bit hairy because of closest,
485 # case 2 condition is a bit hairy because of closest,
481 # we compute it on its own
486 # we compute it on its own
482 case2condition = ((current not in succmarkers)
487 case2condition = ((current not in succmarkers)
483 or (closest and current != initialnode
488 or (closest and current != initialnode
484 and current in repo))
489 and current in repo))
485
490
486 if current in cache:
491 if current in cache:
487 # case (1): We already know the successors sets
492 # case (1): We already know the successors sets
488 stackedset.remove(toproceed.pop())
493 stackedset.remove(toproceed.pop())
489 elif case2condition:
494 elif case2condition:
490 # case (2): end of walk.
495 # case (2): end of walk.
491 if current in repo:
496 if current in repo:
492 # We have a valid successors.
497 # We have a valid successors.
493 cache[current] = [_succs((current,))]
498 cache[current] = [_succs((current,))]
494 else:
499 else:
495 # Final obsolete version is unknown locally.
500 # Final obsolete version is unknown locally.
496 # Do not count that as a valid successors
501 # Do not count that as a valid successors
497 cache[current] = []
502 cache[current] = []
498 else:
503 else:
499 # cases (3) and (4)
504 # cases (3) and (4)
500 #
505 #
501 # We proceed in two phases. Phase 1 aims to distinguish case (3)
506 # We proceed in two phases. Phase 1 aims to distinguish case (3)
502 # from case (4):
507 # from case (4):
503 #
508 #
504 # For each direct successors of CURRENT, we check whether its
509 # For each direct successors of CURRENT, we check whether its
505 # successors sets are known. If they are not, we stack the
510 # successors sets are known. If they are not, we stack the
506 # unknown node and proceed to the next iteration of the while
511 # unknown node and proceed to the next iteration of the while
507 # loop. (case 3)
512 # loop. (case 3)
508 #
513 #
509 # During this step, we may detect obsolescence cycles: a node
514 # During this step, we may detect obsolescence cycles: a node
510 # with unknown successors sets but already in the call stack.
515 # with unknown successors sets but already in the call stack.
511 # In such a situation, we arbitrary set the successors sets of
516 # In such a situation, we arbitrary set the successors sets of
512 # the node to nothing (node pruned) to break the cycle.
517 # the node to nothing (node pruned) to break the cycle.
513 #
518 #
514 # If no break was encountered we proceed to phase 2.
519 # If no break was encountered we proceed to phase 2.
515 #
520 #
516 # Phase 2 computes successors sets of CURRENT (case 4); see details
521 # Phase 2 computes successors sets of CURRENT (case 4); see details
517 # in phase 2 itself.
522 # in phase 2 itself.
518 #
523 #
519 # Note the two levels of iteration in each phase.
524 # Note the two levels of iteration in each phase.
520 # - The first one handles obsolescence markers using CURRENT as
525 # - The first one handles obsolescence markers using CURRENT as
521 # precursor (successors markers of CURRENT).
526 # precursor (successors markers of CURRENT).
522 #
527 #
523 # Having multiple entry here means divergence.
528 # Having multiple entry here means divergence.
524 #
529 #
525 # - The second one handles successors defined in each marker.
530 # - The second one handles successors defined in each marker.
526 #
531 #
527 # Having none means pruned node, multiple successors means split,
532 # Having none means pruned node, multiple successors means split,
528 # single successors are standard replacement.
533 # single successors are standard replacement.
529 #
534 #
530 for mark in sorted(succmarkers[current]):
535 for mark in sorted(succmarkers[current]):
531 for suc in mark[1]:
536 for suc in mark[1]:
532 if suc not in cache:
537 if suc not in cache:
533 if suc in stackedset:
538 if suc in stackedset:
534 # cycle breaking
539 # cycle breaking
535 cache[suc] = []
540 cache[suc] = []
536 else:
541 else:
537 # case (3) If we have not computed successors sets
542 # case (3) If we have not computed successors sets
538 # of one of those successors we add it to the
543 # of one of those successors we add it to the
539 # `toproceed` stack and stop all work for this
544 # `toproceed` stack and stop all work for this
540 # iteration.
545 # iteration.
541 toproceed.append(suc)
546 toproceed.append(suc)
542 stackedset.add(suc)
547 stackedset.add(suc)
543 break
548 break
544 else:
549 else:
545 continue
550 continue
546 break
551 break
547 else:
552 else:
548 # case (4): we know all successors sets of all direct
553 # case (4): we know all successors sets of all direct
549 # successors
554 # successors
550 #
555 #
551 # Successors set contributed by each marker depends on the
556 # Successors set contributed by each marker depends on the
552 # successors sets of all its "successors" node.
557 # successors sets of all its "successors" node.
553 #
558 #
554 # Each different marker is a divergence in the obsolescence
559 # Each different marker is a divergence in the obsolescence
555 # history. It contributes successors sets distinct from other
560 # history. It contributes successors sets distinct from other
556 # markers.
561 # markers.
557 #
562 #
558 # Within a marker, a successor may have divergent successors
563 # Within a marker, a successor may have divergent successors
559 # sets. In such a case, the marker will contribute multiple
564 # sets. In such a case, the marker will contribute multiple
560 # divergent successors sets. If multiple successors have
565 # divergent successors sets. If multiple successors have
561 # divergent successors sets, a Cartesian product is used.
566 # divergent successors sets, a Cartesian product is used.
562 #
567 #
563 # At the end we post-process successors sets to remove
568 # At the end we post-process successors sets to remove
564 # duplicated entry and successors set that are strict subset of
569 # duplicated entry and successors set that are strict subset of
565 # another one.
570 # another one.
566 succssets = []
571 succssets = []
567 for mark in sorted(succmarkers[current]):
572 for mark in sorted(succmarkers[current]):
568 # successors sets contributed by this marker
573 # successors sets contributed by this marker
569 base = _succs()
574 base = _succs()
570 base.markers.add(mark)
575 base.markers.add(mark)
571 markss = [base]
576 markss = [base]
572 for suc in mark[1]:
577 for suc in mark[1]:
573 # cardinal product with previous successors
578 # cardinal product with previous successors
574 productresult = []
579 productresult = []
575 for prefix in markss:
580 for prefix in markss:
576 for suffix in cache[suc]:
581 for suffix in cache[suc]:
577 newss = prefix.copy()
582 newss = prefix.copy()
578 newss.markers.update(suffix.markers)
583 newss.markers.update(suffix.markers)
579 for part in suffix:
584 for part in suffix:
580 # do not duplicated entry in successors set
585 # do not duplicated entry in successors set
581 # first entry wins.
586 # first entry wins.
582 if part not in newss:
587 if part not in newss:
583 newss.append(part)
588 newss.append(part)
584 productresult.append(newss)
589 productresult.append(newss)
585 markss = productresult
590 markss = productresult
586 succssets.extend(markss)
591 succssets.extend(markss)
587 # remove duplicated and subset
592 # remove duplicated and subset
588 seen = []
593 seen = []
589 final = []
594 final = []
590 candidates = sorted((s for s in succssets if s),
595 candidates = sorted((s for s in succssets if s),
591 key=len, reverse=True)
596 key=len, reverse=True)
592 for cand in candidates:
597 for cand in candidates:
593 for seensuccs in seen:
598 for seensuccs in seen:
594 if cand.canmerge(seensuccs):
599 if cand.canmerge(seensuccs):
595 seensuccs.markers.update(cand.markers)
600 seensuccs.markers.update(cand.markers)
596 break
601 break
597 else:
602 else:
598 final.append(cand)
603 final.append(cand)
599 seen.append(cand)
604 seen.append(cand)
600 final.reverse() # put small successors set first
605 final.reverse() # put small successors set first
601 cache[current] = final
606 cache[current] = final
602 return cache[initialnode]
607 return cache[initialnode]
603
608
604 def successorsandmarkers(repo, ctx):
609 def successorsandmarkers(repo, ctx):
605 """compute the raw data needed for computing obsfate
610 """compute the raw data needed for computing obsfate
606 Returns a list of dict, one dict per successors set
611 Returns a list of dict, one dict per successors set
607 """
612 """
608 if not ctx.obsolete():
613 if not ctx.obsolete():
609 return None
614 return None
610
615
611 ssets = successorssets(repo, ctx.node(), closest=True)
616 ssets = successorssets(repo, ctx.node(), closest=True)
612
617
613 # closestsuccessors returns an empty list for pruned revisions, remap it
618 # closestsuccessors returns an empty list for pruned revisions, remap it
614 # into a list containing an empty list for future processing
619 # into a list containing an empty list for future processing
615 if ssets == []:
620 if ssets == []:
616 ssets = [[]]
621 ssets = [[]]
617
622
618 # Try to recover pruned markers
623 # Try to recover pruned markers
619 succsmap = repo.obsstore.successors
624 succsmap = repo.obsstore.successors
620 fullsuccessorsets = [] # successor set + markers
625 fullsuccessorsets = [] # successor set + markers
621 for sset in ssets:
626 for sset in ssets:
622 if sset:
627 if sset:
623 fullsuccessorsets.append(sset)
628 fullsuccessorsets.append(sset)
624 else:
629 else:
625 # successorsset return an empty set() when ctx or one of its
630 # successorsset return an empty set() when ctx or one of its
626 # successors is pruned.
631 # successors is pruned.
627 # In this case, walk the obs-markers tree again starting with ctx
632 # In this case, walk the obs-markers tree again starting with ctx
628 # and find the relevant pruning obs-makers, the ones without
633 # and find the relevant pruning obs-makers, the ones without
629 # successors.
634 # successors.
630 # Having these markers allow us to compute some information about
635 # Having these markers allow us to compute some information about
631 # its fate, like who pruned this changeset and when.
636 # its fate, like who pruned this changeset and when.
632
637
633 # XXX we do not catch all prune markers (eg rewritten then pruned)
638 # XXX we do not catch all prune markers (eg rewritten then pruned)
634 # (fix me later)
639 # (fix me later)
635 foundany = False
640 foundany = False
636 for mark in succsmap.get(ctx.node(), ()):
641 for mark in succsmap.get(ctx.node(), ()):
637 if not mark[1]:
642 if not mark[1]:
638 foundany = True
643 foundany = True
639 sset = _succs()
644 sset = _succs()
640 sset.markers.add(mark)
645 sset.markers.add(mark)
641 fullsuccessorsets.append(sset)
646 fullsuccessorsets.append(sset)
642 if not foundany:
647 if not foundany:
643 fullsuccessorsets.append(_succs())
648 fullsuccessorsets.append(_succs())
644
649
645 values = []
650 values = []
646 for sset in fullsuccessorsets:
651 for sset in fullsuccessorsets:
647 values.append({'successors': sset, 'markers': sset.markers})
652 values.append({'successors': sset, 'markers': sset.markers})
648
653
649 return values
654 return values
650
655
651 def successorsetverb(successorset):
656 def successorsetverb(successorset):
652 """ Return the verb summarizing the successorset
657 """ Return the verb summarizing the successorset
653 """
658 """
654 if not successorset:
659 if not successorset:
655 verb = 'pruned'
660 verb = 'pruned'
656 elif len(successorset) == 1:
661 elif len(successorset) == 1:
657 verb = 'rewritten'
662 verb = 'rewritten'
658 else:
663 else:
659 verb = 'split'
664 verb = 'split'
660 return verb
665 return verb
661
666
662 def markersdates(markers):
667 def markersdates(markers):
663 """returns the list of dates for a list of markers
668 """returns the list of dates for a list of markers
664 """
669 """
665 return [m[4] for m in markers]
670 return [m[4] for m in markers]
666
671
667 def markersusers(markers):
672 def markersusers(markers):
668 """ Returns a sorted list of markers users without duplicates
673 """ Returns a sorted list of markers users without duplicates
669 """
674 """
670 markersmeta = [dict(m[3]) for m in markers]
675 markersmeta = [dict(m[3]) for m in markers]
671 users = set(meta.get('user') for meta in markersmeta if meta.get('user'))
676 users = set(meta.get('user') for meta in markersmeta if meta.get('user'))
672
677
673 return sorted(users)
678 return sorted(users)
674
679
675 def markersoperations(markers):
680 def markersoperations(markers):
676 """ Returns a sorted list of markers operations without duplicates
681 """ Returns a sorted list of markers operations without duplicates
677 """
682 """
678 markersmeta = [dict(m[3]) for m in markers]
683 markersmeta = [dict(m[3]) for m in markers]
679 operations = set(meta.get('operation') for meta in markersmeta
684 operations = set(meta.get('operation') for meta in markersmeta
680 if meta.get('operation'))
685 if meta.get('operation'))
681
686
682 return sorted(operations)
687 return sorted(operations)
@@ -1,167 +1,167 b''
1 Test the 'effect-flags' feature
1 Test the 'effect-flags' feature
2
2
3 Global setup
3 Global setup
4 ============
4 ============
5
5
6 $ . $TESTDIR/testlib/obsmarker-common.sh
6 $ . $TESTDIR/testlib/obsmarker-common.sh
7 $ cat >> $HGRCPATH <<EOF
7 $ cat >> $HGRCPATH <<EOF
8 > [ui]
8 > [ui]
9 > interactive = true
9 > interactive = true
10 > [phases]
10 > [phases]
11 > publish=False
11 > publish=False
12 > [extensions]
12 > [extensions]
13 > rebase =
13 > rebase =
14 > [experimental]
14 > [experimental]
15 > evolution = all
15 > evolution = all
16 > effect-flags = 1
16 > effect-flags = 1
17 > EOF
17 > EOF
18
18
19 $ hg init $TESTTMP/effect-flags
19 $ hg init $TESTTMP/effect-flags
20 $ cd $TESTTMP/effect-flags
20 $ cd $TESTTMP/effect-flags
21 $ mkcommit ROOT
21 $ mkcommit ROOT
22
22
23 amend touching the description only
23 amend touching the description only
24 -----------------------------------
24 -----------------------------------
25
25
26 $ mkcommit A0
26 $ mkcommit A0
27 $ hg commit --amend -m "A1"
27 $ hg commit --amend -m "A1"
28
28
29 check result
29 check result
30
30
31 $ hg debugobsolete --rev .
31 $ hg debugobsolete --rev .
32 471f378eab4c5e25f6c77f785b27c936efb22874 fdf9bde5129a28d4548fadd3f62b265cdd3b7a2e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
32 471f378eab4c5e25f6c77f785b27c936efb22874 fdf9bde5129a28d4548fadd3f62b265cdd3b7a2e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
33
33
34 amend touching the user only
34 amend touching the user only
35 ----------------------------
35 ----------------------------
36
36
37 $ mkcommit B0
37 $ mkcommit B0
38 $ hg commit --amend -u "bob <bob@bob.com>"
38 $ hg commit --amend -u "bob <bob@bob.com>"
39
39
40 check result
40 check result
41
41
42 $ hg debugobsolete --rev .
42 $ hg debugobsolete --rev .
43 ef4a313b1e0ade55718395d80e6b88c5ccd875eb 5485c92d34330dac9d7a63dc07e1e3373835b964 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'}
43 ef4a313b1e0ade55718395d80e6b88c5ccd875eb 5485c92d34330dac9d7a63dc07e1e3373835b964 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'}
44
44
45 amend touching the date only
45 amend touching the date only
46 ----------------------------
46 ----------------------------
47
47
48 $ mkcommit B1
48 $ mkcommit B1
49 $ hg commit --amend -d "42 0"
49 $ hg commit --amend -d "42 0"
50
50
51 check result
51 check result
52
52
53 $ hg debugobsolete --rev .
53 $ hg debugobsolete --rev .
54 2ef0680ff45038ac28c9f1ff3644341f54487280 4dd84345082e9e5291c2e6b3f335bbf8bf389378 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'amend', 'user': 'test'}
54 2ef0680ff45038ac28c9f1ff3644341f54487280 4dd84345082e9e5291c2e6b3f335bbf8bf389378 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '32', 'operation': 'amend', 'user': 'test'}
55
55
56 amend touching the branch only
56 amend touching the branch only
57 ----------------------------
57 ----------------------------
58
58
59 $ mkcommit B2
59 $ mkcommit B2
60 $ hg branch my-branch
60 $ hg branch my-branch
61 marked working directory as branch my-branch
61 marked working directory as branch my-branch
62 (branches are permanent and global, did you want a bookmark?)
62 (branches are permanent and global, did you want a bookmark?)
63 $ hg commit --amend
63 $ hg commit --amend
64
64
65 check result
65 check result
66
66
67 $ hg debugobsolete --rev .
67 $ hg debugobsolete --rev .
68 bd3db8264ceebf1966319f5df3be7aac6acd1a8e 14a01456e0574f0e0a0b15b2345486a6364a8d79 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'amend', 'user': 'test'}
68 bd3db8264ceebf1966319f5df3be7aac6acd1a8e 14a01456e0574f0e0a0b15b2345486a6364a8d79 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'amend', 'user': 'test'}
69
69
70 $ hg up default
70 $ hg up default
71 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
71 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
72
72
73 rebase (parents change)
73 rebase (parents change)
74 -----------------------
74 -----------------------
75
75
76 $ mkcommit C0
76 $ mkcommit C0
77 $ mkcommit D0
77 $ mkcommit D0
78 $ hg rebase -r . -d 'desc(B0)'
78 $ hg rebase -r . -d 'desc(B0)'
79 rebasing 10:c85eff83a034 "D0" (tip)
79 rebasing 10:c85eff83a034 "D0" (tip)
80
80
81 check result
81 check result
82
82
83 $ hg debugobsolete --rev .
83 $ hg debugobsolete --rev .
84 c85eff83a0340efd9da52b806a94c350222f3371 da86aa2f19a30d6686b15cae15c7b6c908ec9699 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'rebase', 'user': 'test'}
84 c85eff83a0340efd9da52b806a94c350222f3371 da86aa2f19a30d6686b15cae15c7b6c908ec9699 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'rebase', 'user': 'test'}
85
85
86 amend touching the diff
86 amend touching the diff
87 -----------------------
87 -----------------------
88
88
89 $ mkcommit E0
89 $ mkcommit E0
90 $ echo 42 >> E0
90 $ echo 42 >> E0
91 $ hg commit --amend
91 $ hg commit --amend
92
92
93 check result
93 check result
94
94
95 $ hg debugobsolete --rev .
95 $ hg debugobsolete --rev .
96 ebfe0333e0d96f68a917afd97c0a0af87f1c3b5f 75781fdbdbf58a987516b00c980bccda1e9ae588 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'amend', 'user': 'test'}
96 ebfe0333e0d96f68a917afd97c0a0af87f1c3b5f 75781fdbdbf58a987516b00c980bccda1e9ae588 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'amend', 'user': 'test'}
97
97
98 amend with multiple effect (desc and meta)
98 amend with multiple effect (desc and meta)
99 -------------------------------------------
99 -------------------------------------------
100
100
101 $ mkcommit F0
101 $ mkcommit F0
102 $ hg branch my-other-branch
102 $ hg branch my-other-branch
103 marked working directory as branch my-other-branch
103 marked working directory as branch my-other-branch
104 $ hg commit --amend -m F1 -u "bob <bob@bob.com>" -d "42 0"
104 $ hg commit --amend -m F1 -u "bob <bob@bob.com>" -d "42 0"
105
105
106 check result
106 check result
107
107
108 $ hg debugobsolete --rev .
108 $ hg debugobsolete --rev .
109 fad47e5bd78e6aa4db1b5a0a1751bc12563655ff a94e0fd5f1c81d969381a76eb0d37ce499a44fae 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '17', 'operation': 'amend', 'user': 'test'}
109 fad47e5bd78e6aa4db1b5a0a1751bc12563655ff a94e0fd5f1c81d969381a76eb0d37ce499a44fae 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '49', 'operation': 'amend', 'user': 'test'}
110
110
111 rebase not touching the diff
111 rebase not touching the diff
112 ----------------------------
112 ----------------------------
113
113
114 $ cat << EOF > H0
114 $ cat << EOF > H0
115 > 0
115 > 0
116 > 1
116 > 1
117 > 2
117 > 2
118 > 3
118 > 3
119 > 4
119 > 4
120 > 5
120 > 5
121 > 6
121 > 6
122 > 7
122 > 7
123 > 8
123 > 8
124 > 9
124 > 9
125 > 10
125 > 10
126 > EOF
126 > EOF
127 $ hg add H0
127 $ hg add H0
128 $ hg commit -m 'H0'
128 $ hg commit -m 'H0'
129 $ echo "H1" >> H0
129 $ echo "H1" >> H0
130 $ hg commit -m "H1"
130 $ hg commit -m "H1"
131 $ hg up -r "desc(H0)"
131 $ hg up -r "desc(H0)"
132 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
132 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
133 $ cat << EOF > H0
133 $ cat << EOF > H0
134 > H2
134 > H2
135 > 0
135 > 0
136 > 1
136 > 1
137 > 2
137 > 2
138 > 3
138 > 3
139 > 4
139 > 4
140 > 5
140 > 5
141 > 6
141 > 6
142 > 7
142 > 7
143 > 8
143 > 8
144 > 9
144 > 9
145 > 10
145 > 10
146 > EOF
146 > EOF
147 $ hg commit -m "H2"
147 $ hg commit -m "H2"
148 created new head
148 created new head
149 $ hg rebase -s "desc(H1)" -d "desc(H2)" -t :merge3
149 $ hg rebase -s "desc(H1)" -d "desc(H2)" -t :merge3
150 rebasing 17:b57fed8d8322 "H1"
150 rebasing 17:b57fed8d8322 "H1"
151 merging H0
151 merging H0
152 $ hg debugobsolete -r tip
152 $ hg debugobsolete -r tip
153 b57fed8d83228a8ae3748d8c3760a77638dd4f8c e509e2eb3df5d131ff7c02350bf2a9edd0c09478 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'rebase', 'user': 'test'}
153 b57fed8d83228a8ae3748d8c3760a77638dd4f8c e509e2eb3df5d131ff7c02350bf2a9edd0c09478 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'rebase', 'user': 'test'}
154
154
155 amend closing the branch should be detected as meta change
155 amend closing the branch should be detected as meta change
156 ----------------------------------------------------------
156 ----------------------------------------------------------
157
157
158 $ hg branch closedbranch
158 $ hg branch closedbranch
159 marked working directory as branch closedbranch
159 marked working directory as branch closedbranch
160 $ mkcommit G0
160 $ mkcommit G0
161 $ mkcommit I0
161 $ mkcommit I0
162 $ hg commit --amend --close-branch
162 $ hg commit --amend --close-branch
163
163
164 check result
164 check result
165
165
166 $ hg debugobsolete -r .
166 $ hg debugobsolete -r .
167 2f599e54c1c6974299065cdf54e1ad640bfb7b5d 12c6238b5e371eea00fd2013b12edce3f070928b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'amend', 'user': 'test'}
167 2f599e54c1c6974299065cdf54e1ad640bfb7b5d 12c6238b5e371eea00fd2013b12edce3f070928b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'amend', 'user': 'test'}
General Comments 0
You need to be logged in to leave comments. Login now