Mercurial > public > mercurial-scm > hg
comparison mercurial/upgrade.py @ 46336:4f17773fc6b5
share: rename share-safe warning config
Config introduced in previous patch was `share.source-safe-mismatch`. Let's
rename the warn as `share.source-safe-mismatch.warn`.
While we are here, made sure we have different configs for upgrade and
downgrade.
Differential Revision: https://phab.mercurial-scm.org/D9786
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 15 Jan 2021 12:08:07 +0530 |
parents | 25be21ec6c65 |
children | 4a58561ace0f 2e8a844d0ae0 |
comparison
equal
deleted
inserted
replaced
46335:25be21ec6c65 | 46336:4f17773fc6b5 |
---|---|
240 | 240 |
241 upgrade_op.print_post_op_messages() | 241 upgrade_op.print_post_op_messages() |
242 | 242 |
243 | 243 |
244 def upgrade_share_to_safe( | 244 def upgrade_share_to_safe( |
245 ui, hgvfs, storevfs, current_requirements, mismatch_config | 245 ui, |
246 hgvfs, | |
247 storevfs, | |
248 current_requirements, | |
249 mismatch_config, | |
250 mismatch_warn, | |
246 ): | 251 ): |
247 """Upgrades a share to use share-safe mechanism""" | 252 """Upgrades a share to use share-safe mechanism""" |
248 wlock = None | 253 wlock = None |
249 store_requirements = localrepo._readrequires(storevfs, False) | 254 store_requirements = localrepo._readrequires(storevfs, False) |
250 original_crequirements = current_requirements.copy() | 255 original_crequirements = current_requirements.copy() |
280 if mismatch_config == b'upgrade-abort': | 285 if mismatch_config == b'upgrade-abort': |
281 raise error.Abort( | 286 raise error.Abort( |
282 _(b'failed to upgrade share, got error: %s') | 287 _(b'failed to upgrade share, got error: %s') |
283 % stringutil.forcebytestr(e.strerror) | 288 % stringutil.forcebytestr(e.strerror) |
284 ) | 289 ) |
285 elif ui.configbool(b'experimental', b'sharesafe-warn-outdated-shares'): | 290 elif mismatch_warn: |
286 ui.warn( | 291 ui.warn( |
287 _(b'failed to upgrade share, got error: %s\n') | 292 _(b'failed to upgrade share, got error: %s\n') |
288 % stringutil.forcebytestr(e.strerror) | 293 % stringutil.forcebytestr(e.strerror) |
289 ) | 294 ) |
290 finally: | 295 finally: |
296 ui, | 301 ui, |
297 hgvfs, | 302 hgvfs, |
298 sharedvfs, | 303 sharedvfs, |
299 current_requirements, | 304 current_requirements, |
300 mismatch_config, | 305 mismatch_config, |
306 mismatch_warn, | |
301 ): | 307 ): |
302 """Downgrades a share which use share-safe to not use it""" | 308 """Downgrades a share which use share-safe to not use it""" |
303 wlock = None | 309 wlock = None |
304 source_requirements = localrepo._readrequires(sharedvfs, True) | 310 source_requirements = localrepo._readrequires(sharedvfs, True) |
305 original_crequirements = current_requirements.copy() | 311 original_crequirements = current_requirements.copy() |
333 if mismatch_config == b'downgrade-abort': | 339 if mismatch_config == b'downgrade-abort': |
334 raise error.Abort( | 340 raise error.Abort( |
335 _(b'failed to downgrade share, got error: %s') | 341 _(b'failed to downgrade share, got error: %s') |
336 % stringutil.forcebytestr(e.strerror) | 342 % stringutil.forcebytestr(e.strerror) |
337 ) | 343 ) |
344 elif mismatch_warn: | |
345 ui.warn( | |
346 _(b'failed to downgrade share, got error: %s\n') | |
347 % stringutil.forcebytestr(e.strerror) | |
348 ) | |
338 finally: | 349 finally: |
339 if wlock: | 350 if wlock: |
340 wlock.release() | 351 wlock.release() |