diff --git a/hgext3rd/tweakdefaults.py b/hgext3rd/tweakdefaults.py --- a/hgext3rd/tweakdefaults.py +++ b/hgext3rd/tweakdefaults.py @@ -40,6 +40,9 @@ # change rebase exit from 1 to 0 if nothing is rebased nooprebase = True + # whether to show a warning on some deprecated usages + singlecolonwarn = False + # educational messages bmnodesthint = '' bmnodestmsg = '' @@ -49,17 +52,11 @@ nodesthint = '' nodestmsg = '' rollbackhint = '' + singlecolonmsg = '' tagsmessage = '' # output new hashes when nodes get updated showupdated = False - - # Show developers warning for using discouraged features. - # - # For example, 'x:y' in revsets shows revision numbers between x and y, - # both inclusive. Usually, this doesn't correspond to any meaningful - # interpretation of the repo and is therefore, discouraged. - develwarn = True """ from __future__ import absolute_import @@ -133,12 +130,12 @@ options.append( ('d', 'dest', '', _('destination for rebase or update'))) - if ui.configbool('tweakdefaults', 'develwarn', True): - # anonymous function to pass ui object to _analyzewrapper - def _analyzewrap(orig, x): - return _analyzewrapper(orig, x, ui) + # anonymous function to pass ui object to _analyzewrapper + def _analyzewrap(orig, x): + return _analyzewrapper(orig, x, ui) - wrapfunction(revsetlang, '_analyze', _analyzewrap) + wrapfunction(revsetlang, '_analyze', _analyzewrap) + try: rebaseext = extensions.find('rebase') # tweakdefaults is already loaded before other extensions @@ -695,16 +692,19 @@ return cmd def _analyzewrapper(orig, x, ui): - """Wraps analyzer to detect the use of colons in the revisions - """ + """Wraps analyzer to detect the use of colons in the revisions""" result = orig(x) - if isinstance(x, tuple) and \ + enabled = ui.configbool('tweakdefaults', 'singlecolonwarn') + + # The last condition is added so that warnings are not shown if + # hg log --follow is invoked w/o arguments + if enabled and isinstance(x, tuple) and \ (x[0] in ('range', 'rangepre', 'rangepost')) and \ x != ('rangepre', ('symbol', '.')): - # The last condition is added so that warnings are not shown if - # hg log --follow is invoked w/o arguments - ui.develwarn("use of ':' is deprecated\n") + msg = ui.config('tweakdefaults', 'singlecolonmsg', + _("warning: use of ':' is deprecated")) + ui.warn('%s\n' % msg) return result diff --git a/tests/test-tweakdefaults.t b/tests/test-tweakdefaults.t --- a/tests/test-tweakdefaults.t +++ b/tests/test-tweakdefaults.t @@ -744,55 +744,47 @@ | o 0 -Test that developer warning is shown whenever ':' is used implicitly or explicitly +Test that warning is shown whenever ':' is used with singlecolonwarn set - $ hg log -G -T '{rev} {bookmarks}' -r '0:2' - devel-warn: use of ':' is deprecated - at: *tweakdefaults.py:* (_analyzewrap) (glob) + $ hg log -G -T '{rev} {bookmarks}' -r '0:2' --config tweakdefaults.singlecolonwarn=1 + warning: use of ':' is deprecated o 2 | o 1 master | o 0 - - $ hg log -G -T '{rev} {bookmarks}' -r '0:2' --config tweakdefaults.develwarn=False + $ hg log -G -T '{rev} {bookmarks}' -r '0:2' o 2 | o 1 master | o 0 - - $ hg log -G -T '{rev} {bookmarks}' -r ':2' - devel-warn: use of ':' is deprecated - at: *tweakdefaults.py:* (_analyzewrap) (glob) + $ hg log -G -T '{rev} {bookmarks}' -r ':2' --config tweakdefaults.singlecolonwarn=1 + warning: use of ':' is deprecated o 2 | o 1 master | o 0 - - $ hg log -G -T '{rev} {bookmarks}' -r ':2' --config tweakdefaults.develwarn=False + $ hg log -G -T '{rev} {bookmarks}' -r ':2' o 2 | o 1 master | o 0 - - $ hg log -G -T '{rev} {bookmarks}' -r '0:' - devel-warn: use of ':' is deprecated - at: *tweakdefaults.py:* (_analyzewrap) (glob) + $ hg log -G -T '{rev} {bookmarks}' -r '0:' --config tweakdefaults.singlecolonwarn=1 + warning: use of ':' is deprecated o 2 | o 1 master | o 0 - - $ hg log -G -T '{rev} {bookmarks}' -r '0:' --config tweakdefaults.develwarn=False + $ hg log -G -T '{rev} {bookmarks}' -r '0:' o 2 | o 1 master @@ -801,10 +793,19 @@ In this testcase warning should not be shown - $ hg log -G -T '{rev} {bookmarks}' -r ':' + $ hg log -G -T '{rev} {bookmarks}' -r ':' --config tweakdefaults.singlecolonwarn=1 o 2 | o 1 master | o 0 +Check that the custom message can be used + $ hg log -G -T '{rev} {bookmarks}' -r '0:' --config tweakdefaults.singlecolonwarn=1 --config tweakdefaults.singlecolonmsg="hey stop that" + hey stop that + o 2 + | + o 1 master + | + o 0 +