Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 14198:8f11fd321014
commands: use util.Abort's hint some more
author | Martin Geisler <mg@aragost.com> |
---|---|
date | Thu, 05 May 2011 14:57:21 +0200 |
parents | c124341c4cea |
children | 30273f0c776b e3da95f84bcd |
comparison
equal
deleted
inserted
replaced
14197:c124341c4cea | 14198:8f11fd321014 |
---|---|
606 repo.dirstate.setbranch(label) | 606 repo.dirstate.setbranch(label) |
607 ui.status(_('reset working directory to branch %s\n') % label) | 607 ui.status(_('reset working directory to branch %s\n') % label) |
608 elif label: | 608 elif label: |
609 if not opts.get('force') and label in repo.branchtags(): | 609 if not opts.get('force') and label in repo.branchtags(): |
610 if label not in [p.branch() for p in repo.parents()]: | 610 if label not in [p.branch() for p in repo.parents()]: |
611 raise util.Abort(_('a branch of the same name already exists' | 611 raise util.Abort(_('a branch of the same name already exists'), |
612 " (use 'hg update' to switch to it)")) | 612 hint=_("use 'hg update' to switch to it")) |
613 repo.dirstate.setbranch(label) | 613 repo.dirstate.setbranch(label) |
614 ui.status(_('marked working directory as branch %s\n') % label) | 614 ui.status(_('marked working directory as branch %s\n') % label) |
615 else: | 615 else: |
616 ui.write("%s\n" % repo.dirstate.branch()) | 616 ui.write("%s\n" % repo.dirstate.branch()) |
617 | 617 |
2922 | 2922 |
2923 if not node: | 2923 if not node: |
2924 branch = repo[None].branch() | 2924 branch = repo[None].branch() |
2925 bheads = repo.branchheads(branch) | 2925 bheads = repo.branchheads(branch) |
2926 if len(bheads) > 2: | 2926 if len(bheads) > 2: |
2927 raise util.Abort(_( | 2927 raise util.Abort(_("branch '%s' has %d heads - " |
2928 "branch '%s' has %d heads - " | 2928 "please merge with an explicit rev") |
2929 "please merge with an explicit rev\n" | 2929 % (branch, len(bheads)), |
2930 "(run 'hg heads .' to see heads)") | 2930 hint=_("run 'hg heads .' to see heads")) |
2931 % (branch, len(bheads))) | |
2932 | 2931 |
2933 parent = repo.dirstate.p1() | 2932 parent = repo.dirstate.p1() |
2934 if len(bheads) == 1: | 2933 if len(bheads) == 1: |
2935 if len(repo.heads()) > 1: | 2934 if len(repo.heads()) > 1: |
2936 raise util.Abort(_( | 2935 raise util.Abort(_("branch '%s' has one head - " |
2937 "branch '%s' has one head - " | 2936 "please merge with an explicit rev") |
2938 "please merge with an explicit rev\n" | 2937 % branch, |
2939 "(run 'hg heads' to see all heads)") | 2938 hint=_("run 'hg heads' to see all heads")) |
2940 % branch) | |
2941 msg = _('there is nothing to merge') | 2939 msg = _('there is nothing to merge') |
2942 if parent != repo.lookup(repo[None].branch()): | 2940 if parent != repo.lookup(repo[None].branch()): |
2943 msg = _('%s - use "hg update" instead') % msg | 2941 msg = _('%s - use "hg update" instead') % msg |
2944 raise util.Abort(msg) | 2942 raise util.Abort(msg) |
2945 | 2943 |
2946 if parent not in bheads: | 2944 if parent not in bheads: |
2947 raise util.Abort(_('working dir not at a head rev - ' | 2945 raise util.Abort(_('working directory not at a head revision'), |
2948 'use "hg update" or merge with an explicit rev')) | 2946 hint=_("use 'hg update' or merge with an " |
2947 "explicit revision")) | |
2949 node = parent == bheads[0] and bheads[-1] or bheads[0] | 2948 node = parent == bheads[0] and bheads[-1] or bheads[0] |
2950 else: | 2949 else: |
2951 node = cmdutil.revsingle(repo, node).node() | 2950 node = cmdutil.revsingle(repo, node).node() |
2952 | 2951 |
2953 if opts.get('preview'): | 2952 if opts.get('preview'): |