Mercurial > hg
annotate mercurial/obsutil.py @ 51661:a0f1378b932e stable
Backed out changeset f28c52a9f7b4
This backout and the previous are due to a large performance regression
detected in repositories with a lot of obsmarkers when performing a clone.
A better fix will come along at the start of the next cycle.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 08 Jul 2024 16:20:04 +0200 |
parents | f28c52a9f7b4 |
children | b8647465b59a 493034cc3265 |
rev | line source |
---|---|
32879
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
1 # obsutil.py - utility functions for obsolescence |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
2 # |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
3 # Copyright 2017 Boris Feld <boris.feld@octobus.net> |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
4 # |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
7 |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
8 |
34420
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
9 import re |
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
10 |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
11 from .i18n import _ |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
12 from .node import ( |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
13 hex, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
14 short, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
15 ) |
33252
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
16 from . import ( |
38588
1c93e0237a24
diffutil: move the module out of utils package
Yuya Nishihara <yuya@tcha.org>
parents:
38587
diff
changeset
|
17 diffutil, |
38707
6b5ca1d0aa1e
obsolete: store user name and note in UTF-8 (issue5754) (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
38706
diff
changeset
|
18 encoding, |
45075
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
19 error, |
33252
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
20 phases, |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
21 util, |
33252
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
22 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
23 from .utils import dateutil |
33252
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
24 |
36953
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
25 ### obsolescence marker flag |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
26 |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
27 ## bumpedfix flag |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
28 # |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
29 # When a changeset A' succeed to a changeset A which became public, we call A' |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
30 # "bumped" because it's a successors of a public changesets |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
31 # |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
32 # o A' (bumped) |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
33 # |`: |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
34 # | o A |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
35 # |/ |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
36 # o Z |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
37 # |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
38 # The way to solve this situation is to create a new changeset Ad as children |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
39 # of A. This changeset have the same content than A'. So the diff from A to A' |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
40 # is the same than the diff from A to Ad. Ad is marked as a successors of A' |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
41 # |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
42 # o Ad |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
43 # |`: |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
44 # | x A' |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
45 # |'| |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
46 # o | A |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
47 # |/ |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
48 # o Z |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
49 # |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
50 # But by transitivity Ad is also a successors of A. To avoid having Ad marked |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
51 # as bumped too, we add the `bumpedfix` flag to the marker. <A', (Ad,)>. |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
52 # This flag mean that the successors express the changes between the public and |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
53 # bumped version and fix the situation, breaking the transitivity of |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
54 # "bumped" here. |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
55 bumpedfix = 1 |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
56 usingsha256 = 2 |
b9bbcf9ffac1
obsolete: move marker flags to obsutil
Anton Shestakov <av6@dwimlabs.net>
parents:
36607
diff
changeset
|
57 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
58 |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48913
diff
changeset
|
59 class marker: |
33148
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
60 """Wrap obsolete marker raw data""" |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
61 |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
62 def __init__(self, repo, data): |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
63 # the repo argument will be used to create changectx in later version |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
64 self._repo = repo |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
65 self._data = data |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
66 self._decodedmeta = None |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
67 |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
68 def __hash__(self): |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
69 return hash(self._data) |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
70 |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
71 def __eq__(self, other): |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
72 if type(other) != type(self): |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
73 return False |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
74 return self._data == other._data |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
75 |
33731
2cb442bc1a76
obsmarker: rename precnode into prednode
Boris Feld <boris.feld@octobus.net>
parents:
33713
diff
changeset
|
76 def prednode(self): |
2cb442bc1a76
obsmarker: rename precnode into prednode
Boris Feld <boris.feld@octobus.net>
parents:
33713
diff
changeset
|
77 """Predecessor changeset node identifier""" |
33148
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
78 return self._data[0] |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
79 |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
80 def succnodes(self): |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
81 """List of successor changesets node identifiers""" |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
82 return self._data[1] |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
83 |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
84 def parentnodes(self): |
33731
2cb442bc1a76
obsmarker: rename precnode into prednode
Boris Feld <boris.feld@octobus.net>
parents:
33713
diff
changeset
|
85 """Parents of the predecessors (None if not recorded)""" |
33148
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
86 return self._data[5] |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
87 |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
88 def metadata(self): |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
89 """Decoded metadata dictionary""" |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
90 return dict(self._data[3]) |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
91 |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
92 def date(self): |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
93 """Creation date as (unixtime, offset)""" |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
94 return self._data[4] |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
95 |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
96 def flags(self): |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
97 """The flags field of the marker""" |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
98 return self._data[2] |
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33146
diff
changeset
|
99 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
100 |
33149
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
101 def getmarkers(repo, nodes=None, exclusive=False): |
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
102 """returns markers known in a repository |
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
103 |
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
104 If <nodes> is specified, only markers "relevant" to those nodes are are |
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
105 returned""" |
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
106 if nodes is None: |
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
107 rawmarkers = repo.obsstore |
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
108 elif exclusive: |
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
109 rawmarkers = exclusivemarkers(repo, nodes) |
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
110 else: |
51661
a0f1378b932e
Backed out changeset f28c52a9f7b4
Raphaël Gomès <rgomes@octobus.net>
parents:
51644
diff
changeset
|
111 rawmarkers = repo.obsstore.relevantmarkers(nodes) |
33149
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
112 |
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
113 for markerdata in rawmarkers: |
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
114 yield marker(repo, markerdata) |
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
115 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
116 |
43580
e513e87b0476
py3: fix sorting of obsolete markers in obsutil (issue6217)
Denis Laxalde <denis@laxalde.org>
parents:
43117
diff
changeset
|
117 def sortedmarkers(markers): |
e513e87b0476
py3: fix sorting of obsolete markers in obsutil (issue6217)
Denis Laxalde <denis@laxalde.org>
parents:
43117
diff
changeset
|
118 # last item of marker tuple ('parents') may be None or a tuple |
e513e87b0476
py3: fix sorting of obsolete markers in obsutil (issue6217)
Denis Laxalde <denis@laxalde.org>
parents:
43117
diff
changeset
|
119 return sorted(markers, key=lambda m: m[:-1] + (m[-1] or (),)) |
e513e87b0476
py3: fix sorting of obsolete markers in obsutil (issue6217)
Denis Laxalde <denis@laxalde.org>
parents:
43117
diff
changeset
|
120 |
e513e87b0476
py3: fix sorting of obsolete markers in obsutil (issue6217)
Denis Laxalde <denis@laxalde.org>
parents:
43117
diff
changeset
|
121 |
32879
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
122 def closestpredecessors(repo, nodeid): |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
123 """yield the list of next predecessors pointing on visible changectx nodes |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
124 |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
125 This function respect the repoview filtering, filtered revision will be |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
126 considered missing. |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
127 """ |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
128 |
33733
d5acd967f95a
obsstore: rename precursors into predecessors
Boris Feld <boris.feld@octobus.net>
parents:
33731
diff
changeset
|
129 precursors = repo.obsstore.predecessors |
32879
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
130 stack = [nodeid] |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
131 seen = set(stack) |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
132 |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
133 while stack: |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
134 current = stack.pop() |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
135 currentpreccs = precursors.get(current, ()) |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
136 |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
137 for prec in currentpreccs: |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
138 precnodeid = prec[0] |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
139 |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
140 # Basic cycle protection |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
141 if precnodeid in seen: |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
142 continue |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
143 seen.add(precnodeid) |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
144 |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
145 if precnodeid in repo: |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
146 yield precnodeid |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
147 else: |
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
148 stack.append(precnodeid) |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
149 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
150 |
33735
e6d8ee3c9ec3
obsutil: rename allprecursors into allpredecessors
Boris Feld <boris.feld@octobus.net>
parents:
33733
diff
changeset
|
151 def allpredecessors(obsstore, nodes, ignoreflags=0): |
33144
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
152 """Yield node for every precursors of <nodes>. |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
153 |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
154 Some precursors may be unknown locally. |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
155 |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
156 This is a linear yield unsuited to detecting folded changesets. It includes |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
157 initial nodes too.""" |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
158 |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
159 remaining = set(nodes) |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
160 seen = set(remaining) |
40461
c7618901584d
obsutil: prefetch method in allpredecessors loop
Boris Feld <boris.feld@octobus.net>
parents:
39920
diff
changeset
|
161 prec = obsstore.predecessors.get |
33144
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
162 while remaining: |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
163 current = remaining.pop() |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
164 yield current |
40461
c7618901584d
obsutil: prefetch method in allpredecessors loop
Boris Feld <boris.feld@octobus.net>
parents:
39920
diff
changeset
|
165 for mark in prec(current, ()): |
33144
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
166 # ignore marker flagged with specified flag |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
167 if mark[2] & ignoreflags: |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
168 continue |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
169 suc = mark[0] |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
170 if suc not in seen: |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
171 seen.add(suc) |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
172 remaining.add(suc) |
d0e5bf12f314
obsutil: move 'allprecursors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33143
diff
changeset
|
173 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
174 |
33145
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
175 def allsuccessors(obsstore, nodes, ignoreflags=0): |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
176 """Yield node for every successor of <nodes>. |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
177 |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
178 Some successors may be unknown locally. |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
179 |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
180 This is a linear yield unsuited to detecting split changesets. It includes |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
181 initial nodes too.""" |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
182 remaining = set(nodes) |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
183 seen = set(remaining) |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
184 while remaining: |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
185 current = remaining.pop() |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
186 yield current |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
187 for mark in obsstore.successors.get(current, ()): |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
188 # ignore marker flagged with specified flag |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
189 if mark[2] & ignoreflags: |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
190 continue |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
191 for suc in mark[1]: |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
192 if suc not in seen: |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
193 seen.add(suc) |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
194 remaining.add(suc) |
0a370b93cca2
obsutil: move 'allsuccessors' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33144
diff
changeset
|
195 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
196 |
33143
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
197 def _filterprunes(markers): |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
198 """return a set with no prune markers""" |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
43661
diff
changeset
|
199 return {m for m in markers if m[1]} |
33143
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
200 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
201 |
33143
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
202 def exclusivemarkers(repo, nodes): |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
203 """set of markers relevant to "nodes" but no other locally-known nodes |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
204 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
205 This function compute the set of markers "exclusive" to a locally-known |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
206 node. This means we walk the markers starting from <nodes> until we reach a |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
207 locally-known precursors outside of <nodes>. Element of <nodes> with |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
208 locally-known successors outside of <nodes> are ignored (since their |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
209 precursors markers are also relevant to these successors). |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
210 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
211 For example: |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
212 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
213 # (A0 rewritten as A1) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
214 # |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
215 # A0 <-1- A1 # Marker "1" is exclusive to A1 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
216 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
217 or |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
218 |
48423
fff5942d445f
typo: s/unkown/unknown across the codebase
Raphaël Gomès <rgomes@octobus.net>
parents:
46791
diff
changeset
|
219 # (A0 rewritten as AX; AX rewritten as A1; AX is unknown locally) |
33143
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
220 # |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
221 # <-1- A0 <-2- AX <-3- A1 # Marker "2,3" are exclusive to A1 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
222 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
223 or |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
224 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
225 # (A0 has unknown precursors, A0 rewritten as A1 and A2 (divergence)) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
226 # |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
227 # <-2- A1 # Marker "2" is exclusive to A0,A1 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
228 # / |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
229 # <-1- A0 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
230 # \ |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
231 # <-3- A2 # Marker "3" is exclusive to A0,A2 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
232 # |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
233 # in addition: |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
234 # |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
235 # Markers "2,3" are exclusive to A1,A2 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
236 # Markers "1,2,3" are exclusive to A0,A1,A2 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
237 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
238 See test/test-obsolete-bundle-strip.t for more examples. |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
239 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
240 An example usage is strip. When stripping a changeset, we also want to |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
241 strip the markers exclusive to this changeset. Otherwise we would have |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
242 "dangling"" obsolescence markers from its precursors: Obsolescence markers |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
243 marking a node as obsolete without any successors available locally. |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
244 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
245 As for relevant markers, the prune markers for children will be followed. |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
246 Of course, they will only be followed if the pruned children is |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
247 locally-known. Since the prune markers are relevant to the pruned node. |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
248 However, while prune markers are considered relevant to the parent of the |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
249 pruned changesets, prune markers for locally-known changeset (with no |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
250 successors) are considered exclusive to the pruned nodes. This allows |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
251 to strip the prune markers (with the rest of the exclusive chain) alongside |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
252 the pruned changesets. |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
253 """ |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
254 # running on a filtered repository would be dangerous as markers could be |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
255 # reported as exclusive when they are relevant for other filtered nodes. |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
256 unfi = repo.unfiltered() |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
257 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
258 # shortcut to various useful item |
43540
c8f1e8412db4
index: use `index.has_node` in `obsutil.exclusivemarkers`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
259 has_node = unfi.changelog.index.has_node |
33733
d5acd967f95a
obsstore: rename precursors into predecessors
Boris Feld <boris.feld@octobus.net>
parents:
33731
diff
changeset
|
260 precursorsmarkers = unfi.obsstore.predecessors |
33143
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
261 successormarkers = unfi.obsstore.successors |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
262 childrenmarkers = unfi.obsstore.children |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
263 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
264 # exclusive markers (return of the function) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
265 exclmarkers = set() |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
266 # we need fast membership testing |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
267 nodes = set(nodes) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
268 # looking for head in the obshistory |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
269 # |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
270 # XXX we are ignoring all issues in regard with cycle for now. |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
271 stack = [n for n in nodes if not _filterprunes(successormarkers.get(n, ()))] |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
272 stack.sort() |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
273 # nodes already stacked |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
274 seennodes = set(stack) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
275 while stack: |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
276 current = stack.pop() |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
277 # fetch precursors markers |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
278 markers = list(precursorsmarkers.get(current, ())) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
279 # extend the list with prune markers |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
280 for mark in successormarkers.get(current, ()): |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
281 if not mark[1]: |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
282 markers.append(mark) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
283 # and markers from children (looking for prune) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
284 for mark in childrenmarkers.get(current, ()): |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
285 if not mark[1]: |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
286 markers.append(mark) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
287 # traverse the markers |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
288 for mark in markers: |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
289 if mark in exclmarkers: |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
290 # markers already selected |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
291 continue |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
292 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
293 # If the markers is about the current node, select it |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
294 # |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
295 # (this delay the addition of markers from children) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
296 if mark[1] or mark[0] == current: |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
297 exclmarkers.add(mark) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
298 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
299 # should we keep traversing through the precursors? |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
300 prec = mark[0] |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
301 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
302 # nodes in the stack or already processed |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
303 if prec in seennodes: |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
304 continue |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
305 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
306 # is this a locally known node ? |
43540
c8f1e8412db4
index: use `index.has_node` in `obsutil.exclusivemarkers`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
307 known = has_node(prec) |
33143
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
308 # if locally-known and not in the <nodes> set the traversal |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
309 # stop here. |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
310 if known and prec not in nodes: |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
311 continue |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
312 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
313 # do not keep going if there are unselected markers pointing to this |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
314 # nodes. If we end up traversing these unselected markers later the |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
315 # node will be taken care of at that point. |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
316 precmarkers = _filterprunes(successormarkers.get(prec)) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
317 if precmarkers.issubset(exclmarkers): |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
318 seennodes.add(prec) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
319 stack.append(prec) |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
320 |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
321 return exclmarkers |
d09ae850296d
obsutil: move 'exclusivemarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
322 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
323 |
33146
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
324 def foreground(repo, nodes): |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
325 """return all nodes in the "foreground" of other node |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
326 |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
327 The foreground of a revision is anything reachable using parent -> children |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
328 or precursor -> successor relation. It is very similar to "descendant" but |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
329 augmented with obsolescence information. |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
330 |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
331 Beware that possible obsolescence cycle may result if complex situation. |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
332 """ |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
333 repo = repo.unfiltered() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
334 foreground = set(repo.set(b'%ln::', nodes)) |
33146
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
335 if repo.obsstore: |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
336 # We only need this complicated logic if there is obsolescence |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
337 # XXX will probably deserve an optimised revset. |
43541
1944aaaecabf
index: use `index.has_node` in `obsutil.foreground`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43540
diff
changeset
|
338 has_node = repo.changelog.index.has_node |
33146
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
339 plen = -1 |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
340 # compute the whole set of successors or descendants |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
341 while len(foreground) != plen: |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
342 plen = len(foreground) |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
43661
diff
changeset
|
343 succs = {c.node() for c in foreground} |
33146
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
344 mutable = [c.node() for c in foreground if c.mutable()] |
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
345 succs.update(allsuccessors(repo.obsstore, mutable)) |
43541
1944aaaecabf
index: use `index.has_node` in `obsutil.foreground`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43540
diff
changeset
|
346 known = (n for n in succs if has_node(n)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
347 foreground = set(repo.set(b'%ln::', known)) |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
43661
diff
changeset
|
348 return {c.node() for c in foreground} |
33146
7017567ebdf2
obsutil: move 'foreground' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33145
diff
changeset
|
349 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
350 |
34422
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
351 # effectflag field |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
352 # |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
353 # Effect-flag is a 1-byte bit field used to store what changed between a |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
354 # changeset and its successor(s). |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
355 # |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
356 # The effect flag is stored in obs-markers metadata while we iterate on the |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
357 # information design. That's why we have the EFFECTFLAGFIELD. If we come up |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
358 # with an incompatible design for effect flag, we can store a new design under |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
359 # another field name so we don't break readers. We plan to extend the existing |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
360 # obsmarkers bit-field when the effect flag design will be stabilized. |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
361 # |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
362 # The effect-flag is placed behind an experimental flag |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
363 # `effect-flags` set to off by default. |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
364 # |
2fd06499dc8e
effectflag: document effect flag
Boris Feld <boris.feld@octobus.net>
parents:
34421
diff
changeset
|
365 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
366 EFFECTFLAGFIELD = b"ef1" |
34413
014d467f9d08
effectflag: store an empty effect flag for the moment
Boris Feld <boris.feld@octobus.net>
parents:
34287
diff
changeset
|
367 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
368 DESCCHANGED = 1 << 0 # action changed the description |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
369 METACHANGED = 1 << 1 # action change the meta |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
370 DIFFCHANGED = 1 << 3 # action change diff introduced by the changeset |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
371 PARENTCHANGED = 1 << 2 # action change the parent |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
372 USERCHANGED = 1 << 4 # the user changed |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
373 DATECHANGED = 1 << 5 # the date changed |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
374 BRANCHCHANGED = 1 << 6 # the branch changed |
34415
51aadc0d0da2
effectflag: detect when description changed
Boris Feld <boris.feld@octobus.net>
parents:
34413
diff
changeset
|
375 |
34420
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
376 METABLACKLIST = [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
377 re.compile(b'^branch$'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
378 re.compile(b'^.*-source$'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
379 re.compile(b'^.*_source$'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
380 re.compile(b'^source$'), |
34420
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
381 ] |
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
382 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
383 |
34420
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
384 def metanotblacklisted(metaitem): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45075
diff
changeset
|
385 """Check that the key of a meta item (extrakey, extravalue) does not |
34420
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
386 match at least one of the blacklist pattern |
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
387 """ |
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
388 metakey = metaitem[0] |
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
389 |
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
390 return not any(pattern.match(metakey) for pattern in METABLACKLIST) |
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
391 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
392 |
34421
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
393 def _prepare_hunk(hunk): |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
394 """Drop all information but the username and patch""" |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
395 cleanhunk = [] |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
396 for line in hunk.splitlines(): |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
397 if line.startswith(b'# User') or not line.startswith(b'#'): |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
398 if line.startswith(b'@@'): |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
399 line = b'@@\n' |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
400 cleanhunk.append(line) |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
401 return cleanhunk |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
402 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
403 |
34421
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
404 def _getdifflines(iterdiff): |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
405 """return a cleaned up lines""" |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
406 lines = next(iterdiff, None) |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
407 |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
408 if lines is None: |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
409 return lines |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
410 |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
411 return _prepare_hunk(lines) |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
412 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
413 |
34421
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
414 def _cmpdiff(leftctx, rightctx): |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
415 """return True if both ctx introduce the "same diff" |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
416 |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
417 This is a first and basic implementation, with many shortcoming. |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
418 """ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
419 diffopts = diffutil.diffallopts(leftctx.repo().ui, {b'git': True}) |
41713
9de6c4f61608
obsutil: don't assume leftctx and rightctx repo as same
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41152
diff
changeset
|
420 |
34421
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
421 # Leftctx or right ctx might be filtered, so we need to use the contexts |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
422 # with an unfiltered repository to safely compute the diff |
41713
9de6c4f61608
obsutil: don't assume leftctx and rightctx repo as same
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41152
diff
changeset
|
423 |
9de6c4f61608
obsutil: don't assume leftctx and rightctx repo as same
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41152
diff
changeset
|
424 # leftctx and rightctx can be from different repository views in case of |
9de6c4f61608
obsutil: don't assume leftctx and rightctx repo as same
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41152
diff
changeset
|
425 # hgsubversion, do don't try to access them from same repository |
9de6c4f61608
obsutil: don't assume leftctx and rightctx repo as same
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41152
diff
changeset
|
426 # rightctx.repo() and leftctx.repo() are not always the same |
9de6c4f61608
obsutil: don't assume leftctx and rightctx repo as same
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41152
diff
changeset
|
427 leftunfi = leftctx._repo.unfiltered()[leftctx.rev()] |
38568
f65e6095c5ac
obsutil: pass a diffopts object to context.diff
Boris Feld <boris.feld@octobus.net>
parents:
38519
diff
changeset
|
428 leftdiff = leftunfi.diff(opts=diffopts) |
41713
9de6c4f61608
obsutil: don't assume leftctx and rightctx repo as same
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41152
diff
changeset
|
429 rightunfi = rightctx._repo.unfiltered()[rightctx.rev()] |
38568
f65e6095c5ac
obsutil: pass a diffopts object to context.diff
Boris Feld <boris.feld@octobus.net>
parents:
38519
diff
changeset
|
430 rightdiff = rightunfi.diff(opts=diffopts) |
34421
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
431 |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
432 left, right = (0, 0) |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
433 while None not in (left, right): |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
434 left = _getdifflines(leftdiff) |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
435 right = _getdifflines(rightdiff) |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
436 |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
437 if left != right: |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
438 return False |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
439 return True |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
440 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
441 |
39920
bae6f1418a95
obsolete: explicitly pass relation items to effectflag computation
Boris Feld <boris.feld@octobus.net>
parents:
39325
diff
changeset
|
442 def geteffectflag(source, successors): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45075
diff
changeset
|
443 """From an obs-marker relation, compute what changed between the |
34413
014d467f9d08
effectflag: store an empty effect flag for the moment
Boris Feld <boris.feld@octobus.net>
parents:
34287
diff
changeset
|
444 predecessor and the successor. |
014d467f9d08
effectflag: store an empty effect flag for the moment
Boris Feld <boris.feld@octobus.net>
parents:
34287
diff
changeset
|
445 """ |
014d467f9d08
effectflag: store an empty effect flag for the moment
Boris Feld <boris.feld@octobus.net>
parents:
34287
diff
changeset
|
446 effects = 0 |
014d467f9d08
effectflag: store an empty effect flag for the moment
Boris Feld <boris.feld@octobus.net>
parents:
34287
diff
changeset
|
447 |
39920
bae6f1418a95
obsolete: explicitly pass relation items to effectflag computation
Boris Feld <boris.feld@octobus.net>
parents:
39325
diff
changeset
|
448 for changectx in successors: |
34415
51aadc0d0da2
effectflag: detect when description changed
Boris Feld <boris.feld@octobus.net>
parents:
34413
diff
changeset
|
449 # Check if description has changed |
51aadc0d0da2
effectflag: detect when description changed
Boris Feld <boris.feld@octobus.net>
parents:
34413
diff
changeset
|
450 if changectx.description() != source.description(): |
51aadc0d0da2
effectflag: detect when description changed
Boris Feld <boris.feld@octobus.net>
parents:
34413
diff
changeset
|
451 effects |= DESCCHANGED |
51aadc0d0da2
effectflag: detect when description changed
Boris Feld <boris.feld@octobus.net>
parents:
34413
diff
changeset
|
452 |
34416
55ef17ec8e59
effectflag: detect when user changed
Boris Feld <boris.feld@octobus.net>
parents:
34415
diff
changeset
|
453 # Check if user has changed |
55ef17ec8e59
effectflag: detect when user changed
Boris Feld <boris.feld@octobus.net>
parents:
34415
diff
changeset
|
454 if changectx.user() != source.user(): |
55ef17ec8e59
effectflag: detect when user changed
Boris Feld <boris.feld@octobus.net>
parents:
34415
diff
changeset
|
455 effects |= USERCHANGED |
55ef17ec8e59
effectflag: detect when user changed
Boris Feld <boris.feld@octobus.net>
parents:
34415
diff
changeset
|
456 |
34417
54af8de9bd09
effectflag: detect when date changed
Boris Feld <boris.feld@octobus.net>
parents:
34416
diff
changeset
|
457 # Check if date has changed |
54af8de9bd09
effectflag: detect when date changed
Boris Feld <boris.feld@octobus.net>
parents:
34416
diff
changeset
|
458 if changectx.date() != source.date(): |
54af8de9bd09
effectflag: detect when date changed
Boris Feld <boris.feld@octobus.net>
parents:
34416
diff
changeset
|
459 effects |= DATECHANGED |
54af8de9bd09
effectflag: detect when date changed
Boris Feld <boris.feld@octobus.net>
parents:
34416
diff
changeset
|
460 |
34418
57980af73cfa
effectflag: detect when branch changed
Boris Feld <boris.feld@octobus.net>
parents:
34417
diff
changeset
|
461 # Check if branch has changed |
57980af73cfa
effectflag: detect when branch changed
Boris Feld <boris.feld@octobus.net>
parents:
34417
diff
changeset
|
462 if changectx.branch() != source.branch(): |
57980af73cfa
effectflag: detect when branch changed
Boris Feld <boris.feld@octobus.net>
parents:
34417
diff
changeset
|
463 effects |= BRANCHCHANGED |
57980af73cfa
effectflag: detect when branch changed
Boris Feld <boris.feld@octobus.net>
parents:
34417
diff
changeset
|
464 |
34419
fa26f5891e68
effectflag: detect when parents changed
Boris Feld <boris.feld@octobus.net>
parents:
34418
diff
changeset
|
465 # Check if at least one of the parent has changed |
fa26f5891e68
effectflag: detect when parents changed
Boris Feld <boris.feld@octobus.net>
parents:
34418
diff
changeset
|
466 if changectx.parents() != source.parents(): |
fa26f5891e68
effectflag: detect when parents changed
Boris Feld <boris.feld@octobus.net>
parents:
34418
diff
changeset
|
467 effects |= PARENTCHANGED |
fa26f5891e68
effectflag: detect when parents changed
Boris Feld <boris.feld@octobus.net>
parents:
34418
diff
changeset
|
468 |
34420
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
469 # Check if other meta has changed |
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
470 changeextra = changectx.extra().items() |
51502
a5d8f261b716
obsutil: sort metadata before comparing in geteffectflag()
Anton Shestakov <av6@dwimlabs.net>
parents:
48946
diff
changeset
|
471 ctxmeta = sorted(filter(metanotblacklisted, changeextra)) |
34420
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
472 |
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
473 sourceextra = source.extra().items() |
51502
a5d8f261b716
obsutil: sort metadata before comparing in geteffectflag()
Anton Shestakov <av6@dwimlabs.net>
parents:
48946
diff
changeset
|
474 srcmeta = sorted(filter(metanotblacklisted, sourceextra)) |
34420
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
475 |
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
476 if ctxmeta != srcmeta: |
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
477 effects |= METACHANGED |
95759620d492
effectflag: detect when meta changed
Boris Feld <boris.feld@octobus.net>
parents:
34419
diff
changeset
|
478 |
34421
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
479 # Check if the diff has changed |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
480 if not _cmpdiff(source, changectx): |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
481 effects |= DIFFCHANGED |
187bc224554a
effectflag: detect when diff changed
Boris Feld <boris.feld@octobus.net>
parents:
34420
diff
changeset
|
482 |
34413
014d467f9d08
effectflag: store an empty effect flag for the moment
Boris Feld <boris.feld@octobus.net>
parents:
34287
diff
changeset
|
483 return effects |
014d467f9d08
effectflag: store an empty effect flag for the moment
Boris Feld <boris.feld@octobus.net>
parents:
34287
diff
changeset
|
484 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
485 |
45075
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
486 def getobsoleted(repo, tr=None, changes=None): |
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
487 """return the set of pre-existing revisions obsoleted by a transaction |
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
488 |
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
489 Either the transaction or changes item of the transaction (for hooks) |
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
490 must be provided, but not both. |
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
491 """ |
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
492 if (tr is None) == (changes is None): |
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
493 e = b"exactly one of tr and changes must be provided" |
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
494 raise error.ProgrammingError(e) |
43557
acaff50079ff
index: use `index.get_rev` in `obsutil.getobsoleted`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43541
diff
changeset
|
495 torev = repo.unfiltered().changelog.index.get_rev |
33252
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
496 phase = repo._phasecache.phase |
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
497 succsmarkers = repo.obsstore.successors.get |
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
498 public = phases.public |
45075
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
499 if changes is None: |
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
500 changes = tr.changes |
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
501 addedmarkers = changes[b'obsmarkers'] |
04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
502 origrepolen = changes[b'origrepolen'] |
35308
137a08d82232
transaction: build changes['revs'] as range instead of a set
Joerg Sonnenberger <joerg@bec.de>
parents:
35010
diff
changeset
|
503 seenrevs = set() |
33252
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
504 obsoleted = set() |
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
505 for mark in addedmarkers: |
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
506 node = mark[0] |
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
507 rev = torev(node) |
39301
5763216ba311
transaction: remember original len(repo) instead of tracking added revs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
39300
diff
changeset
|
508 if rev is None or rev in seenrevs or rev >= origrepolen: |
33252
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
509 continue |
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
510 seenrevs.add(rev) |
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
511 if phase(repo, rev) == public: |
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
512 continue |
33713
888f24810ea2
obsutil: defend against succsmarkers() returning None
Augie Fackler <augie@google.com>
parents:
33274
diff
changeset
|
513 if set(succsmarkers(node) or []).issubset(addedmarkers): |
33252
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
514 obsoleted.add(rev) |
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
515 return obsoleted |
53b3a1968aa6
obsolete: reports the number of local changeset obsoleted when unbundling
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33149
diff
changeset
|
516 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
517 |
33909
84f72072bde6
obsolete: introduce a _succs class
Boris Feld <boris.feld@octobus.net>
parents:
33857
diff
changeset
|
518 class _succs(list): |
84f72072bde6
obsolete: introduce a _succs class
Boris Feld <boris.feld@octobus.net>
parents:
33857
diff
changeset
|
519 """small class to represent a successors with some metadata about it""" |
84f72072bde6
obsolete: introduce a _succs class
Boris Feld <boris.feld@octobus.net>
parents:
33857
diff
changeset
|
520 |
33911
34e10e09afa5
obsolete: track markers in _succs
Boris Feld <boris.feld@octobus.net>
parents:
33910
diff
changeset
|
521 def __init__(self, *args, **kwargs): |
34e10e09afa5
obsolete: track markers in _succs
Boris Feld <boris.feld@octobus.net>
parents:
33910
diff
changeset
|
522 super(_succs, self).__init__(*args, **kwargs) |
34e10e09afa5
obsolete: track markers in _succs
Boris Feld <boris.feld@octobus.net>
parents:
33910
diff
changeset
|
523 self.markers = set() |
34e10e09afa5
obsolete: track markers in _succs
Boris Feld <boris.feld@octobus.net>
parents:
33910
diff
changeset
|
524 |
33910
dba493981284
obsolete: add an explicit '_succs.copy()' method
Boris Feld <boris.feld@octobus.net>
parents:
33909
diff
changeset
|
525 def copy(self): |
33911
34e10e09afa5
obsolete: track markers in _succs
Boris Feld <boris.feld@octobus.net>
parents:
33910
diff
changeset
|
526 new = _succs(self) |
34e10e09afa5
obsolete: track markers in _succs
Boris Feld <boris.feld@octobus.net>
parents:
33910
diff
changeset
|
527 new.markers = self.markers.copy() |
34e10e09afa5
obsolete: track markers in _succs
Boris Feld <boris.feld@octobus.net>
parents:
33910
diff
changeset
|
528 return new |
33910
dba493981284
obsolete: add an explicit '_succs.copy()' method
Boris Feld <boris.feld@octobus.net>
parents:
33909
diff
changeset
|
529 |
33941
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
530 @util.propertycache |
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
531 def _set(self): |
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
532 # immutable |
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
533 return set(self) |
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
534 |
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
535 def canmerge(self, other): |
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
536 return self._set.issubset(other._set) |
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
537 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
538 |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
539 def successorssets(repo, initialnode, closest=False, cache=None): |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
540 """Return set of all latest successors of initial nodes |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
541 |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
542 The successors set of a changeset A are the group of revisions that succeed |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
543 A. It succeeds A as a consistent whole, each revision being only a partial |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
544 replacement. By default, the successors set contains non-obsolete |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
545 changesets only, walking the obsolescence graph until reaching a leaf. If |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
546 'closest' is set to True, closest successors-sets are return (the |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
547 obsolescence walk stops on known changesets). |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
548 |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
549 This function returns the full list of successor sets which is why it |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
550 returns a list of tuples and not just a single tuple. Each tuple is a valid |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
551 successors set. Note that (A,) may be a valid successors set for changeset A |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
552 (see below). |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
553 |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
554 In most cases, a changeset A will have a single element (e.g. the changeset |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
555 A is replaced by A') in its successors set. Though, it is also common for a |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
556 changeset A to have no elements in its successor set (e.g. the changeset |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
557 has been pruned). Therefore, the returned list of successors sets will be |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
558 [(A',)] or [], respectively. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
559 |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
560 When a changeset A is split into A' and B', however, it will result in a |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
561 successors set containing more than a single element, i.e. [(A',B')]. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
562 Divergent changesets will result in multiple successors sets, i.e. [(A',), |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
563 (A'')]. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
564 |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
565 If a changeset A is not obsolete, then it will conceptually have no |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
566 successors set. To distinguish this from a pruned changeset, the successor |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
567 set will contain itself only, i.e. [(A,)]. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
568 |
33272
df90f4d6c609
obsolete: small doc update for 'successorssets'
Boris Feld <boris.feld@octobus.net>
parents:
33252
diff
changeset
|
569 Finally, final successors unknown locally are considered to be pruned |
df90f4d6c609
obsolete: small doc update for 'successorssets'
Boris Feld <boris.feld@octobus.net>
parents:
33252
diff
changeset
|
570 (pruned: obsoleted without any successors). (Final: successors not affected |
df90f4d6c609
obsolete: small doc update for 'successorssets'
Boris Feld <boris.feld@octobus.net>
parents:
33252
diff
changeset
|
571 by markers). |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
572 |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
573 The 'closest' mode respect the repoview filtering. For example, without |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
574 filter it will stop at the first locally known changeset, with 'visible' |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
575 filter it will stop on visible changesets). |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
576 |
33272
df90f4d6c609
obsolete: small doc update for 'successorssets'
Boris Feld <boris.feld@octobus.net>
parents:
33252
diff
changeset
|
577 The optional `cache` parameter is a dictionary that may contains |
df90f4d6c609
obsolete: small doc update for 'successorssets'
Boris Feld <boris.feld@octobus.net>
parents:
33252
diff
changeset
|
578 precomputed successors sets. It is meant to reuse the computation of a |
df90f4d6c609
obsolete: small doc update for 'successorssets'
Boris Feld <boris.feld@octobus.net>
parents:
33252
diff
changeset
|
579 previous call to `successorssets` when multiple calls are made at the same |
df90f4d6c609
obsolete: small doc update for 'successorssets'
Boris Feld <boris.feld@octobus.net>
parents:
33252
diff
changeset
|
580 time. The cache dictionary is updated in place. The caller is responsible |
df90f4d6c609
obsolete: small doc update for 'successorssets'
Boris Feld <boris.feld@octobus.net>
parents:
33252
diff
changeset
|
581 for its life span. Code that makes multiple calls to `successorssets` |
df90f4d6c609
obsolete: small doc update for 'successorssets'
Boris Feld <boris.feld@octobus.net>
parents:
33252
diff
changeset
|
582 *should* use this cache mechanism or risk a performance hit. |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
583 |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
584 Since results are different depending of the 'closest' most, the same cache |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
585 cannot be reused for both mode. |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
586 """ |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
587 |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
588 succmarkers = repo.obsstore.successors |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
589 |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
590 # Stack of nodes we search successors sets for |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
591 toproceed = [initialnode] |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
592 # set version of above list for fast loop detection |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
593 # element added to "toproceed" must be added here |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
594 stackedset = set(toproceed) |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
595 if cache is None: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
596 cache = {} |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
597 |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
598 # This while loop is the flattened version of a recursive search for |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
599 # successors sets |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
600 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
601 # def successorssets(x): |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
602 # successors = directsuccessors(x) |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
603 # ss = [[]] |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
604 # for succ in directsuccessors(x): |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
605 # # product as in itertools cartesian product |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
606 # ss = product(ss, successorssets(succ)) |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
607 # return ss |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
608 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
609 # But we can not use plain recursive calls here: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
610 # - that would blow the python call stack |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
611 # - obsolescence markers may have cycles, we need to handle them. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
612 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
613 # The `toproceed` list act as our call stack. Every node we search |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
614 # successors set for are stacked there. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
615 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
616 # The `stackedset` is set version of this stack used to check if a node is |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
617 # already stacked. This check is used to detect cycles and prevent infinite |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
618 # loop. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
619 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
620 # successors set of all nodes are stored in the `cache` dictionary. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
621 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
622 # After this while loop ends we use the cache to return the successors sets |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
623 # for the node requested by the caller. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
624 while toproceed: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
625 # Every iteration tries to compute the successors sets of the topmost |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
626 # node of the stack: CURRENT. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
627 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
628 # There are four possible outcomes: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
629 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
630 # 1) We already know the successors sets of CURRENT: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
631 # -> mission accomplished, pop it from the stack. |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
632 # 2) Stop the walk: |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
633 # default case: Node is not obsolete |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
634 # closest case: Node is known at this repo filter level |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
635 # -> the node is its own successors sets. Add it to the cache. |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
636 # 3) We do not know successors set of direct successors of CURRENT: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
637 # -> We add those successors to the stack. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
638 # 4) We know successors sets of all direct successors of CURRENT: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
639 # -> We can compute CURRENT successors set and add it to the |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
640 # cache. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
641 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
642 current = toproceed[-1] |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
643 |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
644 # case 2 condition is a bit hairy because of closest, |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
645 # we compute it on its own |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
646 case2condition = (current not in succmarkers) or ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
647 closest and current != initialnode and current in repo |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
648 ) |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
649 |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
650 if current in cache: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
651 # case (1): We already know the successors sets |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
652 stackedset.remove(toproceed.pop()) |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
653 elif case2condition: |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
654 # case (2): end of walk. |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
655 if current in repo: |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33272
diff
changeset
|
656 # We have a valid successors. |
33909
84f72072bde6
obsolete: introduce a _succs class
Boris Feld <boris.feld@octobus.net>
parents:
33857
diff
changeset
|
657 cache[current] = [_succs((current,))] |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
658 else: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
659 # Final obsolete version is unknown locally. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
660 # Do not count that as a valid successors |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
661 cache[current] = [] |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
662 else: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
663 # cases (3) and (4) |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
664 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
665 # We proceed in two phases. Phase 1 aims to distinguish case (3) |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
666 # from case (4): |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
667 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
668 # For each direct successors of CURRENT, we check whether its |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
669 # successors sets are known. If they are not, we stack the |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
670 # unknown node and proceed to the next iteration of the while |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
671 # loop. (case 3) |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
672 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
673 # During this step, we may detect obsolescence cycles: a node |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
674 # with unknown successors sets but already in the call stack. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
675 # In such a situation, we arbitrary set the successors sets of |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
676 # the node to nothing (node pruned) to break the cycle. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
677 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
678 # If no break was encountered we proceed to phase 2. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
679 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
680 # Phase 2 computes successors sets of CURRENT (case 4); see details |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
681 # in phase 2 itself. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
682 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
683 # Note the two levels of iteration in each phase. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
684 # - The first one handles obsolescence markers using CURRENT as |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
685 # precursor (successors markers of CURRENT). |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
686 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
687 # Having multiple entry here means divergence. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
688 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
689 # - The second one handles successors defined in each marker. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
690 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
691 # Having none means pruned node, multiple successors means split, |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
692 # single successors are standard replacement. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
693 # |
43580
e513e87b0476
py3: fix sorting of obsolete markers in obsutil (issue6217)
Denis Laxalde <denis@laxalde.org>
parents:
43117
diff
changeset
|
694 for mark in sortedmarkers(succmarkers[current]): |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
695 for suc in mark[1]: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
696 if suc not in cache: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
697 if suc in stackedset: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
698 # cycle breaking |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
699 cache[suc] = [] |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
700 else: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
701 # case (3) If we have not computed successors sets |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
702 # of one of those successors we add it to the |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
703 # `toproceed` stack and stop all work for this |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
704 # iteration. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
705 toproceed.append(suc) |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
706 stackedset.add(suc) |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
707 break |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
708 else: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
709 continue |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
710 break |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
711 else: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
712 # case (4): we know all successors sets of all direct |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
713 # successors |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
714 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
715 # Successors set contributed by each marker depends on the |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
716 # successors sets of all its "successors" node. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
717 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
718 # Each different marker is a divergence in the obsolescence |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
719 # history. It contributes successors sets distinct from other |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
720 # markers. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
721 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
722 # Within a marker, a successor may have divergent successors |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
723 # sets. In such a case, the marker will contribute multiple |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
724 # divergent successors sets. If multiple successors have |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
725 # divergent successors sets, a Cartesian product is used. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
726 # |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
727 # At the end we post-process successors sets to remove |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
728 # duplicated entry and successors set that are strict subset of |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
729 # another one. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
730 succssets = [] |
43580
e513e87b0476
py3: fix sorting of obsolete markers in obsutil (issue6217)
Denis Laxalde <denis@laxalde.org>
parents:
43117
diff
changeset
|
731 for mark in sortedmarkers(succmarkers[current]): |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
732 # successors sets contributed by this marker |
33911
34e10e09afa5
obsolete: track markers in _succs
Boris Feld <boris.feld@octobus.net>
parents:
33910
diff
changeset
|
733 base = _succs() |
34e10e09afa5
obsolete: track markers in _succs
Boris Feld <boris.feld@octobus.net>
parents:
33910
diff
changeset
|
734 base.markers.add(mark) |
34e10e09afa5
obsolete: track markers in _succs
Boris Feld <boris.feld@octobus.net>
parents:
33910
diff
changeset
|
735 markss = [base] |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
736 for suc in mark[1]: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
737 # cardinal product with previous successors |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
738 productresult = [] |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
739 for prefix in markss: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
740 for suffix in cache[suc]: |
33910
dba493981284
obsolete: add an explicit '_succs.copy()' method
Boris Feld <boris.feld@octobus.net>
parents:
33909
diff
changeset
|
741 newss = prefix.copy() |
33911
34e10e09afa5
obsolete: track markers in _succs
Boris Feld <boris.feld@octobus.net>
parents:
33910
diff
changeset
|
742 newss.markers.update(suffix.markers) |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
743 for part in suffix: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
744 # do not duplicated entry in successors set |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
745 # first entry wins. |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
746 if part not in newss: |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
747 newss.append(part) |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
748 productresult.append(newss) |
41152
191fac9ff9d3
obsutil: fix the issue5686
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
40528
diff
changeset
|
749 if productresult: |
191fac9ff9d3
obsutil: fix the issue5686
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
40528
diff
changeset
|
750 markss = productresult |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
751 succssets.extend(markss) |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
752 # remove duplicated and subset |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
753 seen = [] |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
754 final = [] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
755 candidates = sorted( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
756 (s for s in succssets if s), key=len, reverse=True |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
757 ) |
33942
54c21114e41d
obsolete: fix old typo
Boris Feld <boris.feld@octobus.net>
parents:
33941
diff
changeset
|
758 for cand in candidates: |
33941
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
759 for seensuccs in seen: |
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
760 if cand.canmerge(seensuccs): |
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
761 seensuccs.markers.update(cand.markers) |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
762 break |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
763 else: |
33941
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
764 final.append(cand) |
c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Boris Feld <boris.feld@octobus.net>
parents:
33912
diff
changeset
|
765 seen.append(cand) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
766 final.reverse() # put small successors set first |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
767 cache[current] = final |
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32879
diff
changeset
|
768 return cache[initialnode] |
33912
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
769 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
770 |
33912
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
771 def successorsandmarkers(repo, ctx): |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
772 """compute the raw data needed for computing obsfate |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
773 Returns a list of dict, one dict per successors set |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
774 """ |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
775 if not ctx.obsolete(): |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
776 return None |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
777 |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
778 ssets = successorssets(repo, ctx.node(), closest=True) |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
779 |
33996
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
780 # closestsuccessors returns an empty list for pruned revisions, remap it |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
781 # into a list containing an empty list for future processing |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
782 if ssets == []: |
46791
d35063ebd761
obsutil: maintain a homogenous list when computing successors
Matt Harbison <matt_harbison@yahoo.com>
parents:
46113
diff
changeset
|
783 ssets = [_succs()] |
33996
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
784 |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
785 # Try to recover pruned markers |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
786 succsmap = repo.obsstore.successors |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
787 fullsuccessorsets = [] # successor set + markers |
33996
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
788 for sset in ssets: |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
789 if sset: |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
790 fullsuccessorsets.append(sset) |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
791 else: |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
792 # successorsset return an empty set() when ctx or one of its |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
793 # successors is pruned. |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
794 # In this case, walk the obs-markers tree again starting with ctx |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
795 # and find the relevant pruning obs-makers, the ones without |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
796 # successors. |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
797 # Having these markers allow us to compute some information about |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
798 # its fate, like who pruned this changeset and when. |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
799 |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
800 # XXX we do not catch all prune markers (eg rewritten then pruned) |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
801 # (fix me later) |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
802 foundany = False |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
803 for mark in succsmap.get(ctx.node(), ()): |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
804 if not mark[1]: |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
805 foundany = True |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
806 sset = _succs() |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
807 sset.markers.add(mark) |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
808 fullsuccessorsets.append(sset) |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
809 if not foundany: |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
810 fullsuccessorsets.append(_succs()) |
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
811 |
33912
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
812 values = [] |
33996
98fa777cd7a1
template: better prune support in obsfate
Boris Feld <boris.feld@octobus.net>
parents:
33995
diff
changeset
|
813 for sset in fullsuccessorsets: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
814 values.append({b'successors': sset, b'markers': sset.markers}) |
33912
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
815 |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33911
diff
changeset
|
816 return values |
33993
3d0f8918351b
template: compute verb in obsfateverb
Boris Feld <boris.feld@octobus.net>
parents:
33942
diff
changeset
|
817 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
818 |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
819 def _getobsfate(successorssets): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45075
diff
changeset
|
820 """Compute a changeset obsolescence fate based on its successorssets. |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
821 Successors can be the tipmost ones or the immediate ones. This function |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
822 return values are not meant to be shown directly to users, it is meant to |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
823 be used by internal functions only. |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
824 Returns one fate from the following values: |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
825 - pruned |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
826 - diverged |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
827 - superseded |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
828 - superseded_split |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
829 """ |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
830 |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
831 if len(successorssets) == 0: |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
832 # The commit has been pruned |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
833 return b'pruned' |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
834 elif len(successorssets) > 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
835 return b'diverged' |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
836 else: |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
837 # No divergence, only one set of successors |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
838 successors = successorssets[0] |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
839 |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
840 if len(successors) == 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
841 return b'superseded' |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
842 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
843 return b'superseded_split' |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
844 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
845 |
35010
b81ad5b78a81
obsfate: makes successorsetverb takes the markers as argument
Boris Feld <boris.feld@octobus.net>
parents:
34873
diff
changeset
|
846 def obsfateverb(successorset, markers): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45075
diff
changeset
|
847 """Return the verb summarizing the successorset and potentially using |
35010
b81ad5b78a81
obsfate: makes successorsetverb takes the markers as argument
Boris Feld <boris.feld@octobus.net>
parents:
34873
diff
changeset
|
848 information from the markers |
33993
3d0f8918351b
template: compute verb in obsfateverb
Boris Feld <boris.feld@octobus.net>
parents:
33942
diff
changeset
|
849 """ |
3d0f8918351b
template: compute verb in obsfateverb
Boris Feld <boris.feld@octobus.net>
parents:
33942
diff
changeset
|
850 if not successorset: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
851 verb = b'pruned' |
33993
3d0f8918351b
template: compute verb in obsfateverb
Boris Feld <boris.feld@octobus.net>
parents:
33942
diff
changeset
|
852 elif len(successorset) == 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
853 verb = b'rewritten' |
33993
3d0f8918351b
template: compute verb in obsfateverb
Boris Feld <boris.feld@octobus.net>
parents:
33942
diff
changeset
|
854 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
855 verb = b'split' |
33993
3d0f8918351b
template: compute verb in obsfateverb
Boris Feld <boris.feld@octobus.net>
parents:
33942
diff
changeset
|
856 return verb |
33994
38f08eaba6b0
template: compute user in obsfateusers
Boris Feld <boris.feld@octobus.net>
parents:
33993
diff
changeset
|
857 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
858 |
33995
c35c0f54f420
template: compute dates in obsfatedate
Boris Feld <boris.feld@octobus.net>
parents:
33994
diff
changeset
|
859 def markersdates(markers): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45075
diff
changeset
|
860 """returns the list of dates for a list of markers""" |
33995
c35c0f54f420
template: compute dates in obsfatedate
Boris Feld <boris.feld@octobus.net>
parents:
33994
diff
changeset
|
861 return [m[4] for m in markers] |
c35c0f54f420
template: compute dates in obsfatedate
Boris Feld <boris.feld@octobus.net>
parents:
33994
diff
changeset
|
862 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
863 |
33994
38f08eaba6b0
template: compute user in obsfateusers
Boris Feld <boris.feld@octobus.net>
parents:
33993
diff
changeset
|
864 def markersusers(markers): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45075
diff
changeset
|
865 """Returns a sorted list of markers users without duplicates""" |
33994
38f08eaba6b0
template: compute user in obsfateusers
Boris Feld <boris.feld@octobus.net>
parents:
33993
diff
changeset
|
866 markersmeta = [dict(m[3]) for m in markers] |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
43661
diff
changeset
|
867 users = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
868 encoding.tolocal(meta[b'user']) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
869 for meta in markersmeta |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
870 if meta.get(b'user') |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
43661
diff
changeset
|
871 } |
33994
38f08eaba6b0
template: compute user in obsfateusers
Boris Feld <boris.feld@octobus.net>
parents:
33993
diff
changeset
|
872 |
38f08eaba6b0
template: compute user in obsfateusers
Boris Feld <boris.feld@octobus.net>
parents:
33993
diff
changeset
|
873 return sorted(users) |
34287
7cdc8c5a481a
templates: introduce a obsfateoperation() function
Martin von Zweigbergk <martinvonz@google.com>
parents:
33996
diff
changeset
|
874 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
875 |
34287
7cdc8c5a481a
templates: introduce a obsfateoperation() function
Martin von Zweigbergk <martinvonz@google.com>
parents:
33996
diff
changeset
|
876 def markersoperations(markers): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45075
diff
changeset
|
877 """Returns a sorted list of markers operations without duplicates""" |
34287
7cdc8c5a481a
templates: introduce a obsfateoperation() function
Martin von Zweigbergk <martinvonz@google.com>
parents:
33996
diff
changeset
|
878 markersmeta = [dict(m[3]) for m in markers] |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
43661
diff
changeset
|
879 operations = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
880 meta.get(b'operation') for meta in markersmeta if meta.get(b'operation') |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
43661
diff
changeset
|
881 } |
34287
7cdc8c5a481a
templates: introduce a obsfateoperation() function
Martin von Zweigbergk <martinvonz@google.com>
parents:
33996
diff
changeset
|
882 |
7cdc8c5a481a
templates: introduce a obsfateoperation() function
Martin von Zweigbergk <martinvonz@google.com>
parents:
33996
diff
changeset
|
883 return sorted(operations) |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
884 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
885 |
37328
11d51e518808
obsutil: make obsfateprinter() less dependent on templater
Yuya Nishihara <yuya@tcha.org>
parents:
36954
diff
changeset
|
886 def obsfateprinter(ui, repo, successors, markers, formatctx): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45075
diff
changeset
|
887 """Build a obsfate string for a single successorset using all obsfate |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
888 related function defined in obsutil |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
889 """ |
34850
62a4ccf9784a
obsfate: filter out current user if not in verbose
Boris Feld <boris.feld@octobus.net>
parents:
34847
diff
changeset
|
890 quiet = ui.quiet |
62a4ccf9784a
obsfate: filter out current user if not in verbose
Boris Feld <boris.feld@octobus.net>
parents:
34847
diff
changeset
|
891 verbose = ui.verbose |
62a4ccf9784a
obsfate: filter out current user if not in verbose
Boris Feld <boris.feld@octobus.net>
parents:
34847
diff
changeset
|
892 normal = not verbose and not quiet |
62a4ccf9784a
obsfate: filter out current user if not in verbose
Boris Feld <boris.feld@octobus.net>
parents:
34847
diff
changeset
|
893 |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
894 line = [] |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
895 |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
896 # Verb |
35010
b81ad5b78a81
obsfate: makes successorsetverb takes the markers as argument
Boris Feld <boris.feld@octobus.net>
parents:
34873
diff
changeset
|
897 line.append(obsfateverb(successors, markers)) |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
898 |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
899 # Operations |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
900 operations = markersoperations(markers) |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
901 if operations: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
902 line.append(b" using %s" % b", ".join(operations)) |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
903 |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
904 # Successors |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
905 if successors: |
37328
11d51e518808
obsutil: make obsfateprinter() less dependent on templater
Yuya Nishihara <yuya@tcha.org>
parents:
36954
diff
changeset
|
906 fmtsuccessors = [formatctx(repo[succ]) for succ in successors] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
907 line.append(b" as %s" % b", ".join(fmtsuccessors)) |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
908 |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
909 # Users |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
910 users = markersusers(markers) |
34850
62a4ccf9784a
obsfate: filter out current user if not in verbose
Boris Feld <boris.feld@octobus.net>
parents:
34847
diff
changeset
|
911 # Filter out current user in not verbose mode to reduce amount of |
62a4ccf9784a
obsfate: filter out current user if not in verbose
Boris Feld <boris.feld@octobus.net>
parents:
34847
diff
changeset
|
912 # information |
62a4ccf9784a
obsfate: filter out current user if not in verbose
Boris Feld <boris.feld@octobus.net>
parents:
34847
diff
changeset
|
913 if not verbose: |
62a4ccf9784a
obsfate: filter out current user if not in verbose
Boris Feld <boris.feld@octobus.net>
parents:
34847
diff
changeset
|
914 currentuser = ui.username(acceptempty=True) |
62a4ccf9784a
obsfate: filter out current user if not in verbose
Boris Feld <boris.feld@octobus.net>
parents:
34847
diff
changeset
|
915 if len(users) == 1 and currentuser in users: |
62a4ccf9784a
obsfate: filter out current user if not in verbose
Boris Feld <boris.feld@octobus.net>
parents:
34847
diff
changeset
|
916 users = None |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
917 |
34850
62a4ccf9784a
obsfate: filter out current user if not in verbose
Boris Feld <boris.feld@octobus.net>
parents:
34847
diff
changeset
|
918 if (verbose or normal) and users: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
919 line.append(b" by %s" % b", ".join(users)) |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
920 |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
921 # Date |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
922 dates = markersdates(markers) |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
923 |
34873
aa849cf5d089
obsfate: fix obsfate_printer with empty date list
Boris Feld <boris.feld@octobus.net>
parents:
34851
diff
changeset
|
924 if dates and verbose: |
34851
6f53a53245a2
obsfate: only display date in verbose mode
Boris Feld <boris.feld@octobus.net>
parents:
34850
diff
changeset
|
925 min_date = min(dates) |
6f53a53245a2
obsfate: only display date in verbose mode
Boris Feld <boris.feld@octobus.net>
parents:
34850
diff
changeset
|
926 max_date = max(dates) |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
927 |
34851
6f53a53245a2
obsfate: only display date in verbose mode
Boris Feld <boris.feld@octobus.net>
parents:
34850
diff
changeset
|
928 if min_date == max_date: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
929 fmtmin_date = dateutil.datestr(min_date, b'%Y-%m-%d %H:%M %1%2') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
930 line.append(b" (at %s)" % fmtmin_date) |
34851
6f53a53245a2
obsfate: only display date in verbose mode
Boris Feld <boris.feld@octobus.net>
parents:
34850
diff
changeset
|
931 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
932 fmtmin_date = dateutil.datestr(min_date, b'%Y-%m-%d %H:%M %1%2') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
933 fmtmax_date = dateutil.datestr(max_date, b'%Y-%m-%d %H:%M %1%2') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
934 line.append(b" (between %s and %s)" % (fmtmin_date, fmtmax_date)) |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34422
diff
changeset
|
935 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
936 return b"".join(line) |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
937 |
35609
c026547454dd
visibility: make the filtered message translatable
Boris Feld <boris.feld@octobus.net>
parents:
35571
diff
changeset
|
938 |
c026547454dd
visibility: make the filtered message translatable
Boris Feld <boris.feld@octobus.net>
parents:
35571
diff
changeset
|
939 filteredmsgtable = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
940 b"pruned": _(b"hidden revision '%s' is pruned"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
941 b"diverged": _(b"hidden revision '%s' has diverged"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
942 b"superseded": _(b"hidden revision '%s' was rewritten as: %s"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
943 b"superseded_split": _(b"hidden revision '%s' was split as: %s"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
944 b"superseded_split_several": _( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
945 b"hidden revision '%s' was split as: %s and %d more" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
946 ), |
35609
c026547454dd
visibility: make the filtered message translatable
Boris Feld <boris.feld@octobus.net>
parents:
35571
diff
changeset
|
947 } |
c026547454dd
visibility: make the filtered message translatable
Boris Feld <boris.feld@octobus.net>
parents:
35571
diff
changeset
|
948 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
949 |
35610
22c42bfbe7ab
visibility: pass a normal repo to _getfilteredreason
Boris Feld <boris.feld@octobus.net>
parents:
35609
diff
changeset
|
950 def _getfilteredreason(repo, changeid, ctx): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45075
diff
changeset
|
951 """return a human-friendly string on why a obsolete changeset is hidden""" |
35610
22c42bfbe7ab
visibility: pass a normal repo to _getfilteredreason
Boris Feld <boris.feld@octobus.net>
parents:
35609
diff
changeset
|
952 successors = successorssets(repo, ctx.node()) |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
953 fate = _getobsfate(successors) |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
954 |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
955 # Be more precise in case the revision is superseded |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
956 if fate == b'pruned': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
957 return filteredmsgtable[b'pruned'] % changeid |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
958 elif fate == b'diverged': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
959 return filteredmsgtable[b'diverged'] % changeid |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
960 elif fate == b'superseded': |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
961 single_successor = short(successors[0][0]) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
962 return filteredmsgtable[b'superseded'] % (changeid, single_successor) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
963 elif fate == b'superseded_split': |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
964 |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
965 succs = [] |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
966 for node_id in successors[0]: |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
967 succs.append(short(node_id)) |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
968 |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
969 if len(succs) <= 2: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
970 fmtsuccs = b', '.join(succs) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
971 return filteredmsgtable[b'superseded_split'] % (changeid, fmtsuccs) |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
972 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
973 firstsuccessors = b', '.join(succs[:2]) |
35571
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
974 remainingnumber = len(succs) - 2 |
265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
Boris Feld <boris.feld@octobus.net>
parents:
35308
diff
changeset
|
975 |
35609
c026547454dd
visibility: make the filtered message translatable
Boris Feld <boris.feld@octobus.net>
parents:
35571
diff
changeset
|
976 args = (changeid, firstsuccessors, remainingnumber) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
977 return filteredmsgtable[b'superseded_split_several'] % args |
36954
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
978 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
979 |
36954
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
980 def divergentsets(repo, ctx): |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
981 """Compute sets of commits divergent with a given one""" |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
982 cache = {} |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
983 base = {} |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
984 for n in allpredecessors(repo.obsstore, [ctx.node()]): |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
985 if n == ctx.node(): |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
986 # a node can't be a base for divergence with itself |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
987 continue |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
988 nsuccsets = successorssets(repo, n, cache) |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
989 for nsuccset in nsuccsets: |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
990 if ctx.node() in nsuccset: |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
991 # we are only interested in *other* successor sets |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
992 continue |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
993 if tuple(nsuccset) in base: |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
994 # we already know the latest base for this divergency |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
995 continue |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
996 base[tuple(nsuccset)] = n |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
997 return [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
998 {b'divergentnodes': divset, b'commonpredecessor': b} |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
999 for divset, b in base.items() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1000 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1001 |
36954
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1002 |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1003 def whyunstable(repo, ctx): |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1004 result = [] |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1005 if ctx.orphan(): |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1006 for parent in ctx.parents(): |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1007 kind = None |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1008 if parent.orphan(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1009 kind = b'orphan' |
36954
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1010 elif parent.obsolete(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1011 kind = b'obsolete' |
36954
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1012 if kind is not None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1013 result.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1014 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1015 b'instability': b'orphan', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1016 b'reason': b'%s parent' % kind, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1017 b'node': parent.hex(), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1018 } |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1019 ) |
36954
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1020 if ctx.phasedivergent(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1021 predecessors = allpredecessors( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1022 repo.obsstore, [ctx.node()], ignoreflags=bumpedfix |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1023 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1024 immutable = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1025 repo[p] for p in predecessors if p in repo and not repo[p].mutable() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1026 ] |
36954
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1027 for predecessor in immutable: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1028 result.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1029 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1030 b'instability': b'phase-divergent', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1031 b'reason': b'immutable predecessor', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1032 b'node': predecessor.hex(), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1033 } |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1034 ) |
36954
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1035 if ctx.contentdivergent(): |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1036 dsets = divergentsets(repo, ctx) |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1037 for dset in dsets: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1038 divnodes = [repo[n] for n in dset[b'divergentnodes']] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1039 result.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1040 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1041 b'instability': b'content-divergent', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1042 b'divergentnodes': divnodes, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1043 b'reason': b'predecessor', |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1044 b'node': hex(dset[b'commonpredecessor']), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1045 } |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41713
diff
changeset
|
1046 ) |
36954
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36953
diff
changeset
|
1047 return result |