annotate hgext/share.py @ 13950:14d0553bd48b

help: do not show full help text for command on option errors Example $ hg clone --jump foo bar hg clone: option --jump not recognized hg clone [OPTION]... SOURCE [DEST] make a copy of an existing repository options: -U --noupdate the clone will include an empty working copy (only a repository) -u --updaterev REV revision, tag or branch to check out -r --rev REV [+] include the specified changeset -b --branch BRANCH [+] clone only the specified branch --pull use pull protocol to copy metadata --uncompressed use uncompressed transfer (fast over LAN) -e --ssh CMD specify ssh command to use --remotecmd CMD specify hg command to run on the remote side --insecure do not verify server certificate (ignoring web.cacerts config) [+] marked option can be specified multiple times use "hg help clone" to show the full help text Motivation for this change If the user already has specified the command, he probably already knows the command to some extent. Apparently, he has a problem with the options, so we show him just the synopsis with the short help and the details about the options, with a hint on the last line how to get the full help text. Why is Mercurial better with this change? Experts who just forgot about the details of an option don't get that much text thrown at them, while the newbies still get a hint on the last line how to get the full help text.
author Adrian Buehlmann <adrian@cadifra.com>
date Sun, 17 Apr 2011 11:37:11 +0200
parents 4ac734b9b3fd
children ea96bdda593c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8801
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
1 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
2 #
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
3 # This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 10256
diff changeset
4 # GNU General Public License version 2 or any later version.
8801
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
5
8894
868670dbc237 extensions: improve the consistency of synopses
Cédric Duval <cedricduval@free.fr>
parents: 8873
diff changeset
6 '''share a common history between several working directories'''
8873
e872ef2e6758 help: add/fix docstrings for a bunch of extensions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8807
diff changeset
7
8801
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
8 from mercurial.i18n import _
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
9 from mercurial import hg, commands
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
10
8807
8bf6eb68ddaf share: allow dest to default to the basename of source
Matt Mackall <mpm@selenic.com>
parents: 8801
diff changeset
11 def share(ui, source, dest=None, noupdate=False):
10798
e46c19c586fa share: drop experimental label
Martin Geisler <mg@lazybytes.net>
parents: 10263
diff changeset
12 """create a new shared repository
8801
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
13
9273
4b8b0c124b99 share: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9075
diff changeset
14 Initialize a new repository and working directory that shares its
4b8b0c124b99 share: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9075
diff changeset
15 history with another repository.
8801
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
16
12389
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 10798
diff changeset
17 .. note::
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 10798
diff changeset
18 using rollback or extensions that destroy/modify history (mq,
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 10798
diff changeset
19 rebase, etc.) can cause considerable confusion with shared
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 10798
diff changeset
20 clones. In particular, if two shared clones are both updated to
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 10798
diff changeset
21 the same changeset, and one of them destroys that changeset
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 10798
diff changeset
22 with rollback, the other clone will suddenly stop working: all
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 10798
diff changeset
23 operations will fail with "abort: working directory has unknown
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 10798
diff changeset
24 parent". The only known workaround is to use debugsetparents on
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 10798
diff changeset
25 the broken clone to reset it to a changeset that still exists
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 10798
diff changeset
26 (e.g. tip).
8801
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
27 """
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
28
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
29 return hg.share(ui, source, dest, not noupdate)
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
30
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
31 cmdtable = {
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
32 "share":
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
33 (share,
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
34 [('U', 'noupdate', None, _('do not create a working copy'))],
8807
8bf6eb68ddaf share: allow dest to default to the basename of source
Matt Mackall <mpm@selenic.com>
parents: 8801
diff changeset
35 _('[-U] SOURCE [DEST]')),
8801
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
36 }
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
37
28eaf6f8abce share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
38 commands.norepo += " share"