[PATCH 3 of 3] clone and update to master, even if master is not on the default branch

arne_bab at web.de arne_bab at web.de
Thu Nov 3 12:11:24 UTC 2011


# HG changeset patch
# User Arne Babenhauserheide <bab at draketo.de>
# Date 1320317212 -3600
# Node ID 9a67b9b844542b79b3bd3e89773730a72107c588
# Parent  7c6ed23884fcb4f09d8133216cdc56ec150124aa
clone and update to master, even if master is not on the default branch.
set the clone branch with master.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5038,10 +5038,10 @@ def update(ui, repo, node=None, rev=None
     """update working directory (or switch revisions)
 
     Update the repository's working directory to the specified
-    changeset. If no changeset is specified, update to the tip of the
-    current named branch. If a bookmark named branch/master (just
-    master for the default branch) exists on the branch, update to
-    that bookmark instead.
+    changeset. If no changeset is specified and a bookmark named
+    master or branch/master exists on the current named branch, update
+    to that bookmark instead. If no changeset is specified and no
+    master exists, update to the tip of the current named branch.
 
     If the changeset is not a descendant of the working directory's
     parent, the update is aborted. With the -c/--check option, the
@@ -5088,10 +5088,9 @@ def update(ui, repo, node=None, rev=None
     if rev is None:
         branch = repo["."].branch()
         branchmaster = branch+"/master"
-        if branch == "default":
-            if ("master" in repo._bookmarks and
-                repo["master"].branch() == "default"):
-                rev = repo["master"].hex()
+        if ("master" in repo._bookmarks and
+            repo["master"].branch() == branch):
+            rev = repo["master"].hex()
         elif (branchmaster in repo._bookmarks and
               repo[branchmaster].branch() == branch):
             rev = repo[branchmaster].hex()
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -363,14 +363,12 @@ def clone(ui, peeropts, source, dest=Non
                     for k, n in srcrepo._bookmarks.iteritems():
                         destrepo.pushkey('bookmarks', k, '', hex(n))
 
-            # check for a master bookmark on the default branch
+            # check for a master bookmark. Clone to this even when it
+            # is not on the default branch
             try:
                 # make sure, master is a bookmark
                 master = destrepo._bookmarks['master']
                 m = destrepo['master']
-                if not m.branch() == 'default':
-                    master = None
-                print "master:", master, m
             except: master = None
 
             if update:



More information about the Mercurial-devel mailing list