commands: hg clone update priority

timeless timeless at gmail.com
Sun Mar 7 08:34:15 CST 2010


# HG changeset patch
# User timeless <timeless at gmail.com>
# Date 1267968489 -7200
# Node ID 633a866a72fbc70b6744002330b7a14f42fb0137
# Parent  b98b6a7363ae69e0538bfc605d3e056a7b444d79
commands: hg clone update priority

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -621,19 +621,17 @@ 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).
+    Mercurial will update the working directory to the first applicable
+    revision from this list ::
+
+      a) null if -U/--noupdate or source repository is empty
+      b) the parent of the source repository if it is local with -u .
+      c) the changeset or tip of the tag/branch specified with -u/--updaterev
+      d) the changeset or tip of the tag/branch specified the first -r/--rev
+      e) the tip of the branch specified with the first -b/--branch
+      f) the tip of the branch specified with the url#branch source syntax
+      g) the tip of the default branch
+      h) tip

     A set of changesets (tags, or branch names) to pull may be specified
     by listing each changeset (tag, or branch name) with -r/--rev.
@@ -649,12 +647,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
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,62 @@
+#!/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 -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,79 @@
+
+% 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 -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