Commit Graph

56 Commits

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