Commit Graph

342 Commits

Author SHA1 Message Date
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
Volker Kleinfeld
7880184af1 Make 'hg import' platform independent.
- moved popen("patch ...") from commands.py to util.py

- files may not be single quoted in popen under windows: fixed

- patch returns the files quoted under windows. quotes need to
  be stripped off: fixed
2005-09-20 21:35:51 -07:00
Bryan O'Sullivan
ae02dc4df3 Switch to new syntax for .hgignore files.
Here is the new syntax, in summary.
Trailing white space is dropped.
The escape character is "\".
Comments start with #.
Empty lines are skipped.
Lines can be of the following formats:
syntax: regexp # defaults following lines to non-rooted regexps
syntax: glob   # defaults following lines to non-rooted globs
re:pattern     # non-rooted regular expression
glob:pattern   # non-rooted glob
pattern        # pattern of the current default type
The default pattern type is regexp, which is completely backwards
compatible with the old hgignore syntax.
In the dirstate class, the ignore method has been reworked to be based
on the util.matcher function, by way of a new dirstate.hgignore
method.
2005-09-17 00:27:27 -07:00
mpm@selenic.com
eac251ef7c Add file encoding/decoding support 2005-09-15 02:59:16 -05:00
Stephen Darnell
b2e16a8dbf Add support for cloning with hardlinks on windows.
In order to use hardlinks, the win32file module is needed, and this is
present in ActivePython.  If it isn't present, or hardlinks are not supported
on the underlying filesystem, a regular copy is used.

When using hardlinks the biggest benefit is probably the saving in space,
but cloning can be much quicker.  For example cloning the Xen tree
(non trivial) without an update goes from about 95s to 15s.

Unix-like platforms should be unaffected, although should be more tolerant on
filesystems that don't support hard links.

(tweaked by mpm to deal with new copyfiles function)

--- hg.orig/mercurial/commands.py	2005-09-13 19:32:53.000000000 -0500
+++ hg/mercurial/commands.py	2005-09-14 12:11:34.000000000 -0500
@@ -620,10 +620,6 @@ def clone(ui, source, dest=None, **opts)

     if other.dev() != -1:
         abspath = os.path.abspath(source)
-        copyfile = (os.stat(dest).st_dev == other.dev()
-                    and getattr(os, 'link', None) or shutil.copy2)
-        if copyfile is not shutil.copy2:
-            ui.note("cloning by hardlink\n")

         # we use a lock here because if we race with commit, we can
         # end up with extra data in the cloned revlogs that's not
@@ -638,7 +634,7 @@ def clone(ui, source, dest=None, **opts)
         for f in files.split():
             src = os.path.join(source, ".hg", f)
             dst = os.path.join(dest, ".hg", f)
-            util.copyfiles(src, dst, copyfile)
+            util.copyfiles(src, dst)

         repo = hg.repository(ui, dest)

Index: hg/mercurial/util.py
===================================================================
--- hg.orig/mercurial/util.py	2005-09-08 00:15:25.000000000 -0500
+++ hg/mercurial/util.py	2005-09-14 12:16:49.000000000 -0500
@@ -12,7 +12,7 @@ platform-specific details from the core.

 import os, errno
 from demandload import *
-demandload(globals(), "re cStringIO")
+demandload(globals(), "re cStringIO shutil")

 def binary(s):
     """return true if a string is binary data using diff's heuristic"""
@@ -217,17 +217,28 @@ def rename(src, dst):
         os.unlink(dst)
         os.rename(src, dst)

-def copyfiles(src, dst, copyfile):
-    """Copy a directory tree, files are copied using 'copyfile'."""
+def copyfiles(src, dst, hardlink=None):
+    """Copy a directory tree using hardlinks if possible"""
+
+    if hardlink is None:
+        hardlink = (os.stat(src).st_dev ==
+                    os.stat(os.path.dirname(dst)).st_dev)

     if os.path.isdir(src):
         os.mkdir(dst)
         for name in os.listdir(src):
             srcname = os.path.join(src, name)
             dstname = os.path.join(dst, name)
-            copyfiles(srcname, dstname, copyfile)
+            copyfiles(srcname, dstname, hardlink)
     else:
-        copyfile(src, dst)
+        if hardlink:
+            try:
+                os_link(src, dst)
+            except:
+                hardlink = False
+                shutil.copy2(src, dst)
+        else:
+            shutil.copy2(src, dst)

 def opener(base):
     """
@@ -244,13 +255,13 @@ def opener(base):

         if mode[0] != "r":
             try:
-                s = os.stat(f)
+                nlink = nlinks(f)
             except OSError:
                 d = os.path.dirname(f)
                 if not os.path.isdir(d):
                     os.makedirs(d)
             else:
-                if s.st_nlink > 1:
+                if nlink > 1:
                     file(f + ".tmp", "wb").write(file(f, "rb").read())
                     rename(f+".tmp", f)

@@ -266,10 +277,41 @@ def _makelock_file(info, pathname):
 def _readlock_file(pathname):
     return file(pathname).read()

+def nlinks(pathname):
+    """Return number of hardlinks for the given file."""
+    return os.stat(pathname).st_nlink
+
+if hasattr(os, 'link'):
+    os_link = os.link
+else:
+    def os_link(src, dst):
+        raise OSError(0, "Hardlinks not supported")
+
 # Platform specific variants
 if os.name == 'nt':
     nulldev = 'NUL:'

+    try: # ActivePython can create hard links using win32file module
+        import win32file
+
+        def os_link(src, dst): # NB will only succeed on NTFS
+            win32file.CreateHardLink(dst, src)
+
+        def nlinks(pathname):
+            """Return number of hardlinks for the given file."""
+            try:
+                fh = win32file.CreateFile(pathname,
+                    win32file.GENERIC_READ, win32file.FILE_SHARE_READ,
+                    None, win32file.OPEN_EXISTING, 0, None)
+                res = win32file.GetFileInformationByHandle(fh)
+                fh.Close()
+                return res[7]
+            except:
+                return os.stat(pathname).st_nlink
+
+    except ImportError:
+        pass
+
     def is_exec(f, last):
         return last
2005-09-14 12:22:20 -05:00
mpm@selenic.com
489a50d0a3 Rewrite copytree as copyfiles
This inverts the logic of copytree to allow copying single files at
the top level.
2005-09-07 19:21:38 -07:00
Bryan O'Sullivan
648041175d Minor cleanups. 2005-09-04 14:21:53 -07:00
Eric Hopper
6b43642f9a Created a class in util called chunkbuffer that buffers reads from an
iterator over strings (aka chunks).

Also added to util (for future use) is a generator function that
iterates over a file n bytes at a time.

Lastly, localrepo was changed to use this new chunkbuffer class when
reading changegroups form the local repository.
2005-09-04 14:11:51 -07:00
Thomas Arendsen Hein
8a6c4666d1 Reverted changeset a180d5833ef6f90ff01b9322f3473017bce7ae55
Volker Kleinfeld agreed that this is dead code and tried to fix a problem
which was already fixed somewhere else.
2005-08-30 21:26:27 +02:00
mpm@selenic.com
e6e4ecb803 localrepo: minor opener usage restructuring 2005-08-27 16:34:54 -07:00
mpm@selenic.com
f1273ca2af Separate out old-http support
- create new statichttprepo class
- pull remote bits out of localrepo
- pull remote bits out of util.opener
- switch hg.repository to use statichttprepo
2005-08-27 16:28:53 -07:00
mpm@selenic.com
06162e7dd0 Move opener to utils
- move the opener code down to util
- add docstring
- change commands.py users to simply use file instead
2005-08-27 14:31:41 -07:00
mpm@selenic.com
8805469355 Update util.py docstrings, fix walk test 2005-08-27 01:13:28 -07:00
mpm@selenic.com
6737d1c923 Change canonpath to not know about repo objects
Code in util should not have any knowledge about repo objects
2005-08-26 23:29:10 -07:00
Volker.Kleinfeld@gmx.de
b206d3baac Fixed system command abord reason on windows. 2005-08-26 19:20:04 -07:00
benoit.boissinot@ens-lyon.fr
95b97f01ed pep-0008 cleanup
- Don't use spaces around the '=' sign when used to indicate a
      keyword argument or a default parameter value.
2005-08-26 13:06:58 +02:00
Bryan O'Sullivan
8b3b079822 Rewrite log command. New version is faster and more featureful.
The original implementation of log walked backwards through history,
which had terrible behaviour.  It took several minutes to view
complete kernel change history on a fast machine, for example.
The rewrite uses a windowed approach to walk hunks of history
forwards, while still giving results in reverse order.  This reduces
run time from five minutes to five seconds on my system.
In addition, the rewrite uses our normal name handling mechanisms, so
you can run a command like "hg log net/ipv4/**.c" and get a useful
answer.  It optimises for three different cases (no arguments, only
files, and anything goes), so it performs well in all circumstances
I've tested.
2005-08-24 12:39:10 -07:00
mpm@selenic.com
af3be1f6a1 Add automatic binary file detection to diff and export
Based on a patch by Fuming Wang

- add util.binary which decides whether a file is binary if it has any NUL
  characters in the first 1K.
- teach mdiff.unidiff to print "binary file <x> has changed" for binary files
- add text flag to cause unidiff and dodiff to treat all files as text
- add -a and --text flags (like diff(1)) to hg diff and export
- update docs
2005-08-23 19:58:46 -07:00
mpm@selenic.com
e7d0341a7b Fix hg clone race with writer
Most read operations in hg don't need locks because we order reads and
writes for consistency. Clone is an exception to this as we're copying
entire file histories and could end up with more file history copied
than we have commits.

For now, make clone take a lock on the source repo. Non-hardlinked
clone should eventually be changed to use lockless pull.
2005-08-16 14:53:47 -08:00
mark.williamson@cl.cam.ac.uk
37633695b1 Minor tweak: os.STOPSIG -> os.WSTOPSIG. Pychecker spotted this one. 2005-08-15 11:46:41 -08:00
mpm@selenic.com
979a3bb825 Fix bug with empty inc and exc
This fixes an exception that showed up when importing patches
2005-08-14 12:23:36 -08:00
Bryan O'Sullivan
3891eab8ea Fix up handling of regexp paths. 2005-08-12 16:09:17 -08:00
Bryan O'Sullivan
dcc0f582eb Fix walk path handling on Windows 2005-08-12 15:06:52 -08:00
Bryan O'Sullivan
52caea4f69 Fix walk code for files that do not exist anywhere, and unhandled types.
Prior to this, a file that did not exist was reported as showing up in
the filesystem, as were files of unsupported types (such as fifos).

Now, an error message is printed and nothing is returned in such cases.

This change also moves the commands.pathto function to the util module,
as the walk code needs it to print non-confusing error messages.
2005-08-12 11:16:58 -08:00
Bryan O'Sullivan
75e6a5bd0e Teach walk code about absolute paths.
The first consequence of this is that absolute and relative paths now
all work in the same way.  The second is that paths that lie outside
the repository now cause an error to be reported, instead of something
arbitrary and expensive being done.

Internally, all of the serious work is in the util package.  The new
canonpath function takes an arbitrary path and either returns a
canonical path or raises an error.  Because it needs to know where the
repository root is, it must be fed a repository or dirstate object, which
has given commands.matchpats and friends a new parameter to pass along.

The util.matcher function uses this to canonicalise globs and relative
path names.

Meanwhile, I've moved the Abort exception from commands to util, and
killed off the redundant util.CommandError exception.
2005-08-07 12:43:11 -08:00
Bryan O'Sullivan
315d7bf18a Kill dead function. 2005-08-07 11:09:21 -08:00
Bryan O'Sullivan
2f2a31ce76 Clean up walk and changes code to use normalised names properly.
New function: commands.pathto returns the relative path from one path
to another.  For example, given foo/bar and baz/quux, it will return
../../baz/quux.  This new function is used by the walk and status code
to print relative paths correctly.

New command: debugwalk exercises the walk code without doing anything
more.

hg.dirstate.walk now yields normalised names.  For example, if you're
in the baz directory and you ask it to walk ../foo/bar/.., it will yield
names starting with foo/.

As a result of this change, all of the other walk and changes methods
in this module also return normalised names.

The util.matcher function now normalises globs and path names, so that
it will match normalised names properly.

Finally, util.matcher uses the non-glob prefix of a glob to tell walk
which directories to scan.  Perviously, a glob like foo/* would scan
everything, but only return matches for foo/*.  Now, foo/* only scans
under foo (using the globprefix function), which is much faster.
2005-07-31 17:42:46 -08:00
Bryan O'Sullivan
4d6bf4b62a Reduce the amount of stat traffic generated by a walk.
When we switched to the new walk code for commands, we no longer passed a
list of specific files to the repo or dirstate walk or changes methods.
This meant that we always walked and attempted to match everything,
which was not efficient.

Now, if we are given any patterns to match, or nothing at all, we still
walk everything.  But if we are given only file names that contain no
glob characters, we only walk those.
2005-07-29 12:30:12 -08:00
thananck@yahoo.com
b2ea3f96f3 Provided platform dependent implementations for explain_exit
os.system return code is system dependent.
2005-07-27 10:18:22 -08:00
mpm@selenic.com
88969029c3 Refactor matchpats and walk
Move core match function code to util
Add some comments and whitespace
Simplify options
Use lambdas instead of always and never
2005-07-21 12:21:33 -05:00
Bryan O'Sullivan
4e963737e8 Get add and locate to use new repo and dirstate walk code.
They use a walk function that abstracts out the irritating details, so
that there's a higher likelihood of commands behaving uniformly.
2005-07-18 06:54:21 -08:00
Thomas Arendsen Hein
e78588e43a Make makelock and readlock work on filesystems without symlink support.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Make makelock and readlock work on filesystems without symlink support.
This way you can have a repository on a fat partiton, e.g. a USB stick.

manifest hash: cea2c120ef2b25a50c5d98b59648f773feefe470
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC1t5yW7P1GVgWeRoRAsKjAJ9BFcn/EqBK/dmJ4BY1pPIZIbDDJACghN3p
VCQS6CJ72MHpzhOOsnOpHzE=
=laDT
-----END PGP SIGNATURE-----
2005-07-14 22:51:47 +01:00
Thomas Arendsen Hein
6564a37beb Use python function instead of external 'cp' command when cloning repos.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Use python function instead of external 'cp' command when cloning repos.
Inspired by a patch from Stephen Darnell.

manifest hash: b525b0bf40f349b362db7c46d62be41572ef65cf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC1ncZW7P1GVgWeRoRAiJmAJ9GaCPaG6yOKb72I+SpDDdcdXTISACePD0H
GR/F+qqzi2imdgIV77ziLcQ=
=YVd2
-----END PGP SIGNATURE-----
2005-07-14 15:30:49 +01:00
mark.williamson@cl.cam.ac.uk
7d47f35832 A number of minor fixes to problems that pychecker found.
# HG changeset patch
# User mark.williamson@cl.cam.ac.uk
# Node ID 55d38977b7f2e73b8c1090179928ac96c8922b90
# Parent  0bda45294416406d4c6fbaf1cb643dd0bf6b3a16
A number of minor fixes to problems that pychecker found.
2005-07-10 16:01:11 -08:00
mpm@selenic.com
24ce1f4da4 Move dirstate.uniq to util.unique
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Move dirstate.uniq to util.unique

manifest hash: 8ac613c30a4471f14ae52f14ed0839d66eeaebb7
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCxQAqywK+sNU5EO8RAsTiAJ9E9/cALe+W8ojtfVdiXXre5dB/9gCeOgxr
mRnVw/WDplkATW5450Pgsug=
=xSfl
-----END PGP SIGNATURE-----
2005-07-01 00:34:50 -08:00
mpm@selenic.com
0fc691de8e [PATCH] Fix use of util.CommandError
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[PATCH] Fix use of util.CommandError

From: Bryan O'Sullivan <bos@serpentine.com>

Fix CommandError so error messages don't say "abort: abort: ...".

manifest hash: 2aea4c8043d321882dcdf846a42a55403ce1086f
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCwvOZywK+sNU5EO8RAqF/AJ9IIr6JPPUc15tb7w4lnI7yMFxSmgCfQUYn
OX7Uz7G3dJNRIjAxJtGwCLo=
=xj/W
-----END PGP SIGNATURE-----
2005-06-29 11:16:41 -08:00
mpm@selenic.com
0fb5db6915 Whitespace cleanups
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whitespace cleanups

manifest hash: ac954bc3a4f034c12638a259ecd65841f5b63c5c
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCwuubywK+sNU5EO8RAluIAJ98XQpNdZUpSmYKgDmrMRlbL76ZzQCfes0t
rknNUN/PhtyA4bzL646dOz4=
=UyCE
-----END PGP SIGNATURE-----
2005-06-29 10:42:35 -08:00
mpm@selenic.com
1c414eddc0 [PATCH] Harden os.system
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[PATCH] Harden os.system

From: Bryan O'Sullivan <bos@serpentine.com>

Add util.system function.  This is similar to os.system, but will
either succeed (if the process finishes with a zero exit code) or raise
a util.CommandError (if the process exits uncleanly or is killed by
a signal).

Add util.explain_exit function.  This tends to be ubiquitous in code
that calls other processes, and must describe what has gone wrong.

Change some uses of os.system over to util.system.

manifest hash: e3bf4adcac5b915432ec0af00efdbcef86bea4b1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCwSipywK+sNU5EO8RAr0RAJkBDt8XQ7mYQAWNHNgTOVt1eyWU1QCfe1oO
2OwxyWqpbRNACVJHHfZ3/Xw=
=OaRX
-----END PGP SIGNATURE-----
2005-06-28 02:38:33 -08:00
mpm@selenic.com
ef9fd5ee6e [PATCH] /dev/null for other OS
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[PATCH] /dev/null for other OS

From: K Thananchayan <thananck@yahoo.com>

Null device name is platform dependent. Introduce util.nulldev
- - platform dependent constant and use it instead of '/dev/null'

manifest hash: 95a1bfdb712c53ef97aaff73f7f4c87e9299cf59
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCvQCGywK+sNU5EO8RAiRBAKCcXasCCFT2+6wgklkgqIt4l3UwugCeKWii
h/8iRYEw8Rp8B67abiFiwyY=
=L3Mk
-----END PGP SIGNATURE-----
2005-06-24 22:58:14 -08:00
mpm@selenic.com
0ef8f163ee Permission handling for the other OS
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Permission handling for the other OS

From: K Thananchayan <thananck@yahoo.com>

Preserve exec permission under Windows on existing source files. Not an ideal
solution as there is no way to specify exec permission for a new file.
Nevertheless, this helps working on crossplatform projects.

manifest hash: c50da52ad4645f40bd6204c4fd458e880bc3f801
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCuvJeywK+sNU5EO8RAscXAJ40eAHZjTip5to6BGPdoXxxL5gNQQCgl5GT
8S1Ckank5I/0ScGtapZKqTA=
=QrQp
-----END PGP SIGNATURE-----
2005-06-23 09:33:18 -08:00
mpm@selenic.com
e0a4782d31 [PATCH] Enables lock work under the other 'OS'
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[PATCH] Enables lock work under the other 'OS'
From: K Thananchayan <thananck@yahoo.com>

os.symlink is not supported under Windows. This patch
introduces util.mklockf, util.getlowner that use
regular files under Winodws but symlink under unix.

tweaked by mpm:
 - changed function names
 - fixed to work on UNIX

manifest hash: 6f650a78a3b203dcad2f861582500b6b4036599a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCuN5sywK+sNU5EO8RAva8AJ9L9z/JHRAJS1bix48ZzSpn9ZUyPwCffhmg
UfLSFBmd5tPDDi3mgsrdDEA=
=ZYS9
-----END PGP SIGNATURE-----
2005-06-21 19:43:40 -08:00
mpm@selenic.com
5e62f2ce10 [PATCH] rename under the other OS
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[PATCH] rename under the other OS

From: K Thananchayan <thananck@yahoo.com>

Rename fails under windows if dest file exists. This
patch add a rename method to util module that removes
the dest file and retries if initial attempt fails.

manifest hash: 2744d9fd1717e15133b411a269df909fa8ec0faf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCuNzDywK+sNU5EO8RAsPBAJ9NQN3bTuJvTem5x+utGnoMkhYc0QCbBFSJ
PoMP69H1UnVE6drFlnlFE0s=
=pePw
-----END PGP SIGNATURE-----
2005-06-21 19:36:35 -08:00
mpm@selenic.com
1a1ca5cd0e [PATCH] file seperator handling for the other 'OS'
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[PATCH]  file seperator handling for the other 'OS'

From: K Thananchayan <thananck@yahoo.com>

The following patch maintains repo root relative source file names in
canonical form (with '/' as file seperator).

Mercurial calls os.path.join, os.path.normpath, os.path.walk that use
platform's file seperator. This patch does not change seperator in
these circumstances (except when the result refer to source files).

manifest hash: 2fbb4cb0d3d0bc4f4de5c7c8803fb738072ec6c5
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCuNuBywK+sNU5EO8RAhAZAKCV8cz11+rdof9n1tHb0uDScF34GgCeITNi
4aVikToPXqXyReN9kFP5pnY=
=xcV5
-----END PGP SIGNATURE-----
2005-06-21 19:31:13 -08:00