[PATCH] branch: help misuse of hg branch to switch branches

Yuya Nishihara yuya at tcha.org
Tue Jan 12 07:50:25 CST 2010


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1263304150 -32400
# Node ID dd3546d401d1c45de1e53a0a06cedb9b160de785
# Parent  318d58fe4ceb49d30961cf2818df51b7434d8000
branch: help misuse of hg branch to switch branches

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

Also removed '(use --force to override)' because it can mislead them.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -430,7 +430,7 @@ 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 'hg update' to switch to it)"))
         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