[PATCH] branch: help misuse of hg branch to switch to an existing branch

Yuya Nishihara yuya at tcha.org
Mon Jan 11 07:30:43 CST 2010


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1263216480 -32400
# Node ID f7a0643eaf007f811f3083a34cb3055dc5267e42
# Parent  192c39586787280159ca1ee8694afa5d6f32052c
branch: help misuse of hg branch to switch to an existing branch

Maybe beginners tend to use 'hg branch EXISTING_BRANCH' instead of
'hg update EXISTING_BRANCH' as me.
If so, let's lead them to the correct place.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -430,7 +430,9 @@ def branch(ui, repo, label=None, **opts)
         if not opts.get('force') and label in repo.branchtags():
             if label not in [p.branch() for p in repo.parents()]:
                 raise util.Abort(_('a branch of the same name already exists'
-                                   ' (use --force to override)'))
+                                   ' (use --force to override)'
+                                   " (or use 'hg update' to switch "
+                                   'to an existing branch)'))
         repo.dirstate.setbranch(encoding.fromlocal(label))
         ui.status(_('marked working directory as branch %s\n') % label)
     else:


More information about the Mercurial-devel mailing list