Commit Graph

374 Commits

Author SHA1 Message Date
mpm@selenic.com
b7bafd9d2e Add debugancestor command 2005-09-16 10:42:20 -07: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
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
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
5b149d41a6 Fix abort message for clone 2005-09-13 14:18:18 -05:00
mpm@selenic.com
ca895153c1 Fix comment typo 2005-09-09 11:47:13 -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
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
09d2a3f668 Add preliminary support for the bundle and unbundle commands 2005-09-08 01:27:25 -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
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
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
bos@serpentine.internal.keyresearch.com
13caea8fc2 Add doc string for debugrename. 2005-09-01 12:13:56 -07:00
bos@serpentine.internal.keyresearch.com
887d7f3fac Fortify the recognition of a diff header. 2005-09-01 09:35:42 -07:00
TK Soh
64dcff79fa Add -p to incoming and outgoing commands to show patch 2005-09-01 09:11:25 -07:00
bos@serpentine.internal.keyresearch.com
1c87d60be4 Revert changeset 0ba7f6134a4a2cbd767c5ec5cc497dbecf1b4e36.
I inadvertantly used "hg import" on a message I saved, expecting it to do
the right thing, but instead it made the commit look like I authored it,
and filled the description with the email header.

Changeset 238f05c9201ffe16c81e32a55d4d6b563cc9f605 contains a guard
against "hg import" doing this again.
2005-09-01 09:08:21 -07:00
bos@serpentine.internal.keyresearch.com
31ab427b7b Make import command reject patches that resemble email messages.
See changeset 0ba7f6134a4a2cbd767c5ec5cc497dbecf1b4e36 for an example
of why this is a good idea.
2005-09-01 09:04:18 -07:00
Bryan O'Sullivan
6881af8a23 Make removal check more complete and informative. 2005-09-01 08:01:10 -07:00
Bryan O'Sullivan
2442e85927 Fix up remove command to use walk code. 2005-09-01 07:48:14 -07:00
bos@serpentine.internal.keyresearch.com
5e8340bea1 From mercurial-bounces@selenic.com Thu Sep 1 07:01:32 2005
Return-Path: <mercurial-bounces@selenic.com>
X-Original-To: bos@serpentine.com
Delivered-To: bos@serpentine.com
Received: from waste.org (waste.org [216.27.176.166]) by
	demesne.serpentine.com (Postfix) with ESMTP id 3616A20B571 for
	<bos@serpentine.com>; Thu,  1 Sep 2005 07:01:32 -0700 (PDT)
Received: from waste.org (localhost [127.0.0.1]) by waste.org
	(8.13.4/8.13.4/Debian-3) with ESMTP id j81DxodQ028829; Thu, 1 Sep 2005
	08:59:51 -0500
Received: from web32904.mail.mud.yahoo.com (web32904.mail.mud.yahoo.com
	[68.142.206.51]) by waste.org (8.13.4/8.13.4/Debian-3) with SMTP id
	j81DxnNA028824 for <mercurial@selenic.com>; Thu, 1 Sep 2005 08:59:49 -0500
Received: (qmail 25859 invoked by uid 60001); 1 Sep 2005 13:59:17 -0000
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com;
	h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding;
	b=O6sELrlCknW3M/gKVqijWs82e/CbDEum1sEitcuLKXaP9dHU175PszOqMgcSKykMY+BVXtcH3NeaXLM3FyBmqNkoPAvesezyFbgQsHSM1S028oOexybCKMvtGQJmz66hzd1fDb0QoPj1gCcGU2VDevQaOesSmo1xF9jJwy2LlLE=
	;
Message-ID: <20050901135917.25856.qmail@web32904.mail.mud.yahoo.com>
Received: from [60.48.222.94] by web32904.mail.mud.yahoo.com via HTTP; Thu,
	01 Sep 2005 06:59:17 PDT
Date: Thu, 1 Sep 2005 06:59:17 -0700 (PDT)
From: TK Soh <teekaysoh@yahoo.com>
To: mercurial@selenic.com
In-Reply-To: <20050828075808.GO27787@waste.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
X-Virus-Scanned: by amavisd-new
Subject: Re: add -p to hg tip
X-BeenThere: mercurial@selenic.com
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: mercurial.selenic.com
List-Unsubscribe: <http://selenic.com/mailman/listinfo/mercurial>,
	<mailto:mercurial-request@selenic.com?subject=unsubscribe>
List-Archive: <http://www.selenic.com/pipermail/mercurial>
List-Post: <mailto:mercurial@selenic.com>
List-Help: <mailto:mercurial-request@selenic.com?subject=help>
List-Subscribe: <http://selenic.com/mailman/listinfo/mercurial>,
	<mailto:mercurial-request@selenic.com?subject=subscribe>
Sender: mercurial-bounces@selenic.com
Errors-To: mercurial-bounces@selenic.com
X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on
	demesne.serpentine.com
X-Spam-Level:
X-Spam-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham
	 version=3.0.4
X-Evolution-Source: imap://bos@www.serpentine.com/
Content-Transfer-Encoding: 8bit
2005-09-01 07:47:26 -07:00
Bryan O'Sullivan
1f4f73a2eb hg serve: print a more useful error message if server can't start. 2005-08-31 11:19:20 -07:00
bos@serpentine.internal.keyresearch.com
d8c746ea08 Merge with TAH. 2005-08-29 10:31:41 -07:00
bos@serpentine.internal.keyresearch.com
d630ed8e52 grep: extend functionality, add man page entry, add unit test.
walkchangerevs now returns a two-tuple.  Its behaviour is also
extensively commented.
The annotate command's getname function has been factored out to a new
function, trimname, so it can be shared between annotate and grep.
The behaviour of grep has been beefed up, so that it now performs a
number of useful functions.
2005-08-29 10:05:49 -07:00
Bryan O'Sullivan
48cf3ef5aa grep: change default to printing first matching rev.
Printing of every matching rev remains via --every-match/-e switch.
2005-08-29 08:24:06 -07:00
Thomas Arendsen Hein
c07446d134 Create [web] section with short username as contact on hg init and hg clone. 2005-08-28 18:27:24 +02:00
Thomas Arendsen Hein
9129755767 Move generating short username to display in hg/hgweb annotate to ui module. 2005-08-28 17:29:28 +02:00
Thomas Arendsen Hein
ec28c4eea8 Changed printing of copies in hg debugstate to: "copy: source -> dest" 2005-08-28 16:24:04 +02:00
mpm@selenic.com
2b4a95a639 Add some rename debugging support 2005-08-27 20:58:53 -07:00
Stephen Darnell
95591d60c6 Remove the lock file copied during clone (was the source lock file)
Index: hg/mercurial/commands.py
===================================================================
2005-08-27 19:15:02 -07:00
TK Soh
50787ba429 Updated manpage and help.
Updated manpage on change to hg status; standardized description
of -print0 options.
2005-08-27 18:55:14 -07:00
mpm@selenic.com
0c4bb9fabe Merge with TAH 2005-08-27 17:26:26 -07:00
mpm@selenic.com
13cd5a12bb commands: use revlog directly for debug commands
This eliminates the import in hg.py
2005-08-27 14:56:58 -07:00