Commit Graph

27 Commits

Author SHA1 Message Date
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