Commit Graph

139 Commits

Author SHA1 Message Date
Dan Villiom Podlaski Christiansen
ec590d5cd4 explicitly close files
Add missing calls to close() to many places where files are
opened. Relying on reference counting to catch them soon-ish is not
portable and fails in environments with a proper GC, such as PyPy.
2010-12-24 15:23:01 +01:00
Martin Geisler
a76e121863 backout of e4cb9628354c
Matt and a majority of crew did not like this approach.
2011-01-27 11:15:08 +01:00
Martin Geisler
d23e1973c2 specify C indention style using Emacs file local variables 2011-01-26 12:05:01 +01:00
Nicolas Dumazet
afb08fe68c inotify: raise correct error if server is already started in a deep repository
When path is too long to be an Unix socket address, we create a socket in a
temporary directory and link from the long path to the shorter one.
But checks in server code at startup were insufficient in this case, and used
to raise an unclear "tried linking .hg/inotify.sock to a temporary socket but
.hg/inotify.sock already exists"
2010-10-09 15:41:53 +02:00
Brodie Rao
0f9d940cb9 cleanup: remove unused variables 2010-08-27 13:32:40 -04:00
Greg Ward
41733adeb2 inotify: show the exact command used to start the server 2010-08-13 13:16:34 -04:00
David Soria Parra
c66423f7bc inotify: remove unused variable 2010-07-24 22:15:22 +02:00
Matt Mackall
33994da433 Merge with stable 2010-07-20 15:07:10 -05:00
Greg Ward
08b5f707c3 inotify: make inotifydirstate.status() returns a tuple of lists.
This makes it consistent with dirstate.status(), which is important if
there are other extensions messing with the output of status().  Those
extensions can safely assume that dirstate.status() returns a tuple of
lists, because its docstring says it does.  But
inotifystatus.dirstate() returns a list of lists, which can break
those other extensions.
2010-07-20 14:00:47 -04:00
Renato Cunha
b6d6b8775c removed exception args indexing (not supported by py3k)
Py3k removed __getitem__ for exception classes. The correct way of
getting the exception arguments is by using the args method.
2010-07-14 23:03:21 -03:00
Nicolas Dumazet
658e3fee6a merge with stable 2010-07-13 22:56:01 +09:00
Renato Cunha
6de8a70a9d inotify: check all components of filenames against hgignore (issue884)
With inotify enabled, files that should be ignored could be detected as
untracked by mercurial. This behavior was wrong because inotify's filestatus
implementation only matched filenames against ignore patterns, instead of
checking if other elements of their paths matched them. This patch fixes the
behavior by checking the file paths against the ignore patterns.

A new test has also been added to the main inotify test to prevent any
regressions.
2010-07-06 22:22:18 -03:00
Renato Cunha
f1db4f7c25 inotify: Port of the C module to py3k.
This patch accomplishes the port of the inotify C module to py3k by #including
mercurial's util.h file, and by defining the necessary boilerplate code
required by py3k through conditional compilation.
2010-07-02 16:22:59 -03:00
Renato Cunha
e091197571 inotify: Better implementation of the event string representation.
This patch reimplements the event_repr function. It got mostly rewritten to
eliminate the need for conditional compilation of the module when building in
py3k. The trick there (thanks to Antoine Pitrou) is to use the % operator to
let the python interpreter format the string to be returned.
2010-07-02 16:21:46 -03:00
Renato Cunha
d43bcc0e6e inotify: make proper use of Python API to get object size.
In older python versions, it was ok to access an object's type by accessing its
ob_type "member". With python 2.6+, the proper way of accessing it is via
Py_TYPE(object). This patch implements the correct call for the inotify
extension. When under python < 2.6, this macro is defined in mercurial's
util.h.
2010-07-02 16:21:42 -03:00
FUJIWARA Katsunori
ce06b102df help: show value requirement and multiple occurrence of options
this helps users to know what kind of option is:

  - no value is required(flag option)
  - value is required
  - value is required, and multiple occurrences are allowed

each kinds are shown as below:

 -f --force              force push
 -e --ssh CMD            specify ssh command to use
 -b --branch BRANCH [+]  a specific branch you would like to push

if one or more 3rd type options are shown, explanation for '[+]' mark
is also shown as footnote.
2010-06-06 17:25:00 +09:00
Greg Ward
f43d8c7735 inotify: expose the same dirstate.status() interface as dirstate.
The real dirstate.status() does not have any keyword args.  For
consistency, wrappers or subclasses should not have them either.
2010-03-07 13:10:23 -05:00
Benoit Boissinot
060818ca9f inotify/inserve: implement --timeout-idle option (issue885)
hg inserve was ignoring and miscomputing the --timeout-idle option (seconds
vs. minutes).

Thanks to Jesse Glick for the bugreport and the initial patch.
2010-02-17 20:44:49 +01:00
Benoit Boissinot
9399306905 regression: missing arg from 3067d5de9e6c dirstate.{walk,status} changes 2010-02-17 20:30:57 +01:00
Brodie Rao
892ba5a830 remove unused imports 2010-02-14 01:52:31 -05:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
cd3ef170f7 Merge with stable 2010-01-19 22:45:09 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Patrick Mezard
48eee05938 Find right hg command for detached process
On Windows, Mercurial can be run from the python script of from a frozen
executable. In the first case, we have to call the python interpreter since the
script is not executable. Frozen executable can be called directly.

Fix 3/3 for issue421
2010-01-06 21:11:58 +01:00
Nicolas Dumazet
7639059665 inotify: improve error messages
* prefix messages by inotify-(client|server)
* make sure that all warning and abort messages use the same format.
* in the case where inotify.sock is an old broken symlink, say so and abort
  instead of trying to overwrite the already existing link
2009-11-19 11:06:01 +09:00
Nicolas Dumazet
696edec52d inotify: add a inotify.pidfile configuration possibility
This will mainly help us in our tests to log pids of inotify servers
started implicitely, to make sure that unkilled inotify daemons do not clutter
the output of unrelated tests.

Also desactivate the workaround introduced in 37824a274d63
2009-11-17 15:36:09 +09:00
Nicolas Dumazet
fd600dc328 inotify: Do not access inotify when dirstate is dirty (issue1811)
Original patch was provided by Simon Heimberg

It delegates dirstate computation to dirstate.status when dirstate is dirty:
better be slow from time to time instead of using wrong data.

This solves issue1719. As the last component, issue1810, is still not solved,
test-inotify-dirty-dirstate will fail for now. It emphasizes a regression due
to e8efd88001e7:

changeset:   9515:e8efd88001e7
user:        Nicolas Dumazet <nicdumz.commits@gmail.com>
date:        Sun Aug 16 11:11:37 2009 +0900
summary:     inotify: use cmdutil.service instead of local daemonizing code

Ancestors of 7c01599dd30 are passing the test, when applied this patch.
Regression has to be investigated, but this patch is important since it affects
often mq operations.
2009-11-11 14:38:59 +09:00
Nicolas Dumazet
800658e086 inotify: mark directories visited during lookup (issue1844)
Emulate the match.dir calls that are made in dirstate.walk:
 * first mark the visited directories on the server side
 * then extend the transmitted response to include this directory list
 * and lastly call match.dir on each directory
2009-11-13 08:31:10 +09:00
Nicolas Dumazet
072c9e497b inotify: use cmdutil.service instead of local daemonizing code 2009-08-16 11:11:37 +09:00
Martin Geisler
9f1896c083 do not attempt to translate ui.debug output 2009-09-19 01:15:38 +02:00
Patrick Mezard
f6c5bd6fa1 Merge with crew-stable 2009-09-05 19:39:46 +02:00
Nicolas Dumazet
a9906a6b8c inotify: _inotify.c: bugfix: remove_watch has to return PyNone on success
We are not currently using that API function in inotify, hence the reason
for the "silent" bug. But returning NULL here causes the interpreter to crash.
Let's keep code clean for reusers :)

The whole "bail" logic was unneeded here.
2009-08-27 11:55:21 +02:00
Nicolas Dumazet
2478119a2e inotify: remove unused import 2009-08-16 11:09:21 +09:00
Nicolas Dumazet
30ca20c99b inotify: repo is not referenced from server, remove the weakref 2009-06-29 01:33:26 +09:00
Nicolas Dumazet
1ff8f59473 inotify: client: no repo use 2009-06-29 01:27:34 +09:00
Nicolas Dumazet
30ee6deafc inotify: server: use dirstate instead of repo 2009-06-29 01:09:33 +09:00
Nicolas Dumazet
e916441762 inotify: server: use wprefix everywhere, introduce prefixlen
self.wprefix = self.repo.root + '/' = self.repo.wjoin('') + '/'
Since we'll eventually get rid of self.repo, keep only the first form.

use self.prefixlen to compute only once the root prefix size.
2009-06-29 01:05:06 +09:00
Nicolas Dumazet
9cb4422b1e inotify: server._updatestatus: simplify control flow 2009-06-28 19:46:36 +09:00
Nicolas Dumazet
5335f5c399 inotify: server: explicitely ignore events in subdirs of .hg/ (issue1735) 2009-07-13 21:55:17 +09:00
Nicolas Dumazet
2645ee079e inotify: fix issue1375, add a test.
The biggest problem was the data structure, which did not allow changing
a file into a directory or vice versa. This problem is fixed by 47d29dcb7266.

The walk() method also had an issue in this case:
 - we know 'path' as a directory. inotify server sleeps.
 - 'path' is deleted
 - 'path' is recreated as a file
 - the server catches up here, and see the deletion. it instantiates a scan(),
   which in its turn calls for walk(repo, path).
 - walk() then assumes that 'path' is a directory and calls os.listdir on it,
   which raises an OSError(errno.ENOTDIR)

Catch the error, and yield the file instead of the directory contents.
2009-07-13 16:49:05 +02:00
Nicolas Dumazet
839cb8fbc8 inotify: server: new data structure to keep track of changes.
== Rationale for the new structure ==

Current structure was a dictionary tree. One directory was tracked
as a dictionary:
 - keys: file/subdir name
 - values:
    - for a file, the status (a/r/m/...)
    - for a subdir, the directory representing the subdir

It allowed efficient lookups, no matter of the type of the terminal leaf:
    for part in path.split('/'): tree = tree[part]

However, there is no way to represent a directory and a file with the same name
because keys are conflicting in the dictionary. Concrete example:

Initial state:

root dir
 |- foo (file)
 |- bar (file)

# data state is: {'foo': 'n', 'bar': 'n'}

Remove foo:

root dir
 |- bar (file)

# Data becomes {'foo': 'r'} until next commit.

Add foo, as a directory, and foo/barbar file:

root dir
 |- bar (file)
 |-> foo (dir)
  |- barbar (file)

# New state should be represented as:
  {'foo': {'barbar': 'a'}, 'bar': 'n'}
  however, the key "foo" is already used and represents the old file.

The dirstate:
 D foo
 A foo/barbar
cannot be represented, hence the need for a new structure.

== The new structure ==

'directory' class. Represents one directory level.
* Notable attributes:
  Two dictionaries:
   - 'files' Maps filename -> status for the current dir.
   - 'dirs' Maps subdir's name -> directory object representing the subdir
* methods
  - walk(), formerly server.walk
  - lookup(), old server.lookup
  - dir(), old server.dir

This new class allows embedding all the tree walks/lookups in its own class,
instead of having everything mixed together in server.

Incidently, since files and directories are not stored in the same
dictionaries, we are solving the previous key conflict problem.

The small drawback is that lookup operation is a bit more complex:
for a path a/b/c/d/e we have to check twice the leaf, if e is a directory or a
file.
2009-05-26 23:00:35 +09:00
Nicolas Dumazet
968f9e4e5f inotify: server: remove wpath method
Only called once. And can be simplified to an easy oneliner.
2009-06-28 19:31:16 +09:00
Simon Heimberg
e0ab0a167d inotify: return version to client even when not matching
Old clients are expecting a version string even in case of mismatch, otherwise
they get stuck.
2009-06-21 18:11:19 +02:00
Martin Geisler
31cc202751 inotify: OPT -> OPTION in cmdline help string 2009-06-27 12:05:01 +02:00
Dirkjan Ochtman
1c6c4a9bc7 extensions: fix up description lines some more 2009-06-24 12:25:56 +02:00
Cédric Duval
dbcec5595d extensions: improve the consistency of synopses
Trying as much as possible to consistently:
 - use a present tense predicate followed by a direct object
 - verb referring directly to the functionality provided
   (ie. not "add command that does this" but simple "do that")
 - keep simple and to the point, leaving details for the long help
   (width is tight, possibly even more so for translations)

Thanks to timeless, Martin Geisler, Rafael Villar Burke, Dan Villiom
Podlaski Christiansen and others for the helpful suggestions.
2009-06-22 15:48:08 +02:00
Nicolas Dumazet
72d6c7e713 inotify: repowatcher: don't use a watches attribute to count watches
The encapsulated watcher alread has a __len__ method for this purpose.
Also, repowatcher.watches was never decremented on watch deletions.
2009-05-23 20:38:08 +09:00
Nicolas Dumazet
020e8eab5b inotify: put the "while True: poll()" loop in pollable class 2009-05-21 23:51:54 +09:00
Nicolas Dumazet
90ce932bee inotify: refactor (un)register methods into pollable object
repowatcher.master becomes unnecessary
2009-05-21 20:15:00 +09:00
Benoit Boissinot
c157c77a0e inotify.server: the decorator eventaction() shouldn't be a method of repowatcher 2009-06-13 18:41:28 +02:00