view doc/hgrc.5.txt @ 1241:3b4f05ff3130

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
author Stephen Darnell
date Wed, 14 Sep 2005 12:22:20 -0500
parents a425bb927ede
children 1945754e466b
line wrap: on
line source

HGRC(5)
=======
Bryan O'Sullivan <bos@serpentine.com>

NAME
----
hgrc - configuration files for Mercurial

SYNOPSIS
--------

The Mercurial system uses a set of configuration files to control
aspects of its behaviour.

FILES
-----

Mercurial reads configuration data from three files:

/etc/mercurial/hgrc::
    Options in this global configuration file apply to all Mercurial
    commands executed by any user in any directory.

$HOME/.hgrc::
    Per-user configuration options that apply to all Mercurial commands,
    no matter from which directory they are run.  Values in this file
    override global settings.

<repo>/.hg/hgrc::
    Per-repository configuration options that only apply in a
    particular repository.  This file is not version-controlled, and
    will not get transferred during a "clone" operation.  Values in
    this file override global and per-user settings.

SYNTAX
------

A configuration file consists of sections, led by a "[section]" header
and followed by "name: value" entries; "name=value" is also accepted.

    [spam]
    eggs=ham
    green=
       eggs

Each line contains one entry.  If the lines that follow are indented,
they are treated as continuations of that entry.

Leading whitespace is removed from values.  Empty lines are skipped.

The optional values can contain format strings which refer to other
values in the same section, or values in a special DEFAULT section.

Lines beginning with "#" or ";" are ignored and may be used to provide
comments.

SECTIONS
--------

This section describes the different sections that may appear in a
Mercurial "hgrc" file, the purpose of each section, its possible
keys, and their possible values.

hooks::
  Commands that get automatically executed by various actions such as
  starting or finishing a commit.
  changegroup;;
    Run after a changegroup has been added via push or pull.
  commit;;
    Run after a changeset has been created. Passed the ID of the newly
    created changeset.
  precommit;;
    Run before starting a commit.  Exit status 0 allows the commit to
    proceed.  Non-zero status will cause the commit to fail.

http_proxy::
  Used to access web-based Mercurial repositories through a HTTP
  proxy.
  host;;
    Host name and (optional) port of the proxy server, for example
    "myproxy:8000".
  no;;
    Optional.  Comma-separated list of host names that should bypass
    the proxy.
  passwd;;
    Optional.  Password to authenticate with at the proxy server.
  user;;
    Optional.  User name to authenticate with at the proxy server.

paths::
  Assigns symbolic names to repositories.  The left side is the
  symbolic name, and the right gives the directory or URL that is the
  location of the repository.

ui::
  User interface controls.
  debug;;
    Print debugging information.  True or False.  Default is False.
  editor;;
    The editor to use during a commit.  Default is $EDITOR or "vi".
  interactive;;
    Allow to prompt the user.  True or False.  Default is True.
  merge;;
    The conflict resolution program to use during a manual merge.
    Default is "hgmerge".
  quiet;;
    Reduce the amount of output printed.  True or False.  Default is False.
  remotecmd;;
    remote command to use for clone/push/pull operations. Default is 'hg'.
  ssh;;
    command to use for SSH connections. Default is 'ssh'.
  username;;
    The committer of a changeset created when running "commit".
    Typically a person's name and email address, e.g. "Fred Widget
    <fred@example.com>".  Default is $EMAIL or username@hostname.
  verbose;;
    Increase the amount of output printed.  True or False.  Default is False.


web::
  Web interface configuration.
  accesslog;;
    Where to output the access log. Default is stdout.
  address;;
    Interface address to bind to. Default is all.
  allowbz2;;
    Whether to allow .tar.bz2 downloading of repo revisions. Default is false.
  allowgz;;
    Whether to allow .tar.gz downloading of repo revisions. Default is false.
  allowpull;;
    Whether to allow pulling from the repository. Default is true.
  allowzip;;
    Whether to allow .zip downloading of repo revisions. Default is false.
    This feature creates temporary files.
  description;;
    Textual description of the repository's purpose or contents.
    Default is "unknown".
  errorlog;;
    Where to output the error log. Default is stderr.
  ipv6;;
    Whether to use IPv6. Default is false.
  name;;
    Repository name to use in the web interface. Default is current
    working directory.
  maxchanges;;
    Maximum number of changes to list on the changelog. Default is 10.
  maxfiles;;
    Maximum number of files to list per changeset. Default is 10.
  port;;
    Port to listen on. Default is 8000.
  style;;
    Which template map style to use.
  templates;;
    Where to find the HTML templates. Default is install path.


AUTHOR
------
Bryan O'Sullivan <bos@serpentine.com>.

Mercurial was written by Matt Mackall <mpm@selenic.com>.

SEE ALSO
--------
hg(1)

COPYING
-------
This manual page is copyright 2005 Bryan O'Sullivan.
Mercurial is copyright 2005 Matt Mackall.
Free use of this software is granted under the terms of the GNU General
Public License (GPL).