[PATCH 2 of 2 V2] devel-warn: issue a warning for old style revsets
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri Jun 19 13:50:43 CDT 2015
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1434737831 25200
# Fri Jun 19 11:17:11 2015 -0700
# Node ID 33f50a0583a7254f0859ea058ea74843efd5cbdb
# Parent a51f19e7f84edf50d1d751d8f55466bb10f4ba05
devel-warn: issue a warning for old style revsets
We have move to smartset class more than a year ago, we now have the tool to
aggressively nudge developer into upgrading their extensions.
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -319,10 +319,17 @@ def getset(repo, subset, x):
if not x:
raise error.ParseError(_("missing argument"))
s = methods[x[0]](repo, subset, *x[1:])
if util.safehasattr(s, 'isascending'):
return s
+ if (repo.ui.configbool('devel', 'all-warnings')
+ or repo.ui.configbool('devel', 'old-revset')):
+ # else case should not happen, because all non-func are internal,
+ # ignoring for now.
+ if x[0] == 'func' and x[1][0] == 'symbol' and x[1][1] in symbols:
+ repo.ui.develwarn('revset "%s" use list instead of smartset, '
+ '(upgrade your code)' % x[1][1])
return baseset(s)
def _getrevsource(repo, r):
extra = repo[r].extra()
for label in ('source', 'transplant_source', 'rebase_source'):
diff --git a/tests/test-devel-warnings.t b/tests/test-devel-warnings.t
--- a/tests/test-devel-warnings.t
+++ b/tests/test-devel-warnings.t
@@ -1,11 +1,11 @@
$ cat << EOF > buggylocking.py
> """A small extension that acquire locks in the wrong order
> """
>
- > from mercurial import cmdutil, repair
+ > from mercurial import cmdutil, repair, revset
>
> cmdtable = {}
> command = cmdutil.command(cmdtable)
>
> @command('buggylocking', [], '')
@@ -45,10 +45,15 @@
> tr = repo.transaction('foobar')
> try:
> repair.strip(repo.ui, repo, [repo['.'].node()])
> finally:
> lo.release()
+ >
+ > def oldstylerevset(repo, subset, x):
+ > return list(subset)
+ >
+ > revset.symbols['oldstyle'] = oldstylerevset
> EOF
$ cat << EOF >> $HGRCPATH
> [extensions]
> buggylocking=$TESTTMP/buggylocking.py
@@ -104,6 +109,10 @@
saved backup bundle to $TESTTMP/lock-checker/.hg/strip-backup/cb9a9f314b8b-cc5ccb0b-backup.hg (glob)
abort: programming error: cannot strip from inside a transaction
(contact your extension maintainer)
[255]
+ $ hg log -r "oldstyle()" -T '{rev}\n'
+ devel-warn: revset "oldstyle" use list instead of smartset, (upgrade your code) at: */mercurial/revset.py:* (mfunc) (glob)
+ 0
+
$ cd ..
More information about the Mercurial-devel
mailing list