Commits

Anonymous committed 5ee6f34

blacklist-improvements

  • Participants
  • Parent commits ebb4208

Comments (0)

Files changed (4)

blacklist-improvements

+# HG changeset patch
+# User Nicolas Dumazet <nicdumz.commits@gmail.com>
+# Date 1260433291 -32400
+# Node ID 5f69e6203b4d171b467415249ad1185b1dd737b0
+# Parent  2b630e4c8f2f626f1e5d0f88646463968860f8ac
+run-tests: split tests/blacklist in tests/blacklists/*
+
+Following discussions with Gilles Morris [1], it seems that it is preferable to
+use several blacklist files in a blacklists/ directory. It is easier to add an
+unversioned file for experiments than modifying a tracked file.
+
+Also fall back to a simpler syntax, giving up ConfigParser, now that section
+names are not needed anymore.
+
+And allow --blacklist parameter to be a complete path, instead of only one
+of the filenames contained in tests/blacklists/
+
+
+[1] http://www.selenic.com/pipermail/mercurial-devel/2009-December/017317.html
+
+diff --git a/tests/blacklists/README b/tests/blacklists/README
+new file mode 100644
+--- /dev/null
++++ b/tests/blacklists/README
+@@ -0,0 +1,14 @@
++Put here definitions of blacklists for run-tests.py
++
++Create a file per blacklist. Each file should list the names of tests that you
++want to be skipped.
++File names are meant to be used as targets for run-tests.py --blacklist
++option.
++Lines starting with # are ignored. White spaces are stripped.
++
++e.g. if you create a blacklist/example file containing:
++ hgrc
++ # some comment
++ help
++then calling "run-tests.py --blacklist blacklists/example" will exclude
++test-hgrc and test-help from the list of tests to run.
+diff --git a/tests/blacklist b/tests/blacklists/inotify-failures
+rename from tests/blacklist
+rename to tests/blacklists/inotify-failures
+--- a/tests/blacklist
++++ b/tests/blacklists/inotify-failures
+@@ -1,37 +1,21 @@
+-# ConfigParser format
+-# Definitions of blacklists for run-tests.py
+-#
+-# Identify in config sections a list of tests you want to be skipped.
+-# Section names are meant to be used as targets for run-tests.py --blacklist
+-# option.
+-# "test-" prefixes should be omitted from test names. Values are not used.
+-#
+-# e.g. if your file looks like:
+-## [example]
+-## hgrc =
+-## help = "this string is not used"
+-# then calling "run-tests.py --blacklist example" will exclude test-hgrc and
+-# test-help from the list of tests to run.
+-
+-[inotify-failures]
+ # When --inotify is activated, help output and config changes:
+-debugcomplete =
+-empty =
+-fncache =
+-globalopts =
+-help =
+-hgrc =
+-inherit-mode =
+-qrecord =
+-strict =
++test-debugcomplete
++test-empty
++test-fncache
++test-globalopts
++test-help
++test-hgrc
++test-inherit-mode
++test-qrecord
++test-strict
+ 
+ # --inotify activates de facto the inotify extension. It does not play well
+ # with inotify-specific tests, which activate/desactivate inotify at will:
+-inotify =
+-inotify-debuginotify =
+-inotify-dirty-dirstate =
+-inotify-issue1208 =
+-inotify-issue1371 =
+-inotify-issue1542 =
+-inotify-issue1556 =
+-inotify-lookup =
++test-inotify
++test-inotify-debuginotify
++test-inotify-dirty-dirstate
++test-inotify-issue1208
++test-inotify-issue1371
++test-inotify-issue1542
++test-inotify-issue1556
++test-inotify-lookup
+diff --git a/tests/run-tests.py b/tests/run-tests.py
+--- a/tests/run-tests.py
++++ b/tests/run-tests.py
+@@ -41,7 +41,6 @@
+ # completes fairly quickly, includes both shell and Python scripts, and
+ # includes some scripts that run daemon processes.)
+ 
+-from ConfigParser import ConfigParser
+ import difflib
+ import errno
+ import optparse
+@@ -134,8 +133,7 @@
+     parser.add_option("--inotify", action="store_true",
+         help="enable inotify extension when running tests")
+     parser.add_option("--blacklist", action="append",
+-        help="skip tests listed in the specified section of "
+-             "the blacklist file")
++        help="skip tests listed in the specified blacklist file")
+ 
+     for option, default in defaults.items():
+         defaults[option] = int(os.environ.get(*default))
+@@ -202,12 +200,22 @@
+         if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0):
+             parser.error('--py3k-warnings can only be used on Python 2.6+')
+     if options.blacklist:
+-        configparser = ConfigParser()
+-        configparser.read("blacklist")
+         blacklist = dict()
+-        for section in options.blacklist:
+-            for (item, value) in configparser.items(section):
+-                blacklist["test-" + item] = section
++        for filename in options.blacklist:
++            try:
++                path = os.path.expanduser(os.path.expandvars(filename))
++                f = open(path, "r")
++            except IOError, err:
++                if err.errno != errno.ENOENT:
++                    raise
++                print "warning: no such blacklist file: %s" % filename
++                continue
++
++            for line in f.readlines():
++                line = line.strip()
++                if line and not line.startswith('#'):
++                    blacklist[line] = filename
++
+         options.blacklist = blacklist
+ 
+     return (options, args)
+@@ -744,9 +752,9 @@
+ 
+         for test in tests:
+             if options.blacklist:
+-                section = options.blacklist.get(test)
+-                if section is not None:
+-                    skips.append((test, "blacklisted (%s section)" % section))
++                filename = options.blacklist.get(test)
++                if filename is not None:
++                    skips.append((test, "blacklisted (%s)" % filename))
+                     skipped += 1
+                     continue
+ 
 # User Nicolas Dumazet <nicdumz.commits@gmail.com>
 # Date 1260525915 -32400
 
-coding style: use iterators instead of list comprehensions
+coding style: use iterators instead of list comprehensions when possible
 
+Most of the core functions now support any iterable as an argument, and
+f([x for x in ...]) is exactly similar to f(x for x in ...).
+Omitting a level of braces then gives more readable code.
+
+It is in particular true for the following calls:
+ * sorted()
+ * tuple(), list(), set(), dict()
+ * min(), max()
+ * str.join()
+ * dict.*(), list.extend()
+
+Calls out of this scope were left alone. In particular:
+ * list.append()
+ * len()
+ * return ([x for x in ...], ...)
+
+ were ignored, as replacing the comprehensions in those would have just been
+ bogus.
+
+ Candidates were selected using grep, but changes were done manually.
+
+diff --git a/contrib/memory.py b/contrib/memory.py
+--- a/contrib/memory.py
++++ b/contrib/memory.py
+@@ -29,8 +29,8 @@
+     finally:
+         if status is not None:
+             status.close()
+-    ui.write_err(", ".join(["%s: %.1f MiB" % (key, value/1024.0)
+-                            for key, value in result.iteritems()]) + "\n")
++    ui.write_err(", ".join("%s: %.1f MiB" % (key, value/1024.0)
++                            for key, value in result.iteritems()) + "\n")
+ 
+ def extsetup(ui):
+     atexit.register(memusage, ui)
+diff --git a/contrib/simplemerge b/contrib/simplemerge
+--- a/contrib/simplemerge
++++ b/contrib/simplemerge
+@@ -37,7 +37,7 @@
+         out_opts.append(('%2s%s' % (shortopt and '-%s' % shortopt,
+                                     longopt and ' --%s' % longopt),
+                          '%s' % desc))
+-    opts_len = max([len(opt[0]) for opt in out_opts])
++    opts_len = max(len(opt[0]) for opt in out_opts)
+     for first, second in out_opts:
+         sys.stdout.write(' %-*s  %s\n' % (opts_len, first, second))
+ 
+diff --git a/doc/gendoc.py b/doc/gendoc.py
+--- a/doc/gendoc.py
++++ b/doc/gendoc.py
+@@ -86,7 +86,7 @@
+         # options
+         opt_output = list(d['opts'])
+         if opt_output:
+-            opts_len = max([len(line[0]) for line in opt_output])
++            opts_len = max(len(line[0]) for line in opt_output)
+             ui.write(_("    options:\n\n"))
+             for optstr, desc in opt_output:
+                 if desc:
 diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py
 --- a/hgext/bugzilla.py
 +++ b/hgext/bugzilla.py
 diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
 --- a/hgext/convert/hg.py
 +++ b/hgext/convert/hg.py
-@@ -187,7 +187,7 @@
+@@ -189,7 +189,7 @@
          except:
              oldlines = []
  
          if newlines == oldlines:
              return None, None
          data = "".join(newlines)
-@@ -328,8 +328,8 @@
+@@ -330,8 +330,8 @@
  
      def gettags(self):
          tags = [t for t in self.repo.tagslist() if t[0] != 'tip']
      def getchangedfiles(self, rev, i):
 -        return sorted([x[0] for x in self.files[rev]])
 +        return sorted(x[0] for x in self.files[rev])
+diff --git a/hgext/gpg.py b/hgext/gpg.py
+--- a/hgext/gpg.py
++++ b/hgext/gpg.py
+@@ -252,9 +252,9 @@
+     message = opts['message']
+     if not message:
+         # we don't translate commit messages
+-        message = "\n".join(["Added signature for changeset %s"
++        message = "\n".join("Added signature for changeset %s"
+                              % hgnode.short(n)
+-                             for n in nodes])
++                             for n in nodes)
+     try:
+         m = match.exact(repo.root, '', ['.hgsigs'])
+         repo.commit(message, opts['user'], opts['date'], match=m)
 diff --git a/hgext/hgk.py b/hgext/hgk.py
 --- a/hgext/hgk.py
 +++ b/hgext/hgk.py
      cmd = ui.config("hgk", "path", "hgk") + " %s %s" % (optstr, " ".join(etc))
      ui.debug("running %s\n" % cmd)
      util.system(cmd)
+diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py
+--- a/hgext/inotify/server.py
++++ b/hgext/inotify/server.py
+@@ -177,7 +177,7 @@
+ 
+         self.tree = directory()
+         self.statcache = {}
+-        self.statustrees = dict([(s, directory()) for s in self.statuskeys])
++        self.statustrees = dict((s, directory()) for s in self.statuskeys)
+ 
+         self.ds_info = self.dirstate_info()
+ 
 diff --git a/hgext/mq.py b/hgext/mq.py
 --- a/hgext/mq.py
 +++ b/hgext/mq.py
 diff --git a/mercurial/url.py b/mercurial/url.py
 --- a/mercurial/url.py
 +++ b/mercurial/url.py
+@@ -181,11 +181,11 @@
+ 
+             # see if we should use a proxy for this url
+             no_list = [ "localhost", "127.0.0.1" ]
+-            no_list.extend([p.lower() for
+-                            p in ui.configlist("http_proxy", "no")])
+-            no_list.extend([p.strip().lower() for
++            no_list.extend(p.lower() for
++                            p in ui.configlist("http_proxy", "no"))
++            no_list.extend(p.strip().lower() for
+                             p in os.getenv("no_proxy", '').split(',')
+-                            if p.strip()])
++                            if p.strip())
+             # "http_proxy.always" config is for running tests on localhost
+             if ui.configbool("http_proxy", "always"):
+                 self.no_list = []
 @@ -540,7 +540,7 @@
  
      handlers.extend((urllib2.HTTPBasicAuthHandler(passmgr),
 diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py
 --- a/mercurial/graphmod.py
 +++ b/mercurial/graphmod.py
-@@ -18,7 +18,6 @@
+@@ -17,7 +17,6 @@
+ Data depends on type.
  """
  
+-import sys
  from mercurial.node import nullrev
--import sys
  
  CHANGESET = 'C'
- 
-@@ -37,14 +36,14 @@
+@@ -37,7 +36,7 @@
          yield (cur, CHANGESET, ctx, sorted(parents))
          cur -= 1
  
      """file cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples
  
      This generator function walks through the revision history of a single
-     file from revision start down to revision stop.
-     """
-     filerev = len(repo.file(path)) - 1
--    if limit < sys.maxint:
-+    if limit is not None:
-         lower = max(0, filerev - limit + 1)
-     else:
-         lower = 0
+loglimit
 iterators
-loglimit
+blacklist-improvements
 debug
 inotify-global-dir-visit
 inot-track-dirs