[PATCH 00 of 24] PYTHONHASHSEED=random

Mads Kiilerich mads at kiilerich.com
Sun Dec 16 16:33:55 CST 2012


These changes are the result of an attempt of running the test suite with
PYTHONHASHSEED=random.

Why do that?
* Because we (almost) can.
* To find out whether this can help spotting some spurious test failures.
* This setting protects against some DOS issues and should arguably be the
  default in Python.
* Testing this way might reveal some places where Mercurial or the test suite
  is fragile. Fixing such issues will make Mercurial more stable and might
  prevent some test failures later on.

The main observable outcome of running with PYTHONHASHSEED=random is that the
iteration order of sets and dicts varies. It is by definition undefined and
nobody should depend on it ... but we happen to do it anyway. The iteration
order is usually stable, and there might be cases where the code and the test
cases happens to work on the tested platforms.

Most of the patches in this series are just fixing variable ordering in the
output. The primary reason to fix these issues is to be able to spot more
serious errors.

Other issues will cause different behaviour and different repository content.
It is mainly in areas where the behaviour already is undefined, but Mercurial
should still be stable and not depend on external factors.

Finally, it seems like at least one real spurious issue was found. It could
thus have some value to aim at making sure the test suite runs cleanly with
PYTHONHASHSEED=random - and configure a buildbot to run that way.

The most obvious solution to random iteration order is to define some stable
order. The most obvious order is to sort the sequence. That adds a overhead,
but it will mostly be sets that will be iterated anyway and it should
especially not be a problem as long as we only enumerate and sort files, heads,
branches, bookmarks etc.

A more efficient future solution could be to use some kind of sorteddict.

- but there might also be other orderings that would make more sense than (for
instance) sorting by hash value.

/Mads



More information about the Mercurial-devel mailing list