author | Pulkit Goyal <7895pulkit@gmail.com> |
Tue, 22 May 2018 23:51:57 +0530 | |
changeset 3758 | 131758265150 |
parent 3697 | 6aff4bb3970d |
child 3899 | 9a6a767bef9d |
permissions | -rw-r--r-- |
2047
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1 |
# Various utility function for the evolve extension |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2 |
# |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
3 |
# Copyright 2017 Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
4 |
# |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
5 |
# This software may be used and distributed according to the terms of the |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
6 |
# GNU General Public License version 2 or any later version. |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
7 |
|
3468
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
8 |
import collections |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
9 |
|
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3656
diff
changeset
|
10 |
from mercurial import ( |
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3656
diff
changeset
|
11 |
obsutil, |
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3656
diff
changeset
|
12 |
) |
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3656
diff
changeset
|
13 |
|
3538
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
14 |
from mercurial.i18n import _ |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
15 |
|
3309
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
16 |
from mercurial.node import nullrev |
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
17 |
|
2763
4a5b0c373e65
commands: move the touch to the 'evocommands' module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2125
diff
changeset
|
18 |
shorttemplate = "[{label('evolve.rev', rev)}] {desc|firstline}\n" |
4a5b0c373e65
commands: move the touch to the 'evocommands' module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2125
diff
changeset
|
19 |
|
2047
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
20 |
def obsexcmsg(ui, message, important=False): |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
21 |
verbose = ui.configbool('experimental', 'verbose-obsolescence-exchange', |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
22 |
False) |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
23 |
if verbose: |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
24 |
message = 'OBSEXC: ' + message |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
25 |
if important or verbose: |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
26 |
ui.status(message) |
2054
f9d65d24b9f9
discovery: split discovery related code in 'obsdiscovery'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
27 |
|
f9d65d24b9f9
discovery: split discovery related code in 'obsdiscovery'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
28 |
def obsexcprg(ui, *args, **kwargs): |
f9d65d24b9f9
discovery: split discovery related code in 'obsdiscovery'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
29 |
topic = 'obsmarkers exchange' |
f9d65d24b9f9
discovery: split discovery related code in 'obsdiscovery'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
30 |
if ui.configbool('experimental', 'verbose-obsolescence-exchange', False): |
f9d65d24b9f9
discovery: split discovery related code in 'obsdiscovery'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
31 |
topic = 'OBSEXC' |
f9d65d24b9f9
discovery: split discovery related code in 'obsdiscovery'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
32 |
ui.progress(topic, *args, **kwargs) |
3309
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
33 |
|
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
34 |
def filterparents(parents): |
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
35 |
"""filter nullrev parents |
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
36 |
|
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
37 |
(and other crazyness)""" |
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
38 |
p1, p2 = parents |
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
39 |
if p1 == nullrev and p2 == nullrev: |
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
40 |
return () |
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
41 |
elif p1 != nullrev and (p2 == nullrev or p1 == p2): |
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
42 |
return (p1,) |
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
43 |
elif p1 == nullrev and p2 != nullrev: |
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
44 |
return (p2,) |
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
45 |
else: |
09db38b34cb9
parents: add a utility to filter parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2763
diff
changeset
|
46 |
return parents |
3340
fd90e73bf79a
caches: factorise the cache warming check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3309
diff
changeset
|
47 |
|
3366
83b372eceb81
caches: pass the transaction to the "shouldwarncache" logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3346
diff
changeset
|
48 |
def shouldwarmcache(repo, tr): |
3340
fd90e73bf79a
caches: factorise the cache warming check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3309
diff
changeset
|
49 |
configbool = repo.ui.configbool |
3368
7310f3ef6dee
caches: add a 'auto' option for obshashrange cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3367
diff
changeset
|
50 |
config = repo.ui.config |
7310f3ef6dee
caches: add a 'auto' option for obshashrange cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3367
diff
changeset
|
51 |
desc = getattr(tr, 'desc', '') |
7310f3ef6dee
caches: add a 'auto' option for obshashrange cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3367
diff
changeset
|
52 |
|
3426
be284a34b822
caches: fix automatic warming trigger
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3369
diff
changeset
|
53 |
autocase = False |
be284a34b822
caches: fix automatic warming trigger
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3369
diff
changeset
|
54 |
if tr is None: |
be284a34b822
caches: fix automatic warming trigger
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3369
diff
changeset
|
55 |
autocase = True |
be284a34b822
caches: fix automatic warming trigger
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3369
diff
changeset
|
56 |
elif desc.startswith('serve'): |
be284a34b822
caches: fix automatic warming trigger
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3369
diff
changeset
|
57 |
autocase = True |
be284a34b822
caches: fix automatic warming trigger
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3369
diff
changeset
|
58 |
elif desc.startswith('push') and not desc.startswith('push-response'): |
be284a34b822
caches: fix automatic warming trigger
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3369
diff
changeset
|
59 |
autocase = True |
be284a34b822
caches: fix automatic warming trigger
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3369
diff
changeset
|
60 |
|
3368
7310f3ef6dee
caches: add a 'auto' option for obshashrange cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3367
diff
changeset
|
61 |
autocache = config('experimental', 'obshashrange.warm-cache', |
3369
c7fbb79cd366
caches: switch to 'auto' warming by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3368
diff
changeset
|
62 |
'auto') == 'auto' |
3368
7310f3ef6dee
caches: add a 'auto' option for obshashrange cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3367
diff
changeset
|
63 |
if autocache: |
7310f3ef6dee
caches: add a 'auto' option for obshashrange cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3367
diff
changeset
|
64 |
warm = autocase |
7310f3ef6dee
caches: add a 'auto' option for obshashrange cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3367
diff
changeset
|
65 |
else: |
3369
c7fbb79cd366
caches: switch to 'auto' warming by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3368
diff
changeset
|
66 |
# note: we should not get to the default case |
3368
7310f3ef6dee
caches: add a 'auto' option for obshashrange cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3367
diff
changeset
|
67 |
warm = configbool('experimental', 'obshashrange.warm-cache', True) |
3367
c26dc74b828d
caches: extract some config reading in 'shouldwarmcache'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3366
diff
changeset
|
68 |
|
3340
fd90e73bf79a
caches: factorise the cache warming check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3309
diff
changeset
|
69 |
if not configbool('experimental', 'obshashrange', False): |
fd90e73bf79a
caches: factorise the cache warming check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3309
diff
changeset
|
70 |
return False |
3367
c26dc74b828d
caches: extract some config reading in 'shouldwarmcache'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3366
diff
changeset
|
71 |
if not warm: |
3340
fd90e73bf79a
caches: factorise the cache warming check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3309
diff
changeset
|
72 |
return False |
3346
f4e28b781143
stablerange: use mergepoint based algorithm for the official stable range
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3340
diff
changeset
|
73 |
maxrevs = repo.ui.configint('experimental', 'obshashrange.max-revs', None) |
f4e28b781143
stablerange: use mergepoint based algorithm for the official stable range
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3340
diff
changeset
|
74 |
if maxrevs is not None and maxrevs < len(repo.unfiltered()): |
f4e28b781143
stablerange: use mergepoint based algorithm for the official stable range
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3340
diff
changeset
|
75 |
return False |
3340
fd90e73bf79a
caches: factorise the cache warming check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3309
diff
changeset
|
76 |
return True |
3467
41ce24cf288d
utility: move MultipleSuccessorsError from __init__.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3426
diff
changeset
|
77 |
|
41ce24cf288d
utility: move MultipleSuccessorsError from __init__.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3426
diff
changeset
|
78 |
class MultipleSuccessorsError(RuntimeError): |
41ce24cf288d
utility: move MultipleSuccessorsError from __init__.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3426
diff
changeset
|
79 |
"""Exception raised by _singlesuccessor when multiple successor sets exists |
41ce24cf288d
utility: move MultipleSuccessorsError from __init__.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3426
diff
changeset
|
80 |
|
41ce24cf288d
utility: move MultipleSuccessorsError from __init__.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3426
diff
changeset
|
81 |
The object contains the list of successorssets in its 'successorssets' |
41ce24cf288d
utility: move MultipleSuccessorsError from __init__.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3426
diff
changeset
|
82 |
attribute to call to easily recover. |
41ce24cf288d
utility: move MultipleSuccessorsError from __init__.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3426
diff
changeset
|
83 |
""" |
41ce24cf288d
utility: move MultipleSuccessorsError from __init__.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3426
diff
changeset
|
84 |
|
41ce24cf288d
utility: move MultipleSuccessorsError from __init__.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3426
diff
changeset
|
85 |
def __init__(self, successorssets): |
41ce24cf288d
utility: move MultipleSuccessorsError from __init__.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3426
diff
changeset
|
86 |
self.successorssets = successorssets |
3468
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
87 |
|
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
88 |
def builddependencies(repo, revs): |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
89 |
"""returns dependency graphs giving an order to solve instability of revs |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
90 |
(see _orderrevs for more information on usage)""" |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
91 |
|
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
92 |
# For each troubled revision we keep track of what instability if any should |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
93 |
# be resolved in order to resolve it. Example: |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
94 |
# dependencies = {3: [6], 6:[]} |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
95 |
# Means that: 6 has no dependency, 3 depends on 6 to be solved |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
96 |
dependencies = {} |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
97 |
# rdependencies is the inverted dict of dependencies |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
98 |
rdependencies = collections.defaultdict(set) |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
99 |
|
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
100 |
for r in revs: |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
101 |
dependencies[r] = set() |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
102 |
for p in repo[r].parents(): |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
103 |
try: |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
104 |
succ = _singlesuccessor(repo, p) |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
105 |
except MultipleSuccessorsError as exc: |
3656
62e4149435d8
utility: convert node from MultipleSuccessorsError to rev numbers (issue5832)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3581
diff
changeset
|
106 |
tset = set() |
62e4149435d8
utility: convert node from MultipleSuccessorsError to rev numbers (issue5832)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3581
diff
changeset
|
107 |
for node in exc.successorssets[0]: |
62e4149435d8
utility: convert node from MultipleSuccessorsError to rev numbers (issue5832)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3581
diff
changeset
|
108 |
tset.add(repo[node].rev()) |
62e4149435d8
utility: convert node from MultipleSuccessorsError to rev numbers (issue5832)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3581
diff
changeset
|
109 |
dependencies[r] = tset |
3468
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
110 |
continue |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
111 |
if succ in revs: |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
112 |
dependencies[r].add(succ) |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
113 |
rdependencies[succ].add(r) |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
114 |
return dependencies, rdependencies |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
115 |
|
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
116 |
def _singlesuccessor(repo, p): |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
117 |
"""returns p (as rev) if not obsolete or its unique latest successors |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
118 |
|
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
119 |
fail if there are no such successor""" |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
120 |
|
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
121 |
if not p.obsolete(): |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
122 |
return p.rev() |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
123 |
obs = repo[p] |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
124 |
ui = repo.ui |
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3656
diff
changeset
|
125 |
newer = obsutil.successorssets(repo, obs.node()) |
3468
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
126 |
# search of a parent which is not killed |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
127 |
while not newer: |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
128 |
ui.debug("stabilize target %s is plain dead," |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
129 |
" trying to stabilize on its parent\n" % |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
130 |
obs) |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
131 |
obs = obs.parents()[0] |
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3656
diff
changeset
|
132 |
newer = obsutil.successorssets(repo, obs.node()) |
3468
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
133 |
if len(newer) > 1 or len(newer[0]) > 1: |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
134 |
raise MultipleSuccessorsError(newer) |
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
135 |
|
a3052824101d
evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3467
diff
changeset
|
136 |
return repo[newer[0][0]].rev() |
3538
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
137 |
|
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
138 |
def revselectionprompt(ui, repo, revs, customheader=""): |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
139 |
"""function to prompt user to choose a revision from all the revs and return |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
140 |
that revision for further tasks |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
141 |
|
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
142 |
revs is a list of rev number of revision from which one revision should be |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
143 |
choosed by the user |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
144 |
customheader is a text which the caller wants as the header of the prompt |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
145 |
which will list revisions to select |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
146 |
|
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
147 |
returns value is: |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
148 |
rev number of revision choosed: if user choose a revision |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
149 |
None: if user entered a wrong input, user quit the prompt, |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
150 |
ui.interactive is not set |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
151 |
""" |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
152 |
|
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
153 |
# ui.interactive is not set, fallback to default behavior and avoid showing |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
154 |
# the prompt |
3758
131758265150
utility: use ui.interactive() instead of checking config value
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3697
diff
changeset
|
155 |
if not ui.interactive(): |
3538
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
156 |
return None |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
157 |
|
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
158 |
promptmsg = customheader + "\n" |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
159 |
for idx, rev in enumerate(revs): |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
160 |
curctx = repo[rev] |
3581
846f7d4fe47e
utility: make sure prompt text is internationalized
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3538
diff
changeset
|
161 |
revmsg = _("%d: [%s] %s\n" % (idx, curctx, |
846f7d4fe47e
utility: make sure prompt text is internationalized
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3538
diff
changeset
|
162 |
curctx.description().split("\n")[0])) |
3538
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
163 |
promptmsg += revmsg |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
164 |
|
3581
846f7d4fe47e
utility: make sure prompt text is internationalized
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3538
diff
changeset
|
165 |
promptmsg += _("q: quit the prompt\n") |
846f7d4fe47e
utility: make sure prompt text is internationalized
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3538
diff
changeset
|
166 |
promptmsg += _("enter the index of the revision you want to select:") |
3538
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
167 |
idxselected = ui.prompt(promptmsg) |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
168 |
|
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
169 |
intidx = None |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
170 |
try: |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
171 |
intidx = int(idxselected) |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
172 |
except ValueError: |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
173 |
if idxselected == 'q': |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
174 |
return None |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
175 |
ui.write_err(_("invalid value '%s' entered for index\n") % idxselected) |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
176 |
return None |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
177 |
|
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
178 |
if intidx >= len(revs) or intidx < 0: |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
179 |
# we can make this error message better |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
180 |
ui.write_err(_("invalid value '%d' entered for index\n") % intidx) |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
181 |
return None |
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
182 |
|
b314c64f336b
utility: add a function to prompt user to choose a revision
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3468
diff
changeset
|
183 |
return revs[intidx] |