Mercurial > hg
comparison mercurial/obsolete.py @ 47020:ba6881c6a178
rewriteutil: check for divergence
This code is adapted from the code in the evolve extension. It seems
to be equivalent as far as the evolve extension's test suite can tell
(the only impact when making their `precheck()` delegate to our
version is that error messages are less detailed).
I had to change the error message to work with "change branch of"
being inserted as the action.
Differential Revision: https://phab.mercurial-scm.org/D10518
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 23 Feb 2021 10:28:42 -0800 |
parents | d55b71393907 |
children | b1e1559f5a45 |
comparison
equal
deleted
inserted
replaced
47019:c4dbbaecaad3 | 47020:ba6881c6a178 |
---|---|
104 propertycache = util.propertycache | 104 propertycache = util.propertycache |
105 | 105 |
106 # Options for obsolescence | 106 # Options for obsolescence |
107 createmarkersopt = b'createmarkers' | 107 createmarkersopt = b'createmarkers' |
108 allowunstableopt = b'allowunstable' | 108 allowunstableopt = b'allowunstable' |
109 allowdivergenceopt = b'allowdivergence' | |
109 exchangeopt = b'exchange' | 110 exchangeopt = b'exchange' |
110 | 111 |
111 | 112 |
112 def _getoptionvalue(repo, option): | 113 def _getoptionvalue(repo, option): |
113 """Returns True if the given repository has the given obsolete option | 114 """Returns True if the given repository has the given obsolete option |
142 def getoptions(repo): | 143 def getoptions(repo): |
143 """Returns dicts showing state of obsolescence features.""" | 144 """Returns dicts showing state of obsolescence features.""" |
144 | 145 |
145 createmarkersvalue = _getoptionvalue(repo, createmarkersopt) | 146 createmarkersvalue = _getoptionvalue(repo, createmarkersopt) |
146 unstablevalue = _getoptionvalue(repo, allowunstableopt) | 147 unstablevalue = _getoptionvalue(repo, allowunstableopt) |
148 divergencevalue = _getoptionvalue(repo, allowdivergenceopt) | |
147 exchangevalue = _getoptionvalue(repo, exchangeopt) | 149 exchangevalue = _getoptionvalue(repo, exchangeopt) |
148 | 150 |
149 # createmarkers must be enabled if other options are enabled | 151 # createmarkers must be enabled if other options are enabled |
150 if (unstablevalue or exchangevalue) and not createmarkersvalue: | 152 if ( |
153 unstablevalue or divergencevalue or exchangevalue | |
154 ) and not createmarkersvalue: | |
151 raise error.Abort( | 155 raise error.Abort( |
152 _( | 156 _( |
153 b"'createmarkers' obsolete option must be enabled " | 157 b"'createmarkers' obsolete option must be enabled " |
154 b"if other obsolete options are enabled" | 158 b"if other obsolete options are enabled" |
155 ) | 159 ) |
156 ) | 160 ) |
157 | 161 |
158 return { | 162 return { |
159 createmarkersopt: createmarkersvalue, | 163 createmarkersopt: createmarkersvalue, |
160 allowunstableopt: unstablevalue, | 164 allowunstableopt: unstablevalue, |
165 allowdivergenceopt: divergencevalue, | |
161 exchangeopt: exchangevalue, | 166 exchangeopt: exchangevalue, |
162 } | 167 } |
163 | 168 |
164 | 169 |
165 def isenabled(repo, option): | 170 def isenabled(repo, option): |