author | Rodrigo Damazio Bovendorp <rdamazio@google.com> |
Thu, 07 May 2020 19:47:59 -0700 | |
changeset 5352 | 10368b3427b1 |
parent 5330 | 0bc31f853862 |
permissions | -rw-r--r-- |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1 |
# Copyright 2011 Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2 |
# Logilab SA <contact@logilab.fr> |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
3 |
# Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
519
9825c7da5b54
ensure all file have a copyright notice
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
517
diff
changeset
|
4 |
# Patrick Mezard <patrick@mezard.eu> |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
5 |
# |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
6 |
# This software may be used and distributed according to the terms of the |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
7 |
# GNU General Public License version 2 or any later version. |
2485
e6ecd35e99ec
refactor: extract templates into a new file
Boris Feld <boris.feld@octobus.net>
parents:
2481
diff
changeset
|
8 |
"""evolve templates |
2032
dd7e092a854a
flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2024
diff
changeset
|
9 |
""" |
2049
b81d3775006b
evolve: move extension metadata in their own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2048
diff
changeset
|
10 |
|
2485
e6ecd35e99ec
refactor: extract templates into a new file
Boris Feld <boris.feld@octobus.net>
parents:
2481
diff
changeset
|
11 |
from . import ( |
2612
fd35b428edfc
obsfate: by default only display the username if differ from the current one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2611
diff
changeset
|
12 |
error, |
2485
e6ecd35e99ec
refactor: extract templates into a new file
Boris Feld <boris.feld@octobus.net>
parents:
2481
diff
changeset
|
13 |
exthelper, |
5330
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
14 |
obshistory, |
2485
e6ecd35e99ec
refactor: extract templates into a new file
Boris Feld <boris.feld@octobus.net>
parents:
2481
diff
changeset
|
15 |
) |
617
469befc27b26
detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
616
diff
changeset
|
16 |
|
1823
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
17 |
from mercurial import ( |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
18 |
templatekw, |
2688
b6e50897b94e
obsfate: override the default log output
Boris Feld <boris.feld@octobus.net>
parents:
2685
diff
changeset
|
19 |
util |
1823
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
20 |
) |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
21 |
|
2041
3b6550261614
exthelper: extract into its own submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
22 |
eh = exthelper.exthelper() |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
23 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
24 |
### template keywords |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
25 |
|
5184
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
26 |
@eh.templatekeyword(b'instabilities', requires={b'ctx', b'templ'}) |
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
27 |
def showinstabilities(context, mapping): |
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
28 |
"""List of strings. Evolution instabilities affecting the changeset |
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
29 |
(zero or more of "orphan", "content-divergent" or "phase-divergent").""" |
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
30 |
ctx = context.resource(mapping, b'ctx') |
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
31 |
return templatekw.compatlist(context, mapping, b'instability', |
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
32 |
ctx.instabilities(), |
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
33 |
plural=b'instabilities') |
4625
a4fde4e3e763
templatekw: add `instabilities` alias for `troubles`
Matt Harbison <matt_harbison@yahoo.com>
parents:
4329
diff
changeset
|
34 |
|
5184
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
35 |
@eh.templatekeyword(b'troubles', requires={b'ctx', b'templ'}) |
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
36 |
def showtroubles(context, mapping): # legacy name for instabilities |
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
37 |
ctx = context.resource(mapping, b'ctx') |
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
38 |
return templatekw.compatlist(context, mapping, b'trouble', |
2ccd7c97ed59
evolve: drop 4.5 compatibility for template keywords
Anton Shestakov <av6@dwimlabs.net>
parents:
5062
diff
changeset
|
39 |
ctx.instabilities(), plural=b'troubles') |
2486
cd4290f923b7
template: add precursors template
Boris Feld <boris.feld@octobus.net>
parents:
2485
diff
changeset
|
40 |
|
5330
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
41 |
@eh.templatekeyword(b'obsorigin', requires={b'ui', b'repo', b'ctx'}) |
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
42 |
def showobsorigin(context, mapping): |
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
43 |
ui = context.resource(mapping, b'ui') |
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
44 |
repo = context.resource(mapping, b'repo') |
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
45 |
ctx = context.resource(mapping, b'ctx') |
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
46 |
values = [] |
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
47 |
r = obshistory.predecessorsandmarkers(repo, ctx.node()) |
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
48 |
for (nodes, markers) in sorted(obshistory.groupbyfoldid(r)): |
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
49 |
v = obshistory.obsoriginprinter(ui, repo, nodes, markers) |
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
50 |
values.append(v) |
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
51 |
return templatekw.compatlist(context, mapping, b'origin', values) |
0bc31f853862
templatekw: add obsorigin keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
5184
diff
changeset
|
52 |
|
4659
4d2f8c99f23a
templates: don't alias keywords directly
Joerg Sonnenberger <joerg@bec.de>
parents:
4329
diff
changeset
|
53 |
_sp = templatekw.showpredecessors |
4662
87d60fed455a
templatekw: keep compatibility with Mercurial 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4660
diff
changeset
|
54 |
if util.safehasattr(_sp, '_requires'): |
87d60fed455a
templatekw: keep compatibility with Mercurial 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4660
diff
changeset
|
55 |
def showprecursors(context, mapping): |
87d60fed455a
templatekw: keep compatibility with Mercurial 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4660
diff
changeset
|
56 |
return _sp(context, mapping) |
4730
a95c6f578f70
py3: back out 23323092f0a7
Martin von Zweigbergk <martinvonz@google.com>
parents:
4719
diff
changeset
|
57 |
showprecursors.__doc__ = _sp._origdoc |
4719
358f548f8d6d
py3: use bytes for template keyword registrations
Martin von Zweigbergk <martinvonz@google.com>
parents:
4718
diff
changeset
|
58 |
_tk = templatekw.templatekeyword(b"precursors", requires=_sp._requires) |
4662
87d60fed455a
templatekw: keep compatibility with Mercurial 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4660
diff
changeset
|
59 |
_tk(showprecursors) |
87d60fed455a
templatekw: keep compatibility with Mercurial 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4660
diff
changeset
|
60 |
else: |
4719
358f548f8d6d
py3: use bytes for template keyword registrations
Martin von Zweigbergk <martinvonz@google.com>
parents:
4718
diff
changeset
|
61 |
templatekw.keywords[b"precursors"] = _sp |
4662
87d60fed455a
templatekw: keep compatibility with Mercurial 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4660
diff
changeset
|
62 |
|
2487
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
63 |
|
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
64 |
def closestsuccessors(repo, nodeid): |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
65 |
""" returns the closest visible successors sets instead. |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
66 |
""" |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
67 |
return directsuccessorssets(repo, nodeid) |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
68 |
|
4659
4d2f8c99f23a
templates: don't alias keywords directly
Joerg Sonnenberger <joerg@bec.de>
parents:
4329
diff
changeset
|
69 |
_ss = templatekw.showsuccessorssets |
4662
87d60fed455a
templatekw: keep compatibility with Mercurial 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4660
diff
changeset
|
70 |
if util.safehasattr(_ss, '_requires'): |
87d60fed455a
templatekw: keep compatibility with Mercurial 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4660
diff
changeset
|
71 |
def showsuccessors(context, mapping): |
87d60fed455a
templatekw: keep compatibility with Mercurial 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4660
diff
changeset
|
72 |
return _ss(context, mapping) |
4730
a95c6f578f70
py3: back out 23323092f0a7
Martin von Zweigbergk <martinvonz@google.com>
parents:
4719
diff
changeset
|
73 |
showsuccessors.__doc__ = _ss._origdoc |
4719
358f548f8d6d
py3: use bytes for template keyword registrations
Martin von Zweigbergk <martinvonz@google.com>
parents:
4718
diff
changeset
|
74 |
_tk = templatekw.templatekeyword(b"successors", requires=_ss._requires) |
4662
87d60fed455a
templatekw: keep compatibility with Mercurial 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4660
diff
changeset
|
75 |
_tk(showsuccessors) |
87d60fed455a
templatekw: keep compatibility with Mercurial 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4660
diff
changeset
|
76 |
else: |
4719
358f548f8d6d
py3: use bytes for template keyword registrations
Martin von Zweigbergk <martinvonz@google.com>
parents:
4718
diff
changeset
|
77 |
templatekw.keywords[b"successors"] = _ss |
2487
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
78 |
|
2612
fd35b428edfc
obsfate: by default only display the username if differ from the current one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2611
diff
changeset
|
79 |
def _getusername(ui): |
fd35b428edfc
obsfate: by default only display the username if differ from the current one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2611
diff
changeset
|
80 |
"""the default username in the config or None""" |
fd35b428edfc
obsfate: by default only display the username if differ from the current one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2611
diff
changeset
|
81 |
try: |
fd35b428edfc
obsfate: by default only display the username if differ from the current one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2611
diff
changeset
|
82 |
return ui.username() |
fd35b428edfc
obsfate: by default only display the username if differ from the current one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2611
diff
changeset
|
83 |
except error.Abort: # no easy way to avoid ui raising Abort here :-/ |
fd35b428edfc
obsfate: by default only display the username if differ from the current one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2611
diff
changeset
|
84 |
return None |
fd35b428edfc
obsfate: by default only display the username if differ from the current one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2611
diff
changeset
|
85 |
|
2487
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
86 |
# copy from mercurial.obsolete with a small change to stop at first known changeset. |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
87 |
|
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
88 |
def directsuccessorssets(repo, initialnode, cache=None): |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
89 |
"""return set of all direct successors of initial nodes |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
90 |
""" |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
91 |
|
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
92 |
succmarkers = repo.obsstore.successors |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
93 |
|
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
94 |
# Stack of nodes we search successors sets for |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
95 |
toproceed = [initialnode] |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
96 |
# set version of above list for fast loop detection |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
97 |
# element added to "toproceed" must be added here |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
98 |
stackedset = set(toproceed) |
2591
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2528
diff
changeset
|
99 |
|
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2528
diff
changeset
|
100 |
pathscache = {} |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2528
diff
changeset
|
101 |
|
2487
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
102 |
if cache is None: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
103 |
cache = {} |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
104 |
while toproceed: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
105 |
current = toproceed[-1] |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
106 |
if current in cache: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
107 |
stackedset.remove(toproceed.pop()) |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
108 |
elif current != initialnode and current in repo: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
109 |
# We have a valid direct successors. |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
110 |
cache[current] = [(current,)] |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
111 |
elif current not in succmarkers: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
112 |
if current in repo: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
113 |
# We have a valid last successors. |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
114 |
cache[current] = [(current,)] |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
115 |
else: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
116 |
# Final obsolete version is unknown locally. |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
117 |
# Do not count that as a valid successors |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
118 |
cache[current] = [] |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
119 |
else: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
120 |
for mark in sorted(succmarkers[current]): |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
121 |
for suc in mark[1]: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
122 |
if suc not in cache: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
123 |
if suc in stackedset: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
124 |
# cycle breaking |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
125 |
cache[suc] = [] |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
126 |
else: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
127 |
# case (3) If we have not computed successors sets |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
128 |
# of one of those successors we add it to the |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
129 |
# `toproceed` stack and stop all work for this |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
130 |
# iteration. |
2591
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2528
diff
changeset
|
131 |
pathscache.setdefault(suc, []).append((current, mark)) |
2487
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
132 |
toproceed.append(suc) |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
133 |
stackedset.add(suc) |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
134 |
break |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
135 |
else: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
136 |
continue |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
137 |
break |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
138 |
else: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
139 |
succssets = [] |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
140 |
for mark in sorted(succmarkers[current]): |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
141 |
# successors sets contributed by this marker |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
142 |
markss = [[]] |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
143 |
for suc in mark[1]: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
144 |
# cardinal product with previous successors |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
145 |
productresult = [] |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
146 |
for prefix in markss: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
147 |
for suffix in cache[suc]: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
148 |
newss = list(prefix) |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
149 |
for part in suffix: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
150 |
# do not duplicated entry in successors set |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
151 |
# first entry wins. |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
152 |
if part not in newss: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
153 |
newss.append(part) |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
154 |
productresult.append(newss) |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
155 |
markss = productresult |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
156 |
succssets.extend(markss) |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
157 |
# remove duplicated and subset |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
158 |
seen = [] |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
159 |
final = [] |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
160 |
candidate = sorted(((set(s), s) for s in succssets if s), |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
161 |
key=lambda x: len(x[1]), reverse=True) |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
162 |
for setversion, listversion in candidate: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
163 |
for seenset in seen: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
164 |
if setversion.issubset(seenset): |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
165 |
break |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
166 |
else: |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
167 |
final.append(listversion) |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
168 |
seen.append(setversion) |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
169 |
final.reverse() # put small successors set first |
590da9c523ae
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
2486
diff
changeset
|
170 |
cache[current] = final |
2591
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2528
diff
changeset
|
171 |
|
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2528
diff
changeset
|
172 |
return cache[initialnode], pathscache |