153 def bitsfrom(container): |
154 def bitsfrom(container): |
154 bits = 0 |
155 bits = 0 |
155 for bit in container: |
156 for bit in container: |
156 bits |= bit |
157 bits |= bit |
157 return bits |
158 return bits |
|
159 |
|
160 # python 2.6 still have deprecation warning enabled by default. We do not want |
|
161 # to display anything to standard user so detect if we are running test and |
|
162 # only use python deprecation warning in this case. |
|
163 _dowarn = bool(encoding.environ.get('HGEMITWARNINGS')) |
|
164 if _dowarn: |
|
165 # explicitly unfilter our warning for python 2.7 |
|
166 # |
|
167 # The option of setting PYTHONWARNINGS in the test runner was investigated. |
|
168 # However, module name set through PYTHONWARNINGS was exactly matched, so |
|
169 # we cannot set 'mercurial' and have it match eg: 'mercurial.scmutil'. This |
|
170 # makes the whole PYTHONWARNINGS thing useless for our usecase. |
|
171 warnings.filterwarnings('default', '', DeprecationWarning, 'mercurial') |
|
172 warnings.filterwarnings('default', '', DeprecationWarning, 'hgext') |
|
173 warnings.filterwarnings('default', '', DeprecationWarning, 'hgext3rd') |
|
174 |
|
175 def nouideprecwarn(msg, version, stacklevel=1): |
|
176 """Issue an python native deprecation warning |
|
177 |
|
178 This is a noop outside of tests, use 'ui.deprecwarn' when possible. |
|
179 """ |
|
180 if _dowarn: |
|
181 msg += ("\n(compatibility will be dropped after Mercurial-%s," |
|
182 " update your code.)") % version |
|
183 warnings.warn(msg, DeprecationWarning, stacklevel + 1) |
158 |
184 |
159 DIGESTS = { |
185 DIGESTS = { |
160 'md5': hashlib.md5, |
186 'md5': hashlib.md5, |
161 'sha1': hashlib.sha1, |
187 'sha1': hashlib.sha1, |
162 'sha512': hashlib.sha512, |
188 'sha512': hashlib.sha512, |