Commit Graph

858 Commits

Author SHA1 Message Date
mpm@selenic.com
b7bafd9d2e Add debugancestor command 2005-09-16 10:42:20 -07:00
mpm@selenic.com
8f5897184a hgweb: use ui:username rather than web:contact
This also removes the creation of .hg/hgrc with web:contact at init time.
2005-09-15 14:05:48 -05:00
mpm@selenic.com
a88a06fe01 Merge with BOS 2005-09-15 03:00:10 -05:00
mpm@selenic.com
eac251ef7c Add file encoding/decoding support 2005-09-15 02:59:16 -05:00
Bryan O'Sullivan
e0b361a94c Clamp negative rev numbers at zero.
Prior to this change, trying to run "hg log -r -50:" in a repo with
less than 50 changes caused an error.  Now that we clamp at zero: no
more error.
2005-09-15 00:04:29 -07:00
Bryan O'Sullivan
6edfd3a956 Get all commands that operate on files to honour --verbose and --quiet.
Fix minor bug in remove command; the when-to-unlink logic was wonky.
2005-09-14 22:32:12 -07:00
Bryan O'Sullivan
b6e3f2ae8c Switch cat command to use walk code.
The old syntax of "hg cat FILE REV" is now obsolete.
Use "hg cat -r REV FILE" instead, as for all other commands.
2005-09-14 21:57:41 -07:00
Bryan O'Sullivan
db7eec2670 Add rename/mv command.
This is the logical equivalent of copy and remove, and is in fact
implemented as such.  It doesn't use the remove command directly.
2005-09-14 16:34:22 -07:00
Bryan O'Sullivan
d5a9cb0366 Fix lots of exception-related problems.
These have been around since the Big Code Split.
2005-09-14 15:41:22 -07:00
Bryan O'Sullivan
75da334110 Merge with MPM. 2005-09-14 14:39:46 -07:00
Bryan O'Sullivan
048d850eb8 Fix up copy command to behave more like regular "cp".
In addition to recording changes, copy now updates the working
directory.
2005-09-14 14:29:02 -07:00
Chris Mason
329f781b37 Files not getting added appropiately
On Wed, 14 Sep 2005 15:15:13 -0400
Daniel Santa Cruz <byteshack@gmail.com> wrote:

> c:> hg debugstate
> a 666          0 09/14/05 15:11:44 a/aa\aa.a
> a 666          0 09/14/05 15:11:47 a/aa\aa.b  <---- notice mixed
> slashes
>
> This all seems very confusing....

Please try this:
2005-09-14 15:50:31 -05:00
mpm@selenic.com
2f510bb7be clone: fall back to pull if we can't lock the source repo 2005-09-14 15:48:34 -05:00
Bryan O'Sullivan
33fe1a1d9e Make remove command really unlink files. 2005-09-14 10:50:03 -07:00
Mikael Berthe
633ea44be0 Fix hg cat when the file cannot be found in the specified revision 2005-09-14 12:35:10 -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
mason@suse.com
2cb2ec20c2 Add log -b to show the branch a specific revision lives in
This can be somewhat slow on very large repositories, so I didn't want
to include it in -v

--- hg.orig/mercurial/commands.py	2005-09-13 14:21:57.000000000 -0500
+++ hg/mercurial/commands.py	2005-09-13 18:55:52.000000000 -0500
@@ -1161,7 +1161,10 @@ def log(ui, repo, *pats, **opts):
             du = dui(ui)
         elif st == 'add':
             du.bump(rev)
-            show_changeset(du, repo, rev)
+            br = None
+            if opts['branch']:
+                br = repo.branchlookup([repo.changelog.node(rev)])
+            show_changeset(du, repo, rev, brinfo=br)
             if opts['patch']:
                 changenode = repo.changelog.node(rev)
                 prev, other = repo.changelog.parents(changenode)
@@ -1743,6 +1746,7 @@ table = {
         (log,
          [('I', 'include', [], 'include path in search'),
           ('X', 'exclude', [], 'exclude path from search'),
+          ('b', 'branch', None, 'show branches'),
           ('r', 'rev', [], 'revision'),
           ('p', 'patch', None, 'show patch')],
          'hg log [-I] [-X] [-r REV]... [-p] [FILE]'),
2005-09-13 19:32:53 -05:00
mpm@selenic.com
1572c012c2 Fix bug with co -C across branches, update tests 2005-09-13 18:38:27 -05:00
mpm@selenic.com
74b4fbfc7a Revert unrelated changes in previous commit 2005-09-13 14:22:48 -05:00
mpm@selenic.com
5b149d41a6 Fix abort message for clone 2005-09-13 14:18:18 -05:00
mpm@selenic.com
e6d013f8fa Revert some exception type changes in revlog 2005-09-13 14:16:15 -05:00
mpm@selenic.com
e271f138e7 dirstate: two more stat -> lstat changes 2005-09-09 12:17:51 -07:00
mpm@selenic.com
ca895153c1 Fix comment typo 2005-09-09 11:47:13 -07:00
mpm@selenic.com
9580bfb453 Fix dangling symlink bug in dirstate walk code 2005-09-09 11:46:35 -07:00
Bryan O'Sullivan
1ca6e5ea0b Replace sequences of {ui.warn, return 1} with raise of util.Abort. 2005-09-09 11:34:34 -07:00
mpm@selenic.com
2373462c92 Add --debugger global option
With this option, hg will drop into the Python debugger on execution.
Running 'continue' will execute normally, and the debugger will be
reinvoked if an exception is raised.
2005-09-08 17:09:31 -07:00
mpm@selenic.com
3e01e32fbe Fix Windows status problem from new dirstate walk code 2005-09-08 15:01:33 -07:00
mpm@selenic.com
470c383d45 Fix missing docstring for unbundle 2005-09-08 12:16:31 -07:00
TK Soh
a0c80ee54b clone: directory names take precedence over symbolic names
If source matches both a directory name and a symbolic
name to repo, the directory will be taken.
2005-09-08 12:10:59 -07:00
mpm@selenic.com
6a3a38d45f import: fix bug in mail-format detection 2005-09-08 12:10:43 -07:00
mpm@selenic.com
cfdcf96098 hgweb: fix scope for RepoError 2005-09-08 10:49:33 -07:00
mpm@selenic.com
09d2a3f668 Add preliminary support for the bundle and unbundle commands 2005-09-08 01:27:25 -07:00
mpm@selenic.com
2fca17c06f Add missing import for hgwebdir 2005-09-08 00:13:52 -07:00
mpm@selenic.com
1c450a3c7e Add reporting instructions to unknown exception backtraces 2005-09-07 23:57:59 -07:00
mpm@selenic.com
81f7ceb9b4 Smarter handling of revlog key errors
Use RevlogError for reporting exceptions
Catch and report RevlogError exceptions at the command parser
2005-09-07 23:38:28 -07:00
mpm@selenic.com
cc15893f9d Clean up hgweb imports
Use demandloading
Pull function-local imports up to demandload
Scope hg and ui bits
2005-09-07 23:13:12 -07:00
mpm@selenic.com
8989165f6e Change grep -e to grep --all
We want to reserve -e for future use and grep compatibility.

I've changed every-match to all out of a general preference for
shorter long option names where short options don't exist.
2005-09-07 20:50:23 -07:00
mpm@selenic.com
913fee3381 Fold import -m option into import -f 2005-09-07 20:09:16 -07:00
mpm@selenic.com
41f723f5dd Revert silly TypeError change 2005-09-07 20:05:22 -07:00
mpm@selenic.com
037765f744 Tighten up clone locking
Add a lock on the destination, expand comment on source lock
2005-09-07 19:37:11 -07:00
mpm@selenic.com
7437b211c9 Clean up local clone file list
We now use an explicit list of files to copy during clone so that we
don't copy anything we shouldn't.
2005-09-07 19:30:23 -07: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
mpm@selenic.com
b4139aa0de Redo local clone hgrc fix
We shouldn't copy hgrc on a local clone, nor localtags. Behavior
should be identical to a remote clone.
2005-09-07 19:16:36 -07:00
Bryan O'Sullivan
2e67ffebe5 Write out hgrc properly.
Previously, we simply appended to the hgrc file, which meant that it
ended up containing multiple "paths" sections.  Now, we only modify
"paths.default".
2005-09-04 15:47:59 -07:00
Bryan O'Sullivan
75cd295fec Commit date validation: more stringent checks, more useful error messages. 2005-09-04 14:47:02 -07:00
Bryan O'Sullivan
fff715d0f9 revlog: raise informative exception if file is missing. 2005-09-04 14:45:03 -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
Bryan O'Sullivan
2bd0c42ab1 Date validation must check for 32-bit width. Don't use assert to check. 2005-09-03 23:51:53 -07:00
Bryan O'Sullivan
b15e572eba Make date/timezone validation in changelog.add more robust. Add test. 2005-09-03 23:28:15 -07:00