[PATCH] commands: document and test hg clone update priority
timeless
timeless at gmail.com
Mon Mar 8 02:47:00 CST 2010
I've moved the section to the very end, which means you
can now see the short/long forms together. I also added
one extra test because greg pointed out that my
documentation was wrong about what -r allowed :).
I claim that we should actually be able to remove all long
forms from help because when you view help you will always
see the table showing the long+short forms (whether it's at
the top or at the bottom is an impl choice which I think we
should eventually change, but that's a conversation for
another time).
# HG changeset patch
# User timeless <timeless at gmail.com>
# Date 1268037863 -7200
# Node ID 59197ffed4cd2104eee0291e47db5b28ef9de845
# Parent 5ee3faa7c563c976d7c4aaa69859719ddeb826a3
commands: document and test hg clone update priority
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -621,20 +621,6 @@ def clone(ui, source, dest=None, **opts)
.hg/hgrc and working directory will be created on the remote side.
Please see 'hg help urls' for important details about ``ssh://`` URLs.
- If the -U/--noupdate option is specified, the new clone will contain
- only a repository (.hg) and no working copy (the working copy parent
- will be the null changeset). Otherwise, clone will initially check
- out (in order of precedence):
-
- a) the changeset, tag or branch specified with -u/--updaterev
- b) the changeset, tag or branch given with the first -r/--rev
- c) the branch given with the first -b/--branch
- d) the branch given with the url#branch source syntax
- e) the head of the default branch
-
- Use 'hg clone -u . src dst' to checkout the source repository's
- parent changeset (applicable for local source repositories only).
-
A set of changesets (tags, or branch names) to pull may be specified
by listing each changeset (tag, or branch name) with -r/--rev.
If -r/--rev is used, the cloned repository will contain only a subset
@@ -649,12 +635,12 @@ def clone(ui, source, dest=None, **opts)
For efficiency, hardlinks are used for cloning whenever the source
and destination are on the same filesystem (note this applies only
- to the repository data, not to the checked out files). Some
+ to the repository data, not to the working directory). Some
filesystems, such as AFS, implement hardlinking incorrectly, but
do not report errors. In these cases, use the --pull option to
avoid hardlinking.
- In some cases, you can clone repositories and checked out files
+ In some cases, you can clone repositories and the working directory
using full hardlinks with ::
$ cp -al REPO REPOCLONE
@@ -665,6 +651,20 @@ def clone(ui, source, dest=None, **opts)
breaks hardlinks (Emacs and most Linux Kernel tools do so). Also,
this is not compatible with certain extensions that place their
metadata under the .hg directory, such as mq.
+
+ Mercurial will update the working directory to the first applicable
+ revision from this list ::
+
+ a) null if -U or the source repository has no changesets
+ b) if -u . and the source repository is local, the first parent of
+ the source repository's working directory
+ c) the changeset specified with -u (if a branch name, this means the
+ latest head of that branch)
+ d) the changeset specified with -r
+ e) the tipmost head specified with -b
+ f) the tipmost head specified with the url#branch source syntax
+ g) the tipmost head of the default branch
+ h) tip
"""
if opts.get('noupdate') and opts.get('updaterev'):
raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
diff --git a/tests/test-clone-update-order b/tests/test-clone-update-order
new file mode 100755
--- /dev/null
+++ b/tests/test-clone-update-order
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+echo
+echo % prepare repo a
+mkdir a
+cd a
+hg init
+echo foo > bar
+hg commit -Am default
+hg up -r null
+hg branch mine
+echo hello > world
+hg commit -Am hello
+hg up -r null
+hg branch other
+echo good > bye
+hg commit -Am other
+hg up -r mine
+
+echo % test -U -u
+hg clone -U -u . .#other ../b -r 0 -r 1 -r 2 -b other
+
+echo % test -U
+hg clone -U .#other ../b -r 0 -r 1 -r 2 -b other
+rm -rf ../b
+
+echo % test -u .
+hg clone -u . .#other ../b -r 0 -r 1 -r 2 -b other
+rm -rf ../b
+
+echo % test -u 0
+hg clone -u 0 .#other ../b -r 0 -r 1 -r 2 -b other
+rm -rf ../b
+
+echo % test -u 1
+hg clone -u 1 .#other ../b -r 0 -r 1 -r 2 -b other
+rm -rf ../b
+
+echo % test -u 2
+hg clone -u 2 .#other ../b -r 0 -r 1 -r 2 -b other
+rm -rf ../b
+
+echo % test -r 0
+hg clone -u 2 .#other ../b -r 0 -r 1 -r 2 -b other
+rm -rf ../b
+
+echo % test -r mine ... mine is ignored
+hg clone -u 2 .#other ../b -r mine -r 0 -r 1 -r 2 -b other
+rm -rf ../b
+
+echo % test -b default
+hg clone .#other ../b -b default -b mine
+rm -rf ../b
+
+echo % test #other
+hg clone .#other ../b
+rm -rf ../b
+
+echo % test tip
+hg clone -U . ../c -r 1 -r 2 > /dev/null
+hg clone ../c ../b
+rm -rf ../b ../c
+cd ..
+
+rm -rf a
+exit 0
diff --git a/tests/test-clone-update-order.out
b/tests/test-clone-update-order.out
new file mode 100644
--- /dev/null
+++ b/tests/test-clone-update-order.out
@@ -0,0 +1,87 @@
+
+% prepare repo a
+adding bar
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+marked working directory as branch mine
+adding world
+created new head
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+marked working directory as branch other
+adding bye
+created new head
+1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+% test -U -u
+abort: cannot specify both --noupdate and --updaterev
+% test -U
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 3 changesets with 3 changes to 3 files (+2 heads)
+% test -u .
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 3 changesets with 3 changes to 3 files (+2 heads)
+updating to branch mine
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% test -u 0
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 3 changesets with 3 changes to 3 files (+2 heads)
+updating to branch default
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% test -u 1
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 3 changesets with 3 changes to 3 files (+2 heads)
+updating to branch mine
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% test -u 2
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 3 changesets with 3 changes to 3 files (+2 heads)
+updating to branch other
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% test -r 0
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 3 changesets with 3 changes to 3 files (+2 heads)
+updating to branch other
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% test -r mine ... mine is ignored
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 3 changesets with 3 changes to 3 files (+2 heads)
+updating to branch other
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% test -b default
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 3 changesets with 3 changes to 3 files (+2 heads)
+updating to branch default
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% test
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+updating to branch other
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% test tip
+updating to branch other
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
More information about the Mercurial-devel
mailing list