Commit Graph

792 Commits

Author SHA1 Message Date
Martin Geisler
5b0900d7be util: use "is" for True/False/None comparisons 2009-05-20 10:50:23 +02:00
Simon Heimberg
e859b5a899 util: use set instead of dict 2009-05-19 09:57:06 +02:00
Bryan O'Sullivan
496cd5e84c util: make atomictempfile saner if mktempcopy fails 2009-05-14 14:12:32 -07:00
Peter Arrenbrecht
a75765cf7f drop unused imports 2009-05-14 15:35:46 +02:00
Bryan O'Sullivan
ff0948b137 util.termwidth: a file-like object may legitimately lack a fileno() method
Spotted in the wild when running a hook while pushing over HTTPS.
2009-05-11 11:53:27 -07:00
Bryan O'Sullivan
64e91f0ca1 atomictempfile: delegate to posixfile instead of inheriting from it 2009-03-26 13:12:11 -07:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Simon Heimberg
f29f0db784 util: overwrite sha1 and _fastsha1 2009-05-08 09:59:15 +02:00
Martin Geisler
97b9a7a062 util: simplify pipefilter and avoid subprocess race
The subprocess module is not thread safe. Spawning a thread to read
the output leads to exceptions like this when Mercurial exits:

  Exception exceptions.TypeError: TypeError("'NoneType' object is not
  callable",) in <bound method Popen.__del__ of <subprocess.Popen
  object at 0x9ed0dcc>> ignored

The bug is already reported in the Python bug tracker:

  http://bugs.python.org/issue1731717
2009-05-07 01:33:44 +02:00
Matt Mackall
01454e7a1b util: kill unused Popen3 2009-05-04 14:22:33 -05:00
Martin Geisler
8fdb40802d util: stop overwriting sha1, overwrite _fastsha1 instead
Some modules (like revlog) would import util.sha1 as _sha1. This
defeats the purpose of having util.sha1 overwrite itself with a faster
version -- revlog would end up always calling the slow version. By
always delegating to util._fastsha1 we avoid this at the cost of an
extra (but unconditional) indirection.
2009-05-04 22:14:52 +02:00
Martin Geisler
6533e94352 util: remove md5
This hash function is broken and should not be used by new code. It is
currently only used by keepalive.
2009-05-04 21:30:39 +02:00
Sune Foldager
b19fc2c469 util: remove warnings when importing md5 and sha 2009-05-04 20:29:05 +02:00
Martin Geisler
21ba2e96f6 util: initialize md5 and sha1 without using extra global variables
This lets the functions skip the "if _sha1 is None" test on each call.
2009-05-03 00:03:35 +02:00
Martin Geisler
11190d5aaa util: always use subprocess 2009-05-02 23:05:35 +02:00
Patrick Mezard
695b5f0d5f Fix missing import from 4bea569e9933 merge 2009-04-30 08:38:20 +02:00
Patrick Mezard
0cdb05f6a7 Merge with crew-stable 2009-04-29 23:56:20 +02:00
Sune Foldager
2f3ee06863 util.rename: use temporary file name for rename-targets on windows
Use a temporary file name as target for a forced rename on Windows. The
target file name is not opened at any time; just renamed into and then
unlinked. Using a temporary instead of a static name is necessary since
otherwise a hg crash can leave the file lying around, blocking future
attempts at renaming.
2009-04-29 09:30:28 +02:00
Martin Geisler
2c8901a1b9 turn some comments back into module docstrings 2009-04-26 01:24:49 +02:00
Martin Geisler
8e4bc1e9ad put license and copyright info into comment blocks 2009-04-26 01:13:08 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Matt Mackall
2f9b02c62d replace util.sort with sorted built-in
This is marginally faster for small and moderately-sized lists
2009-04-26 16:50:44 -05:00
Matt Mackall
9ec97bdefe util: take propertycache from context.py 2009-04-26 16:50:44 -05:00
Matt Mackall
8a63c10958 util: kill configparser wrapper 2009-04-26 16:50:43 -05:00
Martin Geisler
44aa7e92d1 util: use built-in set instead of util.unique 2009-04-22 00:56:06 +02:00
Martin Geisler
1deb417a82 util: use built-in set and frozenset
This drops Python 2.3 compatibility.
2009-04-22 00:55:32 +02:00
Martin Geisler
cc72b62ca4 util: return boolean result directly in util.binary 2009-04-22 17:14:58 +02:00
Dirkjan Ochtman
fe39d83f68 cleanup: remove all trailing whitespace 2009-03-23 13:11:11 +01:00
Matt Mackall
5871cdf2c8 audit: be even pickier (issue1450) 2009-03-04 17:02:16 -06:00
Sune Foldager
3fb25f365e util: don't overwrite os-specific functions with general ones 2009-04-04 18:12:43 +02:00
Justin Peng
d4938a90ee Correct a bug on date formats with '>' or '<' accompanied by space characters. 2009-04-01 09:11:00 -07:00
Matt Mackall
642f4d7151 move encoding bits from util to encoding
In addition to cleaning up util, this gets rid of some circular dependencies.
2009-04-03 14:51:48 -05:00
Matt Mackall
2cddde0437 move util.Abort to error.py 2009-04-03 13:20:52 -05:00
Steve Borho
67420334f3 windows: hoist expand_glob() back into util.py
The windows version of expand_glob() requires patkind(). To
avoid a circular dependency, move function back into util.py.
2009-03-26 22:07:01 -05:00
Matt Mackall
0952760f82 util: split out posix, windows, and win32 modules 2009-03-26 13:54:44 -05:00
Alexander Solovyov
475ce753d3 templater: ability to display diffstat for log-like commands 2009-03-23 10:41:42 +01:00
Peter Arrenbrecht
19591b6a8c cleanup: drop unused assignments 2009-03-23 13:13:06 +01:00
Matt Mackall
7c27807553 audit: check for casefolding of .hg (issue1450) 2009-02-16 17:37:23 -06:00
Matt Mackall
f547c37df5 rename: simplify forced renaming
This should help work around virus scanner issues with rename on Windows.
2009-02-16 17:37:23 -06:00
Will Maier
fbbafcd5d7 Use shutil.copystat in copyfile(). 2009-02-09 07:55:42 -06:00
Mads Kiilerich
d775f5aa2a Make util.find_exe alway returns existing file, fixing issue1459
It seems like the old behaviour with different handling for commands with and
without path was intended, but I think this behaviour of util.find_exe is
better:
* Always returns existing file
* or None if command not found - no default
* Windows: Returned file thus always ends with extension from PATHEXT

This fixes http://www.selenic.com/mercurial/bts/issue1459. The change might
fix other unintended behaviour too.
2009-01-25 21:20:13 +01:00
Matt Mackall
6a6762635c simplify colwidth a bit 2009-01-23 14:51:09 -06:00
Shun-ichi GOTO
fccc1f5345 Also find correct column width of wide characters.
Use unicodedata.east_asian_width() to determine wide/full width
characters if available. Otherwise, return character count as before.
2009-01-21 20:29:47 +09:00
Matt Mackall
104a85dee5 error: move SignatureError 2009-01-12 13:51:43 -06:00
Matt Mackall
7f3bf9b19d error: move SignalInterrupt
now derived from KeyboardInterrupt to simplify catches
2009-01-12 11:48:05 -06:00
Matt Mackall
534da54d07 error: move UnexpectedOutput (now ResponseError) 2009-01-12 11:28:28 -06:00
Matt Mackall
356502607f refactor version code
- simplify version detection code
- move detection code into setup.py
- move version reading function into util.py
- drop version.py code

This makes hg more closely follow its own recommendation of how to deal with
versioning your builds: use hg id in your build script.
2009-01-10 18:02:38 -06:00
Matt Mackall
a25d874c56 Merge with -stable 2008-12-31 18:00:35 -06:00
Matt Mackall
71a02e35c5 audit: reject paths with .hg (issue 1450)
Spotted by Peter Arrenbrecht
2008-12-31 16:27:20 -06:00
Alexander Solovyov
c1774bb6c3 python implementation of diffstat
Implemented as two functions: diffstat, which yields lines of text,
formatted as a usual diffstat output, and diffstatdata, which is called
inside diffstat to do real performing and yield file names with
appropriate data (numbers of added and removed lines).
2008-12-25 10:48:24 +02:00
Dirkjan Ochtman
265b2d6c5c merge with crew-stable 2008-12-19 18:49:02 +01:00
Dirkjan Ochtman
600f058f30 hgweb: mq repos should be in non-recursive collections, too 2008-12-19 18:24:49 +01:00
Dirkjan Ochtman
8215a72dd6 merge with crew-stable 2008-12-19 08:20:19 +01:00
Benoit Allard
6edf6273f0 hgweb: recurse down collections only if ** in [paths]
collections: direct child repos only
paths *: direct child repos only (like collections)
paths **: recursive discovery

When ** is used, the mq repository (if any) is also shown.
2008-12-18 22:32:48 +01:00
Patrick Mezard
42823196e7 Merge with crew-stable 2008-12-10 00:29:10 +01:00
Patrick Mezard
1ab0600f40 util: disable walkrepo() recursive behaviour
Revert b1aea76f700 and c6d3b233571e for performances reasons. Traversing
checkout working directories may be too expensive.
2008-12-10 00:16:12 +01:00
Benoit Boissinot
de1bbc2aa9 exceptions should inherit the Exception class 2008-12-06 15:53:57 +01:00
Matt Mackall
013115d873 encoding: normalize some silly encoding names 2008-12-02 13:05:40 -06:00
Mads Kiilerich
f97a1f6cd5 util: use existing never() instead of custom lambda 2008-11-27 00:57:32 +01:00
Matt Mackall
c163f654f6 Merge with crew 2008-11-25 16:24:22 -06:00
Matt Mackall
648df6f0b1 dispatch: generalize signature checking for extension command wrapping 2008-11-18 16:02:14 -06:00
Brendan Cully
f4cee1477f templater: return data in increasing chunk sizes
Currently hgweb is not streaming its output -- it accumulates the
entire response before sending it. This patch restores streaming
behaviour. To avoid having to synchronously write many tiny fragments,
this patch also adds buffering to the template generator. Local
testing of a fetch of a 100,000 line file with wget produces a slight
slowdown overall (up from 6.5 seconds to 7.2 seconds), but instead of
waiting 6 seconds for headers to arrive, output begins immediately.
2008-11-21 15:51:40 -08:00
Patrick Mezard
2e3aa68a1d Fix util._statfiles_clustered() failing at root of a windows drive
Report and initial fix by Andrei Vermel <avermel@mail.ru>.
2008-11-01 15:15:14 +03:00
Benoit Boissinot
214af7ec3c factor out the url handling from httprepo
Create url.py to handle all the url handling:
- proxy handling
- workaround various python bugs
- handle username/password embedded in the url
2008-10-27 21:50:01 +01:00
Benoit Allard
31ab3aeaed hgwebdir: show nested repositories (issue1336) 2008-10-22 18:23:32 +02:00
Thomas Arendsen Hein
593bff360d Add util.popen3 fallback, simplify import of Popen3 2008-10-19 12:19:55 +02:00
Thomas Arendsen Hein
b7ce96daba Fix util.popen2 for Python 2.3
1. trigger ImportError early, so fallbacks are activated
2. util.popen2 replaces previous usage of os.popen2, not popen2.popen2
2008-10-19 12:13:25 +02:00
Patrick Mezard
45970973da util: handle EINVAL in _statfiles_clustered()
Raised when osutil.listdir is called on a non-directory entry.
2008-10-18 20:50:08 +02:00
Patrick Mezard
f7eb935395 util: subprocess close_fds option is unix only 2008-10-18 15:49:15 +02:00
Petr Kodl
681e2c1a41 Take advantage of fstat calls clustering per directory if OS support it.
util module implements two versions of statfiles function

_statfiles calls lstat per file

_statfiles_clustered takes advantage of optimizations in osutil.c, stats all
files in directory at once when new directory is hit and caches the results

util.statfiles dispatches to appropriate version during module loading

The speedup on directory tree with 2k directories and 63k files is about
factor of 1.8 (1.3s -> 0.8s for hg diff - hg startup overhead about .2s)

At this point only Win32 now benefit from this patch.
Rest of OSes use the non clustered implementation.
2008-10-09 10:29:47 -04:00
Dirkjan Ochtman
67bd09df5b python2.6: use subprocess if available 2008-10-05 21:35:26 +02:00
Dirkjan Ochtman
6b51480caa merge with crew-stable 2008-08-12 17:47:08 +02:00
Matt Mackall
bfc02d4c70 util: set_flags should survive failure to create link 2008-08-10 21:55:23 -05:00
Matt Mackall
e03f4e2f73 util: set_flags shouldn't know about repo flag formats 2008-08-10 21:55:06 -05:00
Adrian Buehlmann
34afc460b4 move filename encoding functions from util.py to new store.py 2008-07-24 16:32:51 +02:00
Benoit Boissinot
664b2fafe8 merge with -stable 2008-07-23 16:14:45 +02:00
Benoit Boissinot
9d636a4b09 make mq and tags hardlink safe
The code didn't check for modes like "r+" or "rb+".
Many thanks to agriffis for noticing it.
2008-07-23 16:08:20 +02:00
Matt Mackall
a65ef7bc5d util: add sort helper 2008-06-27 18:28:45 -05:00
Matt Mackall
b2155285a8 rename checkfolding to checkcase 2008-06-26 13:58:24 -05:00
Matt Mackall
d462e1fc26 simplify flag handling
add _checklink var to dirstate
introduce dirstate.flagfunc
switch users of util.execfunc/linkfunc to flagfunc
change manifestdict.set to take a flags string
change ctx.fileflags to ctx.flags
change gitmode func to a dict
remove util.execfunc/linkfunc
2008-06-26 13:46:34 -05:00
Paul Moore
c966bce328 Add a new function, fspath
The function, given a relative filename and a root, returns the filename
modified to use the case actually stored in the filesystem (or None if the
file does not exist). The returned name is relative to the root, but retains
the path separators used in the input path. (This is not strictly necessary,
but retaining the path separators minimises misleading test suite failures).

A win32-specific implementation (using win32api.FindFiles) is possible, but it
has not been implemented as testing seems to demonstrate that the
win32-specific code is not significantly faster (thanks to the caching of
results in the generic code).
2008-06-06 19:23:23 +01:00
Matt Mackall
b74465983b remove default arg from patkind 2008-05-12 11:37:08 -05:00
Matt Mackall
fd009cd512 walk: kill util.cmdmatcher and _matcher 2008-05-12 11:37:07 -05:00
Dirkjan Ochtman
2f149e4634 replace usage of os.popen() with util.popen()
To make this possible, I added a mode parameter to both implementations of
util.popen(), defaulting to 'r' (as it does in the Python stdlib).
2008-04-14 14:34:38 +02:00
Christian Ebert
af73383537 Let util.binary check entire data for \0 (issue1066, issue1079) 2008-04-08 13:19:36 +02:00
Bryan O'Sullivan
8250520fe1 Merge 2008-04-09 15:28:30 -07:00
Bryan O'Sullivan
6ab8739d08 Tidy code, fix typo 2008-04-09 15:27:57 -07:00
Dirkjan Ochtman
34d6bea8db python 2.6 compatibility: compatibility wrappers for hash functions 2008-04-04 22:36:40 +02:00
Patrick Mezard
a8a4885e0a util: check fileno() validity in win32 set_binary() 2008-03-21 21:56:55 +01:00
Patrick Mezard
9672ec918b util: test fileno() availability in win32 set_binary()
Fix suggested by Alexander Belchenko <bialix@ukr.net>
2008-03-20 22:41:40 +01:00
Eric Hopper
63836614e1 hgwebdir: Tiny fix for webdir on non-symlink capable platforms. 2008-03-17 12:40:02 -07:00
Eric Hopper
0a50218866 Allow hgwebdir collections to follow symlinks. 2008-03-15 12:42:34 -07:00
Eric Hopper
798a7f0917 Check for patches repo with os.path.isdir not os.path.exists 2008-03-02 08:51:02 -08:00
Matt Mackall
44c538327c dates: Fix bare times to be relative to "today" 2008-03-11 17:42:51 -05:00
Matt Mackall
555abf8390 dates: improve timezone handling
datestr:
- add format specifiers %1 and %2 for timezone hours and minutes
- remove timezone and timezone format options
- correctly find timezone hours and minutes for fractional and negative timezones
- update users

strdate:
- correctly find timezone hours and minutes for fractional and negative timezones
2008-03-11 17:42:41 -05:00
Matt Mackall
309ee9f391 dates: fix fractional timezone display rounding bug 2008-03-10 02:54:37 -05:00
Joel Rosdahl
4f8012378a Remove unused imports 2008-03-06 22:23:41 +01:00
Peter Arrenbrecht
7f8994bad6 util: make walkrepos() return .hg/patches if present 2008-02-21 20:56:06 +01:00
Stefan Rank
e62243ce74 Also search for .hgrc if mercurial.ini not found on windows 2008-02-20 21:31:42 +01:00
Paul Moore ext:(%22)
2c78824696 Added hgexecutable support for py2exe/frozen scripts 2007-12-20 20:02:51 +00:00
Matt Mackall
ebf85d18e1 util: get rid of is_win_9x wart 2007-12-18 14:01:42 -06:00
Shun-ichi GOTO
903870798f Workaround for "Not enough space" error due to the bug of Windows.
Large write requests fail when stdout is switched to binary mode.
As a workaround, limit the data size to write once.
2007-12-14 16:47:41 +01:00
Steve Borho
dafb712d34 fix typo in sshargs
the original typo dated back to early 2005
2007-12-13 14:25:51 -06:00
Steve Borho
caa5fee772 win32: fix ssh://host:port when using Plink
Moves ssh argument building to platform specific utils code.
The win32 version looks for plink in ssh command string and
uses '-P' in lieu of '-p' for specifying a port
2007-12-12 16:44:26 -06:00
Manuel Holtgrewe
4a33cb8d98 Do not display passwords with pull/push/incoming/outgoing
Passwords specified in the repository URL are now displayed as '***'
when accessing the remote repository.
2007-11-05 20:29:32 +01:00
Maxim Dounin
8561d688a1 Fix file-changed-to-dir and dir-to-file commits (issue660).
Allow adding to dirstate files that clash with previously existing
but marked for removal. Protect from reintroducing clashes by revert.

This change doesn't address related issues with update. Current
workaround is to do "clean" update by manually removing conflicting
files/dirs from working directory.
2007-11-05 20:05:44 +03:00
Patrick Mezard
6aa1e21320 Fix Windows os.popen bug with interleaved stdout/stderr output
See python bug 1366 "popen spawned process may not write to stdout under windows" for more details.
2007-11-01 12:05:14 +01:00
Walter Doerwald
c1832411b0 Simplify utils.walkrepos(). 2007-08-28 18:00:07 +02:00
Thomas Arendsen Hein
a1c1677af4 Fix bad behaviour when specifying an invalid date (issue700)
commit (aborts _after_ typing in a commit message)
backout (aborted after the initial revert)
tag (edited .hgtags and couldn't commit)
import (patch applied, then commit fails)
qnew (aborts on bad dates, but writes any valid date into the # Date header)
qrefresh (like qnew)
sign (like tag)
fetch (merge, merge, merge, merge, abort)
2008-02-17 21:34:28 +01:00
Thomas Arendsen Hein
48cd266d6d merge with crew 2008-02-16 13:34:11 +01:00
Thomas Arendsen Hein
728ba019da Make annotae/grep print short dates with -q/--quiet.
Move shortdate() from templatefilters to util to avoid code duplication.
2008-02-16 13:33:38 +01:00
Patrick Mezard
5d1baa1a2e util: always define a dummy lookup_reg() 2008-02-13 23:09:28 +01:00
Alexis S. L. Carvalho
38c9e04993 util.pathto: return '.' instead of an empty string
This could happen with something like
pathto(repo.root, 'foo/bar', 'foo/bar')
2008-02-15 10:38:37 -02:00
Thomas Arendsen Hein
3d8e3d2b46 merge with main 2008-02-14 00:13:20 +01:00
Dirkjan Ochtman
5df65fdd07 better handle errors with date parsing (issue983)
Windows cannot always handle a 1970-01-01 parameter to time.mktime().
2008-02-13 16:46:43 +01:00
Alexis S. L. Carvalho
918227be30 Make files in .hg inherit the permissions from .hg/store 2008-02-09 18:38:54 -02:00
Matt Mackall
7fb82b40e9 ignore: split up huge patterns
Some versions of Python silently mishandle large regexes, so split
them up at a conservative 20k.
2008-02-11 16:13:43 -06:00
Matt Mackall
ad1e6058b9 filemerge: add config item for GUI tools
<tool>.gui indicates whether a tool requires a GUI to run
2008-02-03 19:29:05 -06:00
Matt Mackall
2c7d69802c merge: add registry look up bits to tool search 2008-02-03 19:29:05 -06:00
Matt Mackall
a849fab9e4 templater: move email function to util 2008-01-31 14:44:19 -06:00
Jesse Glick
e01183da16 Permit glob patterns to use nested curly braces. 2008-01-25 15:54:25 -05:00
Thomas Arendsen Hein
ddce807d45 merge with crew-stable 2008-01-22 00:55:01 +01:00
Thomas Arendsen Hein
133747d109 Fix double import of 're'. 2008-01-21 22:00:44 +01:00
Shun-ichi GOTO
da69eb2702 Fix not to use os.sep directly.
This change is intended for MBCS support.
2008-01-09 21:30:37 +09:00
Shun-ichi GOTO
fa59648c70 Add util.splitpath() and use it instead of using os.sep directly.
This change is intended to allow hooking splitpath() by win32mbcs
extension for MBCS support.
2008-01-09 21:30:36 +09:00
Shun-ichi GOTO
188e44cf4b Add endswithsep() and use it instead of using os.sep and os.altsep directly.
This change is intended to allow hooking endswithsep() by win32mbcs
extension for MBCS support.
2008-01-09 21:30:35 +09:00
Bryan O'Sullivan
5b8903b6d7 util: drop params added during experimentation 2008-01-04 13:56:31 -08:00
Bryan O'Sullivan
497bf2ca7a fetch: hide authentication details 2008-01-04 11:58:27 -08:00
Thomas Arendsen Hein
347da85c36 Removed tabs and trailing whitespace in python files 2007-12-29 19:49:48 +01:00
Patrick Mezard
db911b9d0f util: filter all st_mode with 0777 in checkexec 2007-12-29 01:14:45 +01:00
Matt Mackall
b35a91a7c0 util: simplify unique 2007-12-27 23:55:40 -06:00
Thomas Arendsen Hein
462c1975db Fix chmod of writable but unowned files (issue530)
This could happen e.g. in group writable local repositories where a file
should become executable on update.

(Patch by Benoit Boissinot attached to issue530)
2007-12-25 14:05:26 +01:00
Matt Mackall
c9efd52e9e util: simplify unique 2007-12-27 23:55:40 -06:00
Matt Mackall
50455803c5 remove unused util.localsub function 2007-12-27 23:55:40 -06:00
Matt Mackall
1baaf41264 atomictempfile: avoid chmod weirdness on Linux vfat 2007-12-27 23:55:40 -06:00
Matt Mackall
bdea7ebd1b checkexec: fix VFAT tempfile droppings with more modern Linux kernels
More recent Linux kernels don't pretend to allow any bogus chmods on
VFAT.
2007-12-27 23:55:40 -06:00
Matt Mackall
614e20b215 util: remove set_exec and set_link methods 2007-12-27 22:47:41 -06:00
Matt Mackall
717ff7e6f8 util: add new set_flags method
This is more efficient than calling set_link and set_exec
2007-12-27 22:27:45 -06:00
Thomas Arendsen Hein
b29abebc1e merge with crew-stable 2007-12-25 14:30:10 +01:00
Benoit Boissinot
c5049e31fc explicitely use integer division 2007-10-11 16:19:12 +02:00
Matt Mackall
0804290ab7 revlog: fix caching of buffer objects 2007-10-11 00:46:53 -05:00
Matt Mackall
8a3a3e49fe chunkiter: handle large reads more efficiently
- for large reads, don't attempt to read more than necessary
- if we've gathered the exact number of bytes needed, avoid a string copy
2007-10-11 00:46:52 -05:00
Matt Mackall
d3f1e8a8cf chunkiter: simplify iter logic 2007-10-11 00:46:49 -05:00
Matt Mackall
614d4b8b33 chunkbuffer: removed unused method and arg 2007-10-11 00:46:48 -05:00
Rafael Villar Burke
1b278771bf Execution bit detection fixes for VFAT on Linux
On Linux VFAT execution mode can be modified, but changes don't
persist a filesy stem remount. The current test can be trickled by
this. We can help with the det ection of VFAT checking whether new
files get created with the execution bits on
 (as usually these partitions are mounted with the exec option, for
convenience)
.
2007-10-05 01:52:53 +02:00
Bryan O'Sullivan
e317f81ab3 Add osutil module, containing a listdir function.
This is similar to os.listdir, only it returns a sorted list of tuples.
2007-10-05 15:01:06 -07:00
Bryan O'Sullivan
5e33599d0f Merge with crew. 2007-10-02 13:49:36 -07:00
Bryan O'Sullivan
65b17f114c util: add default argument to strdate 2007-10-02 13:46:59 -07:00
Benoit Boissinot
7cf891935c merge with -stable 2007-10-02 20:25:35 +02:00
Steve Borho
9f12241241 set_exec: do not chmod a symlink 2007-10-02 20:22:33 +02:00
Patrick Mezard
7c1d0710ee Merge with crew-stable 2007-09-10 23:53:23 +02:00
Alexis S. L. Carvalho
29dea75576 sshrepo: fix Windows command quoting 2007-09-10 23:34:33 +02:00
Patrick Mezard
239ea63571 extdiff: avoid repr() doubling paths backslashes under Windows 2007-09-10 23:36:01 +02:00
Robert Bachmann
ecb337b8cb Added support for the Atom syndication format 2007-08-30 16:42:17 +02:00
Benoit Boissinot
6c80bb0bbe merge with crew-stable 2007-08-24 00:39:59 +02:00
Benoit Boissinot
0d54a05da3 merge with -stable 2007-08-24 00:39:16 +02:00
Benoit Boissinot
f71cd2e266 check exec: return fallback in case of error during the check
If there is any error while checking if exec is supported,
we can return fallback.
fix issue705
2007-08-24 00:38:08 +02:00
Matt Mackall
dbef99a2d7 Merge with -stable 2007-08-19 14:04:26 -05:00
Matt Mackall
0bcff0f870 match: handle large regexes
Some Python versions don't handle large regexes, so when we hit an
overflow, split our regex in two.
2007-08-19 14:03:56 -05:00
Alexis S. L. Carvalho
3b929dfbb5 path_auditor: cache names of audited directories
We use a separate cache to avoid problems with

audit = path_auditor(repo.root)
audit("subrepo")
audit("subrepo/file")

whitelisting "subrepo" (which is fine) and then using the same whitelist
with "subrepo/file" (which is not fine).

Since we create a separate path_auditor for every path on the command line,
a "hg add dir/a dir/b dir/c" will still lstat dir 3 times just to audit
the paths.
2007-08-18 21:36:10 -03:00
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
Alexis S. L. Carvalho
6ccee3793b util._matcher: unify pattern normalization
This should fix issue347.

It also highlights one issue with the directory walking code when
you have an --include pattern that matches the end of a filename.
This is fixed by the next patch.
2007-03-10 23:00:53 -03:00
Alexis S. L. Carvalho
cc4356d95d util.*matcher: change default "names" argument
names=['.'] means "include (recursively) only files from the current subdir";
the function then did a hack to walk the whole tree.  Clean that up.

This also fixes a problem where "--include ." works in a subdir, but not
on the tree root.
2007-03-10 23:00:51 -03:00
Alexis S. L. Carvalho
7a7a8339ec util._matcher: fix handling of path: patterns 2007-03-10 23:00:49 -03:00
Alexis S. L. Carvalho
a2bea59405 util._matcher: fix handling of relglob: patterns 2007-03-10 23:00:48 -03:00
Alexis S. L. Carvalho
c83e2fe93d A 'glob:foo?bar' pattern determines a root - the tree root 2007-03-10 23:00:47 -03:00
Alexis S. L. Carvalho
2f70c57d86 util._matcher: update comments
This should match the code better.  Except for bugs...
2007-03-10 23:00:45 -03:00
Alexis S. L. Carvalho
2593ea959d small globprefix fix 2007-03-10 23:00:42 -03:00
Patrick Mezard
5a74c065fc stdout raises EINVAL when flush() is called on a closed pipe under win32.
Maybe the exception should be caught and translated at raise location instead (sshserver.py).
2007-02-19 10:32:46 +01:00
Alexis S. L. Carvalho
62a7370570 Fix util.shellquote on windows. 2007-02-15 05:38:00 -02:00
Jun Inoue
db15047102 Fix accessing the repo through a symlink. 2007-02-15 05:18:23 -02:00
Andrei Vermel
0483a4d2c4 Fix wrong module reference in copyfile exception 2007-02-06 00:09:36 +03:00
Alexis S. L. Carvalho
93c60f1213 Fallback to ascii if getpreferredencoding raises an exception
Fixes issue478.
2007-01-30 18:32:23 -02:00
Alexis S. L. Carvalho
5b836109d8 docopy: deal with globs on windows in a better way 2007-01-30 18:32:20 -02:00
Alexis S. L. Carvalho
29a5332aa9 Explicitly expand globs on Windows 2007-01-30 18:32:18 -02:00
Alexis S. L. Carvalho
fa687a48e6 add util.lexists 2007-03-26 21:36:26 -03:00
Alexis S. L. Carvalho
6cbf527646 use os.path.islink instead of util.is_link; remove util.is_link 2007-03-23 23:40:25 -03:00
Eric St-Jean
18a4192512 fix util.copyfile to deal with symlinks 2007-03-21 23:20:56 -04:00
Alexis S. L. Carvalho
ec44599dd1 Merge additional fixes for my matcher changes 2007-03-20 22:21:05 -03:00
Alexis S. L. Carvalho
dd2869375e Merge some matcher fixes/cleanups and add some more hg locate tests 2007-03-16 22:58:49 -03:00
Alexis S. L. Carvalho
47cb22b5a2 Merge with crew-stable 2007-03-16 00:45:18 -03:00
Alexis S. L. Carvalho
e488c0e84f Fix handling of paths when run outside the repo.
The main problem was that dirstate.getcwd() returned just "",
which was interpreted as "we're at the repo root".  It now returns
an absolute path.

The util.pathto function was also changed to deal with the "cwd is
an absolute path" case.
2007-03-16 00:22:58 -03:00
Alexis S. L. Carvalho
fcb39243b1 pass repo.root to util.pathto() in preparation for the next patch 2007-03-16 00:22:57 -03:00
Alexis S. L. Carvalho
641d95a966 Merge a bunch of matcher and locate fixes. 2007-03-10 23:21:33 -03:00
Alexis S. L. Carvalho
93eb041452 Merge with crew-stable 2007-03-04 09:03:21 -03:00
Alexis S. L. Carvalho
c235d44d85 util_win32.py: fix user_rcpath
Fixes issue504.
2007-02-16 05:53:03 -02:00
Shane Holloway
79d891fab8 Combined the two os_rcpath methods into a single one near rcpath in mercurial/util.py
The os_rcpath method delegates to system_rcpath and user_rcpath from the
different platform implementations.
2007-02-15 09:51:57 -07:00
Alexis S. L. Carvalho
d4de823a64 merge with crew-stable 2007-02-16 05:27:37 -02:00
Shane Holloway
02d303cdfe Unified *_rcpath so the interface is similar across operating systems
Changed os_rcpath to combine system_rcpath and user_rcpath.  Changed
system_rcpath and user_rcpath to both return a list of paths to add to the
combined rcpath for both Windows NT and other platforms.
2007-02-14 15:20:06 -07:00
Alexis S. L. Carvalho
e9dc052e2a allow values that aren't strings in util.configparser 2007-02-09 03:48:26 -02:00
Matt Mackall
28f682beac Merge with stable 2007-02-06 16:12:22 -06:00
Alexis S. L. Carvalho
fff454d591 Merge with crew-stable 2007-01-30 19:36:56 -02:00
Alexis S. L. Carvalho
4f27c0fe1c catch AttributeError in util.checklink
There's no symlink function in the os module on windows.

Fixes issue468
2007-01-05 00:01:51 -02:00
Matt Mackall
2e27ddd82b symlinks: use is_link wherever is_exec is used 2006-12-29 20:04:31 -06:00
Matt Mackall
1dc3ac012f symlinks: add a linkfunc 2006-12-29 20:04:31 -06:00
Matt Mackall
5a767e44a9 symlinks: add basic symlink functions to util.py 2006-12-29 20:04:31 -06:00
Matt Mackall
4b1ae5ef0a symlinks: check whether a filesystem supports symlinks 2006-12-29 20:04:31 -06:00
Matt Mackall
30b8c51a84 exec: remove last flag from is_exec 2006-12-29 20:04:31 -06:00
Matt Mackall
9d8e9305e4 pull umask-checking up 2006-12-29 20:04:30 -06:00
Matt Mackall
b875ad6c04 exec: add execfunc to simplify exec flag support on non-exec filesystems 2006-12-29 20:04:30 -06:00
Matt Mackall
1ee7fd016e pull umask-checking up 2006-12-29 20:04:30 -06:00
Matt Mackall
a76da2edbe exec: checkexec checks whether filesystem supports exec flags 2006-12-29 20:04:30 -06:00
Alexis S. L. Carvalho
d725a42fd8 merge with crew-stable 2006-12-16 02:51:16 -02:00
Alexis S. L. Carvalho
88251bd81b util.system: fix quoting on windows 2006-12-16 02:38:18 -02:00
Matt Mackall
296d6a7cb8 Simplify i18n imports 2006-12-14 20:25:19 -06:00
Matt Mackall
f17a4e1934 Replace demandload with new demandimport 2006-12-13 13:27:09 -06:00
Benoit Boissinot
def42107f3 fix reserved char on windows, '[]+' are allowed 2006-12-10 21:53:01 +01:00
Benoit Boissinot
e5024feef0 fix errors spotted by pychecker 2006-12-10 19:41:57 +01:00
Matt Mackall
6d9bbc8702 Merge Benoit's .hg/store support 2006-12-10 02:11:02 -06:00
Matt Mackall
03f3b2efc4 make transcoding more robust
default to ASCII
abort if unknown encoding
wrap abort strings with _
add test
2006-12-09 12:46:01 -06:00
Alexis S. L. Carvalho
edf9fef62b Allow the user to specify the fallback encoding for the changelog
Example: use EUC-JP instead of ISO-8859-1:

[ui]
fallbackencoding = EUC-JP
2006-12-08 22:01:05 -02:00
Matt Mackall
d589171997 Add --date support to log
Add --date opt
Filter log with matchdate
Fix "-{days}" match format
2006-12-06 15:29:17 -06:00
Matt Mackall
d7141083eb Add date matching support
Add extended date formats (eg "Dec", "2006")
Add a couple missing basic date formats
Improve default date element scheme to parsedate
Add matchdate function to match a date spec
Add -e switch and range matching to debugdate
2006-12-06 15:11:44 -06:00
Matt Mackall
dcf070dde9 parsedate: add UTC and GMT timezones 2006-12-06 13:13:42 -06:00
Matt Mackall
63c91a1801 improve date parsing for numerous new date formats
Add lots of new date formats
Formats without year, month, or day default to current
Strip leading and trailing whitespace
2006-12-06 13:13:31 -06:00
Matt Mackall
fb391fcb13 parsedate: allow '' for epoch 2006-12-06 13:13:27 -06:00
Matt Mackall
9630fc215f parsedate: use Abort rather than ValueError 2006-12-06 13:13:26 -06:00
Benoit Boissinot
e005ffc8c4 switch to the .hg/store layout, fix the tests 2006-12-01 13:34:09 +01:00
Benoit Boissinot
31a06c4e2b create the encode and decode functions for the store 2006-12-10 00:07:02 +01:00
Matt Mackall
2356030286 imported patch folding 2006-12-04 17:10:29 -06:00
Matt Mackall
3982f645e8 Add functions for transcoding and manipulating multibyte strings 2006-12-03 16:16:33 -06:00
Matt Mackall
8b091a9c1d Add encoding detection 2006-12-03 16:16:33 -06:00
Thomas Arendsen Hein
9b62ceebc7 Move ellipsis code to util.ellipsis() and improve maxlength handling. 2006-12-02 22:35:17 +01:00
Benoit Boissinot
3bad25e752 only print a warning when no username is specified
- revert most of 8b55c0ba
- display the username during interactive commit
2006-11-28 21:16:05 +01:00
Alexis S. L. Carvalho
6e218edeb5 Avoid looking up usernames if the current user owns the .hgrc file
Converting uids into usernames may be somewhat expensive when NIS
or LDAP is involved.
2006-11-18 23:51:14 -02:00
Thomas Arendsen Hein
411d64ce3e white space and line break cleanups 2006-11-17 08:06:54 +01:00
Alexis S. L. Carvalho
2a74758338 fix util.pathto
All users of this function pass a local path (which uses os.sep) as the
first argument and a "/"-separated path as the second argument.
2006-11-15 18:56:47 -02:00
Matt Mackall
0cc86247a3 util: add copyfile function 2006-11-13 13:26:57 -06:00
Thomas Arendsen Hein
11cdc6b21b Merge with upstream 2006-10-27 23:09:46 +02:00
Matt Mackall
e803b50ef2 Make util.unique return a list 2006-10-27 14:06:32 -05:00
Matt Mackall
24c7fbb0f1 shortname: truncate at '.' too 2006-10-27 11:30:20 -05:00
Thomas Arendsen Hein
a0477d89a5 New UnexpectedOutput exception to catch server errors in localrepo.stream_in
If the unexpected is a string, the empty string will be mentioned, and long
strings are cut to at most 400 chars.
2006-10-27 18:17:12 +02:00
Alexis S. L. Carvalho
c44cea1532 Only read .hg/hgrc files from trusted users/groups
The list of trusted users and groups is specified in the [trusted]
section of a hgrc; the current user is always trusted; "*" can be
used to trust all users/groups.

Global hgrc files are always read.

On Windows (and other systems that don't have the pwd and grp modules),
all .hg/hgrc files are read.

This is essentially the same patch that was previously applied as
revision f077d29b114d.
2006-10-26 19:25:44 +02:00
Benoit Boissinot
dc9483558a makes username mandatory 2006-10-18 22:24:03 +02:00
Alexis S. L. Carvalho
a85d162373 Use a case-sensitive version of SafeConfigParser everywhere
This change has the potential to break existing setups, but the current
behaviour (the keys in configuration files are always lower-cased) can
bite us in a few places:

- no way to use a Command in [defaults]
- hgext.Extension doesn't work in [extensions]
- you can't use an Upper/case/PATH in the [paths] section of hgweb.config
- you can't (easily) protect paths with upper-case letters with the
  acl extension
- you can't specify a /Path/TO/a/rEPO in the [reposubs] section for
  the notify extension
2006-10-16 15:38:53 -03:00
Jose M. Prieto
7670d11c8a Add documentation about the date formats allowed in the command line 2006-10-03 12:33:22 +02:00
Jose M. Prieto
a76c2de547 util.strdate: assume local time when no timezone specified 2006-10-03 12:33:18 +02:00
Jose M. Prieto
06cffb7de4 util.strdate: compute timestamp using UTC, not local timezone 2006-10-03 12:33:14 +02:00
Thomas Arendsen Hein
9b9bf4b064 shortuser should stop before the first space character.
Examples:
"Foo Bar <foo.bar AT example DOT com>" -> "foo.bar"
(instead of "foo.bar AT example DOT com>" as it was before.)
"Foo Bar" -> "Foo"
2006-09-27 20:34:52 +02:00
Benoit Boissinot
38d7621ab8 add comments in cachefunc 2006-09-22 17:58:22 +02:00
Brendan Cully
d30b83d2de Add cachefunc to abstract function call cache 2006-09-22 08:19:25 -07:00
Benoit Boissinot
2caa3e642d fix warnings spotted by pychecker 2006-09-18 17:43:31 +02:00
Vadim Gelfer
853998bf60 fix issue 322.
do not allow to add files that shadow files or directories already in dirstate.
2006-08-18 21:03:29 -07:00
Vadim Gelfer
92dd5b8dc0 move commands.addremove_lock to cmdutil.addremove 2006-08-13 16:57:45 -07:00
Vadim Gelfer
2eab8e108e merge git patch code. 2006-08-12 12:47:18 -07:00
Vadim Gelfer
dc377b58c1 update copyrights. 2006-08-12 12:30:02 -07:00
Brendan Cully
4f1b3a83bb Move patch-related code into its own module. 2006-08-11 15:50:16 -07:00
Brendan Cully
7601c19932 Teach import to understand git diff extensions.
Vanilla patch chokes on git patches that include files that are copied
or renamed, then modified. So this code detects that case and rewrites
the patch if necessary.
2006-08-11 15:50:07 -07:00
Benoit Boissinot
dc4c4a5959 util.patch: use shellquote 2006-08-06 16:42:36 +02:00
Brendan Cully
5d7f00c97d Add portable shell-quoting function; teach mq to use it. 2006-08-05 15:23:26 -07:00
Vadim Gelfer
74f5dcdc3d import: make patch apply if run in subdir
fix is same as for mq patch. patch apply code should be merged.
2006-08-01 15:51:13 -07:00
Vadim Gelfer
b7a96d1742 clean up hg.py: move repo constructor code into each repo module 2006-07-31 07:11:12 -07:00
Vadim Gelfer
4f0a39d96b util.getuser: better comments 2006-07-24 09:22:47 -07:00
Vadim Gelfer
b5dfaa64f0 util.getuser: raise exception if win32api not available. 2006-07-24 09:19:25 -07:00
Vadim Gelfer
07de9b45fd fix windows username problem. 2006-07-24 09:11:26 -07:00
Vadim Gelfer
9ea4436262 add support for streaming clone.
existing clone code uses pull to get changes from remote repo.  is very
slow, uses lots of memory and cpu.

new clone code has server write file data straight to client, client
writes file data straight to disk.  memory and cpu used are very low,
clone is much faster over lan.

new client can still clone with pull, can still clone from older servers.
new server can still serve older clients.
2006-07-14 11:17:22 -07:00
Chris Mason
e09c656d7d util.parsedate should understand dates from hg export 2006-07-13 09:40:01 -07:00
Vadim Gelfer
a7c3b963b0 move most of tag code to localrepository class. 2006-07-12 08:59:20 -07:00
Benoit Boissinot
7dd019b60b use __contains__, index or split instead of str.find
str.find return -1 when the substring is not found, -1 evaluate
to True and is a valid index, which can lead to bugs.
Using alternatives when possible makes the code clearer and less
prone to bugs. (and __contains__ is faster in microbenchmarks)
2006-07-09 01:30:30 +02:00
Benoit Boissinot
fbf78b7285 str.rsplit does not exist in python 2.3 2006-06-30 23:02:08 +02:00
Benoit Boissinot
eb4253c05c validate the resulting date in parsedate 2006-06-30 18:48:06 +02:00
Jose M. Prieto
9f3a9a5e6e Allow the use of human readable dates (issue 251) 2006-06-30 18:47:35 +02:00
Vadim Gelfer
29a0efc318 fix -I/-X when relative paths used or in subdir 2006-06-21 17:30:31 -07:00
Vadim Gelfer
cbbcaa74fe merge with crew. 2006-06-20 23:58:45 -07:00
Vadim Gelfer
9a0c813fdc use demandload more. 2006-06-20 23:58:21 -07:00
Vadim Gelfer
b1e704337e util: add limit to amount filechunkiter will read 2006-06-20 15:13:17 -07:00
Vadim Gelfer
6144b74dd7 replace os.stat with os.lstat in some where. 2006-06-16 12:58:24 -07:00
Volker Kleinfeld
138d9f83fc Remove quotes from patch command.
When the gpatch fix for solaris was introduced in b67447b909f3 the
patch command was "". For some strange reason windows 2000 is
not happy with those quotes when given in os.popen.
2006-05-18 22:35:41 -07:00
Thomas Arendsen Hein
cfcf8066dd Use platform path for renaming file in util.atomictempfile.rename() 2006-05-18 21:01:38 +02:00
Volker Kleinfeld
94db8d7fec On win98 os.path.expanuser('~') does not result in a useable directory.
The MSDN recommendation for user specific directories is the use of
shell.ShGetSpecialFolder, so use it.

For details see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shgetspecialfolderpath.asp
2006-05-14 23:44:50 -07:00
Thomas Arendsen Hein
d8dda7e592 On Windows look for mercurial.ini in $USERPROFILE, too, if available
as os.path.expanduser('~') does not always yield a useful directory.

Based on a patch from Edouard Gomez <ed.gomez@free.fr>
2006-05-14 18:24:32 +02:00
Manpreet Singh
cc6f64ec98 Make hg status work for repositories in root directory on windows (issue 228) 2006-05-13 23:00:05 -07:00
Manpreet Singh
05f4a37fe7 Make it possible to use the root directory as the root of a repository. 2006-05-11 21:55:15 -07:00
Vadim Gelfer
5a3e6d2974 make reason for sys.argv change obvious in code. 2006-05-11 09:01:32 -07:00
Vadim Gelfer
edc07498a2 merge with crew. 2006-05-11 08:48:52 -07:00
Shun-ichi GOTO
876fe3cdc4 Check existance of sys.argv for the use from mod_python. 2006-05-11 08:48:36 -07:00
Vadim Gelfer
20d2979fe8 windows: revlog.lazyparser not always safe to use.
can not use on windows < nt or if win32 api not available.
2006-05-10 11:10:18 -07:00
Vadim Gelfer
4b2d02c52a reduce memory used by util.opener when making a temp copy of a file. 2006-05-09 11:12:45 -07:00
Vadim Gelfer
f337648835 add filename to IOError if read of file fails.
if file replaced with directory or symlink, IOError not fully filled out.
2006-05-08 08:20:56 -07:00
Vadim Gelfer
47101ddc97 add util.samestat function for windows.
windows does not have os.path.samestat, and stat().st_ino is always zero,
so util.samestat always returns false on windows.
2006-05-03 22:47:08 -07:00
Vadim Gelfer
75ddc9a984 merge with crew. 2006-05-02 14:37:55 -07:00
Vadim Gelfer
fad839fb0b fix file handling bugs on windows.
add util.posixfile class that has posix semantics on windows.
fix util.rename so it works with stupid windows delete semantics.
2006-05-02 14:30:00 -07:00
Thomas Arendsen Hein
092be2daa9 Use better names (hg-{usage}-{random}.{suffix}) for temporary files. 2006-04-30 21:11:22 +02:00
Vadim Gelfer
3f5f35a23b move SignalInterrupt class into util module. 2006-04-28 14:50:23 -07:00
Vadim Gelfer
acc87bc678 fix issue 217.
fall back to fixed path if windows >= nt function not present.
2006-04-25 08:37:05 -07:00
Jim Meyering
29bdfc218f Fix issue 165: `hg status' with abs path containing a symlink-to-dir fails 2006-04-21 16:09:43 -07:00
Alexis S. L. Carvalho
e1e5a2b65c Ignore EPIPE in pipefilter
This hides the following traceback (there's a race condition involved,
so you may have to try a few times to hit it):

$ hg sign --key key-that-does-not-exist
Signing 2062:4bad92f4ea65
gpg: skipped "key-that-does-not-exist": secret key not available
gpg: signing failed: secret key not available
Exception in thread Thread-1:
Traceback (most recent call last):
  File "threading.py", line 442, in __bootstrap
    self.run()
  File "threading.py", line 422, in run
    self.__target(*self.__args, **self.__kwargs)
  File "mercurial/util.py", line 24, in writer
    pin.close()
IOError: [Errno 32] Broken pipe

abort: Error while signing
2006-04-19 11:41:25 -07:00
Vadim Gelfer
39bf3d1d78 fix util.canonpath on windows.
old test for absolute path was not portable. use os.path api instead.
2006-04-19 09:08:45 -07:00
Chris Mason
92b1bcb569 merge revlogng with mpm tip 2006-04-18 19:50:12 -04:00
Vadim Gelfer
7c29a12e6d import: use gpatch if present on system. patch is broken on solaris.
fixes issue 205.

add new useful function, util.find_in_path.
2006-04-13 17:42:49 -07:00
Vadim Gelfer
d688aaeffa util.unlink should only catch OSError. 2006-04-13 13:46:56 -07:00
Chris Mason
b52474f560 merge 0.8.1 with revlogng 2006-04-08 20:10:46 -04:00
Vadim Gelfer
86b6b506c0 fix exception handling on windows.
move win32 code into util_win32.py.
2006-04-08 14:12:43 -07:00
Vadim Gelfer
3e74e23053 util.copyfiles: only switch to copy if hardlink raises IOError or OSError.
before this, interrupting clone would give "file a same as file b" error
because caught KeyboardInterrupt.
2006-04-05 17:17:07 -07:00
mason@suse.com
9131eec8e3 Create an atomic opener that does not automatically rename on close
The revlog.checkinlinesize() uses an atomic opener to replace the
index file after converting it from inline to traditional .i and .d
files.  If this operation is interrupted, the atomic file class can
overwrite a valid file with a partially written one.

This patch introduces an atomic opener that does not automatically
replace the destination file with the tempfile.  This way
an interrupted checkinlinesize() call turns into a noop.
2006-04-04 16:38:44 -04:00
Vadim Gelfer
74afe6ba38 more windows fixes. 2006-03-30 18:35:52 -08:00
Vadim Gelfer
08cb794787 clean up lee's windows testpid fix. 2006-03-30 18:27:04 -08:00
Lee Cantey
5f23e95446 Fixes to testpid() for Windows.
Handle processes that no longer exist and processes that belong to another user.

Enables the lock breaking changes from 0ab4c12ad060 and subsequently "fixes" the left over locks reported in bug 112.
2006-03-30 18:20:08 -08:00
Benoit Boissinot
cc702f58e2 merge with self 2006-03-23 23:55:51 +01:00
Benoit Boissinot
61a488204f make it possible to escape characters in a glob expression 2006-03-23 23:39:53 +01:00
Vadim Gelfer
2e0f1be283 add changelog style to command line template.
to use, "hg log --style=changelog".  makes different output with no
flags, -q, -v, --debug.

templater module has new template filters for this.
email - committer email address
fill68 - refill text to 68 colums
fill76 - refill text to 76 colums
tabindent - prefix every not empty line with tab
shortdate - iso 8631 date, no time zone
stringify - turn template iterator into string
2006-03-21 23:29:21 -08:00
Thomas Arendsen Hein
1bf1db0503 Enable path validation for copy, rename, debugwalk and other canonpath users.
This fixed the last bit of issue134.
Added some tests to test-rename and test-walk.
2006-03-19 14:53:58 +01:00
Benoit Boissinot
5d3762058d merge with crew 2006-03-15 07:15:13 +01:00
Benoit Boissinot
c1f8a06c2d use a proper test instead of catching every exception 2006-03-15 07:09:42 +01:00
TK Soh
d55c1834ad change default strftime format for better portability
On some systems, such as Solaris and HP-UX, "%c" format
give output without the leading zero on the single-digit
month-day.
2006-03-14 22:01:30 -08:00
Vadim Gelfer
9504f432e5 add HGRCPATH env var, list of places to look for hgrc files.
if set, override default hgrc search path.
if empty, only .hg/hgrc of current repo read.

for each element, if directory, all entries in directory with end in
".rc" are added to path.  else, element is added to path.

big thing about this change is that user "~/.hgrc" and system hgrc not
longer breaks tests.  run-tests makes HGRCPATH empty now.
2006-03-14 21:40:46 -08:00
Vadim Gelfer
03ca08b56f merge with crew. 2006-03-12 16:21:59 -08:00
Vadim Gelfer
97a9d5c4ee merge util.esystem and util.system. 2006-03-10 22:42:59 -08:00
Vadim Gelfer
a8e31fc914 fix broken environment save/restore when a hook runs.
move "run commend with different env/cwd" code out to function in util.
new function is called esystem.
2006-03-10 22:24:19 -08:00
Vadim Gelfer
61a7953729 change lock format to let us detect and break stale locks.
old style: symlink to pid
new style: symlink to hostname:pid

if lock code finds new-style lock, it breaks lock if locking pid is on
same machine and pid is not alive.

otherwise, lock is left alone.  this makes locking code safe with
old-style locks and with locks on other machines.

new code makes server part of mercurial more robust in case machine
crashes, power fails, or crazy user does kill -9.
2006-03-10 08:31:31 -08:00
Thomas Arendsen Hein
3ffc79286b Validate paths before reading or writing files in repository or working dir.
Fixes security relevant issue134.
2006-03-04 19:01:45 +01:00
Vadim Gelfer
cd790c58f1 merge with crew. 2006-03-03 09:39:37 -08:00
Thomas Arendsen Hein
47314a5f51 Whitespace, tab and formatting cleanups, mainly in mq.py 2006-02-28 23:25:34 +01:00
Vadim Gelfer
75d0535141 move shortuser into util module. 2006-02-27 11:32:10 -08:00
Vadim Gelfer
3052663b45 hgwebdir: export collections of repos
now you can use [collections] section in hgweb.config to export entire
tree of repos.
2006-02-10 11:25:07 -08:00
efiring@manini.soest.hawaii.edu
75812b6144 Fix rcpath for hgwebdir case (sys.argv is empty) 2006-01-24 13:59:11 +13:00
Vadim Gelfer
f1758a02f6 make invalid pattern message not confusing. 2006-01-02 15:52:56 -08:00
Vadim Gelfer
859b47ca42 if hgignore contains errors, print message that is not confusing. 2006-01-02 15:48:16 -08:00
Vadim Gelfer
ff1f653af7 eliminate backtrace when piping output on windows.
this fixes issue 54.
2006-01-02 15:25:33 -08:00
Matt Mackall
2df834f9a4 Merge with crew 2005-12-16 11:13:08 -06:00
Benoit Boissinot
f88ffe1792 do not copy atime and mtime in util.copyfiles
it is unsupported on some fs (vfat) and we don't need to copy
it one clone anyway
2005-12-16 01:32:44 -06:00
Benoit Boissinot
78898f92b4 if a filename contains spaces, patch adds quote around it 2005-12-15 17:50:10 +01:00
Vadim Gelfer
3ec3d8787c delete unintended print statement 2005-12-12 07:50:43 -08:00
Vadim Gelfer
c968155220 merge with crew 2005-12-11 15:38:42 -08:00
Arun Sharma
ee55457e68 Handle hg under / 2005-12-01 10:48:42 -06:00
Robin Farine
42b0262a8a export patkind() from util 2005-12-01 10:48:22 -06:00
Benoit Boissinot
f7ef42efdd close file before renaming it (since it doesn't work the other way on windows) 2005-11-14 21:47:07 +01:00
twaldmann@thinkmo.de
55d74a6b77 fixed some stuff pychecker shows, marked unclear/wrong stuff with XXX 2005-11-14 03:59:35 +02:00
Benoit Boissinot
4aae3736a7 add an atomic argument to util.opener
when atomic is used, the file while be renamed on close
2005-11-11 15:33:59 -08:00
Benoit Boissinot
8a08aa0106 copy the mode of the file when breaking hardlinks 2005-11-09 13:38:46 -08:00
Vadim Gelfer
c9f1399932 make mercurial look in more places for config files.
now it searches <install dir>/etc/mercurial, /etc/mercurial, and user
hgrc.

this allows site-wide configuration to be shared over automounted nfs
partition, instead of chenging on every system.  option of having local
configuration on every system remains.

old code for searching /etc/mercurial/hgrc.d never worked, this code
is tested and works.
2005-11-04 11:51:01 -08:00
Benoit Boissinot
8be93f3049 fix handling of daylight saving time 2005-10-31 10:56:42 -07:00
Benoit Boissinot
bc51f024c7 fix a bug where hg could remove file ending with .tmp
util.opener used a fixed filename for writing tempfile
instead of using the tempfile module.
2005-10-28 17:18:50 -07:00
Benoit Boissinot
93854a176d further fix traceback on invalid .hgignore patterns
Please apply this little fix (matchfn return None if no patterns are
specified).
2005-10-26 16:10:56 -07:00
Benoit Boissinot
0e649f370c abort on invalid pattern in matcher 2005-10-25 14:58:11 -07:00
olivier.maquelin@intel.com
fa3a9847db Avoid insertion/deletion of CRs on stdio during hg serve 2005-10-24 14:34:48 -07:00
Benoit Boissinot
abe08fd52f refactor some unlink/remove code and make sure we prune empty dir 2005-10-19 00:10:52 -07:00
Benoit Boissinot
6c6a4b138f Do not use 'glob' expansion by default on OS != 'nt' 2005-10-19 00:02:41 -07:00
Benoit Boissinot
06e39e559b i18n part2: use '_' for all strings who are part of the user interface 2005-10-18 18:38:39 -07:00
Benoit Boissinot
e38e94088a i18n first part: make '_' available for files who need it 2005-10-18 18:37:48 -07:00
Zbynek Winkler
f5c4f54863 Try to use ini-file in the same directory as the exe as the default on NT. 2005-10-18 17:57:27 -07:00
Matt Mackall
42508becda Fix patch failure reporting exception 2005-10-15 15:04:45 -07:00
Eric Hopper
01737b862f Fixed a bug in my changes to httprepo.py 2005-10-03 16:07:54 -07:00
mpm@selenic.com
d701e53cd5 Add support for /etc/mercurial/hgrc.d/*.rc 2005-09-23 19:35:23 -07:00
Bryan O'Sullivan
139919b045 Allow files to be opened in text mode, even on Windows. 2005-09-23 10:28:55 -07:00
Bryan O'Sullivan
566df77193 Clean up date and timezone handling.
We used to pass changelog dates around as a "unixtime timezone" string
containing a pair of encoded ints.  Now, they get passed around as a
(unixtime, timezone) tuple of numbers, which makes much more sense.
2005-09-22 23:19:47 -07:00
Bryan O'Sullivan
f46e4d82a5 Fix up representation of dates in hgweb.
Date display is now uniform both on the command line and via the web
interface.
2005-09-22 22:46:50 -07:00
mpm@selenic.com
9282c26f18 Merge with TAH 2005-09-22 09:41:34 -07:00
Bryan O'Sullivan
ffb420798b Enhance the file filtering capabilities.
We now allow filtering through either pipes or pairs of temporary
files.  The latter appear to be mandatory for use on Windows.
2005-09-21 11:44:08 -07:00
Bryan O'Sullivan
1cc739dd2e Use platform-appropriate rc file names. 2005-09-21 09:56:30 -07:00
Thomas Arendsen Hein
455a56454d Cleanup of tabs and trailing spaces. 2005-09-21 07:56:19 +02:00