README
author Stephen Darnell
Wed, 14 Sep 2005 12:22:20 -0500
changeset 1241 3b4f05ff3130
parent 981 4f81068ed8cd
child 1308 2073e5a71008
permissions -rw-r--r--
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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
445
fe48ffa3665f README tidy-up
mpm@selenic.com
parents: 330
diff changeset
     1
MERCURIAL QUICK-START
fe48ffa3665f README tidy-up
mpm@selenic.com
parents: 330
diff changeset
     2
204
161cef501e8d README: integrate various changes and suggestions from Rafael Villar Burke
mpm@selenic.com
parents: 182
diff changeset
     3
Setting up Mercurial:
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     4
204
161cef501e8d README: integrate various changes and suggestions from Rafael Villar Burke
mpm@selenic.com
parents: 182
diff changeset
     5
 Note: some distributions fails to include bits of distutils by
205
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
     6
 default, you'll need python-dev to install. You'll also need a C
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
     7
 compiler and a 3-way merge tool like merge, tkdiff, or kdiff3.
204
161cef501e8d README: integrate various changes and suggestions from Rafael Villar Burke
mpm@selenic.com
parents: 182
diff changeset
     8
161cef501e8d README: integrate various changes and suggestions from Rafael Villar Burke
mpm@selenic.com
parents: 182
diff changeset
     9
 First, unpack the source:
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    10
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    11
 $ tar xvzf mercurial-<ver>.tar.gz
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    12
 $ cd mercurial-<ver>
204
161cef501e8d README: integrate various changes and suggestions from Rafael Villar Burke
mpm@selenic.com
parents: 182
diff changeset
    13
205
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
    14
 To install system-wide:
204
161cef501e8d README: integrate various changes and suggestions from Rafael Villar Burke
mpm@selenic.com
parents: 182
diff changeset
    15
161cef501e8d README: integrate various changes and suggestions from Rafael Villar Burke
mpm@selenic.com
parents: 182
diff changeset
    16
 $ python setup.py install   # change python to python2.3 if 2.2 is default
161cef501e8d README: integrate various changes and suggestions from Rafael Villar Burke
mpm@selenic.com
parents: 182
diff changeset
    17
205
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
    18
 To install in your home directory (~/bin and ~/lib, actually), run:
204
161cef501e8d README: integrate various changes and suggestions from Rafael Villar Burke
mpm@selenic.com
parents: 182
diff changeset
    19
161cef501e8d README: integrate various changes and suggestions from Rafael Villar Burke
mpm@selenic.com
parents: 182
diff changeset
    20
 $ python2.3 setup.py install --home=~
507
dd8b19114fe7 README: mention lib64/
mpm@selenic.com
parents: 445
diff changeset
    21
 $ export PYTHONPATH=${HOME}/lib/python  # (or lib64/ on some systems)
dd8b19114fe7 README: mention lib64/
mpm@selenic.com
parents: 445
diff changeset
    22
 $ export PATH=${HOME}/bin:$PATH         # add these to your .bashrc
205
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
    23
204
161cef501e8d README: integrate various changes and suggestions from Rafael Villar Burke
mpm@selenic.com
parents: 182
diff changeset
    24
 And finally:
161cef501e8d README: integrate various changes and suggestions from Rafael Villar Burke
mpm@selenic.com
parents: 182
diff changeset
    25
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    26
 $ hg                                    # test installation, show help
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    27
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    28
 If you get complaints about missing modules, you probably haven't set
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    29
 PYTHONPATH correctly.
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    30
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    31
Setting up a Mercurial project:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    32
445
fe48ffa3665f README tidy-up
mpm@selenic.com
parents: 330
diff changeset
    33
 $ cd project/
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    34
 $ hg init         # creates .hg
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    35
 $ hg addremove    # add all unknown files and remove all missing files
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    36
 $ hg commit       # commit all changes, edit changelog entry
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    37
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    38
 Mercurial will look for a file named .hgignore in the root of your
633
f597539c7abd Slim down and update README a bit
Matt Mackall <mpm@selenic.com>
parents: 631
diff changeset
    39
 repository which contains a set of regular expressions to ignore in
f597539c7abd Slim down and update README a bit
Matt Mackall <mpm@selenic.com>
parents: 631
diff changeset
    40
 file paths.
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    41
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    42
Branching and merging:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    43
633
f597539c7abd Slim down and update README a bit
Matt Mackall <mpm@selenic.com>
parents: 631
diff changeset
    44
 $ hg clone linux linux-work    # create a new branch
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    45
 $ cd linux-work
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    46
 $ <make changes>
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    47
 $ hg commit
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    48
 $ cd ../linux
261
3dae0296551d Update README
mpm@selenic.com
parents: 241
diff changeset
    49
 $ hg pull ../linux-work     # pull changesets from linux-work
445
fe48ffa3665f README tidy-up
mpm@selenic.com
parents: 330
diff changeset
    50
 $ hg update -m              # merge the new tip from linux-work into
261
3dae0296551d Update README
mpm@selenic.com
parents: 241
diff changeset
    51
                             # our working directory
633
f597539c7abd Slim down and update README a bit
Matt Mackall <mpm@selenic.com>
parents: 631
diff changeset
    52
 $ hg commit                 # commit the result of the merge
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    53
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    54
Importing patches:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    55
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    56
 Fast:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    57
 $ patch < ../p/foo.patch
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    58
 $ hg addremove
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    59
 $ hg commit
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    60
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    61
 Faster:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    62
 $ patch < ../p/foo.patch
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    63
 $ hg commit `lsdiff -p1 ../p/foo.patch`
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    64
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    65
 Fastest:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    66
 $ cat ../p/patchlist | xargs hg import -p1 -b ../p 
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    67
205
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
    68
Exporting a patch:
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
    69
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
    70
 (make changes)
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
    71
 $ hg commit
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
    72
 $ hg tip
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
    73
 28237:747a537bd090880c29eae861df4d81b245aa0190
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
    74
 $ hg export 28237 > foo.patch    # export changeset 28237
d255d99a7cbd README: integrate some changes from Kevin Smith
mpm@selenic.com
parents: 204
diff changeset
    75
63
1c590d34bf61 Minor changes for release 0.4e
mpm@selenic.com
parents: 27
diff changeset
    76
Network support:
1c590d34bf61 Minor changes for release 0.4e
mpm@selenic.com
parents: 27
diff changeset
    77
445
fe48ffa3665f README tidy-up
mpm@selenic.com
parents: 330
diff changeset
    78
 # pull from the primary Mercurial repo
633
f597539c7abd Slim down and update README a bit
Matt Mackall <mpm@selenic.com>
parents: 631
diff changeset
    79
 foo$ hg clone http://selenic.com/hg/ 
f597539c7abd Slim down and update README a bit
Matt Mackall <mpm@selenic.com>
parents: 631
diff changeset
    80
 foo$ cd hg
1
273ce12ad8f1 Update README to discuss remote pull, rsync, and the hg repo
mpm@selenic.com
parents: 0
diff changeset
    81
160
5c331d941c7f Update the README a bit
mpm@selenic.com
parents: 81
diff changeset
    82
 # export your current repo via HTTP with browsable interface
5c331d941c7f Update the README a bit
mpm@selenic.com
parents: 81
diff changeset
    83
 foo$ hg serve -n "My repo" -p 80
5c331d941c7f Update the README a bit
mpm@selenic.com
parents: 81
diff changeset
    84
 
327
a9ad98a9c9bc Tweak README for branch, push, and .hgrc
mpm@selenic.com
parents: 261
diff changeset
    85
 # pushing changes to a remote repo with SSH
a9ad98a9c9bc Tweak README for branch, push, and .hgrc
mpm@selenic.com
parents: 261
diff changeset
    86
 foo$ hg push ssh://user@example.com/~/hg/
a9ad98a9c9bc Tweak README for branch, push, and .hgrc
mpm@selenic.com
parents: 261
diff changeset
    87
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    88
 # merge changes from a remote machine
261
3dae0296551d Update README
mpm@selenic.com
parents: 241
diff changeset
    89
 bar$ hg pull http://foo/
445
fe48ffa3665f README tidy-up
mpm@selenic.com
parents: 330
diff changeset
    90
 bar$ hg update -m        # merge changes into your working directory
63
1c590d34bf61 Minor changes for release 0.4e
mpm@selenic.com
parents: 27
diff changeset
    91
160
5c331d941c7f Update the README a bit
mpm@selenic.com
parents: 81
diff changeset
    92
 # Set up a CGI server on your webserver
445
fe48ffa3665f README tidy-up
mpm@selenic.com
parents: 330
diff changeset
    93
 foo$ cp hgweb.cgi ~/public_html/hg/index.cgi
fe48ffa3665f README tidy-up
mpm@selenic.com
parents: 330
diff changeset
    94
 foo$ emacs ~/public_html/hg/index.cgi # adjust the defaults
969
1d5b97537561 Minor README updates
mpm@selenic.com
parents: 633
diff changeset
    95
1d5b97537561 Minor README updates
mpm@selenic.com
parents: 633
diff changeset
    96
For more info:
1d5b97537561 Minor README updates
mpm@selenic.com
parents: 633
diff changeset
    97
1d5b97537561 Minor README updates
mpm@selenic.com
parents: 633
diff changeset
    98
 Documentation in doc/
1d5b97537561 Minor README updates
mpm@selenic.com
parents: 633
diff changeset
    99
 Mercurial website at http://selenic.com/mercurial
1d5b97537561 Minor README updates
mpm@selenic.com
parents: 633
diff changeset
   100
 Mercurial wiki at http://selenic.com/mercurial/wiki