Commit Graph

282 Commits

Author SHA1 Message Date
Patrick Mezard
aebb857395 util: ignore invalid path errors in path_auditor. 2007-08-13 19:42:50 +02:00
Bryan O'Sullivan
6cbcae9959 Make a few portability improvements to path auditing code. 2007-08-10 10:51:47 -07:00
Bryan O'Sullivan
1b98353d91 Make audit_path more stringent.
The following properties of a path are now checked for:

    - under top-level .hg
    - starts at the root of a windows drive
    - contains ".."
    - traverses a symlink (e.g. a/symlink_here/b)
    - inside a nested repository

If any of these is true, the path is rejected.

The check for traversing a symlink is arguably stricter than necessary;
perhaps we should be checking for symlinks that point outside the
repository.
2007-08-10 10:46:03 -07:00
Patrick Mezard
6b51a27d18 Merge with crew-stable 2007-08-06 10:57:51 +02:00
Patrick Mezard
3857228c9a Fix issue 653: symlinks checkout failure on non-supporting platforms 2007-08-06 10:08:28 +02:00
Thomas Arendsen Hein
325c8db06b merge with crew-stable 2007-08-04 22:27:52 +02:00
Thomas Arendsen Hein
ae0d60a260 Simplify/correct finding the hg executable (fixes issue644)
Simply use find_exe('hg') as the default value for $HG and require to manually
set it if you have special requirements.

While the default will not always be 100% correct (i.e. the identical hg
version) for many users it is and for the others the hg executable found in
the PATH should do most things correctly.

Developers or other users with multiple installs can set $HG or run something
like util.set_hgexecutable in their shell or python scripts.

Additionally util.hgexecutable() is now available so extensions can access
the value with a public interface, too.
2007-08-04 22:25:12 +02:00
Benoit Boissinot
84d45c7794 fix unused variables reported by pychecker 2007-07-20 09:31:32 +02:00
Bryan O'Sullivan
a7c1cdf4bc Print meaningful error message if os.symlink fails 2007-07-19 15:29:33 -07:00
Jesse Glick
5b3c852e55 typo fix 2007-07-12 10:55:49 -04:00
Alexis S. L. Carvalho
3739335e3b util._hgexecutable: default to 'hg'
This should make hooks work even if util.set_hgexecutable is not called
(e.g. hgweb.cgi).

Fixes issue625.
2007-07-11 18:15:21 -03:00
Alexis S. L. Carvalho
422bcbcb1d Add symlink method to util.opener.
Differences from os.symlink:

- the symlink name is relative to the opener base directory

- if a file with that name already exists, it's removed

- if necessary, parent directories are created

- if the system (OS or filesystem) doesn't support symlinks, a
  regular file is created.  Its contents are the symlink target.
2007-07-11 17:40:41 -03:00
Alexis S. L. Carvalho
2a73361d92 turn util.opener into a class 2007-07-11 17:40:41 -03:00
Nathan Jones
8fc48b4f99 Fix serve on Windows without win32* modules. 2007-06-26 10:48:58 -04:00
Jean-Francois PIERONNE
7a71f63f2b OpenVMS patches 2007-06-08 16:24:43 +02:00
Markus F.X.J. Oberhumer
84ffe403b9 Add support for RFC2822 to util.parsedate(). 2007-06-25 14:46:20 +02:00
Thomas Arendsen Hein
2e76adae49 Remember path to 'hg' executable and pass to external tools and hooks as $HG. 2007-06-23 20:21:10 +02:00
Patrick Mezard
21ea8128a8 Merge with crew 2007-06-21 22:19:41 +02:00
Marcos Chaves
f5c072cbc9 Handle CTRL+C in serve under Windows. 2007-06-21 21:58:18 +02:00
Thomas Arendsen Hein
9a78cd828a Remove useless variable assignments in util.opener.
The original idea might have been to prevent circular references, but
as this assignment would have created another reference, this makes
no difference.
2007-06-21 19:24:27 +02:00
Eric Hopper
bdc1293e28 Provide a version independent way to use the set datatype. 2007-06-19 08:37:41 -07:00
Thomas Arendsen Hein
4d29c6dc8e Updated copyright notices and add "and others" to "hg version" 2007-06-19 08:51:34 +02:00
Brendan Cully
4a2d1da1c5 Work around heisenbug in Popen3.__del__ 2007-06-18 14:52:31 -07:00
Brendan Cully
497f138a19 Respect locale environment variables on darwin.
In python 2.4+ on darwin, locale.getpreferredencoding() returns
mac-roman regardless of what LC_CTYPE, LANG etc are set to. This can
produce hard-to-notice conversion errors if input text is not in
mac-roman. So this patch overrides it with setlocale/getlocale if the
environment has been customized, on the assumption that the user has
done so deliberately.
2007-06-11 12:14:31 -07:00
Thomas Arendsen Hein
7a4d62e035 Removed trailing \n in calls to util.Abort() 2007-06-09 13:25:54 +02:00
Thomas Arendsen Hein
49220695bc Removed trailing whitespace and tabs from python files 2007-06-06 20:22:52 +02:00
Alexis S. L. Carvalho
54dcd12c54 Remove atomicfile class.
The interface provided by opener(atomic=True) is inherently unsafe:
if an exception is raised in the code using the atomic file, the
possibly incomplete file will be renamed to its final destination,
defeating the whole purpose of atomic files.

To get around this, we would either need some bad hacks involving
sys.exc_info (to make sure things work in except: blocks), or an
interface to say "file is complete; rename it".

This is the exact interface provided by atomictempfile.  Since there
are no remaining users of the atomicfile class, just remove it.
2007-06-05 19:55:27 -03:00
Bryan O'Sullivan
d67a234671 Introduce find_exe. Use instead of find_in_path for programs.
The behaviour of find_in_path was broken for config options containing
path names, because it always searched the given path, even when not
necessary.  The find_exe function is more polite: if the name passed
to it contains a path component, it just returns it.
2007-05-27 14:26:54 -07:00
Patrick Mezard
37afbaec09 Fix issue483 - mq does not work under windows with gnu-win32 patch.
Add --binary option to patch command under win32.
2007-05-12 21:09:29 +02:00
Patrick Mezard
b4ca391b19 Move win32 find_in_files from util_win32 to util. 2007-05-06 16:40:53 +02:00
Alexis S. L. Carvalho
13b54a8829 Fix minor mismerge.
The caching of umask ended up being duplicated.
2007-04-28 17:55:45 -03:00
Brendan Cully
3787b004e8 Do not automatically rename an atomicfile if a write to it has generated an exception. 2007-04-25 13:14:01 -07:00
Bryan O'Sullivan
390039e974 util._matcher: speed up regexp matching.
In cdc7e3627e1b, Benoit made a change that substantially slows matching
when a big .hgignore file is in play, because it calls into the regexp
matching engine potentially hundreds of times per file to be matched.

I've partly rolled back his change, so that we only call into the matcher
once per file, but preserved the ability to report a meaningful error
message if there's a syntax error in the regexp.
2007-04-24 10:53:25 -07:00
Matt Mackall
a6178f3d01 Merge with crew 2007-04-12 12:42:22 -05:00
Matt Mackall
e293a4cd6d Merge with stable 2007-04-10 14:05:15 -05:00
Alexis S. L. Carvalho
ea51c7fac2 Merge with crew-stable. 2007-04-09 04:57:25 -03:00
Alexis S. L. Carvalho
c250e89b1e atomicfile: don't copy the original file if it'll be truncated 2007-04-09 04:24:17 -03:00
Alexis S. L. Carvalho
c9f461c7af util.opener: if requested, use atomicfile even if the file doesn't exist
Right now, surprisingly enough, if you request an atomic file but the
file still doesn't exist, you get a regular file.  AFAICS, the only time
this happens is during the initial creation of the dirstate.
2007-04-09 04:24:17 -03:00
Alexis S. L. Carvalho
cbe674cc00 cache os.umask even on windows 2007-04-09 04:24:17 -03:00
Alexis S. L. Carvalho
8cf3bc3446 Merge last few matcher/locate fixes. 2007-04-04 04:22:08 -03:00
Alexis S. L. Carvalho
e021806e69 change relglob: patterns to be consistent with glob: patterns
With this change, you have to use "hg locate 'hgweb/**'" to locate
all the files in directories named hgweb.  OTOH, "hg locate '*l'"
will locate only files that end with "l" - e.g. a file called "hg.py"
will not be matched just because it's in a directory whose name ends
with "l" (e.g. "mercurial").
2007-04-04 04:22:06 -03:00
Alexis S. L. Carvalho
8d4f62f9f3 Revert changeset 8e97d9d074da; add another test for glob: patterns
With that changeset, it's impossible to use a glob: pattern to match
e.g. all files ending in .py - glob:**.py would also match all files
in a directory called dir.py.
2007-04-04 04:22:05 -03:00
Alexis S. L. Carvalho
db8accc4c6 glob:<directory> patterns match the files in that directory.
This makes the behaviour of glob: patterns more consistent:
hg status glob:dir  and   hg status -I glob:dir  will match
the same files.

It's also consistent with the fact that {rel,}path patterns
recursively match the contents of a directory.
2007-03-20 22:09:55 -03:00
Alexis S. L. Carvalho
2ed671d3fa util._matcher: remove superfluous variable 2007-03-16 22:48:23 -03:00
Alexis S. L. Carvalho
a782e3309d util._matcher: use "." as the root of empty {rel,}path patterns
Should fix issue332. Really.
2007-03-16 22:48:20 -03:00
Alexis S. L. Carvalho
ec56d01ca6 Optimize return value of util._matcher for hgignore case 2007-03-10 23:01:02 -03:00
Alexis S. L. Carvalho
05eea28e33 Optimize return value of util._matcher for common command line case
This will trigger every time somebody runs something like "hg diff"
or "hg status" without any arguments.

The important part here is returning util.always as the match function,
which is a much simpler (and faster) function than the usual return
value, and allows other code to just skip the filtering if it knows
all files will match.
2007-03-10 23:01:00 -03:00
Alexis S. L. Carvalho
c3d6308137 remove unused "head" hack from util._matcher 2007-03-10 23:00:59 -03:00
Alexis S. L. Carvalho
b53e6f3897 change locate to use relglobs by default
This makes its default behaviour useful again (issue108), and
changes it search the entire repository by default (instead
of just the cwd), just like all other commands.

It also hides issue204 by default, but you'll still see the
same behaviour if you give it a relpath: pattern.
2007-03-10 23:00:57 -03:00
Alexis S. L. Carvalho
393022dbbb dirstate.statwalk: explicitly test for ignored directories
This removes a hack where we appended '/' to a dirname so that:
- it would not appear on the "dc" dict
- it would always be matched by the match function

This was a contorted way of checking if the directory was matched by
some hgignore pattern, and it would still fail with some uses of
--include/--exclude patterns.

Things would still work fine if we removed the check altogether and
just appended things to "work" directly, but then we would end up
walking ignored directories too, which could be quite a bit of work.

This allows further simplification of the match function returned by
util._matcher, and fixes walking the working directory with a
--include pattern that matches only the end of a name.
2007-03-10 23:00:54 -03:00