test-inotify: test symlink indirection for unix sockets

The inotify code performs a delicate dance to work around the 108-byte
limit on unix domain socket path names on Linux.

This change sets us up to safely refactor that code without breaking
it. (It is redundant with part of test-inotify-issue1208.t, but we will
shortly make that test go away.)

--HG--
extra : rebase_source : c8dfa0f461967438222e919afe39ef175a5bb7f6
inotify: don't fall over just because of a dangling symlink

Previously, the inotify server failed to start if .hg/inotify.sock was
a symlink that pointed to a non-existent path. This behaviour does not
seem to make any sense.

Now, if we encounter a broken symlink, we unlink it and continue.

--HG--
extra : rebase_source : d1828f471b089e81496fd56beba7d040d307fb2c
posix: move server side of unix domain sockets out of inotify

We also turn the unix domain socket into a class, so that we have a
sensible place to hang its logically related attributes and behaviour.

We'll shortly want to reuse this in other code.

--HG--
extra : rebase_source : 547172cf2a975f7806f078285b3712f38ecb53f5
tests: make test-inotify-issue1208.t disappear

--HG--
extra : rebase_source : f9314e2a9392afca968142eed7ac671744173387
inotify: pacify pestiferous pyflakes precipitously
clfilter: add actual repo filtering mechanism

We add a `filtered` method on repo. This method return an instance of `repoview`
that behaves exactly as the original repository but with a filtered changelog
attribute. Filters are identified by a "name". Planned filter are `unserved`,
`hidden` and `mutable`. Filtering the repository in place what out of question
as it wont not allows multiple thread to share the same repo. It would makes
control of the filtering scope harder too. See the `repoview` docstring for
details.

A mechanism to compute filtered revision is also installed. Some caches will be
installed in later commit.

--HG--
extra : rebase_source : 11467c762b77075ad012f420ee993f21218324ec
clfilter: add a cache on repo for set of revision to filter for a given set.

Recomputing the filtered revisions at every access to changelog is far too
expensive. This changeset introduce a cache for this information. This cache is
hold by the repository (unfiltered repository) and invalidated when necessary.
This cache is not a protected attribute (leading _) because some logic that
invalidate it is not held by the local repo itself.

--HG--
extra : rebase_source : 54f51cc8f3a34dac96178a873e7aad5ad4fe207a
clfilter: introduce a "unserver" filtering mode

This mode is for repository used as a server. It filter secret and hidden
changeset out.

It is put to use in later changeset.

--HG--
extra : rebase_source : 92ce40f2bb8a27653c52d2aa43333b9f0c0b19ea
clfilter: use filtering in `visiblebranchmap`

Here is the first real use of changelog filtering. The change is very small to
allow testing the new filter with a setup close to the original one.

We replace custom post processing on branchmap function by call to the
standard code pass on a filtering repo.

In later coming will have wider usage of filtering that will make the dedicated
function useless.

--HG--
extra : rebase_source : f04dd8c07b2429876569eab9136160d5c9c98bd2
clfilter: use filtering in `visibleheads`

This is the second real use of changelog filtering. The change is very small to
allow testing the new filter with a setup close to the original one.

We replace custom post processing on `heads`function by call to the standard
code pass on a filtering repo.

In later coming will have wider usage of filtering that will make the dedicated
function useless.

--HG--
extra : rebase_source : 454e0d340af6677f9e6c96ed8f83f2cc4b79d49a
cache: group obscache and revsfiltercache invalidation in a single function

Both caches are very volatile and needs invalidation on the same kind of event.
revsfiltercache actually depends on the content of revsfiltercache.

--HG--
extra : rebase_source : f14f34849f9411ba55e7ac0dd953050f09e1f77a
hidden: invalidate hiddenrevs when needed

The `hiddenrevs` cache is volatile too (It use content from `obscache`). When
unsure it is invalidated when necessary. In a near future, the cache will
probably be moved to `revsfiltercache`

--HG--
extra : rebase_source : 41d7e99714ac389d6d71daa60aad220f77aa5108
inotify: on Python < 2.6, socket.error lacks errno
tests: fix some slash-based Windows failures

--HG--
extra : rebase_source : 8d87e16aaefec77a6df29b62915aa2f146c26c00
subrepo: append subrepo path to subrepo error messages

This change appends the subrepo path to subrepo errors. That is, when there
is an error performing an operation a subrepo, rather than displaying a message
such as:

pushing subrepo MYSUBREPO to PATH
searching for changes
abort: push creates new remote head HEADHASH!
hint: did you forget to merge? use push -f to force

mercurial will show:

pushing subrepo MYSUBREPO to PATH
searching for changes
abort: push creates new remote head HEADHASH! (in subrepo MYSUBREPO)
hint: did you forget to merge? use push -f to force

The rationale for this change is that the current error messages make it hard
for TortoiseHg (and similar tools) to tell the user which subrepo caused the
push failure.

The "(in subrepo MYSUBREPO)" message has been added to those subrepo methods
were it made sense (by using a decorator). We avoid appending "(in subrepo XXX)"
multiple times when subrepos are nexted by throwing a "SubrepoAbort" exception
after the extra message is appended. The decorator will then "ignore" (i.e. just
re-raise) the exception and never add the message again.

A small drawback of this method is that part of the exception trace is lost when
the exception is catched and re-raised by the annotatesubrepoerror decorator.

Also, because the state() function already printed the subrepo path when it
threw an error, that error has been changed to avoid duplicating the subrepo
path in the error message.

Note that I have also updated several subrepo related tests to reflect these
changes.

--HG--
extra : rebase_source : d568164712dbb1575cf33564ba05a9567336813e
test-pathencode: accept --seed parameter in hex as well

test-pathencode.py outputs the seed value in hex if it finds a deviation.

This change allows to specify the seed value as a command line
parameter for test-pathencode.py in hex as well.

--HG--
extra : amend_source : 9eb274e4e637bcb54839482bbcb1f217bee47ae7
hook: disable demandimport before importing hooks

This solved an obscure bug for me. In upgrading Distribute on the server, a
patch was added to has a try: import a except ImportError thing that's only
supposed to work with Python 3.3. I'm using 2.7. My hook failed with an
ImportError because of this. It seems kind of sensible to turn off
demandimport before importing the hook, since the except ImportError pattern
is used quite a bit in Python code (including in other Distribute code).
branchmap: simplify _branchtags using a new _cacheabletip method

The current _branchtags method is a remnant of an older, much larger function.
Its only remaining role is to help MQ to alter the version of branchcache we
store on disk. As MQ mutates the repository it ensures persistent cache does not
contain anything it is likely to alter.

This changeset makes explicit the stable vs volatile part of repository and
reduces the MQ specific code to the computation of this limit. The main
_branchtags code now handles this possible limit in all cases.

This will help to extract the branchmap logic from the repository.

The new code of _branchtags is a bit duplicated, but as I expect major
refactoring of this section I'm not keen to setup factorisation function here.

--HG--
extra : rebase_source : aa0e6e4fda8672e936c641d1995c62f6309fd311
branchmap: factorise access to changelog in updatebranchcache

This prepares merge of `updatebranchcache` and `_branchtags`.

--HG--
extra : rebase_source : d20c4bc7770e10f888f9459b968cc054e565b4c2
branchmap: merge _branchtags into updatebranchcache

Now that nobody overwrite it, there is no reasons for `_branchtags` to remains
separated from `updatebranchcache`.

--HG--
extra : rebase_source : d0553a9c6554c0e7f12208d8830a4da0114f9a8a