mercurial/commands.py
author Jonathan Nieder <jrnieder@gmail.com>
Thu, 03 Feb 2011 00:27:44 -0600
branchstable
changeset 13340 02aa06a021a0
parent 13328 a939f08fae9c
child 13343 69e69b131458
permissions -rw-r--r--
backout: make help more explicit about what backout does The help for backout explains: The backout command merges the reverse effect of the reverted changeset into the working directory. Unfortunately, that does not make it obvious to a newcomer what the backout command does. Since it performs a 3-way merge, what is the common ancestor? Will the result be automatically committed? What is this reverted changeset --- is it the rev passed with -r on the command line or its inverse? So try to clarify the description, avoiding jargon and being explicit about what happens from the user's perspective. Thanks to Gilles Moris, Steve Borho, Kevin Bullock, and timeless for help.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
249
619e775aa7f9 import and startup cleanups
mpm@selenic.com
parents: 248
diff changeset
     1
# commands.py - command processing for mercurial
619e775aa7f9 import and startup cleanups
mpm@selenic.com
parents: 248
diff changeset
     2
#
4635
63b9d2deed48 Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4614
diff changeset
     3
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
249
619e775aa7f9 import and startup cleanups
mpm@selenic.com
parents: 248
diff changeset
     4
#
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8210
diff changeset
     5
# 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: 10224
diff changeset
     6
# GNU General Public License version 2 or any later version.
249
619e775aa7f9 import and startup cleanups
mpm@selenic.com
parents: 248
diff changeset
     7
6211
f89fd07fc51d Expand import * to allow Pyflakes to find problems
Joel Rosdahl <joel@rosdahl.net>
parents: 6210
diff changeset
     8
from node import hex, nullid, nullrev, short
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
     9
from lock import release
7013
f56e788fa292 i18n: mark help strings for translation
Martin Geisler <mg@daimi.au.dk>
parents: 7012
diff changeset
    10
from i18n import _, gettext
9678
e2b1de5fee04 remove unused imports
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9675
diff changeset
    11
import os, re, sys, difflib, time, tempfile
12273
e392d00ab5b0 incoming: move code from commands to cmdutil
Martin Geisler <mg@lazybytes.net>
parents: 12272
diff changeset
    12
import hg, util, revlog, extensions, copies, error
11301
3d0591a66118 move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11297
diff changeset
    13
import patch, help, mdiff, url, encoding, templatekw, discovery
11004
7bb10d3dbcd6 hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents: 11003
diff changeset
    14
import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server
10651
5f091fc1bab7 style: use consistent variable names (*mod) with imports which would shadow
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10650
diff changeset
    15
import merge as mergemod
11276
f28b58e35768 revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents: 11273
diff changeset
    16
import minirst, revset
11336
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
    17
import dagparser
2731
ad4155e757da Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents: 2718
diff changeset
    18
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
    19
# Commands start here, listed alphabetically
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
    20
724
1c0c413cccdd Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 723
diff changeset
    21
def add(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    22
    """add the specified files on the next commit
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    23
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
    24
    Schedule files to be version controlled and added to the
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
    25
    repository.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    26
3829
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3822
diff changeset
    27
    The files will be added to the repository at the next commit. To
11193
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
    28
    undo an add before that, see :hg:`forget`.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    29
7807
bd8f44638847 help: miscellaneous language fixes
timeless <timeless@gmail.com>
parents: 7765
diff changeset
    30
    If no names are given, add all files to the repository.
10446
a565a2445eb5 commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents: 10445
diff changeset
    31
a565a2445eb5 commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents: 10445
diff changeset
    32
    .. container:: verbose
a565a2445eb5 commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents: 10445
diff changeset
    33
a565a2445eb5 commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents: 10445
diff changeset
    34
       An example showing how new (unknown) files are added
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
    35
       automatically by :hg:`add`::
10446
a565a2445eb5 commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents: 10445
diff changeset
    36
a565a2445eb5 commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents: 10445
diff changeset
    37
         $ ls
a565a2445eb5 commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents: 10445
diff changeset
    38
         foo.c
a565a2445eb5 commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents: 10445
diff changeset
    39
         $ hg status
a565a2445eb5 commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents: 10445
diff changeset
    40
         ? foo.c
a565a2445eb5 commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents: 10445
diff changeset
    41
         $ hg add
a565a2445eb5 commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents: 10445
diff changeset
    42
         adding foo.c
a565a2445eb5 commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents: 10445
diff changeset
    43
         $ hg status
10448
6e5a47398fc5 commands: correct example in add help text
Martin Geisler <mg@lazybytes.net>
parents: 10446
diff changeset
    44
         A foo.c
11507
35e2d453cf0d commands: document return values of add and paths commands
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11488
diff changeset
    45
35e2d453cf0d commands: document return values of add and paths commands
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11488
diff changeset
    46
    Returns 0 if all files are successfully added.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    47
    """
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    48
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
    49
    m = cmdutil.match(repo, pats, opts)
12270
166b9866580a add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12269
diff changeset
    50
    rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
166b9866580a add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12269
diff changeset
    51
                           opts.get('subrepos'), prefix="")
12269
877236cdd437 add: move main part to cmdutil to make it easier to reuse
Martin Geisler <mg@lazybytes.net>
parents: 12266
diff changeset
    52
    return rejected and 1 or 0
213
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 212
diff changeset
    53
766
b444a7e053f1 Get addremove to use new walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 764
diff changeset
    54
def addremove(ui, repo, *pats, **opts):
3181
3637d5d17cbc Documentation fixes for addremove.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3172
diff changeset
    55
    """add all new files, delete all missing files
2181
690da72b0b16 deprecate addremove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2179
diff changeset
    56
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
    57
    Add all new files and remove all missing files from the
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
    58
    repository.
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
    59
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
    60
    New files are ignored if they match any of the patterns in
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
    61
    .hgignore. As with add, these changes take effect at the next
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
    62
    commit.
2958
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
    63
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
    64
    Use the -s/--similarity option to detect renamed files. With a
9249
16f4cfc69e4f commands: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9219
diff changeset
    65
    parameter greater than 0, this compares every removed file with
16f4cfc69e4f commands: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9219
diff changeset
    66
    every added file and records those similar enough as renames. This
16f4cfc69e4f commands: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9219
diff changeset
    67
    option takes a percentage between 0 (disabled) and 100 (files must
16f4cfc69e4f commands: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9219
diff changeset
    68
    be identical) as its parameter. Detecting renamed files this way
11518
8d827f4a23f1 commands: mention "hg status -C" in addremove help
Arnab Bose <hirak99@gmail.com>
parents: 11515
diff changeset
    69
    can be expensive. After using this option, :hg:`status -C` can be
8d827f4a23f1 commands: mention "hg status -C" in addremove help
Arnab Bose <hirak99@gmail.com>
parents: 11515
diff changeset
    70
    used to check which files were identified as moved or renamed.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
    71
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
    72
    Returns 0 if all files are successfully added.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    73
    """
4966
8d982aef0be1 addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents: 4950
diff changeset
    74
    try:
11551
4484a7b661f2 commands: addremove does similarity 100 by default
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11525
diff changeset
    75
        sim = float(opts.get('similarity') or 100)
4966
8d982aef0be1 addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents: 4950
diff changeset
    76
    except ValueError:
8d982aef0be1 addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents: 4950
diff changeset
    77
        raise util.Abort(_('similarity must be a number'))
2958
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
    78
    if sim < 0 or sim > 100:
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
    79
        raise util.Abort(_('similarity must be between 0 and 100'))
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
    80
    return cmdutil.addremove(repo, pats, opts, similarity=sim / 100.0)
219
8ff4532376a4 hg checkout: refuse to checkout if there are outstanding changes
mpm@selenic.com
parents: 214
diff changeset
    81
733
1966c553f652 Convert annotate over to walk interface.
Bryan O'Sullivan <bos@serpentine.com>
parents: 732
diff changeset
    82
def annotate(ui, repo, *pats, **opts):
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
    83
    """show changeset information by line for each file
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    84
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
    85
    List changes in files, showing the revision id responsible for
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
    86
    each line
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
    87
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
    88
    This command is useful for discovering when a change was made and
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
    89
    by whom.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    90
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
    91
    Without the -a/--text option, annotate will avoid processing files
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
    92
    it detects as binary. With -a, annotate will annotate the file
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
    93
    anyway, although the results will probably be neither useful
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
    94
    nor desirable.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
    95
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
    96
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    97
    """
10579
f142fa3c0a8c Make annotate --follow an alias for -f/--file to behave like in older versions
Thomas Arendsen Hein <thomas@intevation.de>
parents: 10564
diff changeset
    98
    if opts.get('follow'):
f142fa3c0a8c Make annotate --follow an alias for -f/--file to behave like in older versions
Thomas Arendsen Hein <thomas@intevation.de>
parents: 10564
diff changeset
    99
        # --follow is deprecated and now just an alias for -f/--file
f142fa3c0a8c Make annotate --follow an alias for -f/--file to behave like in older versions
Thomas Arendsen Hein <thomas@intevation.de>
parents: 10564
diff changeset
   100
        # to mimic the behavior of Mercurial before version 1.5
f142fa3c0a8c Make annotate --follow an alias for -f/--file to behave like in older versions
Thomas Arendsen Hein <thomas@intevation.de>
parents: 10564
diff changeset
   101
        opts['file'] = 1
f142fa3c0a8c Make annotate --follow an alias for -f/--file to behave like in older versions
Thomas Arendsen Hein <thomas@intevation.de>
parents: 10564
diff changeset
   102
6134
7b937b26adf7 Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6133
diff changeset
   103
    datefunc = ui.quiet and util.shortdate or util.datestr
7b937b26adf7 Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6133
diff changeset
   104
    getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
1522
d07d729ce306 Added --date option to annotate.
lupus@debian.org
parents: 1519
diff changeset
   105
744
3d88f6dd1ed4 Handle empty file list for annotate
mpm@selenic.com
parents: 743
diff changeset
   106
    if not pats:
8761
0289f384e1e5 Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents: 8760
diff changeset
   107
        raise util.Abort(_('at least one filename or pattern is required'))
744
3d88f6dd1ed4 Handle empty file list for annotate
mpm@selenic.com
parents: 743
diff changeset
   108
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   109
    opmap = [('user', lambda x: ui.shortuser(x[0].user())),
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   110
             ('number', lambda x: str(x[0].rev())),
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   111
             ('changeset', lambda x: short(x[0].node())),
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   112
             ('date', getdate),
10369
98a0421b9e52 commands: annotate follows by default, separate -f/--file option
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10365
diff changeset
   113
             ('file', lambda x: x[0].path()),
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   114
            ]
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   115
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
   116
    if (not opts.get('user') and not opts.get('changeset')
10369
98a0421b9e52 commands: annotate follows by default, separate -f/--file option
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10365
diff changeset
   117
        and not opts.get('date') and not opts.get('file')):
714
29fcd195e056 Some cleanups in commands.annotate().
Thomas Arendsen Hein <thomas@intevation.de>
parents: 712
diff changeset
   118
        opts['number'] = 1
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
   119
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   120
    linenumber = opts.get('line_number') is not None
10394
4612cded5176 fix coding style (reported by pylint)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10390
diff changeset
   121
    if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   122
        raise util.Abort(_('at least one of -n/-c is required for -l'))
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   123
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   124
    funcmap = [func for op, func in opmap if opts.get(op)]
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   125
    if linenumber:
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   126
        lastfunc = funcmap[-1]
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   127
        funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   128
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   129
    ctx = repo[opts.get('rev')]
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
   130
    m = cmdutil.match(repo, pats, opts)
10369
98a0421b9e52 commands: annotate follows by default, separate -f/--file option
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10365
diff changeset
   131
    follow = not opts.get('no_follow')
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
   132
    for abs in ctx.walk(m):
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
   133
        fctx = ctx[abs]
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   134
        if not opts.get('text') and util.binary(fctx.data()):
6584
29c77e5dfb3c walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents: 6583
diff changeset
   135
            ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
1016
836667830fee Teach annotate about binary files
mpm@selenic.com
parents: 1015
diff changeset
   136
            continue
836667830fee Teach annotate about binary files
mpm@selenic.com
parents: 1015
diff changeset
   137
10369
98a0421b9e52 commands: annotate follows by default, separate -f/--file option
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10365
diff changeset
   138
        lines = fctx.annotate(follow=follow, linenumber=linenumber)
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
   139
        pieces = []
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
   140
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   141
        for f in funcmap:
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   142
            l = [f(n) for n, dummy in lines]
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   143
            if l:
11611
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
   144
                sized = [(x, encoding.colwidth(x)) for x in l]
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
   145
                ml = max([w for x, w in sized])
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
   146
                pieces.append(["%s%s" % (' ' * (ml - w), x) for x, w in sized])
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
   147
771
0de223012086 Fixes for annotate
mpm@selenic.com
parents: 770
diff changeset
   148
        if pieces:
0de223012086 Fixes for annotate
mpm@selenic.com
parents: 770
diff changeset
   149
            for p, l in zip(zip(*pieces), lines):
0de223012086 Fixes for annotate
mpm@selenic.com
parents: 770
diff changeset
   150
                ui.write("%s: %s" % (" ".join(p), l[1]))
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
   151
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   152
def archive(ui, repo, dest, **opts):
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   153
    '''create an unversioned archive of a repository revision
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   154
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   155
    By default, the revision used is the parent of the working
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
   156
    directory; use -r/--rev to specify a different revision.
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
   157
10650
9ea7238ad935 archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents: 10649
diff changeset
   158
    The archive type is automatically detected based on file
9ea7238ad935 archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents: 10649
diff changeset
   159
    extension (or override using -t/--type).
9ea7238ad935 archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents: 10649
diff changeset
   160
9ea7238ad935 archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents: 10649
diff changeset
   161
    Valid types are:
9892
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
   162
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
   163
    :``files``: a directory full of files (default)
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
   164
    :``tar``:   tar archive, uncompressed
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
   165
    :``tbz2``:  tar archive, compressed using bzip2
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
   166
    :``tgz``:   tar archive, compressed using gzip
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
   167
    :``uzip``:  zip archive, uncompressed
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
   168
    :``zip``:   zip archive, compressed using deflate
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   169
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   170
    The exact name of the destination archive or directory is given
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
   171
    using a format string; see :hg:`help export` for details.
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   172
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   173
    Each member added to an archive file has a directory prefix
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
   174
    prepended. Use -p/--prefix to specify a format string for the
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
   175
    prefix. The default is the basename of the archive, with suffixes
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
   176
    removed.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   178
    Returns 0 on success.
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   179
    '''
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   180
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   181
    ctx = repo[opts.get('rev')]
5061
a49f2a4d5ff7 archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents: 4966
diff changeset
   182
    if not ctx:
7528
eadcc075967e archive: fix bogus error message with no working directory
Matt Mackall <mpm@selenic.com>
parents: 7527
diff changeset
   183
        raise util.Abort(_('no working directory: please specify a revision'))
5061
a49f2a4d5ff7 archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents: 4966
diff changeset
   184
    node = ctx.node()
2874
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2871
diff changeset
   185
    dest = cmdutil.make_filename(repo, dest, node)
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   186
    if os.path.realpath(dest) == repo.root:
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   187
        raise util.Abort(_('repository root cannot be destination'))
10650
9ea7238ad935 archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents: 10649
diff changeset
   188
11557
57bdc2239535 archival: move commands.archive.guess_type to archival.guesskind
Martin Geisler <mg@lazybytes.net>
parents: 11551
diff changeset
   189
    kind = opts.get('type') or archival.guesskind(dest) or 'files'
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   190
    prefix = opts.get('prefix')
10650
9ea7238ad935 archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents: 10649
diff changeset
   191
2476
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
   192
    if dest == '-':
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
   193
        if kind == 'files':
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
   194
            raise util.Abort(_('cannot archive plain files to stdout'))
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
   195
        dest = sys.stdout
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
   196
        if not prefix:
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
   197
            prefix = os.path.basename(repo.root) + '-%h'
10650
9ea7238ad935 archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents: 10649
diff changeset
   198
2874
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2871
diff changeset
   199
    prefix = cmdutil.make_filename(repo, prefix, node)
10650
9ea7238ad935 archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents: 10649
diff changeset
   200
    matchfn = cmdutil.match(repo, [], opts)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   201
    archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
12323
f00953d9533c subrepo: add support for 'hg archive'
Martin Geisler <mg@aragost.com>
parents: 12274
diff changeset
   202
                     matchfn, prefix, subrepos=opts.get('subrepos'))
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   203
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
   204
def backout(ui, repo, node=None, rev=None, **opts):
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   205
    '''reverse effect of earlier changeset
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   206
13340
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   207
    Prepare a new changeset with the effect of REV undone in the
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   208
    current working directory.
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   209
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   210
    If REV is the parent of the working directory, then this changeset
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   211
    is committed automatically. Otherwise, hg needs to merge the
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   212
    changes and the merged result is left uncommitted.
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   213
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   214
    By default, the pending changeset will have one parent,
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   215
    maintaining a linear history. With --merge, the pending changeset
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   216
    will instead have two parents: the old parent of the working
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   217
    directory and a child of REV that simply undoes REV.
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   218
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   219
    Before version 1.7, the default behavior was equivalent to
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   220
    specifying --merge followed by :hg:`update --clean .` to cancel
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   221
    the merge and leave the child of REV as a head to be merged
02aa06a021a0 backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents: 13328
diff changeset
   222
    separately.
6163
1f733c2f0165 Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6161
diff changeset
   223
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
   224
    See :hg:`help dates` for a list of formats valid for -d/--date.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   225
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   226
    Returns 0 on success.
6163
1f733c2f0165 Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6161
diff changeset
   227
    '''
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
   228
    if rev and node:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
   229
        raise util.Abort(_("please specify just one revision"))
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
   230
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
   231
    if not rev:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
   232
        rev = node
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   233
4726
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4718
diff changeset
   234
    if not rev:
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4718
diff changeset
   235
        raise util.Abort(_("please specify a revision to backout"))
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4718
diff changeset
   236
6139
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
   237
    date = opts.get('date')
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
   238
    if date:
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
   239
        opts['date'] = util.parsedate(date)
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
   240
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
   241
    cmdutil.bail_if_changed(repo)
5716
be367cbafe70 cmdutil: make bail_if_changed bail on uncommitted merge
Matt Mackall <mpm@selenic.com>
parents: 5688
diff changeset
   242
    node = repo.lookup(rev)
be367cbafe70 cmdutil: make bail_if_changed bail on uncommitted merge
Matt Mackall <mpm@selenic.com>
parents: 5688
diff changeset
   243
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   244
    op1, op2 = repo.dirstate.parents()
5568
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 5542
diff changeset
   245
    a = repo.changelog.ancestor(op1, node)
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 5542
diff changeset
   246
    if a != node:
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   247
        raise util.Abort(_('cannot backout change on a different branch'))
5568
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 5542
diff changeset
   248
2614
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
   249
    p1, p2 = repo.changelog.parents(node)
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
   250
    if p1 == nullid:
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   251
        raise util.Abort(_('cannot backout a change with no parents'))
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   252
    if p2 != nullid:
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   253
        if not opts.get('parent'):
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   254
            raise util.Abort(_('cannot backout a merge changeset without '
2614
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
   255
                               '--parent'))
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
   256
        p = repo.lookup(opts['parent'])
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
   257
        if p not in (p1, p2):
3679
2956948b81f3 fix warnings generated by pygettext.py.
Marcos Chaves <marcos.nospam@gmail.com>
parents: 3673
diff changeset
   258
            raise util.Abort(_('%s is not a parent of %s') %
3680
69cf255a55a1 Indentation cleanups for 2956948b81f3.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3679
diff changeset
   259
                             (short(p), short(node)))
2614
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
   260
        parent = p
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
   261
    else:
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   262
        if opts.get('parent'):
2614
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
   263
            raise util.Abort(_('cannot use --parent on non-merge changeset'))
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
   264
        parent = p1
5568
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 5542
diff changeset
   265
6423
fb374b1b3911 backout: reverse changeset belongs on current branch
Matt Mackall <mpm@selenic.com>
parents: 6385
diff changeset
   266
    # the backout should appear on the same branch
fb374b1b3911 backout: reverse changeset belongs on current branch
Matt Mackall <mpm@selenic.com>
parents: 6385
diff changeset
   267
    branch = repo.dirstate.branch()
2808
30f59f4a327e Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents: 2806
diff changeset
   268
    hg.clean(repo, node, show_stats=False)
6423
fb374b1b3911 backout: reverse changeset belongs on current branch
Matt Mackall <mpm@selenic.com>
parents: 6385
diff changeset
   269
    repo.dirstate.setbranch(branch)
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   270
    revert_opts = opts.copy()
3814
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
   271
    revert_opts['date'] = None
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
   272
    revert_opts['all'] = True
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   273
    revert_opts['rev'] = hex(parent)
6031
7383384793fb revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6030
diff changeset
   274
    revert_opts['no_backup'] = None
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   275
    revert(ui, repo, **revert_opts)
12727
52971985be14 backout: provide linear backout as a default (without --merge option)
Gilles Moris <gilles.moris@free.fr>
parents: 12726
diff changeset
   276
    if not opts.get('merge') and op1 != node:
12810
a68ccfd9c7be backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents: 12809
diff changeset
   277
        try:
a68ccfd9c7be backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents: 12809
diff changeset
   278
            ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
a68ccfd9c7be backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents: 12809
diff changeset
   279
            return hg.update(repo, op1)
a68ccfd9c7be backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents: 12809
diff changeset
   280
        finally:
a68ccfd9c7be backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents: 12809
diff changeset
   281
            ui.setconfig('ui', 'forcemerge', '')
12727
52971985be14 backout: provide linear backout as a default (without --merge option)
Gilles Moris <gilles.moris@free.fr>
parents: 12726
diff changeset
   282
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   283
    commit_opts = opts.copy()
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   284
    commit_opts['addremove'] = False
2159
5c34b98ad6b1 Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2158
diff changeset
   285
    if not commit_opts['message'] and not commit_opts['logfile']:
9183
d0225fa2f6c4 do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents: 9128
diff changeset
   286
        # we don't translate commit messages
9197
a05aa192a00a commands: remove ineffective parenthesis
Martin Geisler <mg@lazybytes.net>
parents: 9196
diff changeset
   287
        commit_opts['message'] = "Backed out changeset %s" % short(node)
2268
6c9305fbebaf fix coding style of backout editor change.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2267
diff changeset
   288
        commit_opts['force_editor'] = True
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   289
    commit(ui, repo, **commit_opts)
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   290
    def nice(node):
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   291
        return '%d:%s' % (repo.changelog.rev(node), short(node))
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   292
    ui.status(_('changeset %s backs out changeset %s\n') %
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   293
              (nice(repo.changelog.tip()), nice(node)))
12727
52971985be14 backout: provide linear backout as a default (without --merge option)
Gilles Moris <gilles.moris@free.fr>
parents: 12726
diff changeset
   294
    if opts.get('merge') and op1 != node:
6161
bc1ba9124799 Reverse the way backout is doing the merge
Gilles Moris <gilles.moris@free.fr>
parents: 6146
diff changeset
   295
        hg.clean(repo, op1, show_stats=False)
12727
52971985be14 backout: provide linear backout as a default (without --merge option)
Gilles Moris <gilles.moris@free.fr>
parents: 12726
diff changeset
   296
        ui.status(_('merging with changeset %s\n')
52971985be14 backout: provide linear backout as a default (without --merge option)
Gilles Moris <gilles.moris@free.fr>
parents: 12726
diff changeset
   297
                  % nice(repo.changelog.tip()))
12810
a68ccfd9c7be backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents: 12809
diff changeset
   298
        try:
a68ccfd9c7be backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents: 12809
diff changeset
   299
            ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
a68ccfd9c7be backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents: 12809
diff changeset
   300
            return hg.merge(repo, hex(repo.changelog.tip()))
a68ccfd9c7be backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents: 12809
diff changeset
   301
        finally:
a68ccfd9c7be backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents: 12809
diff changeset
   302
            ui.setconfig('ui', 'forcemerge', '')
12727
52971985be14 backout: provide linear backout as a default (without --merge option)
Gilles Moris <gilles.moris@free.fr>
parents: 12726
diff changeset
   303
    return 0
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   304
7227
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   305
def bisect(ui, repo, rev=None, extra=None, command=None,
5775
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   306
               reset=None, good=None, bad=None, skip=None, noupdate=None):
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   307
    """subdivision search of changesets
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   308
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
   309
    This command helps to find changesets which introduce problems. To
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
   310
    use, mark the earliest changeset you know exhibits the problem as
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
   311
    bad, then mark the latest changeset which is free from the problem
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
   312
    as good. Bisect will update your working directory to a revision
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
   313
    for testing (unless the -U/--noupdate option is specified). Once
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   314
    you have performed tests, mark the working directory as good or
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   315
    bad, and bisect will either update to another candidate changeset
6928
1a4c66d741a2 bisect: expand help text to explain REV argument and --noupdate
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6858
diff changeset
   316
    or announce that it has found the bad revision.
7184
380fda3eed13 clean up trailing spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7037
diff changeset
   317
6928
1a4c66d741a2 bisect: expand help text to explain REV argument and --noupdate
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6858
diff changeset
   318
    As a shortcut, you can also use the revision argument to mark a
1a4c66d741a2 bisect: expand help text to explain REV argument and --noupdate
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6858
diff changeset
   319
    revision as good or bad without checking it out first.
7227
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   320
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   321
    If you supply a command, it will be used for automatic bisection.
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   322
    Its exit status will be used to mark revisions as good or bad:
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   323
    status 0 means good, 125 means to skip the revision, 127
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   324
    (command not found) will abort the bisection, and any other
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   325
    non-zero exit status means the revision is bad.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   326
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   327
    Returns 0 on success.
5775
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   328
    """
7227
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   329
    def print_result(nodes, good):
5775
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   330
        displayer = cmdutil.show_changeset(ui, repo, {})
6858
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   331
        if len(nodes) == 1:
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   332
            # narrowed it down to a single revision
8088
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   333
            if good:
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   334
                ui.write(_("The first good revision is:\n"))
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   335
            else:
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   336
                ui.write(_("The first bad revision is:\n"))
7369
87158be081b8 cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7364
diff changeset
   337
            displayer.show(repo[nodes[0]])
12178
1ef9b0b5efec bisect: warn about ending on a merge with only one side marked
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12177
diff changeset
   338
            parents = repo[nodes[0]].parents()
1ef9b0b5efec bisect: warn about ending on a merge with only one side marked
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12177
diff changeset
   339
            if len(parents) > 1:
12179
1447d3a9ff4a check-code: fix ternary expression introduced in 1ef9b0b5efec
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12178
diff changeset
   340
                side = good and state['bad'] or state['good']
12178
1ef9b0b5efec bisect: warn about ending on a merge with only one side marked
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12177
diff changeset
   341
                num = len(set(i.node() for i in parents) & set(side))
1ef9b0b5efec bisect: warn about ending on a merge with only one side marked
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12177
diff changeset
   342
                if num == 1:
1ef9b0b5efec bisect: warn about ending on a merge with only one side marked
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12177
diff changeset
   343
                    common = parents[0].ancestor(parents[1])
1ef9b0b5efec bisect: warn about ending on a merge with only one side marked
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12177
diff changeset
   344
                    ui.write(_('Not all ancestors of this changeset have been'
1ef9b0b5efec bisect: warn about ending on a merge with only one side marked
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12177
diff changeset
   345
                               ' checked.\nTo check the other ancestors, start'
1ef9b0b5efec bisect: warn about ending on a merge with only one side marked
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12177
diff changeset
   346
                               ' from the common ancestor, %s.\n' % common))
6858
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   347
        else:
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   348
            # multiple possible revisions
8088
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   349
            if good:
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   350
                ui.write(_("Due to skipped revisions, the first "
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   351
                        "good revision could be any of:\n"))
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   352
            else:
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   353
                ui.write(_("Due to skipped revisions, the first "
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   354
                        "bad revision could be any of:\n"))
6858
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   355
            for n in nodes:
7369
87158be081b8 cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7364
diff changeset
   356
                displayer.show(repo[n])
10152
56284451a22c Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents: 10111
diff changeset
   357
        displayer.close()
7227
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   358
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   359
    def check_state(state, interactive=True):
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   360
        if not state['good'] or not state['bad']:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   361
            if (good or bad or skip or reset) and interactive:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   362
                return
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   363
            if not state['good']:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   364
                raise util.Abort(_('cannot bisect (no known good revisions)'))
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   365
            else:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   366
                raise util.Abort(_('cannot bisect (no known bad revisions)'))
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   367
        return True
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   368
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   369
    # backward compatibility
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   370
    if rev in "good bad reset init".split():
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   371
        ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   372
        cmd, rev, extra = rev, extra, None
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   373
        if cmd == "good":
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   374
            good = True
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   375
        elif cmd == "bad":
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   376
            bad = True
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   377
        else:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   378
            reset = True
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   379
    elif extra or good + bad + skip + reset + bool(command) > 1:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   380
        raise util.Abort(_('incompatible arguments'))
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   381
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   382
    if reset:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   383
        p = repo.join("bisect.state")
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   384
        if os.path.exists(p):
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   385
            os.unlink(p)
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   386
        return
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   387
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   388
    state = hbisect.load_state(repo)
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   389
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   390
    if command:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   391
        changesets = 1
7590
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   392
        try:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   393
            while changesets:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   394
                # update state
9584
17da88da1abd bisect: use util.system and fix good/bad when using -c
Matt Mackall <mpm@selenic.com>
parents: 9569
diff changeset
   395
                status = util.system(command)
7590
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   396
                if status == 125:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   397
                    transition = "skip"
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   398
                elif status == 0:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   399
                    transition = "good"
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   400
                # status < 0 means process was killed
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   401
                elif status == 127:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   402
                    raise util.Abort(_("failed to execute %s") % command)
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   403
                elif status < 0:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   404
                    raise util.Abort(_("%s killed") % command)
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   405
                else:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   406
                    transition = "bad"
8805
2726a6df11e9 bisect: improve --command output
Patrick Mezard <pmezard@gmail.com>
parents: 8802
diff changeset
   407
                ctx = repo[rev or '.']
2726a6df11e9 bisect: improve --command output
Patrick Mezard <pmezard@gmail.com>
parents: 8802
diff changeset
   408
                state[transition].append(ctx.node())
2726a6df11e9 bisect: improve --command output
Patrick Mezard <pmezard@gmail.com>
parents: 8802
diff changeset
   409
                ui.status(_('Changeset %d:%s: %s\n') % (ctx, ctx, transition))
7590
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   410
                check_state(state, interactive=False)
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   411
                # bisect
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   412
                nodes, changesets, good = hbisect.bisect(repo.changelog, state)
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   413
                # update to next check
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   414
                cmdutil.bail_if_changed(repo)
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   415
                hg.clean(repo, nodes[0], show_stats=False)
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   416
        finally:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   417
            hbisect.save_state(repo, state)
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   418
        print_result(nodes, good)
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   419
        return
7227
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   420
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   421
    # update state
12177
80399b5b5f13 bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12173
diff changeset
   422
80399b5b5f13 bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12173
diff changeset
   423
    if rev:
80399b5b5f13 bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12173
diff changeset
   424
        nodes = [repo.lookup(i) for i in cmdutil.revrange(repo, [rev])]
80399b5b5f13 bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12173
diff changeset
   425
    else:
80399b5b5f13 bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12173
diff changeset
   426
        nodes = [repo.lookup('.')]
80399b5b5f13 bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12173
diff changeset
   427
9689
57cee011ffcb bisect: no need to save the state if it wasn't changed
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9687
diff changeset
   428
    if good or bad or skip:
57cee011ffcb bisect: no need to save the state if it wasn't changed
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9687
diff changeset
   429
        if good:
12177
80399b5b5f13 bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12173
diff changeset
   430
            state['good'] += nodes
9689
57cee011ffcb bisect: no need to save the state if it wasn't changed
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9687
diff changeset
   431
        elif bad:
12177
80399b5b5f13 bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12173
diff changeset
   432
            state['bad'] += nodes
9689
57cee011ffcb bisect: no need to save the state if it wasn't changed
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9687
diff changeset
   433
        elif skip:
12177
80399b5b5f13 bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12173
diff changeset
   434
            state['skip'] += nodes
9689
57cee011ffcb bisect: no need to save the state if it wasn't changed
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9687
diff changeset
   435
        hbisect.save_state(repo, state)
7227
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   436
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   437
    if not check_state(state):
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   438
        return
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   439
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   440
    # actually bisect
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   441
    nodes, changesets, good = hbisect.bisect(repo.changelog, state)
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   442
    if changesets == 0:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   443
        print_result(nodes, good)
6858
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   444
    else:
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   445
        assert len(nodes) == 1 # only a single node can be tested next
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   446
        node = nodes[0]
5775
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   447
        # compute the approximate number of remaining tests
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   448
        tests, size = 0, 2
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   449
        while size <= changesets:
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   450
            tests, size = tests + 1, size * 2
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   451
        rev = repo.changelog.rev(node)
9012
ada93c6bf554 bisect: fix format specifiers for integers
Cédric Duval <cedricduval@free.fr>
parents: 8995
diff changeset
   452
        ui.write(_("Testing changeset %d:%s "
ada93c6bf554 bisect: fix format specifiers for integers
Cédric Duval <cedricduval@free.fr>
parents: 8995
diff changeset
   453
                   "(%d changesets remaining, ~%d tests)\n")
6217
fe8dbbe9520d Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
Joel Rosdahl <joel@rosdahl.net>
parents: 6212
diff changeset
   454
                 % (rev, short(node), changesets, tests))
5775
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   455
        if not noupdate:
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   456
            cmdutil.bail_if_changed(repo)
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   457
            return hg.clean(repo, node)
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   458
4202
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4200
diff changeset
   459
def branch(ui, repo, label=None, **opts):
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   460
    """set or show the current branch name
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   461
4601
e69da61e467e Notify the user that hg branch does not create a branch until commit
Brendan Cully <brendan@kublai.com>
parents: 4593
diff changeset
   462
    With no argument, show the current branch name. With one argument,
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   463
    set the working directory branch name (the branch will not exist
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   464
    in the repository until the next commit). Standard practice
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   465
    recommends that primary development take place on the 'default'
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   466
    branch.
4202
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4200
diff changeset
   467
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
   468
    Unless -f/--force is specified, branch will not let you set a
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   469
    branch name that already exists, even if it's inactive.
5999
d1fe1a4eb2b7 Mention 'hg update' to switch branches in help for branch and branches.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5998
diff changeset
   470
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
   471
    Use -C/--clean to reset the working directory branch to that of
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
   472
    the parent of the working directory, negating a previous branch
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
   473
    change.
7006
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
   474
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
   475
    Use the command :hg:`update` to switch to an existing branch. Use
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
   476
    :hg:`commit --close-branch` to mark this branch as closed.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   477
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   478
    Returns 0 on success.
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   479
    """
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   480
7006
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
   481
    if opts.get('clean'):
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
   482
        label = repo[None].parents()[0].branch()
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
   483
        repo.dirstate.setbranch(label)
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
   484
        ui.status(_('reset working directory to branch %s\n') % label)
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
   485
    elif label:
10315
be324d31b6c5 commands: label from user is in local encoding
Steve Borho <steve@borho.org>
parents: 10269
diff changeset
   486
        utflabel = encoding.fromlocal(label)
be324d31b6c5 commands: label from user is in local encoding
Steve Borho <steve@borho.org>
parents: 10269
diff changeset
   487
        if not opts.get('force') and utflabel in repo.branchtags():
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
   488
            if label not in [p.branch() for p in repo.parents()]:
4202
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4200
diff changeset
   489
                raise util.Abort(_('a branch of the same name already exists'
10596
7648f32713f2 branch: help misuse of hg branch to switch branches
Yuya Nishihara <yuya@tcha.org>
parents: 10579
diff changeset
   490
                                   " (use 'hg update' to switch to it)"))
10315
be324d31b6c5 commands: label from user is in local encoding
Steve Borho <steve@borho.org>
parents: 10269
diff changeset
   491
        repo.dirstate.setbranch(utflabel)
4601
e69da61e467e Notify the user that hg branch does not create a branch until commit
Brendan Cully <brendan@kublai.com>
parents: 4593
diff changeset
   492
        ui.status(_('marked working directory as branch %s\n') % label)
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   493
    else:
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
   494
        ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch()))
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   495
8991
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
   496
def branches(ui, repo, active=False, closed=False):
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   497
    """list repository named branches
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   498
4675
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
   499
    List the repository's named branches, indicating which ones are
8991
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
   500
    inactive. If -c/--closed is specified, also list branches which have
11193
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
   501
    been marked closed (see :hg:`commit --close-branch`).
8991
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
   502
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
   503
    If -a/--active is specified, only show active branches. A branch
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
   504
    is considered active if it contains repository heads.
5999
d1fe1a4eb2b7 Mention 'hg update' to switch branches in help for branch and branches.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5998
diff changeset
   505
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
   506
    Use the command :hg:`update` to switch to an existing branch.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   507
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   508
    Returns 0.
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   509
    """
8991
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
   510
6631
a2b13cac0922 Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6625
diff changeset
   511
    hexfunc = ui.debugflag and hex or short
9675
ee913987e4b0 localrepo/branchcache: remove lbranchmap(), convert users to use utf-8 names
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9665
diff changeset
   512
    activebranches = [repo[n].branch() for n in repo.heads()]
8796
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
   513
    def testactive(tag, node):
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
   514
        realhead = tag in activebranches
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
   515
        open = node in repo.branchheads(tag, closed=False)
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
   516
        return realhead and open
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
   517
    branches = sorted([(testactive(tag, node), repo.changelog.rev(node), tag)
8210
344751cd8cb8 replace various uses of list.reverse()
Matt Mackall <mpm@selenic.com>
parents: 8209
diff changeset
   518
                          for tag, node in repo.branchtags().items()],
344751cd8cb8 replace various uses of list.reverse()
Matt Mackall <mpm@selenic.com>
parents: 8209
diff changeset
   519
                      reverse=True)
6631
a2b13cac0922 Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6625
diff changeset
   520
a2b13cac0922 Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6625
diff changeset
   521
    for isactive, node, tag in branches:
a2b13cac0922 Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6625
diff changeset
   522
        if (not active) or isactive:
9675
ee913987e4b0 localrepo/branchcache: remove lbranchmap(), convert users to use utf-8 names
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9665
diff changeset
   523
            encodedtag = encoding.tolocal(tag)
4675
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
   524
            if ui.quiet:
9675
ee913987e4b0 localrepo/branchcache: remove lbranchmap(), convert users to use utf-8 names
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9665
diff changeset
   525
                ui.write("%s\n" % encodedtag)
4675
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
   526
            else:
7656
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   527
                hn = repo.lookup(node)
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   528
                if isactive:
11969
52ec5c813723 color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 11941
diff changeset
   529
                    label = 'branches.active'
7656
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   530
                    notice = ''
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   531
                elif hn not in repo.branchheads(tag, closed=False):
8991
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
   532
                    if not closed:
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
   533
                        continue
11969
52ec5c813723 color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 11941
diff changeset
   534
                    label = 'branches.closed'
9951
9b626a63f556 commands: mark strings for translation
Martin Geisler <mg@lazybytes.net>
parents: 9894
diff changeset
   535
                    notice = _(' (closed)')
7656
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   536
                else:
11969
52ec5c813723 color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 11941
diff changeset
   537
                    label = 'branches.inactive'
9951
9b626a63f556 commands: mark strings for translation
Martin Geisler <mg@lazybytes.net>
parents: 9894
diff changeset
   538
                    notice = _(' (inactive)')
11969
52ec5c813723 color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 11941
diff changeset
   539
                if tag == repo.dirstate.branch():
52ec5c813723 color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 11941
diff changeset
   540
                    label = 'branches.current'
9675
ee913987e4b0 localrepo/branchcache: remove lbranchmap(), convert users to use utf-8 names
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9665
diff changeset
   541
                rev = str(node).rjust(31 - encoding.colwidth(encodedtag))
11969
52ec5c813723 color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 11941
diff changeset
   542
                rev = ui.label('%s:%s' % (rev, hexfunc(hn)), 'log.changeset')
52ec5c813723 color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 11941
diff changeset
   543
                encodedtag = ui.label(encodedtag, label)
52ec5c813723 color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 11941
diff changeset
   544
                ui.write("%s %s%s\n" % (encodedtag, rev, notice))
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   545
2494
73ac95671788 push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2493
diff changeset
   546
def bundle(ui, repo, fname, dest=None, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   547
    """create a changegroup file
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   548
3511
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3510
diff changeset
   549
    Generate a compressed changegroup file collecting changesets not
7807
bd8f44638847 help: miscellaneous language fixes
timeless <timeless@gmail.com>
parents: 7765
diff changeset
   550
    known to be in another repository.
3511
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3510
diff changeset
   551
10376
a2950e053614 help: Improved body text
timeless <timeless@mozdev.org>
parents: 10375
diff changeset
   552
    If you omit the destination repository, then hg assumes the
a2950e053614 help: Improved body text
timeless <timeless@mozdev.org>
parents: 10375
diff changeset
   553
    destination will have all the nodes you specify with --base
6448
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
   554
    parameters. To create a bundle containing all changesets, use
8903
d403cf4eb32d help: describe bundle compression methods (issue1523)
Henrik Stuart <hg@hstuart.dk>
parents: 8902
diff changeset
   555
    -a/--all (or --base null).
d403cf4eb32d help: describe bundle compression methods (issue1523)
Henrik Stuart <hg@hstuart.dk>
parents: 8902
diff changeset
   556
8958
8358cf63f612 commands: improve bundle compression methods description
Stefano Mioli <jstevie@gmail.com>
parents: 8955
diff changeset
   557
    You can change compression method with the -t/--type option.
8358cf63f612 commands: improve bundle compression methods description
Stefano Mioli <jstevie@gmail.com>
parents: 8955
diff changeset
   558
    The available compression methods are: none, bzip2, and
8903
d403cf4eb32d help: describe bundle compression methods (issue1523)
Henrik Stuart <hg@hstuart.dk>
parents: 8902
diff changeset
   559
    gzip (by default, bundles are compressed using bzip2).
3511
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3510
diff changeset
   560
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
   561
    The bundle file can then be transferred using conventional means
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
   562
    and applied to another repository with the unbundle or pull
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
   563
    command. This is useful when direct push and pull are not
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
   564
    available or when exporting an entire repository is undesirable.
3511
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3510
diff changeset
   565
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3510
diff changeset
   566
    Applying bundles preserves all changeset contents including
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3510
diff changeset
   567
    permissions, copy/rename information, and revision history.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   568
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   569
    Returns 0 on success, 1 if no changes found.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   570
    """
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   571
    revs = opts.get('rev') or None
6171
73b1de288801 Add --all option to bundle command
John Mulligan <phlogistonjohn@yahoo.com>
parents: 6163
diff changeset
   572
    if opts.get('all'):
73b1de288801 Add --all option to bundle command
John Mulligan <phlogistonjohn@yahoo.com>
parents: 6163
diff changeset
   573
        base = ['null']
73b1de288801 Add --all option to bundle command
John Mulligan <phlogistonjohn@yahoo.com>
parents: 6163
diff changeset
   574
    else:
73b1de288801 Add --all option to bundle command
John Mulligan <phlogistonjohn@yahoo.com>
parents: 6163
diff changeset
   575
        base = opts.get('base')
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   576
    if base:
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   577
        if dest:
8669
6f0f69da003e commands: typo in bundle abort message
Martin Geisler <mg@lazybytes.net>
parents: 8664
diff changeset
   578
            raise util.Abort(_("--base is incompatible with specifying "
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   579
                               "a destination"))
3318
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   580
        base = [repo.lookup(rev) for rev in base]
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   581
        # create the right base
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   582
        # XXX: nodesbetween / changegroup* should be "fixed" instead
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   583
        o = []
8464
7af92e70bb25 revlog: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8408
diff changeset
   584
        has = set((nullid,))
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   585
        for n in base:
3631
770c4fc03b8e bundle: don't use sets.Set
Matt Mackall <mpm@selenic.com>
parents: 3629
diff changeset
   586
            has.update(repo.changelog.reachable(n))
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   587
        if revs:
11636
c10eaf1210cd bundle: lookup revisions after addbranchrevs
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11629
diff changeset
   588
            revs = [repo.lookup(rev) for rev in revs]
c10eaf1210cd bundle: lookup revisions after addbranchrevs
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11629
diff changeset
   589
            visit = revs[:]
c10eaf1210cd bundle: lookup revisions after addbranchrevs
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11629
diff changeset
   590
            has.difference_update(visit)
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   591
        else:
3318
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   592
            visit = repo.changelog.heads()
3631
770c4fc03b8e bundle: don't use sets.Set
Matt Mackall <mpm@selenic.com>
parents: 3629
diff changeset
   593
        seen = {}
3318
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   594
        while visit:
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   595
            n = visit.pop(0)
3631
770c4fc03b8e bundle: don't use sets.Set
Matt Mackall <mpm@selenic.com>
parents: 3629
diff changeset
   596
            parents = [p for p in repo.changelog.parents(n) if p not in has]
3318
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   597
            if len(parents) == 0:
10479
bb508b312359 bundle: exclude csets given in --base, unless they are in --rev (issue1910)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10448
diff changeset
   598
                if n not in has:
bb508b312359 bundle: exclude csets given in --base, unless they are in --rev (issue1910)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10448
diff changeset
   599
                    o.append(n)
3318
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   600
            else:
3512
630e0b216192 fix graph traversal in commands.bundle (it wasn't O(n))
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3511
diff changeset
   601
                for p in parents:
630e0b216192 fix graph traversal in commands.bundle (it wasn't O(n))
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3511
diff changeset
   602
                    if p not in seen:
3631
770c4fc03b8e bundle: don't use sets.Set
Matt Mackall <mpm@selenic.com>
parents: 3629
diff changeset
   603
                        seen[p] = 1
3512
630e0b216192 fix graph traversal in commands.bundle (it wasn't O(n))
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3511
diff changeset
   604
                        visit.append(p)
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   605
    else:
10365
d757bc0c7865 interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents: 10364
diff changeset
   606
        dest = ui.expandpath(dest or 'default-push', dest or 'default')
10379
a78bfaf988e1 add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents: 10376
diff changeset
   607
        dest, branches = hg.parseurl(dest, opts.get('branch'))
11273
d1908cb95a82 remoteui: move from cmdutil to hg
Matt Mackall <mpm@selenic.com>
parents: 11219
diff changeset
   608
        other = hg.repository(hg.remoteui(repo, opts), dest)
10365
d757bc0c7865 interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents: 10364
diff changeset
   609
        revs, checkout = hg.addbranchrevs(repo, other, branches, revs)
11636
c10eaf1210cd bundle: lookup revisions after addbranchrevs
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11629
diff changeset
   610
        if revs:
c10eaf1210cd bundle: lookup revisions after addbranchrevs
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11629
diff changeset
   611
            revs = [repo.lookup(rev) for rev in revs]
11301
3d0591a66118 move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11297
diff changeset
   612
        o = discovery.findoutgoing(repo, other, force=opts.get('force'))
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   613
10616
65b178f30eae bundle: fix bundle generation for empty changegroup
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10596
diff changeset
   614
    if not o:
65b178f30eae bundle: fix bundle generation for empty changegroup
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10596
diff changeset
   615
        ui.status(_("no changes found\n"))
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   616
        return 1
10616
65b178f30eae bundle: fix bundle generation for empty changegroup
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10596
diff changeset
   617
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   618
    if revs:
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   619
        cg = repo.changegroupsubset(o, revs, 'bundle')
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   620
    else:
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   621
        cg = repo.changegroup(o, 'bundle')
6570
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   622
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   623
    bundletype = opts.get('type', 'bzip2').lower()
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   624
    btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   625
    bundletype = btypes.get(bundletype)
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   626
    if bundletype not in changegroup.bundletypes:
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   627
        raise util.Abort(_('unknown bundle type specified with --type'))
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   628
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   629
    changegroup.writebundle(cg, fname, bundletype)
1218
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
   630
1254
e6560042b7b8 Switch cat command to use walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1253
diff changeset
   631
def cat(ui, repo, file1, *pats, **opts):
3914
283ee8971570 doc string fix: hg cat and manifest default to current parent revision.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3900
diff changeset
   632
    """output the current or given revision of files
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   633
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
   634
    Print the specified files as they were at the given revision. If
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
   635
    no revision is given, the parent of the working directory is used,
3915
3c82ab166eea doc fix: hg tags defaults to current parent revision, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3914
diff changeset
   636
    or tip if no revision is checked out.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   637
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   638
    Output may be to a file, in which case the name of the file is
6448
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
   639
    given using a format string. The formatting rules are the same as
9892
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
   640
    for the export command, with the following additions:
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
   641
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
   642
    :``%s``: basename of file being printed
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
   643
    :``%d``: dirname of file being printed, or '.' if in repository root
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
   644
    :``%p``: root-relative path name of file being printed
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   645
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   646
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   647
    """
12618
0ae35296fbf4 revsets: introduce revsingle helper
Matt Mackall <mpm@selenic.com>
parents: 12613
diff changeset
   648
    ctx = cmdutil.revsingle(repo, opts.get('rev'))
4697
5b2d986de0f8 cat: return an error on failure
Matt Mackall <mpm@selenic.com>
parents: 4692
diff changeset
   649
    err = 1
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
   650
    m = cmdutil.match(repo, (file1,) + pats, opts)
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
   651
    for abs in ctx.walk(m):
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   652
        fp = cmdutil.make_file(repo, opts.get('output'), ctx.node(), pathname=abs)
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
   653
        data = ctx[abs].data()
6094
3998c1b0828f cat --decode: Drop short option, use opts.get() instead of opts[]
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6093
diff changeset
   654
        if opts.get('decode'):
6093
f5b00b6e426a Option --decode for hg cat to apply decode filters.
Jesse Glick <jesse.glick@sun.com>
parents: 6068
diff changeset
   655
            data = repo.wwritedata(abs, data)
f5b00b6e426a Option --decode for hg cat to apply decode filters.
Jesse Glick <jesse.glick@sun.com>
parents: 6068
diff changeset
   656
        fp.write(data)
4697
5b2d986de0f8 cat: return an error on failure
Matt Mackall <mpm@selenic.com>
parents: 4692
diff changeset
   657
        err = 0
5b2d986de0f8 cat: return an error on failure
Matt Mackall <mpm@selenic.com>
parents: 4692
diff changeset
   658
    return err
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
   659
698
df78d8ccac4c Use python function instead of external 'cp' command when cloning repos.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 697
diff changeset
   660
def clone(ui, source, dest=None, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   661
    """make a copy of an existing repository
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   662
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   663
    Create a copy of an existing repository in a new directory.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   664
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   665
    If no destination directory name is specified, it defaults to the
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   666
    basename of the source.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   667
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   668
    The location of the source is added to the new repository's
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   669
    .hg/hgrc file, as the default to be used for future pulls.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   670
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
   671
    See :hg:`help urls` for valid source format details.
7942
553cef16031f mention default branch in branch and clone help
Matt Mackall <mpm@selenic.com>
parents: 7880
diff changeset
   672
9970
36760956f6d3 commands: mark "ssh://" as inline literals in help texts
Martin Geisler <mg@lazybytes.net>
parents: 9952
diff changeset
   673
    It is possible to specify an ``ssh://`` URL as the destination, but no
7942
553cef16031f mention default branch in branch and clone help
Matt Mackall <mpm@selenic.com>
parents: 7880
diff changeset
   674
    .hg/hgrc and working directory will be created on the remote side.
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
   675
    Please see :hg:`help urls` for important details about ``ssh://`` URLs.
7942
553cef16031f mention default branch in branch and clone help
Matt Mackall <mpm@selenic.com>
parents: 7880
diff changeset
   676
9714
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   677
    A set of changesets (tags, or branch names) to pull may be specified
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   678
    by listing each changeset (tag, or branch name) with -r/--rev.
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   679
    If -r/--rev is used, the cloned repository will contain only a subset
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   680
    of the changesets of the source repository. Only the set of changesets
9806
dafbe321fc1a clone: simplify help text
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 9747
diff changeset
   681
    defined by all -r/--rev options (including all their ancestors)
dafbe321fc1a clone: simplify help text
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 9747
diff changeset
   682
    will be pulled into the destination repository.
9714
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   683
    No subsequent changesets (including subsequent tags) will be present
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   684
    in the destination.
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   685
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   686
    Using -r/--rev (or 'clone src#rev dest') implies --pull, even for
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   687
    local source repositories.
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   688
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   689
    For efficiency, hardlinks are used for cloning whenever the source
2762
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
   690
    and destination are on the same filesystem (note this applies only
10637
7ce62865d72a commands: document and test hg clone update priority
timeless <timeless@gmail.com>
parents: 10616
diff changeset
   691
    to the repository data, not to the working directory). Some
2762
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
   692
    filesystems, such as AFS, implement hardlinking incorrectly, but
6448
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
   693
    do not report errors. In these cases, use the --pull option to
2762
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
   694
    avoid hardlinking.
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
   695
10637
7ce62865d72a commands: document and test hg clone update priority
timeless <timeless@gmail.com>
parents: 10616
diff changeset
   696
    In some cases, you can clone repositories and the working directory
9249
16f4cfc69e4f commands: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9219
diff changeset
   697
    using full hardlinks with ::
2762
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
   698
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
   699
      $ cp -al REPO REPOCLONE
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
   700
7983
7b813bdbd5d0 Change double spaces to single spaces in help texts.
Martin Geisler <mg@daimi.au.dk>
parents: 7982
diff changeset
   701
    This is the fastest way to clone, but it is not always safe. The
6509
5279848424e7 issue 1053: heavily qualify the "cp -al" advice for cloning
Bryan O'Sullivan <bos@serpentine.com>
parents: 6469
diff changeset
   702
    operation is not atomic (making sure REPO is not modified during
5279848424e7 issue 1053: heavily qualify the "cp -al" advice for cloning
Bryan O'Sullivan <bos@serpentine.com>
parents: 6469
diff changeset
   703
    the operation is up to you) and you have to make sure your editor
7983
7b813bdbd5d0 Change double spaces to single spaces in help texts.
Martin Geisler <mg@daimi.au.dk>
parents: 7982
diff changeset
   704
    breaks hardlinks (Emacs and most Linux Kernel tools do so). Also,
6509
5279848424e7 issue 1053: heavily qualify the "cp -al" advice for cloning
Bryan O'Sullivan <bos@serpentine.com>
parents: 6469
diff changeset
   705
    this is not compatible with certain extensions that place their
5279848424e7 issue 1053: heavily qualify the "cp -al" advice for cloning
Bryan O'Sullivan <bos@serpentine.com>
parents: 6469
diff changeset
   706
    metadata under the .hg directory, such as mq.
10637
7ce62865d72a commands: document and test hg clone update priority
timeless <timeless@gmail.com>
parents: 10616
diff changeset
   707
7ce62865d72a commands: document and test hg clone update priority
timeless <timeless@gmail.com>
parents: 10616
diff changeset
   708
    Mercurial will update the working directory to the first applicable
7ce62865d72a commands: document and test hg clone update priority
timeless <timeless@gmail.com>
parents: 10616
diff changeset
   709
    revision from this list:
7ce62865d72a commands: document and test hg clone update priority
timeless <timeless@gmail.com>
parents: 10616
diff changeset
   710
10645
ac280ab55c9f commands: remove extra indentation from list in help text
Martin Geisler <mg@lazybytes.net>
parents: 10637
diff changeset
   711
    a) null if -U or the source repository has no changesets
ac280ab55c9f commands: remove extra indentation from list in help text
Martin Geisler <mg@lazybytes.net>
parents: 10637
diff changeset
   712
    b) if -u . and the source repository is local, the first parent of
ac280ab55c9f commands: remove extra indentation from list in help text
Martin Geisler <mg@lazybytes.net>
parents: 10637
diff changeset
   713
       the source repository's working directory
ac280ab55c9f commands: remove extra indentation from list in help text
Martin Geisler <mg@lazybytes.net>
parents: 10637
diff changeset
   714
    c) the changeset specified with -u (if a branch name, this means the
ac280ab55c9f commands: remove extra indentation from list in help text
Martin Geisler <mg@lazybytes.net>
parents: 10637
diff changeset
   715
       latest head of that branch)
ac280ab55c9f commands: remove extra indentation from list in help text
Martin Geisler <mg@lazybytes.net>
parents: 10637
diff changeset
   716
    d) the changeset specified with -r
ac280ab55c9f commands: remove extra indentation from list in help text
Martin Geisler <mg@lazybytes.net>
parents: 10637
diff changeset
   717
    e) the tipmost head specified with -b
ac280ab55c9f commands: remove extra indentation from list in help text
Martin Geisler <mg@lazybytes.net>
parents: 10637
diff changeset
   718
    f) the tipmost head specified with the url#branch source syntax
ac280ab55c9f commands: remove extra indentation from list in help text
Martin Geisler <mg@lazybytes.net>
parents: 10637
diff changeset
   719
    g) the tipmost head of the default branch
ac280ab55c9f commands: remove extra indentation from list in help text
Martin Geisler <mg@lazybytes.net>
parents: 10637
diff changeset
   720
    h) tip
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   721
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   722
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   723
    """
9714
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   724
    if opts.get('noupdate') and opts.get('updaterev'):
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   725
        raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
   726
11273
d1908cb95a82 remoteui: move from cmdutil to hg
Matt Mackall <mpm@selenic.com>
parents: 11219
diff changeset
   727
    r = hg.clone(hg.remoteui(ui, opts), source, dest,
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   728
                 pull=opts.get('pull'),
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   729
                 stream=opts.get('uncompressed'),
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   730
                 rev=opts.get('rev'),
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   731
                 update=opts.get('updaterev') or not opts.get('noupdate'),
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   732
                 branch=opts.get('branch'))
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   733
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   734
    return r is None
515
03f27b1381f9 Whitespace cleanups
mpm@selenic.com
parents: 513
diff changeset
   735
813
80fd2958235a Adapt commit to use file matching code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 812
diff changeset
   736
def commit(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   737
    """commit the specified files or all outstanding changes
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   738
7983
7b813bdbd5d0 Change double spaces to single spaces in help texts.
Martin Geisler <mg@daimi.au.dk>
parents: 7982
diff changeset
   739
    Commit changes to the given files into the repository. Unlike a
11193
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
   740
    centralized RCS, this operation is a local operation. See
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
   741
    :hg:`push` for a way to actively distribute your changes.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   742
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
   743
    If a list of files is omitted, all changes reported by :hg:`status`
1995
2da2d46862fb Spelling fix: "commited" -> "committed"
mcmillen@cs.cmu.edu
parents: 1994
diff changeset
   744
    will be committed.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   745
6385
0d4e068e9e52 commit: when committing the results of a merge, it's all or nothing
Bryan O'Sullivan <bos@serpentine.com>
parents: 6375
diff changeset
   746
    If you are committing the result of a merge, do not provide any
8761
0289f384e1e5 Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents: 8760
diff changeset
   747
    filenames or -I/-X filters.
6385
0d4e068e9e52 commit: when committing the results of a merge, it's all or nothing
Bryan O'Sullivan <bos@serpentine.com>
parents: 6375
diff changeset
   748
11877
8f40125a0ed8 commit: explicitly document the existence of "last-message.txt"
Greg Ward <greg-hg@gerg.ca>
parents: 11836
diff changeset
   749
    If no commit message is specified, Mercurial starts your
8f40125a0ed8 commit: explicitly document the existence of "last-message.txt"
Greg Ward <greg-hg@gerg.ca>
parents: 11836
diff changeset
   750
    configured editor where you can enter a message. In case your
8f40125a0ed8 commit: explicitly document the existence of "last-message.txt"
Greg Ward <greg-hg@gerg.ca>
parents: 11836
diff changeset
   751
    commit fails, you will find a backup of your message in
8f40125a0ed8 commit: explicitly document the existence of "last-message.txt"
Greg Ward <greg-hg@gerg.ca>
parents: 11836
diff changeset
   752
    ``.hg/last-message.txt``.
6163
1f733c2f0165 Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6161
diff changeset
   753
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
   754
    See :hg:`help dates` for a list of formats valid for -d/--date.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   755
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   756
    Returns 0 on success, 1 if nothing changed.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   757
    """
7655
cce37dab7ad6 branch closing: mark closed branches with a 'close' extra
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7643
diff changeset
   758
    extra = {}
cce37dab7ad6 branch closing: mark closed branches with a 'close' extra
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7643
diff changeset
   759
    if opts.get('close_branch'):
11163
acd61dc44a39 commit: prevent closing non-head changesets
Gilles Moris <gilles.moris@free.fr>
parents: 11104
diff changeset
   760
        if repo['.'].node() not in repo.branchheads():
acd61dc44a39 commit: prevent closing non-head changesets
Gilles Moris <gilles.moris@free.fr>
parents: 11104
diff changeset
   761
            # The topo heads set is included in the branch heads set of the
acd61dc44a39 commit: prevent closing non-head changesets
Gilles Moris <gilles.moris@free.fr>
parents: 11104
diff changeset
   762
            # current branch, so it's sufficient to test branchheads
acd61dc44a39 commit: prevent closing non-head changesets
Gilles Moris <gilles.moris@free.fr>
parents: 11104
diff changeset
   763
            raise util.Abort(_('can only close branch heads'))
7655
cce37dab7ad6 branch closing: mark closed branches with a 'close' extra
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7643
diff changeset
   764
        extra['close'] = 1
8407
223000a687b0 commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents: 8397
diff changeset
   765
    e = cmdutil.commiteditor
223000a687b0 commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents: 8397
diff changeset
   766
    if opts.get('force_editor'):
223000a687b0 commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents: 8397
diff changeset
   767
        e = cmdutil.commitforceeditor
223000a687b0 commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents: 8397
diff changeset
   768
6600
b822a379860b match: stop passing files through commitfunc
Matt Mackall <mpm@selenic.com>
parents: 6599
diff changeset
   769
    def commitfunc(ui, repo, message, match, opts):
8706
25e9c71b89de commit: drop the now-unused files parameter
Matt Mackall <mpm@selenic.com>
parents: 8704
diff changeset
   770
        return repo.commit(message, opts.get('user'), opts.get('date'), match,
25e9c71b89de commit: drop the now-unused files parameter
Matt Mackall <mpm@selenic.com>
parents: 8704
diff changeset
   771
                           editor=e, extra=extra)
6336
4b0c9c674707 warn about new heads on commit (issue842)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6321
diff changeset
   772
11173
5b48d819d5f9 commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents: 11169
diff changeset
   773
    branch = repo[None].branch()
5b48d819d5f9 commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents: 11169
diff changeset
   774
    bheads = repo.branchheads(branch)
5b48d819d5f9 commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents: 11169
diff changeset
   775
6369
53912d30ac40 Avoid calling heads() twice on every hg commit.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6367
diff changeset
   776
    node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
53912d30ac40 Avoid calling heads() twice on every hg commit.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6367
diff changeset
   777
    if not node:
8995
7b19cda0fa10 commit: lose some pointless 'nothing changed' messages
Matt Mackall <mpm@selenic.com>
parents: 8992
diff changeset
   778
        ui.status(_("nothing changed\n"))
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   779
        return 1
11173
5b48d819d5f9 commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents: 11169
diff changeset
   780
5b48d819d5f9 commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents: 11169
diff changeset
   781
    ctx = repo[node]
5b48d819d5f9 commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents: 11169
diff changeset
   782
    parents = ctx.parents()
5b48d819d5f9 commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents: 11169
diff changeset
   783
11317
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   784
    if bheads and not [x for x in parents
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   785
                       if x.node() in bheads and x.branch() == branch]:
6336
4b0c9c674707 warn about new heads on commit (issue842)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6321
diff changeset
   786
        ui.status(_('created new head\n'))
11317
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   787
        # The message is not printed for initial roots. For the other
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   788
        # changesets, it is printed in the following situations:
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   789
        #
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   790
        # Par column: for the 2 parents with ...
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   791
        #   N: null or no parent
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   792
        #   B: parent is on another named branch
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   793
        #   C: parent is a regular non head changeset
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   794
        #   H: parent was a branch head of the current branch
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   795
        # Msg column: whether we print "created new head" message
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   796
        # In the following, it is assumed that there already exists some
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   797
        # initial branch heads of the current branch, otherwise nothing is
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   798
        # printed anyway.
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   799
        #
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   800
        # Par Msg Comment
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   801
        # NN   y  additional topo root
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   802
        #
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   803
        # BN   y  additional branch root
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   804
        # CN   y  additional topo head
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   805
        # HN   n  usual case
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   806
        #
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   807
        # BB   y  weird additional branch root
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   808
        # CB   y  branch merge
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   809
        # HB   n  merge with named branch
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   810
        #
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   811
        # CC   y  additional head from merge
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   812
        # CH   n  merge with a head
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   813
        #
b66e414d38b0 commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents: 11311
diff changeset
   814
        # HH   n  head merge: head count decreases
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
   815
11164
e84600b0d81b commit: inform the commiter when resurrecting a closed changeset
Gilles Moris <gilles.moris@free.fr>
parents: 11163
diff changeset
   816
    if not opts.get('close_branch'):
e84600b0d81b commit: inform the commiter when resurrecting a closed changeset
Gilles Moris <gilles.moris@free.fr>
parents: 11163
diff changeset
   817
        for r in parents:
11515
cc982ff2dcf8 commands: only warn when reopening the workdir's branch
Robert Bauck Hamar <r.b.hamar@usit.uio.no>
parents: 11508
diff changeset
   818
            if r.extra().get('close') and r.branch() == branch:
11164
e84600b0d81b commit: inform the commiter when resurrecting a closed changeset
Gilles Moris <gilles.moris@free.fr>
parents: 11163
diff changeset
   819
                ui.status(_('reopening closed branch head %d\n') % r)
e84600b0d81b commit: inform the commiter when resurrecting a closed changeset
Gilles Moris <gilles.moris@free.fr>
parents: 11163
diff changeset
   820
6935
03916abdfb64 Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents: 6934
diff changeset
   821
    if ui.debugflag:
11173
5b48d819d5f9 commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents: 11169
diff changeset
   822
        ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex()))
6935
03916abdfb64 Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents: 6934
diff changeset
   823
    elif ui.verbose:
11173
5b48d819d5f9 commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents: 11169
diff changeset
   824
        ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx))
6935
03916abdfb64 Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents: 6934
diff changeset
   825
1253
a45e717c61a8 Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1250
diff changeset
   826
def copy(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   827
    """mark files as copied for the next commit
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   828
6448
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
   829
    Mark dest as having copies of source files. If dest is a
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
   830
    directory, copies are put in that directory. If dest is a file,
7807
bd8f44638847 help: miscellaneous language fixes
timeless <timeless@gmail.com>
parents: 7765
diff changeset
   831
    the source must be a single file.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   832
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   833
    By default, this command copies the contents of files as they
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   834
    exist in the working directory. If invoked with -A/--after, the
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   835
    operation is recorded, but no copying is performed.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   836
7807
bd8f44638847 help: miscellaneous language fixes
timeless <timeless@gmail.com>
parents: 7765
diff changeset
   837
    This command takes effect with the next commit. To undo a copy
11193
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
   838
    before that, see :hg:`revert`.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   839
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   840
    Returns 0 on success, 1 if errors are encountered.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   841
    """
4914
9a2a73ea6135 repo locks: use True/False
Matt Mackall <mpm@selenic.com>
parents: 4906
diff changeset
   842
    wlock = repo.wlock(False)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
   843
    try:
5610
2493a478f395 copy: handle rename internally
Matt Mackall <mpm@selenic.com>
parents: 5589
diff changeset
   844
        return cmdutil.copy(ui, repo, pats, opts)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
   845
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
   846
        wlock.release()
363
ae96b7e1318d Add hg copy
mpm@selenic.com
parents: 355
diff changeset
   847
6189
81cbb5dfdec0 Make hg debugancestor accept -R by making it an optionalrepo command.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6188
diff changeset
   848
def debugancestor(ui, repo, *args):
1262
325c07fd2ebd Add debugancestor command
mpm@selenic.com
parents: 1257
diff changeset
   849
    """find the ancestor revision of two revisions in a given index"""
6188
3b0c2b71e0d7 debugancestor: use *args instead of *opts, to not confuse with option dicts.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6182
diff changeset
   850
    if len(args) == 3:
3b0c2b71e0d7 debugancestor: use *args instead of *opts, to not confuse with option dicts.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6182
diff changeset
   851
        index, rev1, rev2 = args
6178
81afdd016867 debugancestor: make the index argument optional, defaulting to 00changelog.i
Bryan O'Sullivan <bos@serpentine.com>
parents: 6171
diff changeset
   852
        r = revlog.revlog(util.opener(os.getcwd(), audit=False), index)
6253
a7e3d0456d92 debugancestor: use repo.lookup when no revlog was specified
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6243
diff changeset
   853
        lookup = r.lookup
6188
3b0c2b71e0d7 debugancestor: use *args instead of *opts, to not confuse with option dicts.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6182
diff changeset
   854
    elif len(args) == 2:
6189
81cbb5dfdec0 Make hg debugancestor accept -R by making it an optionalrepo command.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6188
diff changeset
   855
        if not repo:
12067
a4fbbe0fbc38 Lowercase error messages
Martin Geisler <mg@lazybytes.net>
parents: 11881
diff changeset
   856
            raise util.Abort(_("there is no Mercurial repository here "
6189
81cbb5dfdec0 Make hg debugancestor accept -R by making it an optionalrepo command.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6188
diff changeset
   857
                               "(.hg not found)"))
6188
3b0c2b71e0d7 debugancestor: use *args instead of *opts, to not confuse with option dicts.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6182
diff changeset
   858
        rev1, rev2 = args
6178
81afdd016867 debugancestor: make the index argument optional, defaulting to 00changelog.i
Bryan O'Sullivan <bos@serpentine.com>
parents: 6171
diff changeset
   859
        r = repo.changelog
6253
a7e3d0456d92 debugancestor: use repo.lookup when no revlog was specified
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6243
diff changeset
   860
        lookup = repo.lookup
6178
81afdd016867 debugancestor: make the index argument optional, defaulting to 00changelog.i
Bryan O'Sullivan <bos@serpentine.com>
parents: 6171
diff changeset
   861
    else:
81afdd016867 debugancestor: make the index argument optional, defaulting to 00changelog.i
Bryan O'Sullivan <bos@serpentine.com>
parents: 6171
diff changeset
   862
        raise util.Abort(_('either two or three arguments required'))
6253
a7e3d0456d92 debugancestor: use repo.lookup when no revlog was specified
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6243
diff changeset
   863
    a = r.ancestor(lookup(rev1), lookup(rev2))
1262
325c07fd2ebd Add debugancestor command
mpm@selenic.com
parents: 1257
diff changeset
   864
    ui.write("%d:%s\n" % (r.rev(a), hex(a)))
325c07fd2ebd Add debugancestor command
mpm@selenic.com
parents: 1257
diff changeset
   865
11337
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   866
def debugbuilddag(ui, repo, text,
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   867
                  mergeable_file=False,
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   868
                  appended_file=False,
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   869
                  overwritten_file=False,
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   870
                  new_file=False):
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   871
    """builds a repo with a given dag from scratch in the current empty repo
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   872
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   873
    Elements:
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   874
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   875
     - "+n" is a linear run of n nodes based on the current default parent
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   876
     - "." is a single node based on the current default parent
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   877
     - "$" resets the default parent to null (implied at the start);
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   878
           otherwise the default parent is always the last node created
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   879
     - "<p" sets the default parent to the backref p
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   880
     - "*p" is a fork at parent p, which is a backref
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   881
     - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   882
     - "/p2" is a merge of the preceding node and p2
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   883
     - ":tag" defines a local tag for the preceding node
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   884
     - "@branch" sets the named branch for subsequent nodes
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   885
     - "!command" runs the command using your shell
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   886
     - "!!my command\\n" is like "!", but to the end of the line
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   887
     - "#...\\n" is a comment up to the end of the line
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   888
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   889
    Whitespace between the above elements is ignored.
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   890
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   891
    A backref is either
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   892
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   893
     - a number n, which references the node curr-n, where curr is the current
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   894
       node, or
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   895
     - the name of a local tag you placed earlier using ":tag", or
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   896
     - empty to denote the default parent.
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   897
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   898
    All string valued-elements are either strictly alphanumeric, or must
11881
2da0cf99b642 debugbuilddag: escape backslash properly in help string
Martin Geisler <mg@lazybytes.net>
parents: 11877
diff changeset
   899
    be enclosed in double quotes ("..."), with "\\" as escape character.
11337
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   900
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   901
    Note that the --overwritten-file and --appended-file options imply the
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   902
    use of "HGMERGE=internal:local" during DAG buildup.
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   903
    """
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   904
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   905
    if not (mergeable_file or appended_file or overwritten_file or new_file):
11342
aecabad8dd7a commands: get rid of generic exception in debugbuilddag
Martin Geisler <mg@aragost.com>
parents: 11338
diff changeset
   906
        raise util.Abort(_('need at least one of -m, -a, -o, -n'))
11337
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   907
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   908
    if len(repo.changelog) > 0:
11342
aecabad8dd7a commands: get rid of generic exception in debugbuilddag
Martin Geisler <mg@aragost.com>
parents: 11338
diff changeset
   909
        raise util.Abort(_('repository is not empty'))
11337
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   910
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   911
    if overwritten_file or appended_file:
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   912
        # we don't want to fail in merges during buildup
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   913
        os.environ['HGMERGE'] = 'internal:local'
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   914
11686
fc360de66217 debugbuilddag: build repository content in binary mode
Patrick Mezard <pmezard@gmail.com>
parents: 11644
diff changeset
   915
    def writefile(fname, text, fmode="wb"):
11337
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   916
        f = open(fname, fmode)
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   917
        try:
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   918
            f.write(text)
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   919
        finally:
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   920
            f.close()
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   921
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   922
    if mergeable_file:
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   923
        linesperrev = 2
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   924
        # determine number of revs in DAG
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   925
        n = 0
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   926
        for type, data in dagparser.parsedag(text):
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   927
            if type == 'n':
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   928
                n += 1
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   929
        # make a file with k lines per rev
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   930
        writefile("mf", "\n".join(str(i) for i in xrange(0, n * linesperrev))
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   931
                  + "\n")
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   932
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   933
    at = -1
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   934
    atbranch = 'default'
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   935
    for type, data in dagparser.parsedag(text):
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   936
        if type == 'n':
11338
285bcf40e04b commands: format is a Python2.6 function
Martin Geisler <mg@aragost.com>
parents: 11337
diff changeset
   937
            ui.status('node %s\n' % str(data))
11337
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   938
            id, ps = data
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   939
            p1 = ps[0]
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   940
            if p1 != at:
12726
61c0df2b089a update: use revsingle to enable use of revsets as update targets (issue1993)
Augie Fackler <durin42@gmail.com>
parents: 12705
diff changeset
   941
                update(ui, repo, node=str(p1), clean=True)
11337
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   942
                at = p1
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   943
            if repo.dirstate.branch() != atbranch:
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   944
                branch(ui, repo, atbranch, force=True)
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   945
            if len(ps) > 1:
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   946
                p2 = ps[1]
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   947
                merge(ui, repo, node=p2)
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   948
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   949
            if mergeable_file:
11686
fc360de66217 debugbuilddag: build repository content in binary mode
Patrick Mezard <pmezard@gmail.com>
parents: 11644
diff changeset
   950
                f = open("mf", "rb+")
11337
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   951
                try:
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   952
                    lines = f.read().split("\n")
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   953
                    lines[id * linesperrev] += " r%i" % id
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   954
                    f.seek(0)
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   955
                    f.write("\n".join(lines))
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   956
                finally:
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   957
                    f.close()
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   958
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   959
            if appended_file:
11686
fc360de66217 debugbuilddag: build repository content in binary mode
Patrick Mezard <pmezard@gmail.com>
parents: 11644
diff changeset
   960
                writefile("af", "r%i\n" % id, "ab")
11337
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   961
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   962
            if overwritten_file:
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   963
                writefile("of", "r%i\n" % id)
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   964
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   965
            if new_file:
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   966
                writefile("nf%i" % id, "r%i\n" % id)
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   967
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   968
            commit(ui, repo, addremove=True, message="r%i" % id, date=(id, 0))
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   969
            at = id
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   970
        elif type == 'l':
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   971
            id, name = data
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   972
            ui.status('tag %s\n' % name)
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   973
            tag(ui, repo, name, local=True)
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   974
        elif type == 'a':
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   975
            ui.status('branch %s\n' % data)
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   976
            atbranch = data
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   977
        elif type in 'cC':
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   978
            r = util.system(data, cwd=repo.root)
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   979
            if r:
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   980
                desc, r = util.explain_exit(r)
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   981
                raise util.Abort(_('%s command %s') % (data, desc))
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
   982
7880
7ca2be800804 add debugcommands command: an easy to parse command + option index
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7875
diff changeset
   983
def debugcommands(ui, cmd='', *args):
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
   984
    """list all available commands and options"""
8209
a1a5a57efe90 replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents: 8190
diff changeset
   985
    for cmd, vals in sorted(table.iteritems()):
7880
7ca2be800804 add debugcommands command: an easy to parse command + option index
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7875
diff changeset
   986
        cmd = cmd.split('|')[0].strip('^')
7ca2be800804 add debugcommands command: an easy to parse command + option index
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7875
diff changeset
   987
        opts = ', '.join([i[1] for i in vals[1]])
7ca2be800804 add debugcommands command: an easy to parse command + option index
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7875
diff changeset
   988
        ui.write('%s: %s\n' % (cmd, opts))
7ca2be800804 add debugcommands command: an easy to parse command + option index
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7875
diff changeset
   989
2034
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
   990
def debugcomplete(ui, cmd='', **opts):
1887
913397c27cd8 new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1875
diff changeset
   991
    """returns the completion list associated with the given command"""
2034
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
   992
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   993
    if opts.get('options'):
2034
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
   994
        options = []
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
   995
        otables = [globalopts]
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
   996
        if cmd:
7213
b4c035057d34 findcmd: have dispatch look up strict flag
Matt Mackall <mpm@selenic.com>
parents: 7212
diff changeset
   997
            aliases, entry = cmdutil.findcmd(cmd, table, False)
2034
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
   998
            otables.append(entry[1])
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
   999
        for t in otables:
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
  1000
            for o in t:
10958
021d5ac3bec0 debugcomplete: don't list deprecated options
Matt Mackall <mpm@selenic.com>
parents: 10957
diff changeset
  1001
                if "(DEPRECATED)" in o[3]:
021d5ac3bec0 debugcomplete: don't list deprecated options
Matt Mackall <mpm@selenic.com>
parents: 10957
diff changeset
  1002
                    continue
2034
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
  1003
                if o[0]:
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
  1004
                    options.append('-%s' % o[0])
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
  1005
                options.append('--%s' % o[1])
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
  1006
        ui.write("%s\n" % "\n".join(options))
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
  1007
        return
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
  1008
7509
62e5d41b0a8b Make debugcomplete -v print aliases as well as commands
Brendan Cully <brendan@kublai.com>
parents: 7449
diff changeset
  1009
    cmdlist = cmdutil.findpossible(cmd, table)
62e5d41b0a8b Make debugcomplete -v print aliases as well as commands
Brendan Cully <brendan@kublai.com>
parents: 7449
diff changeset
  1010
    if ui.verbose:
62e5d41b0a8b Make debugcomplete -v print aliases as well as commands
Brendan Cully <brendan@kublai.com>
parents: 7449
diff changeset
  1011
        cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
8209
a1a5a57efe90 replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents: 8190
diff changeset
  1012
    ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1887
913397c27cd8 new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1875
diff changeset
  1013
5741
8ee0de123989 add debugfsinfo to check fs capabilities
Matt Mackall <mpm@selenic.com>
parents: 5716
diff changeset
  1014
def debugfsinfo(ui, path = "."):
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1015
    """show information detected about current filesystem"""
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 9012
diff changeset
  1016
    open('.debugfsinfo', 'w').write('')
5741
8ee0de123989 add debugfsinfo to check fs capabilities
Matt Mackall <mpm@selenic.com>
parents: 5716
diff changeset
  1017
    ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
8ee0de123989 add debugfsinfo to check fs capabilities
Matt Mackall <mpm@selenic.com>
parents: 5716
diff changeset
  1018
    ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
6746
1dca460e7d1e rename checkfolding to checkcase
Matt Mackall <mpm@selenic.com>
parents: 6743
diff changeset
  1019
    ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
5741
8ee0de123989 add debugfsinfo to check fs capabilities
Matt Mackall <mpm@selenic.com>
parents: 5716
diff changeset
  1020
                                and 'yes' or 'no'))
8ee0de123989 add debugfsinfo to check fs capabilities
Matt Mackall <mpm@selenic.com>
parents: 5716
diff changeset
  1021
    os.unlink('.debugfsinfo')
8ee0de123989 add debugfsinfo to check fs capabilities
Matt Mackall <mpm@selenic.com>
parents: 5716
diff changeset
  1022
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1023
def debugrebuildstate(ui, repo, rev="tip"):
1755
a8f7791e3680 add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1754
diff changeset
  1024
    """rebuild the dirstate as it would look like for the given revision"""
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1025
    ctx = repo[rev]
1760
13f8e068d13c fix typo in debugrebuildstate
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1755
diff changeset
  1026
    wlock = repo.wlock()
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1027
    try:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1028
        repo.dirstate.rebuild(ctx.node(), ctx.manifest())
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1029
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
  1030
        wlock.release()
1755
a8f7791e3680 add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1754
diff changeset
  1031
596
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
  1032
def debugcheckstate(ui, repo):
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
  1033
    """validate the correctness of the current dirstate"""
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1034
    parent1, parent2 = repo.dirstate.parents()
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1035
    m1 = repo[parent1].manifest()
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1036
    m2 = repo[parent2].manifest()
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1037
    errors = 0
4906
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4904
diff changeset
  1038
    for f in repo.dirstate:
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4904
diff changeset
  1039
        state = repo.dirstate[f]
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1040
        if state in "nr" and f not in m1:
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  1041
            ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1042
            errors += 1
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1043
        if state in "a" and f in m1:
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  1044
            ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1045
            errors += 1
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1046
        if state in "m" and f not in m1 and f not in m2:
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  1047
            ui.warn(_("%s in state %s, but not in either manifest\n") %
582
df8a5a0098d4 Remove all remaining print statements
mpm@selenic.com
parents: 580
diff changeset
  1048
                    (f, state))
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1049
            errors += 1
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1050
    for f in m1:
4906
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4904
diff changeset
  1051
        state = repo.dirstate[f]
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1052
        if state not in "nrm":
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  1053
            ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1054
            errors += 1
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1055
    if errors:
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  1056
        error = _(".hg/dirstate inconsistent with current parent's manifest")
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  1057
        raise util.Abort(error)
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1058
3553
e1508621e9ef add --untrusted to showconfig
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3521
diff changeset
  1059
def showconfig(ui, repo, *values, **opts):
2410
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1060
    """show combined config settings from all hgrc files
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1061
8664
f265106ccb53 commands: expand "arg" -> "argument" in showconfig help strings
Martin Geisler <mg@lazybytes.net>
parents: 8636
diff changeset
  1062
    With no arguments, print names and values of all config items.
f265106ccb53 commands: expand "arg" -> "argument" in showconfig help strings
Martin Geisler <mg@lazybytes.net>
parents: 8636
diff changeset
  1063
f265106ccb53 commands: expand "arg" -> "argument" in showconfig help strings
Martin Geisler <mg@lazybytes.net>
parents: 8636
diff changeset
  1064
    With one argument of the form section.name, print just the value
f265106ccb53 commands: expand "arg" -> "argument" in showconfig help strings
Martin Geisler <mg@lazybytes.net>
parents: 8636
diff changeset
  1065
    of that config item.
f265106ccb53 commands: expand "arg" -> "argument" in showconfig help strings
Martin Geisler <mg@lazybytes.net>
parents: 8636
diff changeset
  1066
f265106ccb53 commands: expand "arg" -> "argument" in showconfig help strings
Martin Geisler <mg@lazybytes.net>
parents: 8636
diff changeset
  1067
    With multiple arguments, print names and values of all config
f265106ccb53 commands: expand "arg" -> "argument" in showconfig help strings
Martin Geisler <mg@lazybytes.net>
parents: 8636
diff changeset
  1068
    items with matching section names.
8279
602ed4982f36 commands: describe --debug in showconfig help
Martin Geisler <mg@lazybytes.net>
parents: 8277
diff changeset
  1069
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  1070
    With --debug, the source (filename and line number) is printed
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  1071
    for each config item.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1072
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1073
    Returns 0 on success.
8279
602ed4982f36 commands: describe --debug in showconfig help
Martin Geisler <mg@lazybytes.net>
parents: 8277
diff changeset
  1074
    """
2410
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1075
11048
9e643a0c3278 showconfig: show rc paths with --debug
Mads Kiilerich <mads@kiilerich.com>
parents: 11009
diff changeset
  1076
    for f in util.rcpath():
9e643a0c3278 showconfig: show rc paths with --debug
Mads Kiilerich <mads@kiilerich.com>
parents: 11009
diff changeset
  1077
        ui.debug(_('read config from: %s\n') % f)
3553
e1508621e9ef add --untrusted to showconfig
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3521
diff changeset
  1078
    untrusted = bool(opts.get('untrusted'))
2410
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1079
    if values:
12697
14853ca7e11b showconfig: don't accept multiple sections and one config item
Brodie Rao <brodie@bitheap.org>
parents: 12689
diff changeset
  1080
        sections = [v for v in values if '.' not in v]
14853ca7e11b showconfig: don't accept multiple sections and one config item
Brodie Rao <brodie@bitheap.org>
parents: 12689
diff changeset
  1081
        items = [v for v in values if '.' in v]
14853ca7e11b showconfig: don't accept multiple sections and one config item
Brodie Rao <brodie@bitheap.org>
parents: 12689
diff changeset
  1082
        if len(items) > 1 or items and sections:
2410
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1083
            raise util.Abort(_('only one config item permitted'))
3553
e1508621e9ef add --untrusted to showconfig
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3521
diff changeset
  1084
    for section, name, value in ui.walkconfig(untrusted=untrusted):
2410
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1085
        sectname = section + '.' + name
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1086
        if values:
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1087
            for v in values:
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1088
                if v == section:
8182
b97abc7c1135 showconfig: show source file and line with --debug
Matt Mackall <mpm@selenic.com>
parents: 8152
diff changeset
  1089
                    ui.debug('%s: ' %
b97abc7c1135 showconfig: show source file and line with --debug
Matt Mackall <mpm@selenic.com>
parents: 8152
diff changeset
  1090
                             ui.configsource(section, name, untrusted))
2410
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1091
                    ui.write('%s=%s\n' % (sectname, value))
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1092
                elif v == sectname:
8182
b97abc7c1135 showconfig: show source file and line with --debug
Matt Mackall <mpm@selenic.com>
parents: 8152
diff changeset
  1093
                    ui.debug('%s: ' %
b97abc7c1135 showconfig: show source file and line with --debug
Matt Mackall <mpm@selenic.com>
parents: 8152
diff changeset
  1094
                             ui.configsource(section, name, untrusted))
2410
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1095
                    ui.write(value, '\n')
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1096
        else:
8182
b97abc7c1135 showconfig: show source file and line with --debug
Matt Mackall <mpm@selenic.com>
parents: 8152
diff changeset
  1097
            ui.debug('%s: ' %
b97abc7c1135 showconfig: show source file and line with --debug
Matt Mackall <mpm@selenic.com>
parents: 8152
diff changeset
  1098
                     ui.configsource(section, name, untrusted))
2410
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
  1099
            ui.write('%s=%s\n' % (sectname, value))
1028
25e7ea0f2cff Add commands.debugconfig.
Bryan O'Sullivan <bos@serpentine.com>
parents: 989
diff changeset
  1100
11371
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1101
def debugpushkey(ui, repopath, namespace, *keyinfo):
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1102
    '''access the pushkey key/value protocol
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1103
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1104
    With two args, list the keys in the given namespace.
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1105
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1106
    With five args, set a key to new if it currently is set to old.
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1107
    Reports success or failure.
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1108
    '''
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1109
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1110
    target = hg.repository(ui, repopath)
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1111
    if keyinfo:
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1112
        key, old, new = keyinfo
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1113
        r = target.pushkey(namespace, key, old, new)
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1114
        ui.status(str(r) + '\n')
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1115
        return not(r)
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1116
    else:
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1117
        for k, v in target.listkeys(namespace).iteritems():
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1118
            ui.write("%s\t%s\n" % (k.encode('string-escape'),
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1119
                                   v.encode('string-escape')))
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  1120
11276
f28b58e35768 revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents: 11273
diff changeset
  1121
def debugrevspec(ui, repo, expr):
f28b58e35768 revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents: 11273
diff changeset
  1122
    '''parse and apply a revision specification'''
f28b58e35768 revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents: 11273
diff changeset
  1123
    if ui.verbose:
f28b58e35768 revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents: 11273
diff changeset
  1124
        tree = revset.parse(expr)
f28b58e35768 revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents: 11273
diff changeset
  1125
        ui.note(tree, "\n")
f28b58e35768 revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents: 11273
diff changeset
  1126
    func = revset.match(expr)
f28b58e35768 revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents: 11273
diff changeset
  1127
    for c in func(repo, range(len(repo))):
f28b58e35768 revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents: 11273
diff changeset
  1128
        ui.write("%s\n" % c)
f28b58e35768 revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents: 11273
diff changeset
  1129
1395
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
  1130
def debugsetparents(ui, repo, rev1, rev2=None):
1470
fb9b84c91222 minor fix on command help docstrings
TK Soh <teekaysoh@yahoo.com>
parents: 1469
diff changeset
  1131
    """manually set the parents of the current working directory
1395
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
  1132
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
  1133
    This is useful for writing repository conversion tools, but should
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
  1134
    be used with care.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1135
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1136
    Returns 0 on success.
1395
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
  1137
    """
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
  1138
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
  1139
    if not rev2:
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
  1140
        rev2 = hex(nullid)
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
  1141
4247
89075f106414 debugsetparents: wlock the repo before updating the dirstate
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4231
diff changeset
  1142
    wlock = repo.wlock()
89075f106414 debugsetparents: wlock the repo before updating the dirstate
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4231
diff changeset
  1143
    try:
89075f106414 debugsetparents: wlock the repo before updating the dirstate
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4231
diff changeset
  1144
        repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2))
89075f106414 debugsetparents: wlock the repo before updating the dirstate
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4231
diff changeset
  1145
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
  1146
        wlock.release()
1395
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
  1147
6296
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  1148
def debugstate(ui, repo, nodates=None):
596
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
  1149
    """show the contents of the current dirstate"""
6296
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  1150
    timestr = ""
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  1151
    showdate = not nodates
8209
a1a5a57efe90 replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents: 8190
diff changeset
  1152
    for file_, ent in sorted(repo.dirstate._map.iteritems()):
6296
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  1153
        if showdate:
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  1154
            if ent[3] == -1:
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  1155
                # Pad or slice to locale representation
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  1156
                locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  1157
                                               time.localtime(0)))
6296
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  1158
                timestr = 'unset'
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  1159
                timestr = (timestr[:locale_len] +
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  1160
                           ' ' * (locale_len - len(timestr)))
6296
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  1161
            else:
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  1162
                timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  1163
                                        time.localtime(ent[3]))
5156
49554ba98951 debugstate: print symlinks as 'lnk', not '777'
Bryan O'Sullivan <bos@serpentine.com>
parents: 5155
diff changeset
  1164
        if ent[1] & 020000:
49554ba98951 debugstate: print symlinks as 'lnk', not '777'
Bryan O'Sullivan <bos@serpentine.com>
parents: 5155
diff changeset
  1165
            mode = 'lnk'
49554ba98951 debugstate: print symlinks as 'lnk', not '777'
Bryan O'Sullivan <bos@serpentine.com>
parents: 5155
diff changeset
  1166
        else:
49554ba98951 debugstate: print symlinks as 'lnk', not '777'
Bryan O'Sullivan <bos@serpentine.com>
parents: 5155
diff changeset
  1167
            mode = '%3o' % (ent[1] & 0777)
6296
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  1168
        ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
3159
e43fd1623fe1 fix users of dirstate.copies broken by b1f10d3223c1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3146
diff changeset
  1169
    for f in repo.dirstate.copies():
e43fd1623fe1 fix users of dirstate.copies broken by b1f10d3223c1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3146
diff changeset
  1170
        ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
  1171
8812
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  1172
def debugsub(ui, repo, rev=None):
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  1173
    if rev == '':
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  1174
        rev = None
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  1175
    for k, v in sorted(repo[rev].substate.items()):
8812
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  1176
        ui.write('path %s\n' % k)
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  1177
        ui.write(' source   %s\n' % v[0])
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  1178
        ui.write(' revision %s\n' % v[1])
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  1179
11336
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1180
def debugdag(ui, repo, file_=None, *revs, **opts):
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1181
    """format the changelog or an index DAG as a concise textual description
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1182
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1183
    If you pass a revlog index, the revlog's DAG is emitted. If you list
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1184
    revision numbers, they get labelled in the output as rN.
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1185
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1186
    Otherwise, the changelog DAG of the current repo is emitted.
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1187
    """
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1188
    spaces = opts.get('spaces')
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1189
    dots = opts.get('dots')
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1190
    if file_:
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1191
        rlog = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1192
        revs = set((int(r) for r in revs))
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1193
        def events():
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1194
            for r in rlog:
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1195
                yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1)))
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1196
                if r in revs:
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1197
                    yield 'l', (r, "r%i" % r)
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1198
    elif repo:
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1199
        cl = repo.changelog
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1200
        tags = opts.get('tags')
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1201
        branches = opts.get('branches')
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1202
        if tags:
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1203
            labels = {}
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1204
            for l, n in repo.tags().items():
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1205
                labels.setdefault(cl.rev(n), []).append(l)
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1206
        def events():
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1207
            b = "default"
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1208
            for r in cl:
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1209
                if branches:
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1210
                    newb = cl.read(cl.node(r))[5]['branch']
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1211
                    if newb != b:
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1212
                        yield 'a', newb
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1213
                        b = newb
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1214
                yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1)))
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1215
                if tags:
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1216
                    ls = labels.get(r)
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1217
                    if ls:
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1218
                        for l in ls:
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1219
                            yield 'l', (r, l)
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1220
    else:
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1221
        raise util.Abort(_('need repo for changelog dag'))
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1222
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1223
    for line in dagparser.dagtextlines(events(),
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1224
                                       addspaces=spaces,
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1225
                                       wraplabels=True,
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1226
                                       wrapannotations=True,
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1227
                                       wrapnonlinear=dots,
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1228
                                       usedots=dots,
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1229
                                       maxlinewidth=70):
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1230
        ui.write(line)
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1231
        ui.write("\n")
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  1232
12131
c061f9882ff7 debugdata: try to access filelogs through repo, if possible
Sune Foldager <cryo@cyanite.org>
parents: 12130
diff changeset
  1233
def debugdata(ui, repo, file_, rev):
4258
b11a2fb59cf5 revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents: 4257
diff changeset
  1234
    """dump the contents of a data file revision"""
12131
c061f9882ff7 debugdata: try to access filelogs through repo, if possible
Sune Foldager <cryo@cyanite.org>
parents: 12130
diff changeset
  1235
    r = None
c061f9882ff7 debugdata: try to access filelogs through repo, if possible
Sune Foldager <cryo@cyanite.org>
parents: 12130
diff changeset
  1236
    if repo:
c061f9882ff7 debugdata: try to access filelogs through repo, if possible
Sune Foldager <cryo@cyanite.org>
parents: 12130
diff changeset
  1237
        filelog = repo.file(file_)
c061f9882ff7 debugdata: try to access filelogs through repo, if possible
Sune Foldager <cryo@cyanite.org>
parents: 12130
diff changeset
  1238
        if len(filelog):
c061f9882ff7 debugdata: try to access filelogs through repo, if possible
Sune Foldager <cryo@cyanite.org>
parents: 12130
diff changeset
  1239
            r = filelog
c061f9882ff7 debugdata: try to access filelogs through repo, if possible
Sune Foldager <cryo@cyanite.org>
parents: 12130
diff changeset
  1240
    if not r:
c061f9882ff7 debugdata: try to access filelogs through repo, if possible
Sune Foldager <cryo@cyanite.org>
parents: 12130
diff changeset
  1241
        r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
1313
1cc7c0cbc30b Fix traceback during invalid rev identifier for debugdata
Anupam Kapoor<anupam.kapoor@gmail.com>
parents: 1312
diff changeset
  1242
    try:
1cc7c0cbc30b Fix traceback during invalid rev identifier for debugdata
Anupam Kapoor<anupam.kapoor@gmail.com>
parents: 1312
diff changeset
  1243
        ui.write(r.revision(r.lookup(rev)))
1cc7c0cbc30b Fix traceback during invalid rev identifier for debugdata
Anupam Kapoor<anupam.kapoor@gmail.com>
parents: 1312
diff changeset
  1244
    except KeyError:
3072
bc3fe3b5b785 Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3071
diff changeset
  1245
        raise util.Abort(_('invalid revision identifier %s') % rev)
1039
4296754ba7b4 Add debugdata for dumping revlog revision data
mpm@selenic.com
parents: 1037
diff changeset
  1246
3812
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
  1247
def debugdate(ui, date, range=None, **opts):
3805
299d6cce6c0b add debugdate command
Matt Mackall <mpm@selenic.com>
parents: 3804
diff changeset
  1248
    """parse and display a date"""
3812
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
  1249
    if opts["extended"]:
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
  1250
        d = util.parsedate(date, util.extendeddateformats)
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
  1251
    else:
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
  1252
        d = util.parsedate(date)
3805
299d6cce6c0b add debugdate command
Matt Mackall <mpm@selenic.com>
parents: 3804
diff changeset
  1253
    ui.write("internal: %s %s\n" % d)
299d6cce6c0b add debugdate command
Matt Mackall <mpm@selenic.com>
parents: 3804
diff changeset
  1254
    ui.write("standard: %s\n" % util.datestr(d))
3812
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
  1255
    if range:
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
  1256
        m = util.matchdate(range)
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
  1257
        ui.write("match: %s\n" % m(d[0]))
3805
299d6cce6c0b add debugdate command
Matt Mackall <mpm@selenic.com>
parents: 3804
diff changeset
  1258
12893
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1259
def debugindex(ui, repo, file_, **opts):
596
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
  1260
    """dump the contents of an index file"""
12132
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1261
    r = None
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1262
    if repo:
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1263
        filelog = repo.file(file_)
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1264
        if len(filelog):
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1265
            r = filelog
12893
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1266
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1267
    format = opts.get('format', 0)
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1268
    if format not in (0, 1):
12965
0d4fb319974b gpg, commands: fixed util.abort to util.Abort typos
Richard Hopkins
parents: 12893
diff changeset
  1269
        raise util.Abort("unknown format %d" % format)
12893
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1270
12132
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1271
    if not r:
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1272
        r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
12893
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1273
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1274
    if format == 0:
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1275
        ui.write("   rev    offset  length   base linkrev"
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1276
                 " nodeid       p1           p2\n")
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1277
    elif format == 1:
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1278
        ui.write("   rev flag   offset   length"
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1279
                 "     size   base   link     p1     p2       nodeid\n")
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1280
6750
fb42030d79d6 add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents: 6749
diff changeset
  1281
    for i in r:
2072
74d3f5336b66 Implement revlogng.
mason@suse.com
parents: 2042
diff changeset
  1282
        node = r.node(i)
12893
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1283
        if format == 0:
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1284
            try:
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1285
                pp = r.parents(node)
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1286
            except:
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1287
                pp = [nullid, nullid]
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1288
            ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1289
                    i, r.start(i), r.length(i), r.base(i), r.linkrev(i),
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1290
                    short(node), short(pp[0]), short(pp[1])))
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1291
        elif format == 1:
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1292
            pr = r.parentrevs(i)
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1293
            ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1294
                    i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  1295
                    r.base(i), r.linkrev(i), pr[0], pr[1], short(node)))
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
  1296
12132
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1297
def debugindexdot(ui, repo, file_):
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  1298
    """dump an index DAG as a graphviz dot file"""
12132
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1299
    r = None
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1300
    if repo:
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1301
        filelog = repo.file(file_)
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1302
        if len(filelog):
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1303
            r = filelog
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1304
    if not r:
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  1305
        r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
582
df8a5a0098d4 Remove all remaining print statements
mpm@selenic.com
parents: 580
diff changeset
  1306
    ui.write("digraph G {\n")
6750
fb42030d79d6 add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents: 6749
diff changeset
  1307
    for i in r:
2287
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
  1308
        node = r.node(i)
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
  1309
        pp = r.parents(node)
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
  1310
        ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
  1311
        if pp[1] != nullid:
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
  1312
            ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
582
df8a5a0098d4 Remove all remaining print statements
mpm@selenic.com
parents: 580
diff changeset
  1313
    ui.write("}\n")
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
  1314
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1315
def debuginstall(ui):
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1316
    '''test Mercurial installation
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1317
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1318
    Returns 0 on success.
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1319
    '''
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1320
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
  1321
    def writetemp(contents):
4849
035489f60842 Use a prefix for debuginstall tempfiles.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4818
diff changeset
  1322
        (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
  1323
        f = os.fdopen(fd, "wb")
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
  1324
        f.write(contents)
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
  1325
        f.close()
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
  1326
        return name
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
  1327
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1328
    problems = 0
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1329
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1330
    # encoding
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
  1331
    ui.status(_("Checking encoding (%s)...\n") % encoding.encoding)
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1332
    try:
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
  1333
        encoding.fromlocal("test")
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1334
    except util.Abort, inst:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1335
        ui.write(" %s\n" % inst)
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1336
        ui.write(_(" (check that your locale is properly set)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1337
        problems += 1
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1338
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1339
    # compiled modules
12004
1fe4702fe2df debuginstall: report installpath
Matt Mackall <mpm@selenic.com>
parents: 11969
diff changeset
  1340
    ui.status(_("Checking installed modules (%s)...\n")
1fe4702fe2df debuginstall: report installpath
Matt Mackall <mpm@selenic.com>
parents: 11969
diff changeset
  1341
              % os.path.dirname(__file__))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1342
    try:
12004
1fe4702fe2df debuginstall: report installpath
Matt Mackall <mpm@selenic.com>
parents: 11969
diff changeset
  1343
        import bdiff, mpatch, base85, osutil
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1344
    except Exception, inst:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1345
        ui.write(" %s\n" % inst)
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1346
        ui.write(_(" One or more extensions could not be found"))
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1347
        ui.write(_(" (check that you compiled the extensions)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1348
        problems += 1
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1349
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1350
    # templates
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1351
    ui.status(_("Checking templates...\n"))
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1352
    try:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1353
        import templater
7874
d812029cda85 cleanup: drop variables for unused return values
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 7850
diff changeset
  1354
        templater.templater(templater.templatepath("map-cmdline.default"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1355
    except Exception, inst:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1356
        ui.write(" %s\n" % inst)
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1357
        ui.write(_(" (templates seem to have been installed incorrectly)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1358
        problems += 1
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1359
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1360
    # patch
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1361
    ui.status(_("Checking patch...\n"))
5310
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1362
    patchproblems = 0
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1363
    a = "1\n2\n3\n4\n"
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1364
    b = "1\n2\n3\ninsert\n4\n"
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1365
    fa = writetemp(a)
5482
e5eedd74e70f Use both the from and to name in mdiff.unidiff.
Dustin Sallings <dustin@spy.net>
parents: 5405
diff changeset
  1366
    d = mdiff.unidiff(a, None, b, None, os.path.basename(fa),
e5eedd74e70f Use both the from and to name in mdiff.unidiff.
Dustin Sallings <dustin@spy.net>
parents: 5405
diff changeset
  1367
        os.path.basename(fa))
5310
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1368
    fd = writetemp(d)
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1369
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1370
    files = {}
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1371
    try:
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1372
        patch.patch(fd, ui, cwd=os.path.dirname(fa), files=files)
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1373
    except util.Abort, e:
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1374
        ui.write(_(" patch call failed:\n"))
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1375
        ui.write(" " + str(e) + "\n")
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1376
        patchproblems += 1
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
  1377
    else:
5310
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1378
        if list(files) != [os.path.basename(fa)]:
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1379
            ui.write(_(" unexpected patch output!\n"))
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1380
            patchproblems += 1
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 9012
diff changeset
  1381
        a = open(fa).read()
5310
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1382
        if a != b:
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1383
            ui.write(_(" patch test failed!\n"))
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1384
            patchproblems += 1
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1385
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1386
    if patchproblems:
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1387
        if ui.config('ui', 'patch'):
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1388
            ui.write(_(" (Current patch tool may be incompatible with patch,"
12083
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  1389
                       " or misconfigured. Please check your configuration"
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  1390
                       " file)\n"))
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4505
diff changeset
  1391
        else:
5760
0145f9afb0e7 Removed tabs and trailing whitespace in python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5741
diff changeset
  1392
            ui.write(_(" Internal patcher failure, please report this error"
12831
4d657b524be8 traceback: point to BugTracker on the wiki
Matt Mackall <mpm@selenic.com>
parents: 12829
diff changeset
  1393
                       " to http://mercurial.selenic.com/wiki/BugTracker\n"))
5310
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1394
    problems += patchproblems
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1395
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1396
    os.unlink(fa)
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
  1397
    os.unlink(fd)
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1398
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1399
    # editor
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1400
    ui.status(_("Checking commit editor...\n"))
5660
3c80ecdc1bcd Use VISUAL in addition to EDITOR when choosing the editor to use.
Osku Salerma <osku@iki.fi>
parents: 5658
diff changeset
  1401
    editor = ui.geteditor()
4488
62019c4427e3 Introduce find_exe. Use instead of find_in_path for programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4438
diff changeset
  1402
    cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0])
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1403
    if not cmdpath:
3855
b9cdd6f2aa43 debuginstall: fix a copy/paste error
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3848
diff changeset
  1404
        if editor == 'vi':
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1405
            ui.write(_(" No commit editor set and can't find vi in PATH\n"))
12083
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  1406
            ui.write(_(" (specify a commit editor in your configuration"
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  1407
                       " file)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1408
        else:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1409
            ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
12083
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  1410
            ui.write(_(" (specify a commit editor in your configuration"
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  1411
                       " file)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1412
            problems += 1
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1413
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1414
    # check username
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1415
    ui.status(_("Checking username...\n"))
9734
36c388a1aa51 commands: call ui.username carefully in debuginstall
Martin Geisler <mg@lazybytes.net>
parents: 9725
diff changeset
  1416
    try:
12063
516b000fbb7e cleanup: remove unused variables
Brodie Rao <brodie@bitheap.org>
parents: 12033
diff changeset
  1417
        ui.username()
9734
36c388a1aa51 commands: call ui.username carefully in debuginstall
Martin Geisler <mg@lazybytes.net>
parents: 9725
diff changeset
  1418
    except util.Abort, e:
36c388a1aa51 commands: call ui.username carefully in debuginstall
Martin Geisler <mg@lazybytes.net>
parents: 9725
diff changeset
  1419
        ui.write(" %s\n" % e)
12083
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  1420
        ui.write(_(" (specify a username in your configuration file)\n"))
9734
36c388a1aa51 commands: call ui.username carefully in debuginstall
Martin Geisler <mg@lazybytes.net>
parents: 9725
diff changeset
  1421
        problems += 1
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1422
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1423
    if not problems:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1424
        ui.status(_("No problems detected\n"))
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1425
    else:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1426
        ui.write(_("%s problems detected,"
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1427
                   " please check your install!\n") % problems)
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1428
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1429
    return problems
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1430
3652
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3651
diff changeset
  1431
def debugrename(ui, repo, file1, *pats, **opts):
1194
c165cbf56bb1 Add doc string for debugrename.
bos@serpentine.internal.keyresearch.com
parents: 1193
diff changeset
  1432
    """dump rename information"""
3652
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3651
diff changeset
  1433
6748
c6cc35a3d1de make debugrename work on p1, not tip
Matt Mackall <mpm@selenic.com>
parents: 6747
diff changeset
  1434
    ctx = repo[opts.get('rev')]
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  1435
    m = cmdutil.match(repo, (file1,) + pats, opts)
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
  1436
    for abs in ctx.walk(m):
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
  1437
        fctx = ctx[abs]
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  1438
        o = fctx.filelog().renamed(fctx.filenode())
6584
29c77e5dfb3c walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents: 6583
diff changeset
  1439
        rel = m.rel(abs)
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  1440
        if o:
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  1441
            ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
3652
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3651
diff changeset
  1442
        else:
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3651
diff changeset
  1443
            ui.write(_("%s not renamed\n") % rel)
1116
0cdd73b0767c Add some rename debugging support
mpm@selenic.com
parents: 1114
diff changeset
  1444
820
89985a1b3427 Clean up walk and changes code to use normalised names properly.
Bryan O'Sullivan <bos@serpentine.com>
parents: 815
diff changeset
  1445
def debugwalk(ui, repo, *pats, **opts):
1053
1539ca091d86 Added missing doc strings for two new debug commmands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1052
diff changeset
  1446
    """show how files match on given patterns"""
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  1447
    m = cmdutil.match(repo, pats, opts)
6585
d3d1d39da2fa walk: remove cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6584
diff changeset
  1448
    items = list(repo.walk(m))
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1449
    if not items:
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1450
        return
6586
d3463007d368 walk: return a single value
Matt Mackall <mpm@selenic.com>
parents: 6585
diff changeset
  1451
    fmt = 'f  %%-%ds  %%-%ds  %%s' % (
d3463007d368 walk: return a single value
Matt Mackall <mpm@selenic.com>
parents: 6585
diff changeset
  1452
        max([len(abs) for abs in items]),
d3463007d368 walk: return a single value
Matt Mackall <mpm@selenic.com>
parents: 6585
diff changeset
  1453
        max([len(m.rel(abs)) for abs in items]))
d3463007d368 walk: return a single value
Matt Mackall <mpm@selenic.com>
parents: 6585
diff changeset
  1454
    for abs in items:
d3463007d368 walk: return a single value
Matt Mackall <mpm@selenic.com>
parents: 6585
diff changeset
  1455
        line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '')
1309
332f225b835c Make debugwalk strip trailing spaces and remove these from test-walk.out
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1285
diff changeset
  1456
        ui.write("%s\n" % line.rstrip())
820
89985a1b3427 Clean up walk and changes code to use normalised names properly.
Bryan O'Sullivan <bos@serpentine.com>
parents: 815
diff changeset
  1457
732
ba0b6d17a6de Convert diff command over to using walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 731
diff changeset
  1458
def diff(ui, repo, *pats, **opts):
1568
1d7d0c07e8f3 make all commands be repo-wide by default
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1567
diff changeset
  1459
    """diff repository (or selected files)
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1460
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1461
    Show differences between revisions for the specified files.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1462
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1463
    Differences between files are shown using the unified diff format.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1464
12389
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 12386
diff changeset
  1465
    .. note::
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 12386
diff changeset
  1466
       diff may generate unexpected results for merges, as it will
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 12386
diff changeset
  1467
       default to comparing against the working directory's first
4ac734b9b3fd Use note admonition
Erik Zielke <ez@aragost.com>
parents: 12386
diff changeset
  1468
       parent changeset if no revisions are specified.
3822
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
  1469
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1470
    When two revision arguments are given, then changes are shown
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1471
    between those revisions. If only one revision is specified then
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1472
    that revision is compared to the working directory, and, when no
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1473
    revisions are specified, the working directory files are compared
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1474
    to its parent.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1475
10527
9c0ba837dc65 commands: correct diff -c explanation
timeless <timeless@mozdev.org>
parents: 10520
diff changeset
  1476
    Alternatively you can specify -c/--change with a revision to see
9c0ba837dc65 commands: correct diff -c explanation
timeless <timeless@mozdev.org>
parents: 10520
diff changeset
  1477
    the changes in that changeset relative to its first parent.
10520
75361931884d commands: mention diff -c
timeless <timeless@mozdev.org>
parents: 10515
diff changeset
  1478
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  1479
    Without the -a/--text option, diff will avoid generating diffs of
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  1480
    files it detects as binary. With -a, diff will generate a diff
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  1481
    anyway, probably with undesirable results.
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  1482
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  1483
    Use the -g/--git option to generate diffs in the git extended diff
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  1484
    format. For more information, read :hg:`help diffs`.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1485
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1486
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1487
    """
7628
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1488
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1489
    revs = opts.get('rev')
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1490
    change = opts.get('change')
9640
9e76232fbfbe diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents: 9636
diff changeset
  1491
    stat = opts.get('stat')
9857
24bc6e414610 diff: change --inverse to --reverse
Martin Geisler <mg@lazybytes.net>
parents: 9839
diff changeset
  1492
    reverse = opts.get('reverse')
7628
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1493
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1494
    if revs and change:
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1495
        msg = _('cannot specify --rev and --change at the same time')
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1496
        raise util.Abort(msg)
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1497
    elif change:
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1498
        node2 = repo.lookup(change)
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1499
        node1 = repo[node2].parents()[0].node()
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1500
    else:
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1501
        node1, node2 = cmdutil.revpair(repo, revs)
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
  1502
9857
24bc6e414610 diff: change --inverse to --reverse
Martin Geisler <mg@lazybytes.net>
parents: 9839
diff changeset
  1503
    if reverse:
9725
3f522d2fa633 diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents: 9718
diff changeset
  1504
        node1, node2 = node2, node1
3f522d2fa633 diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents: 9718
diff changeset
  1505
9642
7d17794f08a9 diffstat: with --git, mark binary files with Bin
Brodie Rao <me+hg@dackz.net>
parents: 9640
diff changeset
  1506
    diffopts = patch.diffopts(ui, opts)
6582
5acbdd3941c4 walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents: 6579
diff changeset
  1507
    m = cmdutil.match(repo, pats, opts)
12167
d2c5b0927c28 diff: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12166
diff changeset
  1508
    cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
d2c5b0927c28 diff: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12166
diff changeset
  1509
                           listsubrepos=opts.get('subrepos'))
396
8f8bb77d560e Show revisions in diffs like CVS, based on a patch from Goffredo Baroncelli.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 395
diff changeset
  1510
580
353a2ce50423 [PATCH] New export patch
mpm@selenic.com
parents: 577
diff changeset
  1511
def export(ui, repo, *changesets, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1512
    """dump the header and diffs for one or more changesets
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1513
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1514
    Print the changeset header and diffs for one or more revisions.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1515
10334
3d75c691b77d commands: fix the list of changeset header information in 'hg help export'
Steve Losh <steve@stevelosh.com>
parents: 10331
diff changeset
  1516
    The information shown in the changeset header is: author, date,
10335
6ae4f390ec61 commands: fix more changeset header information in 'hg help export'
Steve Losh <steve@stevelosh.com>
parents: 10334
diff changeset
  1517
    branch name (if non-default), changeset hash, parent(s) and commit
6ae4f390ec61 commands: fix more changeset header information in 'hg help export'
Steve Losh <steve@stevelosh.com>
parents: 10334
diff changeset
  1518
    comment.
3822
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
  1519
12390
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  1520
    .. note::
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  1521
       export may generate unexpected diff output for merge
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  1522
       changesets, as it will compare the merge changeset against its
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  1523
       first parent only.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1524
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1525
    Output may be to a file, in which case the name of the file is
9892
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
  1526
    given using a format string. The formatting rules are as follows:
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
  1527
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
  1528
    :``%%``: literal "%" character
11718
3e979f47a4c9 help: fix bytes/digit confusion for hashes
Matt Mackall <mpm@selenic.com>
parents: 11697
diff changeset
  1529
    :``%H``: changeset hash (40 hexadecimal digits)
9892
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
  1530
    :``%N``: number of patches being generated
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
  1531
    :``%R``: changeset revision number
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
  1532
    :``%b``: basename of the exporting repository
11718
3e979f47a4c9 help: fix bytes/digit confusion for hashes
Matt Mackall <mpm@selenic.com>
parents: 11697
diff changeset
  1533
    :``%h``: short-form changeset hash (12 hexadecimal digits)
9892
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
  1534
    :``%n``: zero-padded sequence number, starting at 1
4322e39bd525 commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents: 9891
diff changeset
  1535
    :``%r``: zero-padded changeset revision number
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1536
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  1537
    Without the -a/--text option, export will avoid generating diffs
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  1538
    of files it detects as binary. With -a, export will generate a
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  1539
    diff anyway, probably with undesirable results.
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  1540
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  1541
    Use the -g/--git option to generate diffs in the git extended diff
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  1542
    format. See :hg:`help diffs` for more information.
7307
56380212d630 help: commands supporting --git point to the gitdiffs topic (issue1352)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7303
diff changeset
  1543
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  1544
    With the --switch-parent option, the diff will be against the
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  1545
    second parent. It can be useful to review a merge.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1546
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1547
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1548
    """
10015
b5f352f33520 commands.export: accept -r option as revision specification
Alexander Solovyov <piranha@piranha.org.ua>
parents: 10014
diff changeset
  1549
    changesets += tuple(opts.get('rev', []))
610
4c02464cb9f0 check export options for changeset before running
shaleh@speakeasy.net
parents: 609
diff changeset
  1550
    if not changesets:
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  1551
        raise util.Abort(_("export requires at least one changeset"))
3707
67f44b825784 Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3706
diff changeset
  1552
    revs = cmdutil.revrange(repo, changesets)
2874
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2871
diff changeset
  1553
    if len(revs) > 1:
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2871
diff changeset
  1554
        ui.note(_('exporting patches:\n'))
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2871
diff changeset
  1555
    else:
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2871
diff changeset
  1556
        ui.note(_('exporting patch:\n'))
10611
e764f24a45ee patch/diff: move patch.export() to cmdutil.export()
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10596
diff changeset
  1557
    cmdutil.export(repo, revs, template=opts.get('output'),
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1558
                 switch_parent=opts.get('switch_parent'),
2888
3848488244fc Move ui.diffopts to patch.diffopts where it belongs
Matt Mackall <mpm@selenic.com>
parents: 2883
diff changeset
  1559
                 opts=patch.diffopts(ui, opts))
246
96cde50a746f Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents: 245
diff changeset
  1560
8902
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1561
def forget(ui, repo, *pats, **opts):
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1562
    """forget the specified files on the next commit
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1563
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1564
    Mark the specified files so they will no longer be tracked
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1565
    after the next commit.
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1566
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1567
    This only removes files from the current branch, not from the
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1568
    entire project history, and it does not delete them from the
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1569
    working directory.
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1570
11193
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
  1571
    To undo a forget before the next commit, see :hg:`add`.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1572
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1573
    Returns 0 on success.
8902
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1574
    """
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1575
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1576
    if not pats:
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1577
        raise util.Abort(_('no files specified'))
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1578
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1579
    m = cmdutil.match(repo, pats, opts)
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1580
    s = repo.status(match=m, clean=True)
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1581
    forget = sorted(s[0] + s[1] + s[3] + s[6])
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1582
    errs = 0
8902
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1583
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1584
    for f in m.files():
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1585
        if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1586
            ui.warn(_('not removing %s: file is already untracked\n')
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1587
                    % m.rel(f))
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1588
            errs = 1
8902
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1589
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1590
    for f in forget:
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1591
        if ui.verbose or not m.exact(f):
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1592
            ui.status(_('removing %s\n') % m.rel(f))
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1593
11303
a1aad8333864 move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11302
diff changeset
  1594
    repo[None].remove(forget, unlink=False)
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1595
    return errs
8902
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1596
1108
7a75d8fbbdaf Remove some options from 'hg grep':
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1106
diff changeset
  1597
def grep(ui, repo, pattern, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1598
    """search for a pattern in specified files and revisions
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1599
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1600
    Search revisions of files for a regular expression.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1601
6448
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
  1602
    This command behaves differently than Unix grep. It only accepts
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
  1603
    Python/Perl regexps. It searches repository history, not the
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  1604
    working directory. It always prints the revision number in which a
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  1605
    match appears.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1606
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1607
    By default, grep only prints output for the first revision of a
6448
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
  1608
    file in which it finds a match. To get it to print every revision
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1609
    that contains a change in match status ("-" for a match that
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1610
    becomes a non-match, or "+" for a non-match that becomes a match),
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1611
    use the --all flag.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1612
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1613
    Returns 0 if a match is found, 1 otherwise.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1614
    """
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1615
    reflags = 0
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1616
    if opts.get('ignore_case'):
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1617
        reflags |= re.I
4877
242026115e6a hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4835
diff changeset
  1618
    try:
242026115e6a hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4835
diff changeset
  1619
        regexp = re.compile(pattern, reflags)
12385
9a93f4fb141b grep: only catch re.error when compiling regular expressions
Brodie Rao <brodie@bitheap.org>
parents: 12382
diff changeset
  1620
    except re.error, inst:
6057
218d5b9aa466 Remove trailing ! from two error messages as this was confusing.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6048
diff changeset
  1621
        ui.warn(_("grep: invalid match pattern: %s\n") % inst)
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1622
        return 1
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  1623
    sep, eol = ':', '\n'
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1624
    if opts.get('print0'):
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  1625
        sep = eol = '\0'
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1626
9097
431462bd8478 fix memory usage of revlog caches by limiting cache size [issue1639]
Matt Mackall <mpm@selenic.com>
parents: 8995
diff changeset
  1627
    getfile = util.lrucachefunc(repo.file)
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1628
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1629
    def matchlines(body):
1059
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
  1630
        begin = 0
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
  1631
        linenum = 0
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
  1632
        while True:
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
  1633
            match = regexp.search(body, begin)
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1634
            if not match:
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1635
                break
1059
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
  1636
            mstart, mend = match.span()
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
  1637
            linenum += body.count('\n', begin, mstart) + 1
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
  1638
            lstart = body.rfind('\n', begin, mstart) + 1 or begin
7230
261a9f47b44b grep: avoid infinite loop when trailing newline is missing
Matt Mackall <mpm@selenic.com>
parents: 7228
diff changeset
  1639
            begin = body.find('\n', mend) + 1 or len(body)
261a9f47b44b grep: avoid infinite loop when trailing newline is missing
Matt Mackall <mpm@selenic.com>
parents: 7228
diff changeset
  1640
            lend = begin - 1
1059
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
  1641
            yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1642
1559
59b3639df0a9 Convert all classes to new-style classes by deriving them from object.
Eric Hopper <hopper@omnifarious.org>
parents: 1552
diff changeset
  1643
    class linestate(object):
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1644
        def __init__(self, line, linenum, colstart, colend):
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1645
            self.line = line
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1646
            self.linenum = linenum
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1647
            self.colstart = colstart
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1648
            self.colend = colend
2869
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1649
6469
fb502719c75c python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents: 6468
diff changeset
  1650
        def __hash__(self):
fb502719c75c python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents: 6468
diff changeset
  1651
            return hash((self.linenum, self.line))
fb502719c75c python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents: 6468
diff changeset
  1652
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1653
        def __eq__(self, other):
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1654
            return self.line == other.line
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1655
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1656
    matches = {}
2870
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
  1657
    copies = {}
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1658
    def grepbody(fn, rev, body):
2869
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1659
        matches[rev].setdefault(fn, [])
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1660
        m = matches[rev][fn]
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1661
        for lnum, cstart, cend, line in matchlines(body):
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1662
            s = linestate(line, lnum, cstart, cend)
2869
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1663
            m.append(s)
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1664
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1665
    def difflinestates(a, b):
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1666
        sm = difflib.SequenceMatcher(None, a, b)
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1667
        for tag, alo, ahi, blo, bhi in sm.get_opcodes():
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1668
            if tag == 'insert':
3472
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3471
diff changeset
  1669
                for i in xrange(blo, bhi):
2869
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1670
                    yield ('+', b[i])
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1671
            elif tag == 'delete':
3472
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3471
diff changeset
  1672
                for i in xrange(alo, ahi):
2869
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1673
                    yield ('-', a[i])
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1674
            elif tag == 'replace':
3472
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3471
diff changeset
  1675
                for i in xrange(alo, ahi):
2869
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1676
                    yield ('-', a[i])
3472
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3471
diff changeset
  1677
                for i in xrange(blo, bhi):
2869
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1678
                    yield ('+', b[i])
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1679
9655
6d7d3f849062 walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents: 9654
diff changeset
  1680
    def display(fn, ctx, pstates, states):
6d7d3f849062 walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents: 9654
diff changeset
  1681
        rev = ctx.rev()
6134
7b937b26adf7 Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6133
diff changeset
  1682
        datefunc = ui.quiet and util.shortdate or util.datestr
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
  1683
        found = False
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  1684
        filerevmatches = {}
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1685
        if opts.get('all'):
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1686
            iter = difflinestates(pstates, states)
2869
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1687
        else:
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1688
            iter = [('', l) for l in states]
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
  1689
        for change, l in iter:
9655
6d7d3f849062 walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents: 9654
diff changeset
  1690
            cols = [fn, str(rev)]
10816
635d601e8f21 grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10654
diff changeset
  1691
            before, match, after = None, None, None
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1692
            if opts.get('line_number'):
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  1693
                cols.append(str(l.linenum))
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1694
            if opts.get('all'):
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  1695
                cols.append(change)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1696
            if opts.get('user'):
9655
6d7d3f849062 walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents: 9654
diff changeset
  1697
                cols.append(ui.shortuser(ctx.user()))
6133
779f2309d67a Add hg grep -d/--date to list the commit date of matched revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6109
diff changeset
  1698
            if opts.get('date'):
9655
6d7d3f849062 walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents: 9654
diff changeset
  1699
                cols.append(datefunc(ctx.date()))
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1700
            if opts.get('files_with_matches'):
9655
6d7d3f849062 walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents: 9654
diff changeset
  1701
                c = (fn, rev)
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  1702
                if c in filerevmatches:
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  1703
                    continue
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  1704
                filerevmatches[c] = 1
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  1705
            else:
10816
635d601e8f21 grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10654
diff changeset
  1706
                before = l.line[:l.colstart]
635d601e8f21 grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10654
diff changeset
  1707
                match = l.line[l.colstart:l.colend]
635d601e8f21 grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10654
diff changeset
  1708
                after = l.line[l.colend:]
635d601e8f21 grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10654
diff changeset
  1709
            ui.write(sep.join(cols))
635d601e8f21 grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10654
diff changeset
  1710
            if before is not None:
635d601e8f21 grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10654
diff changeset
  1711
                ui.write(sep + before)
635d601e8f21 grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10654
diff changeset
  1712
                ui.write(match, label='grep.match')
635d601e8f21 grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10654
diff changeset
  1713
                ui.write(after)
635d601e8f21 grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10654
diff changeset
  1714
            ui.write(eol)
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
  1715
            found = True
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
  1716
        return found
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1717
1145
bd917e1a26dd grep: change default to printing first matching rev.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1116
diff changeset
  1718
    skip = {}
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1719
    revfiles = {}
9652
2cb0cab10d2e walkchangerevs: pull out matchfn
Matt Mackall <mpm@selenic.com>
parents: 9625
diff changeset
  1720
    matchfn = cmdutil.match(repo, pats, opts)
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
  1721
    found = False
2870
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
  1722
    follow = opts.get('follow')
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1723
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1724
    def prep(ctx, fns):
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1725
        rev = ctx.rev()
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1726
        pctx = ctx.parents()[0]
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1727
        parent = pctx.rev()
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1728
        matches.setdefault(rev, {})
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1729
        matches.setdefault(parent, {})
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1730
        files = revfiles.setdefault(rev, [])
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1731
        for fn in fns:
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1732
            flog = getfile(fn)
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1733
            try:
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1734
                fnode = ctx.filenode(fn)
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1735
            except error.LookupError:
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1736
                continue
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1737
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1738
            copied = flog.renamed(fnode)
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1739
            copy = follow and copied and copied[0]
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1740
            if copy:
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1741
                copies.setdefault(rev, {})[fn] = copy
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1742
            if fn in skip:
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1743
                if copy:
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1744
                    skip[copy] = True
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1745
                continue
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1746
            files.append(fn)
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1747
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1748
            if fn not in matches[rev]:
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1749
                grepbody(fn, rev, flog.read(fnode))
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1750
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1751
            pfn = copy or fn
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1752
            if pfn not in matches[parent]:
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1753
                try:
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1754
                    fnode = pctx.filenode(pfn)
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1755
                    grepbody(pfn, parent, flog.read(fnode))
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents: 7632
diff changeset
  1756
                except error.LookupError:
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1757
                    pass
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1758
9665
1de5ebfa5585 walkchangerevs: drop ui arg
Matt Mackall <mpm@selenic.com>
parents: 9663
diff changeset
  1759
    for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1760
        rev = ctx.rev()
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1761
        parent = ctx.parents()[0].rev()
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1762
        for fn in sorted(revfiles.get(rev, [])):
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1763
            states = matches[rev][fn]
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1764
            copy = copies.get(rev, {}).get(fn)
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1765
            if fn in skip:
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1766
                if copy:
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1767
                    skip[copy] = True
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1768
                continue
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1769
            pstates = matches.get(parent, {}).get(copy or fn, [])
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1770
            if pstates or states:
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1771
                r = display(fn, ctx, pstates, states)
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1772
                found = found or r
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1773
                if r and not opts.get('all'):
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1774
                    skip[fn] = True
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1775
                    if copy:
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1776
                        skip[copy] = True
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1777
        del matches[rev]
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  1778
        del revfiles[rev]
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1779
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1780
    return not found
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1781
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1782
def heads(ui, repo, *branchrevs, **opts):
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1783
    """show current repository heads or show branch heads
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1784
10350
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1785
    With no arguments, show all repository branch heads.
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1786
9502
8d7d68dd91fd commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents: 9189
diff changeset
  1787
    Repository "heads" are changesets with no child changesets. They are
8d7d68dd91fd commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents: 9189
diff changeset
  1788
    where development generally takes place and are the usual targets
10350
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1789
    for update and merge operations. Branch heads are changesets that have
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1790
    no child changeset on the same branch.
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1791
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1792
    If one or more REVs are given, only branch heads on the branches
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1793
    associated with the specified changesets are shown.
9502
8d7d68dd91fd commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents: 9189
diff changeset
  1794
8d7d68dd91fd commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents: 9189
diff changeset
  1795
    If -c/--closed is specified, also show branch heads marked closed
11193
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
  1796
    (see :hg:`commit --close-branch`).
9502
8d7d68dd91fd commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents: 9189
diff changeset
  1797
8d7d68dd91fd commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents: 9189
diff changeset
  1798
    If STARTREV is specified, only those heads that are descendants of
8d7d68dd91fd commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents: 9189
diff changeset
  1799
    STARTREV will be displayed.
10350
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1800
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1801
    If -t/--topo is specified, named branch mechanics will be ignored and only
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1802
    changesets without children will be shown.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1803
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1804
    Returns 0 if matching heads are found, 1 if not.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1805
    """
10328
0798a3d5f812 commands: simplify heads a little bit before I start hacking it up
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10326
diff changeset
  1806
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1807
    if opts.get('rev'):
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1808
        start = repo.lookup(opts['rev'])
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1809
    else:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1810
        start = None
10328
0798a3d5f812 commands: simplify heads a little bit before I start hacking it up
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10326
diff changeset
  1811
10350
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1812
    if opts.get('topo'):
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1813
        heads = [repo[h] for h in repo.heads(start)]
1550
ccb9b62de892 add a -r/--rev option to heads to show only heads descendant from rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1547
diff changeset
  1814
    else:
10348
0fc5222c0951 commands: externalize branchheads so we can do it for all branches at once
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10347
diff changeset
  1815
        heads = []
0fc5222c0951 commands: externalize branchheads so we can do it for all branches at once
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10347
diff changeset
  1816
        for b, ls in repo.branchmap().iteritems():
0fc5222c0951 commands: externalize branchheads so we can do it for all branches at once
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10347
diff changeset
  1817
            if start is None:
10350
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1818
                heads += [repo[h] for h in ls]
10348
0fc5222c0951 commands: externalize branchheads so we can do it for all branches at once
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10347
diff changeset
  1819
                continue
0fc5222c0951 commands: externalize branchheads so we can do it for all branches at once
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10347
diff changeset
  1820
            startrev = repo.changelog.rev(start)
0fc5222c0951 commands: externalize branchheads so we can do it for all branches at once
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10347
diff changeset
  1821
            descendants = set(repo.changelog.descendants(startrev))
0fc5222c0951 commands: externalize branchheads so we can do it for all branches at once
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10347
diff changeset
  1822
            descendants.add(startrev)
10350
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1823
            rev = repo.changelog.rev
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1824
            heads += [repo[h] for h in ls if rev(h) in descendants]
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1825
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1826
    if branchrevs:
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1827
        decode, encode = encoding.fromlocal, encoding.tolocal
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1828
        branches = set(repo[decode(br)].branch() for br in branchrevs)
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1829
        heads = [h for h in heads if h.branch() in branches]
10328
0798a3d5f812 commands: simplify heads a little bit before I start hacking it up
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10326
diff changeset
  1830
10349
20356e69710c commands: actually implement --closed for topological heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10348
diff changeset
  1831
    if not opts.get('closed'):
10350
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1832
        heads = [h for h in heads if not h.extra().get('close')]
10349
20356e69710c commands: actually implement --closed for topological heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10348
diff changeset
  1833
20356e69710c commands: actually implement --closed for topological heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10348
diff changeset
  1834
    if opts.get('active') and branchrevs:
20356e69710c commands: actually implement --closed for topological heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10348
diff changeset
  1835
        dagheads = repo.heads(start)
10350
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1836
        heads = [h for h in heads if h.node() in dagheads]
10349
20356e69710c commands: actually implement --closed for topological heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10348
diff changeset
  1837
20356e69710c commands: actually implement --closed for topological heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10348
diff changeset
  1838
    if branchrevs:
10350
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1839
        haveheads = set(h.branch() for h in heads)
10346
e2db50cae6e6 commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10345
diff changeset
  1840
        if branches - haveheads:
e2db50cae6e6 commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10345
diff changeset
  1841
            headless = ', '.join(encode(b) for b in branches - haveheads)
e2db50cae6e6 commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10345
diff changeset
  1842
            msg = _('no open branch heads found on branches %s')
e2db50cae6e6 commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10345
diff changeset
  1843
            if opts.get('rev'):
e2db50cae6e6 commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10345
diff changeset
  1844
                msg += _(' (started at %s)' % opts['rev'])
e2db50cae6e6 commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10345
diff changeset
  1845
            ui.warn((msg + '\n') % headless)
e2db50cae6e6 commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10345
diff changeset
  1846
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1847
    if not heads:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1848
        return 1
10328
0798a3d5f812 commands: simplify heads a little bit before I start hacking it up
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10326
diff changeset
  1849
10350
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  1850
    heads = sorted(heads, key=lambda x: -x.rev())
3643
b4ad640a3bcf templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3631
diff changeset
  1851
    displayer = cmdutil.show_changeset(ui, repo, opts)
10331
ec5240a22f4a commands: always order heads recent to oldest
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10330
diff changeset
  1852
    for ctx in heads:
ec5240a22f4a commands: always order heads recent to oldest
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10330
diff changeset
  1853
        displayer.show(ctx)
10152
56284451a22c Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents: 10111
diff changeset
  1854
    displayer.close()
221
2bfe525ef6ca Beginning of multi-head support
mpm@selenic.com
parents: 220
diff changeset
  1855
10364
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  1856
def help_(ui, name=None, with_version=False, unknowncmd=False):
7210
833d1250ce00 help: update help
Matt Mackall <mpm@selenic.com>
parents: 7197
diff changeset
  1857
    """show help for a given topic or a help overview
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1858
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  1859
    With no arguments, print a list of commands with short help messages.
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1860
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  1861
    Given a topic, extension, or command name, print help for that
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1862
    topic.
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1863
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1864
    Returns 0 if successful.
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  1865
    """
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1866
    option_lists = []
12689
c52c629ce19e termwidth: move to ui.ui from util
Augie Fackler <durin42@gmail.com>
parents: 12688
diff changeset
  1867
    textwidth = ui.termwidth() - 2
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1868
4315
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1869
    def addglobalopts(aliases):
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1870
        if ui.verbose:
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1871
            option_lists.append((_("global options:"), globalopts))
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1872
            if name == 'shortlist':
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1873
                option_lists.append((_('use "hg help" for the full list '
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1874
                                       'of commands'), ()))
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1875
        else:
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1876
            if name == 'shortlist':
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1877
                msg = _('use "hg help" for the full list of commands '
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1878
                        'or "hg -v" for details')
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1879
            elif aliases:
13230
827a1cc127bf commands: clarify which aliases "hg help -v" show (issue2572)
Martin Geisler <mg@aragost.com>
parents: 13135
diff changeset
  1880
                msg = _('use "hg -v help%s" to show builtin aliases and '
4315
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1881
                        'global options') % (name and " " + name or "")
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1882
            else:
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1883
                msg = _('use "hg -v help %s" to show global options') % name
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1884
            option_lists.append((msg, ()))
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1885
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1886
    def helpcmd(name):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1887
        if with_version:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1888
            version_(ui)
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1889
            ui.write('\n')
6652
ffcf8e82f647 help: enable listing of a subset of the command list
Johannes Stezenbach <js@sig21.net>
parents: 6642
diff changeset
  1890
ffcf8e82f647 help: enable listing of a subset of the command list
Johannes Stezenbach <js@sig21.net>
parents: 6642
diff changeset
  1891
        try:
10364
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  1892
            aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd)
7643
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
  1893
        except error.AmbiguousCommand, inst:
9035
8e34f363dd77 compat: don't reference an exception var inside a lambda
Alejandro Santos <alejolp@alejolp.com>
parents: 9031
diff changeset
  1894
            # py3k fix: except vars can't be used outside the scope of the
8e34f363dd77 compat: don't reference an exception var inside a lambda
Alejandro Santos <alejolp@alejolp.com>
parents: 9031
diff changeset
  1895
            # except block, nor can be used inside a lambda. python issue4617
8e34f363dd77 compat: don't reference an exception var inside a lambda
Alejandro Santos <alejolp@alejolp.com>
parents: 9031
diff changeset
  1896
            prefix = inst.args[0]
8e34f363dd77 compat: don't reference an exception var inside a lambda
Alejandro Santos <alejolp@alejolp.com>
parents: 9031
diff changeset
  1897
            select = lambda c: c.lstrip('^').startswith(prefix)
6652
ffcf8e82f647 help: enable listing of a subset of the command list
Johannes Stezenbach <js@sig21.net>
parents: 6642
diff changeset
  1898
            helplist(_('list of commands:\n\n'), select)
ffcf8e82f647 help: enable listing of a subset of the command list
Johannes Stezenbach <js@sig21.net>
parents: 6642
diff changeset
  1899
            return
ffcf8e82f647 help: enable listing of a subset of the command list
Johannes Stezenbach <js@sig21.net>
parents: 6642
diff changeset
  1900
10021
0022f5c5459e help: don't display bogus help messages for invalid aliases
Brodie Rao <me+hg@dackz.net>
parents: 10015
diff changeset
  1901
        # check if it's an invalid alias and display its error if it is
0022f5c5459e help: don't display bogus help messages for invalid aliases
Brodie Rao <me+hg@dackz.net>
parents: 10015
diff changeset
  1902
        if getattr(entry[0], 'badalias', False):
10364
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  1903
            if not unknowncmd:
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  1904
                entry[0](ui)
10021
0022f5c5459e help: don't display bogus help messages for invalid aliases
Brodie Rao <me+hg@dackz.net>
parents: 10015
diff changeset
  1905
            return
0022f5c5459e help: don't display bogus help messages for invalid aliases
Brodie Rao <me+hg@dackz.net>
parents: 10015
diff changeset
  1906
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1907
        # synopsis
9901
cb2a1836c50a commands: minor refactoring
Henri Wiechers <hwiechers@gmail.com>
parents: 9894
diff changeset
  1908
        if len(entry) > 2:
cb2a1836c50a commands: minor refactoring
Henri Wiechers <hwiechers@gmail.com>
parents: 9894
diff changeset
  1909
            if entry[2].startswith('hg'):
cb2a1836c50a commands: minor refactoring
Henri Wiechers <hwiechers@gmail.com>
parents: 9894
diff changeset
  1910
                ui.write("%s\n" % entry[2])
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  1911
            else:
9901
cb2a1836c50a commands: minor refactoring
Henri Wiechers <hwiechers@gmail.com>
parents: 9894
diff changeset
  1912
                ui.write('hg %s %s\n' % (aliases[0], entry[2]))
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  1913
        else:
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  1914
            ui.write('hg %s\n' % aliases[0])
5783
28d9f8cd02f2 Move aliases section in help below synopsis (issue362)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5781
diff changeset
  1915
28d9f8cd02f2 Move aliases section in help below synopsis (issue362)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5781
diff changeset
  1916
        # aliases
28d9f8cd02f2 Move aliases section in help below synopsis (issue362)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5781
diff changeset
  1917
        if not ui.quiet and len(aliases) > 1:
28d9f8cd02f2 Move aliases section in help below synopsis (issue362)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5781
diff changeset
  1918
            ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1919
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1920
        # description
9901
cb2a1836c50a commands: minor refactoring
Henri Wiechers <hwiechers@gmail.com>
parents: 9894
diff changeset
  1921
        doc = gettext(entry[0].__doc__)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1922
        if not doc:
7598
26adfaccdf73 lowercase help output
Martin Geisler <mg@daimi.au.dk>
parents: 7596
diff changeset
  1923
            doc = _("(no help text available)")
10564
6ded6243bde2 alias: fixes exception when displaying translated help text
Yuya Nishihara <yuya@tcha.org>
parents: 10559
diff changeset
  1924
        if hasattr(entry[0], 'definition'):  # aliased command
11524
24965bb270b7 dispatch: add shell aliases
Steve Losh <steve@stevelosh.com>
parents: 11515
diff changeset
  1925
            if entry[0].definition.startswith('!'):  # shell alias
24965bb270b7 dispatch: add shell aliases
Steve Losh <steve@stevelosh.com>
parents: 11515
diff changeset
  1926
                doc = _('shell alias for::\n\n    %s') % entry[0].definition[1:]
24965bb270b7 dispatch: add shell aliases
Steve Losh <steve@stevelosh.com>
parents: 11515
diff changeset
  1927
            else:
24965bb270b7 dispatch: add shell aliases
Steve Losh <steve@stevelosh.com>
parents: 11515
diff changeset
  1928
                doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1929
        if ui.quiet:
9136
31177742f54a for calls expecting bool args, pass bool instead of int
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 9102
diff changeset
  1930
            doc = doc.splitlines()[0]
10445
8b45102934e2 commands: support verbose help
Martin Geisler <mg@lazybytes.net>
parents: 10413
diff changeset
  1931
        keep = ui.verbose and ['verbose'] or []
8b45102934e2 commands: support verbose help
Martin Geisler <mg@lazybytes.net>
parents: 10413
diff changeset
  1932
        formatted, pruned = minirst.format(doc, textwidth, keep=keep)
8b45102934e2 commands: support verbose help
Martin Geisler <mg@lazybytes.net>
parents: 10413
diff changeset
  1933
        ui.write("\n%s\n" % formatted)
8b45102934e2 commands: support verbose help
Martin Geisler <mg@lazybytes.net>
parents: 10413
diff changeset
  1934
        if pruned:
8b45102934e2 commands: support verbose help
Martin Geisler <mg@lazybytes.net>
parents: 10413
diff changeset
  1935
            ui.write(_('\nuse "hg -v help %s" to show verbose help\n') % name)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1936
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1937
        if not ui.quiet:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1938
            # options
9901
cb2a1836c50a commands: minor refactoring
Henri Wiechers <hwiechers@gmail.com>
parents: 9894
diff changeset
  1939
            if entry[1]:
cb2a1836c50a commands: minor refactoring
Henri Wiechers <hwiechers@gmail.com>
parents: 9894
diff changeset
  1940
                option_lists.append((_("options:\n"), entry[1]))
4315
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1941
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1942
            addglobalopts(False)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1943
4950
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1944
    def helplist(header, select=None):
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1945
        h = {}
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1946
        cmds = {}
7622
4dd7b28003d2 use dict.iteritems() rather than dict.items()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7598
diff changeset
  1947
        for c, e in table.iteritems():
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1948
            f = c.split("|", 1)[0]
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1949
            if select and not select(f):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1950
                continue
7197
f60730693efc help: show extension commands in short list, separate extension list in help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7196
diff changeset
  1951
            if (not select and name != 'shortlist' and
f60730693efc help: show extension commands in short list, separate extension list in help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7196
diff changeset
  1952
                e[0].__module__ != __name__):
7126
111813de4188 remove extension commands from global help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7125
diff changeset
  1953
                continue
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1954
            if name == "shortlist" and not f.startswith("^"):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1955
                continue
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1956
            f = f.lstrip("^")
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1957
            if not ui.debugflag and f.startswith("debug"):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1958
                continue
9128
98d90ad54749 commands: hide deprecated commands.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9097
diff changeset
  1959
            doc = e[0].__doc__
98d90ad54749 commands: hide deprecated commands.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9097
diff changeset
  1960
            if doc and 'DEPRECATED' in doc and not ui.verbose:
98d90ad54749 commands: hide deprecated commands.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9097
diff changeset
  1961
                continue
98d90ad54749 commands: hide deprecated commands.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9097
diff changeset
  1962
            doc = gettext(doc)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1963
            if not doc:
7598
26adfaccdf73 lowercase help output
Martin Geisler <mg@daimi.au.dk>
parents: 7596
diff changeset
  1964
                doc = _("(no help text available)")
9136
31177742f54a for calls expecting bool args, pass bool instead of int
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 9102
diff changeset
  1965
            h[f] = doc.splitlines()[0].rstrip()
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1966
            cmds[f] = c.lstrip("^")
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1967
4950
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1968
        if not h:
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1969
            ui.status(_('no commands defined\n'))
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1970
            return
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1971
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1972
        ui.status(header)
8209
a1a5a57efe90 replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents: 8190
diff changeset
  1973
        fns = sorted(h)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1974
        m = max(map(len, fns))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1975
        for f in fns:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1976
            if ui.verbose:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1977
                commands = cmds[f].replace("|",", ")
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1978
                ui.write(" %s:\n      %s\n"%(commands, h[f]))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1979
            else:
12698
7aef77e74cf3 util: make wrap() require a width argument
Matt Mackall <mpm@selenic.com>
parents: 12697
diff changeset
  1980
                ui.write('%s\n' % (util.wrap(h[f], textwidth,
11297
d320e70442a5 replace Python standard textwrap by MBCS sensitive one for i18n text
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11276
diff changeset
  1981
                                             initindent=' %-*s   ' % (m, f),
d320e70442a5 replace Python standard textwrap by MBCS sensitive one for i18n text
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11276
diff changeset
  1982
                                             hangindent=' ' * (m + 4))))
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1983
4315
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1984
        if not ui.quiet:
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1985
            addglobalopts(True)
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  1986
3795
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1987
    def helptopic(name):
7012
78341ea65d16 restructure helptable
Martin Geisler <mg@daimi.au.dk>
parents: 7006
diff changeset
  1988
        for names, header, doc in help.helptable:
78341ea65d16 restructure helptable
Martin Geisler <mg@daimi.au.dk>
parents: 7006
diff changeset
  1989
            if name in names:
78341ea65d16 restructure helptable
Martin Geisler <mg@daimi.au.dk>
parents: 7006
diff changeset
  1990
                break
78341ea65d16 restructure helptable
Martin Geisler <mg@daimi.au.dk>
parents: 7006
diff changeset
  1991
        else:
7643
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
  1992
            raise error.UnknownCommand(name)
3795
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1993
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1994
        # description
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1995
        if not doc:
7598
26adfaccdf73 lowercase help output
Martin Geisler <mg@daimi.au.dk>
parents: 7596
diff changeset
  1996
            doc = _("(no help text available)")
8366
0bf0045000b5 some modernization cleanups, forward compatibility
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8313
diff changeset
  1997
        if hasattr(doc, '__call__'):
3796
58133ba5847d Allow topics to be callables
Matt Mackall <mpm@selenic.com>
parents: 3795
diff changeset
  1998
            doc = doc()
3795
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1999
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2000
        ui.write("%s\n\n" % header)
9540
cad36e496640 help: un-indent help topics
Martin Geisler <mg@lazybytes.net>
parents: 9537
diff changeset
  2001
        ui.write("%s\n" % minirst.format(doc, textwidth, indent=4))
3795
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  2002
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2003
    def helpext(name):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2004
        try:
4544
930ed513c864 Create a separate module for managing extensions
Matt Mackall <mpm@selenic.com>
parents: 4543
diff changeset
  2005
            mod = extensions.find(name)
10364
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2006
            doc = gettext(mod.__doc__) or _('no help text available')
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2007
        except KeyError:
10364
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2008
            mod = None
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2009
            doc = extensions.disabledext(name)
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2010
            if not doc:
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2011
                raise error.UnknownCommand(name)
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2012
9280
b694531a5aa7 commands: Check if helptext contains a newline before we split
David Soria Parra <dsp@php.net>
parents: 9249
diff changeset
  2013
        if '\n' not in doc:
b694531a5aa7 commands: Check if helptext contains a newline before we split
David Soria Parra <dsp@php.net>
parents: 9249
diff changeset
  2014
            head, tail = doc, ""
b694531a5aa7 commands: Check if helptext contains a newline before we split
David Soria Parra <dsp@php.net>
parents: 9249
diff changeset
  2015
        else:
b694531a5aa7 commands: Check if helptext contains a newline before we split
David Soria Parra <dsp@php.net>
parents: 9249
diff changeset
  2016
            head, tail = doc.split('\n', 1)
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2017
        ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head))
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2018
        if tail:
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2019
            ui.write(minirst.format(tail, textwidth))
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2020
            ui.status('\n\n')
4009
86098ec4b77a fix hg help <ext> for extension that do not define any command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3915
diff changeset
  2021
10364
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2022
        if mod:
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2023
            try:
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2024
                ct = mod.cmdtable
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2025
            except AttributeError:
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2026
                ct = {}
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2027
            modcmds = set([c.split('|', 1)[0] for c in ct])
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2028
            helplist(_('list of commands:\n\n'), modcmds.__contains__)
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2029
        else:
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2030
            ui.write(_('use "hg help extensions" for information on enabling '
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2031
                       'extensions\n'))
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2032
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2033
    def helpextcmd(name):
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2034
        cmd, ext, mod = extensions.disabledcmd(name, ui.config('ui', 'strict'))
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2035
        doc = gettext(mod.__doc__).splitlines()[0]
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2036
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2037
        msg = help.listexts(_("'%s' is provided by the following "
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2038
                              "extension:") % cmd, {ext: doc}, len(ext),
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2039
                            indent=4)
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2040
        ui.write(minirst.format(msg, textwidth))
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2041
        ui.write('\n\n')
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2042
        ui.write(_('use "hg help extensions" for information on enabling '
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2043
                   'extensions\n'))
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2044
12821
165079e564f0 revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 12810
diff changeset
  2045
    help.addtopichook('revsets', revset.makedoc)
165079e564f0 revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 12810
diff changeset
  2046
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2047
    if name and name != 'shortlist':
3795
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  2048
        i = None
10364
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2049
        if unknowncmd:
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2050
            queries = (helpextcmd,)
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2051
        else:
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2052
            queries = (helptopic, helpcmd, helpext, helpextcmd)
de1e7099d100 dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents: 10355
diff changeset
  2053
        for f in queries:
3795
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  2054
            try:
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  2055
                f(name)
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  2056
                i = None
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  2057
                break
7643
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
  2058
            except error.UnknownCommand, inst:
3795
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  2059
                i = inst
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  2060
        if i:
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  2061
            raise i
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2062
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2063
    else:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2064
        # program name
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2065
        if ui.verbose or with_version:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2066
            version_(ui)
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2067
        else:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2068
            ui.status(_("Mercurial Distributed SCM\n"))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2069
        ui.status('\n')
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2070
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2071
        # list of commands
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2072
        if name == "shortlist":
4950
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  2073
            header = _('basic commands:\n\n')
4315
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  2074
        else:
4950
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  2075
            header = _('list of commands:\n\n')
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  2076
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  2077
        helplist(header)
9839
0a3fc37261ab help: don't show extension list on extension help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9831
diff changeset
  2078
        if name != 'shortlist':
0a3fc37261ab help: don't show extension list on extension help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9831
diff changeset
  2079
            exts, maxlength = extensions.enabled()
0a3fc37261ab help: don't show extension list on extension help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9831
diff changeset
  2080
            text = help.listexts(_('enabled extensions:'), exts, maxlength)
0a3fc37261ab help: don't show extension list on extension help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9831
diff changeset
  2081
            if text:
0a3fc37261ab help: don't show extension list on extension help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9831
diff changeset
  2082
                ui.write("\n%s\n" % minirst.format(text, textwidth))
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2083
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2084
    # list all option lists
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2085
    opt_output = []
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2086
    multioccur = False
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2087
    for title, options in option_lists:
4315
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4267
diff changeset
  2088
        opt_output.append(("\n%s" % title, None))
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2089
        for option in options:
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2090
            if len(option) == 5:
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2091
                shortopt, longopt, default, desc, optlabel = option
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2092
            else:
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2093
                shortopt, longopt, default, desc = option
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2094
                optlabel = _("VALUE") # default label
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2095
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  2096
            if _("DEPRECATED") in desc and not ui.verbose:
10339
23e608f42f2c fix spaces/identation issues
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10331
diff changeset
  2097
                continue
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2098
            if isinstance(default, list):
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2099
                numqualifier = " %s [+]" % optlabel
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2100
                multioccur = True
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2101
            elif (default is not None) and not isinstance(default, bool):
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2102
                numqualifier = " %s" % optlabel
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2103
            else:
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2104
                numqualifier = ""
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2105
            opt_output.append(("%2s%s" %
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2106
                               (shortopt and "-%s" % shortopt,
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2107
                                longopt and " --%s%s" %
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2108
                                (longopt, numqualifier)),
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2109
                               "%s%s" % (desc,
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2110
                                         default
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2111
                                         and _(" (default: %s)") % default
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2112
                                         or "")))
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2113
    if multioccur:
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2114
        msg = _("\n[+] marked option can be specified multiple times")
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2115
        if ui.verbose and name != 'shortlist':
11611
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
  2116
            opt_output.append((msg, None))
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  2117
        else:
11611
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
  2118
            opt_output.insert(-1, (msg, None))
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2119
7196
3f6a4f1de43f help: show help topics by default in 'hg help', with longest available id
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7185
diff changeset
  2120
    if not name:
7210
833d1250ce00 help: update help
Matt Mackall <mpm@selenic.com>
parents: 7197
diff changeset
  2121
        ui.write(_("\nadditional help topics:\n\n"))
6653
a78d8edaeedd help: list special help topics with -v
Johannes Stezenbach <js@sig21.net>
parents: 6652
diff changeset
  2122
        topics = []
7012
78341ea65d16 restructure helptable
Martin Geisler <mg@daimi.au.dk>
parents: 7006
diff changeset
  2123
        for names, header, doc in help.helptable:
9537
460e410c39be commands: simpler sort of help topic names
Martin Geisler <mg@lazybytes.net>
parents: 9508
diff changeset
  2124
            topics.append((sorted(names, key=len, reverse=True)[0], header))
6653
a78d8edaeedd help: list special help topics with -v
Johannes Stezenbach <js@sig21.net>
parents: 6652
diff changeset
  2125
        topics_len = max([len(s[0]) for s in topics])
a78d8edaeedd help: list special help topics with -v
Johannes Stezenbach <js@sig21.net>
parents: 6652
diff changeset
  2126
        for t, desc in topics:
a78d8edaeedd help: list special help topics with -v
Johannes Stezenbach <js@sig21.net>
parents: 6652
diff changeset
  2127
            ui.write(" %-*s  %s\n" % (topics_len, t, desc))
a78d8edaeedd help: list special help topics with -v
Johannes Stezenbach <js@sig21.net>
parents: 6652
diff changeset
  2128
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2129
    if opt_output:
11611
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
  2130
        colwidth = encoding.colwidth
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
  2131
        # normalize: (opt or message, desc or None, width of opt)
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
  2132
        entries = [desc and (opt, desc, colwidth(opt)) or (opt, None, 0)
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
  2133
                   for opt, desc in opt_output]
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
  2134
        hanging = max([e[2] for e in entries])
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
  2135
        for opt, desc, width in entries:
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
  2136
            if desc:
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
  2137
                initindent = ' %s%s  ' % (opt, ' ' * (hanging - width))
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
  2138
                hangindent = ' ' * (hanging + 3)
12698
7aef77e74cf3 util: make wrap() require a width argument
Matt Mackall <mpm@selenic.com>
parents: 12697
diff changeset
  2139
                ui.write('%s\n' % (util.wrap(desc, textwidth,
11297
d320e70442a5 replace Python standard textwrap by MBCS sensitive one for i18n text
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11276
diff changeset
  2140
                                             initindent=initindent,
d320e70442a5 replace Python standard textwrap by MBCS sensitive one for i18n text
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11276
diff changeset
  2141
                                             hangindent=hangindent)))
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  2142
            else:
11611
4f5a6df2af92 i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11518
diff changeset
  2143
                ui.write("%s\n" % opt)
221
2bfe525ef6ca Beginning of multi-head support
mpm@selenic.com
parents: 220
diff changeset
  2144
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
  2145
def identify(ui, repo, source=None,
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
  2146
             rev=None, num=None, id=None, branch=None, tags=None):
4665
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
  2147
    """identify the working copy or specified revision
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
  2148
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2149
    With no revision, print a summary of the current state of the
8027
9c7ca86fc658 expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8026
diff changeset
  2150
    repository.
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
  2151
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2152
    Specifying a path to a repository root or Mercurial bundle will
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2153
    cause lookup to operate on that repository/bundle.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2154
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2155
    This summary identifies the repository state using one or two
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2156
    parent hash identifiers, followed by a "+" if there are
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2157
    uncommitted changes in the working directory, a list of tags for
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2158
    this revision and a branch name for non-default branches.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2159
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2160
    Returns 0 if successful.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2161
    """
4662
f9b8ea362b49 identify: show nullid for empty repo
Matt Mackall <mpm@selenic.com>
parents: 4659
diff changeset
  2162
5330
4528858e7202 make identify an optionalrepo command
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5329
diff changeset
  2163
    if not repo and not source:
12067
a4fbbe0fbc38 Lowercase error messages
Martin Geisler <mg@lazybytes.net>
parents: 11881
diff changeset
  2164
        raise util.Abort(_("there is no Mercurial repository here "
5330
4528858e7202 make identify an optionalrepo command
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5329
diff changeset
  2165
                           "(.hg not found)"))
4528858e7202 make identify an optionalrepo command
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5329
diff changeset
  2166
2966
fb493241d7f6 Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents: 2963
diff changeset
  2167
    hexfunc = ui.debugflag and hex or short
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2168
    default = not (num or id or branch or tags)
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2169
    output = []
4664
dedb8abfd0e1 identify: use contexts
Matt Mackall <mpm@selenic.com>
parents: 4662
diff changeset
  2170
7757
af6a63438a8a identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7743
diff changeset
  2171
    revs = []
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
  2172
    if source:
10365
d757bc0c7865 interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents: 10364
diff changeset
  2173
        source, branches = hg.parseurl(ui.expandpath(source))
7757
af6a63438a8a identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7743
diff changeset
  2174
        repo = hg.repository(ui, source)
10365
d757bc0c7865 interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents: 10364
diff changeset
  2175
        revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
7757
af6a63438a8a identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7743
diff changeset
  2176
af6a63438a8a identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7743
diff changeset
  2177
    if not repo.local():
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
  2178
        if not rev and revs:
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
  2179
            rev = revs[0]
4667
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
  2180
        if not rev:
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
  2181
            rev = "tip"
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
  2182
        if num or branch or tags:
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
  2183
            raise util.Abort(
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
  2184
                "can't query remote revision number, branch, or tags")
7757
af6a63438a8a identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7743
diff changeset
  2185
        output = [hexfunc(repo.lookup(rev))]
4667
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
  2186
    elif not rev:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2187
        ctx = repo[None]
4665
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
  2188
        parents = ctx.parents()
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2189
        changed = False
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2190
        if default or id or num:
10515
98bc3e195720 identify: don't include unknown in status
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10505
diff changeset
  2191
            changed = util.any(repo.status())
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2192
        if default or id:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2193
            output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2194
                                (changed) and "+" or "")]
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2195
        if num:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2196
            output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2197
                                    (changed) and "+" or ""))
4665
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
  2198
    else:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2199
        ctx = repo[rev]
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2200
        if default or id:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2201
            output = [hexfunc(ctx.node())]
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2202
        if num:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2203
            output.append(str(ctx.rev()))
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2204
7757
af6a63438a8a identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7743
diff changeset
  2205
    if repo.local() and default and not ui.quiet:
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
  2206
        b = encoding.tolocal(ctx.branch())
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2207
        if b != 'default':
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2208
            output.append("(%s)" % b)
3415
9a6491770b04 Report branch for hg id
Matt Mackall <mpm@selenic.com>
parents: 3414
diff changeset
  2209
386
494c8e3f47f3 Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 371
diff changeset
  2210
        # multiple tags for a single parent separated by '/'
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2211
        t = "/".join(ctx.tags())
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2212
        if t:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2213
            output.append(t)
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2214
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2215
    if branch:
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
  2216
        output.append(encoding.tolocal(ctx.branch()))
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2217
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2218
    if tags:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  2219
        output.extend(ctx.tags())
339
a76fc9c4b67b added hg identify|id (based on a patch from Andrew Thompson)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 338
diff changeset
  2220
386
494c8e3f47f3 Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 371
diff changeset
  2221
    ui.write("%s\n" % ' '.join(output))
339
a76fc9c4b67b added hg identify|id (based on a patch from Andrew Thompson)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 338
diff changeset
  2222
437
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
  2223
def import_(ui, repo, patch1, *patches, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2224
    """import an ordered set of patches
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2225
9649
20b91f91f9ca minor documentation improvements
timeless@mozdev.org
parents: 9646
diff changeset
  2226
    Import a list of patches and commit them individually (unless
20b91f91f9ca minor documentation improvements
timeless@mozdev.org
parents: 9646
diff changeset
  2227
    --no-commit is specified).
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2228
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2229
    If there are outstanding changes in the working directory, import
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  2230
    will abort unless given the -f/--force flag.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2231
6448
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
  2232
    You can import a patch straight from a mail message. Even patches
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2233
    as attachments work (to use the body part, it must have type
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2234
    text/plain or text/x-patch). From and Subject headers of email
6448
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
  2235
    message are used as default committer and commit message. All
2515
a6700c222314 import: make help clearer. suggested by asak.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2513
diff changeset
  2236
    text/plain body parts before first diff are added to commit
a6700c222314 import: make help clearer. suggested by asak.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2513
diff changeset
  2237
    message.
2504
158d3d2ae070 import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2494
diff changeset
  2238
11193
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
  2239
    If the imported patch was generated by :hg:`export`, user and
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2240
    description from patch override values from message headers and
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  2241
    body. Values given on command line with -m/--message and -u/--user
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  2242
    override these.
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2243
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2244
    If --exact is specified, import will set the working directory to
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2245
    the parent of each patch before applying it, and will abort if the
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2246
    resulting changeset has a different ID than the one recorded in
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2247
    the patch. This may happen due to character set problems or other
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2248
    deficiencies in the text patch format.
4263
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
  2249
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  2250
    With -s/--similarity, hg will attempt to discover renames and
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  2251
    copies in the patch in the same way as 'addremove'.
7402
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  2252
8931
4c99eafb101e commands: add note about import retrieving patches from URLs
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8927
diff changeset
  2253
    To read a patch from standard input, use "-" as the patch name. If
4c99eafb101e commands: add note about import retrieving patches from URLs
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8927
diff changeset
  2254
    a URL is specified, the patch will be downloaded from it.
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  2255
    See :hg:`help dates` for a list of formats valid for -d/--date.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2256
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2257
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2258
    """
437
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
  2259
    patches = (patch1,) + patches
500
ebc4714a7632 [PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents: 499
diff changeset
  2260
6139
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
  2261
    date = opts.get('date')
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
  2262
    if date:
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
  2263
        opts['date'] = util.parsedate(date)
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
  2264
7402
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  2265
    try:
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  2266
        sim = float(opts.get('similarity') or 0)
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  2267
    except ValueError:
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  2268
        raise util.Abort(_('similarity must be a number'))
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  2269
    if sim < 0 or sim > 100:
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  2270
        raise util.Abort(_('similarity must be between 0 and 100'))
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  2271
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2272
    if opts.get('exact') or not opts.get('force'):
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
  2273
        cmdutil.bail_if_changed(repo)
966
022bcc738389 hg import: abort with uncommitted changes, override with --force
mpm@selenic.com
parents: 965
diff changeset
  2274
437
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
  2275
    d = opts["base"]
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
  2276
    strip = opts["strip"]
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2277
    wlock = lock = None
10384
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2278
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2279
    def tryone(ui, hunk):
10413
e433002acb05 fix up a bunch of check-code warnings
Matt Mackall <mpm@selenic.com>
parents: 10405
diff changeset
  2280
        tmpname, message, user, date, branch, nodeid, p1, p2 = \
e433002acb05 fix up a bunch of check-code warnings
Matt Mackall <mpm@selenic.com>
parents: 10405
diff changeset
  2281
            patch.extract(ui, hunk)
10384
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2282
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2283
        if not tmpname:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2284
            return None
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2285
        commitid = _('to working directory')
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2286
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2287
        try:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2288
            cmdline_message = cmdutil.logmessage(opts)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2289
            if cmdline_message:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2290
                # pickup the cmdline msg
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2291
                message = cmdline_message
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2292
            elif message:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2293
                # pickup the patch msg
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2294
                message = message.strip()
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2295
            else:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2296
                # launch the editor
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2297
                message = None
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2298
            ui.debug('message:\n%s\n' % message)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2299
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2300
            wp = repo.parents()
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2301
            if opts.get('exact'):
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2302
                if not nodeid or not p1:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2303
                    raise util.Abort(_('not a Mercurial patch'))
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2304
                p1 = repo.lookup(p1)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2305
                p2 = repo.lookup(p2 or hex(nullid))
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2306
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2307
                if p1 != wp[0].node():
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2308
                    hg.clean(repo, p1)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2309
                repo.dirstate.setparents(p1, p2)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2310
            elif p2:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2311
                try:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2312
                    p1 = repo.lookup(p1)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2313
                    p2 = repo.lookup(p2)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2314
                    if p1 == wp[0].node():
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2315
                        repo.dirstate.setparents(p1, p2)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2316
                except error.RepoError:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2317
                    pass
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2318
            if opts.get('exact') or opts.get('import_branch'):
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2319
                repo.dirstate.setbranch(branch or 'default')
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2320
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2321
            files = {}
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2322
            try:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2323
                patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2324
                            files=files, eolmode=None)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2325
            finally:
12266
00658492e2aa patch: break import cycle with cmdutil
Martin Geisler <mg@lazybytes.net>
parents: 12179
diff changeset
  2326
                files = cmdutil.updatedir(ui, repo, files,
00658492e2aa patch: break import cycle with cmdutil
Martin Geisler <mg@lazybytes.net>
parents: 12179
diff changeset
  2327
                                          similarity=sim / 100.0)
10384
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2328
            if not opts.get('no_commit'):
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2329
                if opts.get('exact'):
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2330
                    m = None
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2331
                else:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2332
                    m = cmdutil.matchfiles(repo, files or [])
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2333
                n = repo.commit(message, opts.get('user') or user,
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2334
                                opts.get('date') or date, match=m,
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2335
                                editor=cmdutil.commiteditor)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2336
                if opts.get('exact'):
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2337
                    if hex(n) != nodeid:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2338
                        repo.rollback()
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2339
                        raise util.Abort(_('patch is damaged'
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2340
                                           ' or loses information'))
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2341
                # Force a dirstate write so that the next transaction
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2342
                # backups an up-do-date file.
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2343
                repo.dirstate.write()
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2344
                if n:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2345
                    commitid = short(n)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2346
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2347
            return commitid
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2348
        finally:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2349
            os.unlink(tmpname)
10405
2d30d66a89ad whitespace cleanup
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 10394
diff changeset
  2350
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2351
    try:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2352
        wlock = repo.wlock()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2353
        lock = repo.lock()
10384
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2354
        lastcommit = None
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2355
        for p in patches:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2356
            pf = os.path.join(d, p)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2357
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2358
            if pf == '-':
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2359
                ui.status(_("applying patch from stdin\n"))
7271
8046f0a070a6 use our urlopener (proxy handling, etc) instead of urllib
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7270
diff changeset
  2360
                pf = sys.stdin
2400
2e90024e1471 import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2397
diff changeset
  2361
            else:
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2362
                ui.status(_("applying %s\n") % p)
7271
8046f0a070a6 use our urlopener (proxy handling, etc) instead of urllib
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7270
diff changeset
  2363
                pf = url.open(ui, pf)
10384
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2364
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2365
            haspatch = False
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2366
            for hunk in patch.split(pf):
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2367
                commitid = tryone(ui, hunk)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2368
                if commitid:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2369
                    haspatch = True
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2370
                    if lastcommit:
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2371
                        ui.status(_('applied %s\n') % lastcommit)
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2372
                    lastcommit = commitid
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2373
832f35386067 import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents: 10379
diff changeset
  2374
            if not haspatch:
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2375
                raise util.Abort(_('no diffs found'))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2376
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2377
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
  2378
        release(lock, wlock)
437
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
  2379
1192
6e165de907c5 Add -p to incoming and outgoing commands to show patch
TK Soh <teekaysoh@yahoo.com>
parents: 1191
diff changeset
  2380
def incoming(ui, repo, source="default", **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2381
    """show new changesets found in source
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2382
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
  2383
    Show new changesets found in the specified path/URL or the default
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2384
    pull location. These are the changesets that would have been pulled
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2385
    if a pull at the time you issued this command.
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2386
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2387
    For remote repository, using --bundle avoids downloading the
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2388
    changesets twice if the incoming is followed by a pull.
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
  2389
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
  2390
    See pull for valid source format details.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2391
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2392
    Returns 0 if there are incoming changes, 1 otherwise.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2393
    """
12274
c02e1ed3d407 incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12273
diff changeset
  2394
    if opts.get('bundle') and opts.get('subrepos'):
c02e1ed3d407 incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12273
diff changeset
  2395
        raise util.Abort(_('cannot combine --bundle and --subrepos'))
c02e1ed3d407 incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12273
diff changeset
  2396
c02e1ed3d407 incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12273
diff changeset
  2397
    ret = hg.incoming(ui, repo, source, opts)
c02e1ed3d407 incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12273
diff changeset
  2398
    return ret
1944
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
  2399
2598
b898afee9d0d Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2597
diff changeset
  2400
def init(ui, dest=".", **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2401
    """create a new repository in the given directory
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2402
6448
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
  2403
    Initialize a new repository in the given directory. If the given
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2404
    directory does not exist, it will be created.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2405
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2406
    If no directory is given, the current directory is used.
2590
911b56853fdd Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2589
diff changeset
  2407
9970
36760956f6d3 commands: mark "ssh://" as inline literals in help texts
Martin Geisler <mg@lazybytes.net>
parents: 9952
diff changeset
  2408
    It is possible to specify an ``ssh://`` URL as the destination.
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  2409
    See :hg:`help urls` for more information.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2410
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2411
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2412
    """
12584
fb24b491e06a init: expand destination url as a configured paths
Mads Kiilerich <mads@kiilerich.com>
parents: 12582
diff changeset
  2413
    hg.repository(hg.remoteui(ui, opts), ui.expandpath(dest), create=1)
338
1e091b3293d5 default path support with .hg/hgrc
mpm@selenic.com
parents: 335
diff changeset
  2414
627
b6c42714d900 Add locate command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 625
diff changeset
  2415
def locate(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2416
    """locate files matching specific patterns
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2417
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2418
    Print files under Mercurial control in the working directory whose
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2419
    names match the given patterns.
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2420
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2421
    By default, this command searches all directories in the working
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2422
    directory. To search just the current directory and its
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2423
    subdirectories, use "--include .".
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2424
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2425
    If no patterns are given to match, this command prints the names
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2426
    of all files under Mercurial control in the working directory.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2427
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2428
    If you want to feed the output of this command into the "xargs"
8032
4726a522a182 commands: use double quotes consistently in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8031
diff changeset
  2429
    command, use the -0 option to both this command and "xargs". This
4726a522a182 commands: use double quotes consistently in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8031
diff changeset
  2430
    will avoid the problem of "xargs" treating single filenames that
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2431
    contain whitespace as multiple filenames.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2432
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2433
    Returns 0 if a match is found, 1 otherwise.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2434
    """
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2435
    end = opts.get('print0') and '\0' or '\n'
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
  2436
    rev = opts.get('rev') or None
742
092937de2ad7 Refactor matchpats and walk
mpm@selenic.com
parents: 740
diff changeset
  2437
4196
1c69c73d85d9 locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4195
diff changeset
  2438
    ret = 1
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  2439
    m = cmdutil.match(repo, pats, opts, default='relglob')
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  2440
    m.bad = lambda x, y: False
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
  2441
    for abs in repo[rev].walk(m):
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
  2442
        if not rev and abs not in repo.dirstate:
4308
a5cde03cd019 locate: don't print "file not found" messages.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4252
diff changeset
  2443
            continue
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2444
        if opts.get('fullpath'):
7570
e05aa73ce2b7 use repo.wjoin(f) instead of os.path.join(repo.root, f)
Martin Geisler <mg@daimi.au.dk>
parents: 7540
diff changeset
  2445
            ui.write(repo.wjoin(abs), end)
724
1c0c413cccdd Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 723
diff changeset
  2446
        else:
6584
29c77e5dfb3c walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents: 6583
diff changeset
  2447
            ui.write(((pats and m.rel(abs)) or abs), end)
4196
1c69c73d85d9 locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4195
diff changeset
  2448
        ret = 0
1c69c73d85d9 locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4195
diff changeset
  2449
1c69c73d85d9 locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4195
diff changeset
  2450
    return ret
627
b6c42714d900 Add locate command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 625
diff changeset
  2451
1031
503aaf19a040 Rewrite log command. New version is faster and more featureful.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1030
diff changeset
  2452
def log(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2453
    """show revision history of entire repository or files
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2454
2741
ae5ce3454ef5 log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2739
diff changeset
  2455
    Print the revision history of the specified files or the entire
ae5ce3454ef5 log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2739
diff changeset
  2456
    project.
ae5ce3454ef5 log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2739
diff changeset
  2457
ae5ce3454ef5 log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2739
diff changeset
  2458
    File history is shown without following rename or copy history of
8761
0289f384e1e5 Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents: 8760
diff changeset
  2459
    files. Use -f/--follow with a filename to follow history across
0289f384e1e5 Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents: 8760
diff changeset
  2460
    renames and copies. --follow without a filename will only show
2784
12a7bfcafd8f Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents: 2783
diff changeset
  2461
    ancestors or descendants of the starting revision. --follow-first
12a7bfcafd8f Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents: 2783
diff changeset
  2462
    only follows the first parent of merge revisions.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2463
12803
a6a0698960cc commands: mark tip:0 as literal text
Martin Geisler <mg@lazybytes.net>
parents: 12788
diff changeset
  2464
    If no revision range is specified, the default is ``tip:0`` unless
2783
2e0cd25fe4ac Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents: 2782
diff changeset
  2465
    --follow is set, in which case the working directory parent is
11384
c04084753990 commands: advertise "hg help revsets" in help for log
Martin Geisler <mg@lazybytes.net>
parents: 11371
diff changeset
  2466
    used as the starting revision. You can specify a revision set for
c04084753990 commands: advertise "hg help revsets" in help for log
Martin Geisler <mg@lazybytes.net>
parents: 11371
diff changeset
  2467
    log, see :hg:`help revsets` for more information.
2783
2e0cd25fe4ac Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents: 2782
diff changeset
  2468
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  2469
    See :hg:`help dates` for a list of formats valid for -d/--date.
6163
1f733c2f0165 Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6161
diff changeset
  2470
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2471
    By default this command prints revision number and changeset id,
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2472
    tags, non-trivial parents, user, date and time, and a summary for
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2473
    each commit. When the -v/--verbose switch is used, the list of
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2474
    changed files and full commit message are shown.
3822
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
  2475
12390
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  2476
    .. note::
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  2477
       log -p/--patch may generate unexpected diff output for merge
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  2478
       changesets, as it will only compare the merge changeset against
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  2479
       its first parent. Also, only files different from BOTH parents
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  2480
       will appear in files:.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2481
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2482
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2483
    """
1756
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
  2484
9652
2cb0cab10d2e walkchangerevs: pull out matchfn
Matt Mackall <mpm@selenic.com>
parents: 9625
diff changeset
  2485
    matchfn = cmdutil.match(repo, pats, opts)
6190
a79d9408806f Move finding/checking the log limit to cmdutil
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6189
diff changeset
  2486
    limit = cmdutil.loglimit(opts)
1756
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
  2487
    count = 0
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
  2488
10060
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10021
diff changeset
  2489
    endrev = None
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2490
    if opts.get('copies') and opts.get('rev'):
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2491
        endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1
3197
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  2492
3813
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  2493
    df = False
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  2494
    if opts["date"]:
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  2495
        df = util.matchdate(opts["date"])
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  2496
10963
9e314c5e6890 log -b: use opts.get() instead of assuming opts is correctly filled
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10962
diff changeset
  2497
    branches = opts.get('branch', []) + opts.get('only_branch', [])
9e314c5e6890 log -b: use opts.get() instead of assuming opts is correctly filled
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10962
diff changeset
  2498
    opts['branch'] = [repo.lookupbranch(b) for b in branches]
10957
0d5f139b23c1 commands: Add 'hg log --branch' and deprecate 'hg log --only-branch'
Steve Losh <steve@stevelosh.com>
parents: 10934
diff changeset
  2499
11488
f786fc4b8764 log: follow filenames through renames (issue647)
Mads Kiilerich <mads@kiilerich.com>
parents: 11459
diff changeset
  2500
    displayer = cmdutil.show_changeset(ui, repo, opts, True)
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2501
    def prep(ctx, fns):
9655
6d7d3f849062 walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents: 9654
diff changeset
  2502
        rev = ctx.rev()
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2503
        parents = [p for p in repo.changelog.parentrevs(rev)
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2504
                   if p != nullrev]
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2505
        if opts.get('no_merges') and len(parents) == 2:
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2506
            return
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2507
        if opts.get('only_merges') and len(parents) != 2:
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2508
            return
10957
0d5f139b23c1 commands: Add 'hg log --branch' and deprecate 'hg log --only-branch'
Steve Losh <steve@stevelosh.com>
parents: 10934
diff changeset
  2509
        if opts.get('branch') and ctx.branch() not in opts['branch']:
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2510
            return
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2511
        if df and not df(ctx.date()[0]):
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2512
            return
12863
60d9692921ea log: do case insensitive search for --user option
Gilles Moris <gilles.moris@free.fr>
parents: 12852
diff changeset
  2513
        if opts['user'] and not [k for k in opts['user']
60d9692921ea log: do case insensitive search for --user option
Gilles Moris <gilles.moris@free.fr>
parents: 12852
diff changeset
  2514
                                 if k.lower() in ctx.user().lower()]:
9663
4164a17e7126 log: tidy up some filter tests
Matt Mackall <mpm@selenic.com>
parents: 9662
diff changeset
  2515
            return
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2516
        if opts.get('keyword'):
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2517
            for k in [kw.lower() for kw in opts['keyword']]:
9663
4164a17e7126 log: tidy up some filter tests
Matt Mackall <mpm@selenic.com>
parents: 9662
diff changeset
  2518
                if (k in ctx.user().lower() or
4164a17e7126 log: tidy up some filter tests
Matt Mackall <mpm@selenic.com>
parents: 9662
diff changeset
  2519
                    k in ctx.description().lower() or
4164a17e7126 log: tidy up some filter tests
Matt Mackall <mpm@selenic.com>
parents: 9662
diff changeset
  2520
                    k in " ".join(ctx.files()).lower()):
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2521
                    break
9663
4164a17e7126 log: tidy up some filter tests
Matt Mackall <mpm@selenic.com>
parents: 9662
diff changeset
  2522
            else:
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2523
                return
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2524
10060
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10021
diff changeset
  2525
        copies = None
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2526
        if opts.get('copies') and rev:
10060
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10021
diff changeset
  2527
            copies = []
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10021
diff changeset
  2528
            getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2529
            for fn in ctx.files():
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2530
                rename = getrenamed(fn, rev)
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2531
                if rename:
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2532
                    copies.append((fn, rename[0]))
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2533
11488
f786fc4b8764 log: follow filenames through renames (issue647)
Mads Kiilerich <mads@kiilerich.com>
parents: 11459
diff changeset
  2534
        revmatchfn = None
f786fc4b8764 log: follow filenames through renames (issue647)
Mads Kiilerich <mads@kiilerich.com>
parents: 11459
diff changeset
  2535
        if opts.get('patch') or opts.get('stat'):
12382
28ddf67198b2 log: include unmodified-in-merge files in log diff/stat (issue2383)
Mads Kiilerich <mads@kiilerich.com>
parents: 12129
diff changeset
  2536
            if opts.get('follow') or opts.get('follow_first'):
28ddf67198b2 log: include unmodified-in-merge files in log diff/stat (issue2383)
Mads Kiilerich <mads@kiilerich.com>
parents: 12129
diff changeset
  2537
                # note: this might be wrong when following through merges
28ddf67198b2 log: include unmodified-in-merge files in log diff/stat (issue2383)
Mads Kiilerich <mads@kiilerich.com>
parents: 12129
diff changeset
  2538
                revmatchfn = cmdutil.match(repo, fns, default='path')
28ddf67198b2 log: include unmodified-in-merge files in log diff/stat (issue2383)
Mads Kiilerich <mads@kiilerich.com>
parents: 12129
diff changeset
  2539
            else:
28ddf67198b2 log: include unmodified-in-merge files in log diff/stat (issue2383)
Mads Kiilerich <mads@kiilerich.com>
parents: 12129
diff changeset
  2540
                revmatchfn = matchfn
11488
f786fc4b8764 log: follow filenames through renames (issue647)
Mads Kiilerich <mads@kiilerich.com>
parents: 11459
diff changeset
  2541
f786fc4b8764 log: follow filenames through renames (issue647)
Mads Kiilerich <mads@kiilerich.com>
parents: 11459
diff changeset
  2542
        displayer.show(ctx, copies=copies, matchfn=revmatchfn)
9662
f3d60543924f walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents: 9656
diff changeset
  2543
9665
1de5ebfa5585 walkchangerevs: drop ui arg
Matt Mackall <mpm@selenic.com>
parents: 9663
diff changeset
  2544
    for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
9687
c6da1cb3b255 log --limit: break after a limited number of csets (broken by f3d60543924f)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9679
diff changeset
  2545
        if count == limit:
c6da1cb3b255 log --limit: break after a limited number of csets (broken by f3d60543924f)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9679
diff changeset
  2546
            break
c6da1cb3b255 log --limit: break after a limited number of csets (broken by f3d60543924f)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9679
diff changeset
  2547
        if displayer.flush(ctx.rev()):
c6da1cb3b255 log --limit: break after a limited number of csets (broken by f3d60543924f)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 9679
diff changeset
  2548
            count += 1
10152
56284451a22c Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents: 10111
diff changeset
  2549
    displayer.close()
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  2550
5155
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2551
def manifest(ui, repo, node=None, rev=None):
3914
283ee8971570 doc string fix: hg cat and manifest default to current parent revision.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3900
diff changeset
  2552
    """output the current or given revision of the project manifest
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2553
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2554
    Print a list of version controlled files for the given revision.
8041
87c5a4af0b5a Fix manifest default rev doc when no rev is checked out (issue1603)
Patrick Mezard <pmezard@gmail.com>
parents: 7850
diff changeset
  2555
    If no revision is given, the first parent of the working directory
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2556
    is used, or the null revision if no revision is checked out.
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2557
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2558
    With -v, print file permissions, symlink and executable bits.
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2559
    With --debug, print file revision hashes.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2560
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2561
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2562
    """
3736
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
  2563
5155
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2564
    if rev and node:
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2565
        raise util.Abort(_("please specify just one revision"))
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2566
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2567
    if not node:
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2568
        node = rev
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2569
6749
51b0e799352f manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents: 6748
diff changeset
  2570
    decor = {'l':'644 @ ', 'x':'755 * ', '':'644   '}
51b0e799352f manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents: 6748
diff changeset
  2571
    ctx = repo[node]
51b0e799352f manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents: 6748
diff changeset
  2572
    for f in ctx:
3736
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
  2573
        if ui.debugflag:
6749
51b0e799352f manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents: 6748
diff changeset
  2574
            ui.write("%40s " % hex(ctx.manifest()[f]))
3736
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
  2575
        if ui.verbose:
6749
51b0e799352f manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents: 6748
diff changeset
  2576
            ui.write(decor[ctx.flags(f)])
3736
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
  2577
        ui.write("%s\n" % f)
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  2578
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2579
def merge(ui, repo, node=None, **opts):
4014
509342f95564 various doc fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4013
diff changeset
  2580
    """merge working directory with another revision
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2581
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2582
    The current working directory is updated with all changes made in
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2583
    the requested revision since the last common predecessor revision.
7977
1cd3775e097c commands: better merge help text
Martin Geisler <mg@daimi.au.dk>
parents: 7976
diff changeset
  2584
1cd3775e097c commands: better merge help text
Martin Geisler <mg@daimi.au.dk>
parents: 7976
diff changeset
  2585
    Files that changed between either parent are marked as changed for
1cd3775e097c commands: better merge help text
Martin Geisler <mg@daimi.au.dk>
parents: 7976
diff changeset
  2586
    the next commit and a commit must be performed before any further
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2587
    updates to the repository are allowed. The next commit will have
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2588
    two parents.
2915
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2911
diff changeset
  2589
12750
05bd2658bbb3 merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents: 12727
diff changeset
  2590
    ``--tool`` can be used to specify the merge tool used for file
05bd2658bbb3 merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents: 12727
diff changeset
  2591
    merges. It overrides the HGMERGE environment variable and your
05bd2658bbb3 merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents: 12727
diff changeset
  2592
    configuration files.
05bd2658bbb3 merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents: 12727
diff changeset
  2593
2915
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2911
diff changeset
  2594
    If no revision is specified, the working directory's parent is a
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2595
    head revision, and the current branch contains exactly one other
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2596
    head, the other head is merged with by default. Otherwise, an
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2597
    explicit revision with which to merge with must be provided.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2598
12750
05bd2658bbb3 merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents: 12727
diff changeset
  2599
    :hg:`resolve` must be used to resolve unresolved files.
05bd2658bbb3 merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents: 12727
diff changeset
  2600
11452
eac141407b85 merge: document how to 'undo' a merge
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
  2601
    To undo an uncommitted merge, use :hg:`update --clean .` which
eac141407b85 merge: document how to 'undo' a merge
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
  2602
    will check out a clean copy of the original merge parent, losing
eac141407b85 merge: document how to 'undo' a merge
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
  2603
    all changes.
eac141407b85 merge: document how to 'undo' a merge
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
  2604
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2605
    Returns 0 on success, 1 if there are unresolved files.
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2606
    """
2806
0bf22c109cc3 Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents: 2803
diff changeset
  2607
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2608
    if opts.get('rev') and node:
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  2609
        raise util.Abort(_("please specify just one revision"))
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  2610
    if not node:
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2611
        node = opts.get('rev')
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  2612
3876
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
  2613
    if not node:
6740
b148e9099133 use repo.changectx(None) to get a workingctx
Matt Mackall <mpm@selenic.com>
parents: 6739
diff changeset
  2614
        branch = repo.changectx(None).branch()
6844
a38dff85d31f merge: use correct branch name for counting heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6843
diff changeset
  2615
        bheads = repo.branchheads(branch)
6723
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2616
        if len(bheads) > 2:
11353
f2b25e8ea6c1 merge: when current branch has 1 or > 2 heads, actually abort.
Greg Ward <greg-hg@gerg.ca>
parents: 11342
diff changeset
  2617
            raise util.Abort(_(
f2b25e8ea6c1 merge: when current branch has 1 or > 2 heads, actually abort.
Greg Ward <greg-hg@gerg.ca>
parents: 11342
diff changeset
  2618
                'branch \'%s\' has %d heads - '
f2b25e8ea6c1 merge: when current branch has 1 or > 2 heads, actually abort.
Greg Ward <greg-hg@gerg.ca>
parents: 11342
diff changeset
  2619
                'please merge with an explicit rev\n'
f2b25e8ea6c1 merge: when current branch has 1 or > 2 heads, actually abort.
Greg Ward <greg-hg@gerg.ca>
parents: 11342
diff changeset
  2620
                '(run \'hg heads .\' to see heads)')
f2b25e8ea6c1 merge: when current branch has 1 or > 2 heads, actually abort.
Greg Ward <greg-hg@gerg.ca>
parents: 11342
diff changeset
  2621
                % (branch, len(bheads)))
6723
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2622
5242
9cd6578750b9 improve error message for 'hg merge' when repo already at branchtip
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5205
diff changeset
  2623
        parent = repo.dirstate.parents()[0]
6723
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2624
        if len(bheads) == 1:
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2625
            if len(repo.heads()) > 1:
11353
f2b25e8ea6c1 merge: when current branch has 1 or > 2 heads, actually abort.
Greg Ward <greg-hg@gerg.ca>
parents: 11342
diff changeset
  2626
                raise util.Abort(_(
f2b25e8ea6c1 merge: when current branch has 1 or > 2 heads, actually abort.
Greg Ward <greg-hg@gerg.ca>
parents: 11342
diff changeset
  2627
                    'branch \'%s\' has one head - '
f2b25e8ea6c1 merge: when current branch has 1 or > 2 heads, actually abort.
Greg Ward <greg-hg@gerg.ca>
parents: 11342
diff changeset
  2628
                    'please merge with an explicit rev\n'
f2b25e8ea6c1 merge: when current branch has 1 or > 2 heads, actually abort.
Greg Ward <greg-hg@gerg.ca>
parents: 11342
diff changeset
  2629
                    '(run \'hg heads\' to see all heads)')
f2b25e8ea6c1 merge: when current branch has 1 or > 2 heads, actually abort.
Greg Ward <greg-hg@gerg.ca>
parents: 11342
diff changeset
  2630
                    % branch)
5242
9cd6578750b9 improve error message for 'hg merge' when repo already at branchtip
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5205
diff changeset
  2631
            msg = _('there is nothing to merge')
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2632
            if parent != repo.lookup(repo[None].branch()):
5542
253736bb0dc9 i18n: fix complaints from pygettext
Matt Mackall <mpm@selenic.com>
parents: 5525
diff changeset
  2633
                msg = _('%s - use "hg update" instead') % msg
5242
9cd6578750b9 improve error message for 'hg merge' when repo already at branchtip
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5205
diff changeset
  2634
            raise util.Abort(msg)
9cd6578750b9 improve error message for 'hg merge' when repo already at branchtip
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5205
diff changeset
  2635
6723
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2636
        if parent not in bheads:
2915
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2911
diff changeset
  2637
            raise util.Abort(_('working dir not at a head rev - '
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2911
diff changeset
  2638
                               'use "hg update" or merge with an explicit rev'))
6723
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2639
        node = parent == bheads[0] and bheads[-1] or bheads[0]
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2640
8834
6d36fc70754e merge: rename -S/--show option to -P/--preview
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8815
diff changeset
  2641
    if opts.get('preview'):
10505
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10479
diff changeset
  2642
        # find nodes that are ancestors of p2 but not of p1
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10479
diff changeset
  2643
        p1 = repo.lookup('.')
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10479
diff changeset
  2644
        p2 = repo.lookup(node)
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10479
diff changeset
  2645
        nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10479
diff changeset
  2646
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2647
        displayer = cmdutil.show_changeset(ui, repo, opts)
10505
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10479
diff changeset
  2648
        for node in nodes:
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10479
diff changeset
  2649
            displayer.show(repo[node])
10152
56284451a22c Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents: 10111
diff changeset
  2650
        displayer.close()
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2651
        return 0
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2652
12788
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  2653
    try:
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  2654
        # ui.forcemerge is an internal variable, do not document
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  2655
        ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  2656
        return hg.merge(repo, node, force=opts.get('force'))
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  2657
    finally:
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  2658
        ui.setconfig('ui', 'forcemerge', '')
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
  2659
2494
73ac95671788 push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2493
diff changeset
  2660
def outgoing(ui, repo, dest=None, **opts):
10376
a2950e053614 help: Improved body text
timeless <timeless@mozdev.org>
parents: 10375
diff changeset
  2661
    """show changesets not found in the destination
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2662
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2663
    Show changesets not found in the specified destination repository
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2664
    or the default push location. These are the changesets that would
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2665
    be pushed if a push was requested.
1811
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
  2666
10376
a2950e053614 help: Improved body text
timeless <timeless@mozdev.org>
parents: 10375
diff changeset
  2667
    See pull for details of valid destination formats.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2668
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2669
    Returns 0 if there are outgoing changes, 1 otherwise.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2670
    """
12272
42ecd56399d7 outgoing: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12271
diff changeset
  2671
    ret = hg.outgoing(ui, repo, dest, opts)
42ecd56399d7 outgoing: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12271
diff changeset
  2672
    return ret
920
270756aa29d5 Add hg outgoing command
mpm@selenic.com
parents: 918
diff changeset
  2673
3658
d12c8668b102 remove legacy hg parents REV syntax
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
  2674
def parents(ui, repo, file_=None, **opts):
8026
683d8ebcf434 expand "dir" to "directory" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8021
diff changeset
  2675
    """show the parents of the working directory or revision
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2676
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2677
    Print the working directory's parent revisions. If a revision is
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  2678
    given via -r/--rev, the parent of that revision will be printed.
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2679
    If a file argument is given, the revision in which the file was
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2680
    last changed (before the working directory revision or the
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2681
    argument to --rev if given) is printed.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2682
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2683
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2684
    """
3658
d12c8668b102 remove legacy hg parents REV syntax
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
  2685
    rev = opts.get('rev')
5298
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2686
    if rev:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2687
        ctx = repo[rev]
5298
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2688
    else:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2689
        ctx = repo[None]
5298
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2690
4586
1fcc076fcb17 Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents: 4451
diff changeset
  2691
    if file_:
6582
5acbdd3941c4 walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents: 6579
diff changeset
  2692
        m = cmdutil.match(repo, (file_,), opts)
5acbdd3941c4 walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents: 6579
diff changeset
  2693
        if m.anypats() or len(m.files()) != 1:
8761
0289f384e1e5 Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents: 8760
diff changeset
  2694
            raise util.Abort(_('can only specify an explicit filename'))
6582
5acbdd3941c4 walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents: 6579
diff changeset
  2695
        file_ = m.files()[0]
5298
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2696
        filenodes = []
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2697
        for cp in ctx.parents():
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2698
            if not cp:
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2699
                continue
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2700
            try:
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2701
                filenodes.append(cp.filenode(file_))
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents: 7632
diff changeset
  2702
            except error.LookupError:
5298
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2703
                pass
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2704
        if not filenodes:
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2705
            raise util.Abort(_("'%s' not found in manifest!") % file_)
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2706
        fl = repo.file(file_)
7361
9fe97eea5510 linkrev: take a revision number rather than a hash
Matt Mackall <mpm@selenic.com>
parents: 7308
diff changeset
  2707
        p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes]
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  2708
    else:
5298
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2709
        p = [cp.node() for cp in ctx.parents()]
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  2710
3643
b4ad640a3bcf templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3631
diff changeset
  2711
    displayer = cmdutil.show_changeset(ui, repo, opts)
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  2712
    for n in p:
1092
0a02315976ff commands: use node functions directly
mpm@selenic.com
parents: 1090
diff changeset
  2713
        if n != nullid:
7743
ec9b726a9428 commands: fix paths command docstring indention
Martin Geisler <mg@daimi.au.dk>
parents: 7739
diff changeset
  2714
            displayer.show(repo[n])
10152
56284451a22c Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents: 10111
diff changeset
  2715
    displayer.close()
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  2716
1858
9fab6e903bae Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1857
diff changeset
  2717
def paths(ui, repo, search=None):
7691
bcdc2fe3fd07 Clarified 'hg paths' command help
Bill Barry <after.fallout@gmail.com>
parents: 7684
diff changeset
  2718
    """show aliases for remote repositories
bcdc2fe3fd07 Clarified 'hg paths' command help
Bill Barry <after.fallout@gmail.com>
parents: 7684
diff changeset
  2719
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2720
    Show definition of symbolic path name NAME. If no name is given,
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2721
    show definition of all available names.
7743
ec9b726a9428 commands: fix paths command docstring indention
Martin Geisler <mg@daimi.au.dk>
parents: 7739
diff changeset
  2722
12083
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  2723
    Path names are defined in the [paths] section of your
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  2724
    configuration file and in ``/etc/mercurial/hgrc``. If run inside a
11009
4d3288197717 commands: better markup in "hg help paths"
Martin Geisler <mg@lazybytes.net>
parents: 11008
diff changeset
  2725
    repository, ``.hg/hgrc`` is used, too.
7693
e040f9d6b2f3 consolidated url help into urls help topic and added information about path aliases
Bill Barry <after.fallout@gmail.com>
parents: 7691
diff changeset
  2726
11007
a0102da324ab commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents: 10948
diff changeset
  2727
    The path names ``default`` and ``default-push`` have a special
a0102da324ab commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents: 10948
diff changeset
  2728
    meaning.  When performing a push or pull operation, they are used
a0102da324ab commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents: 10948
diff changeset
  2729
    as fallbacks if no location is specified on the command-line.
a0102da324ab commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents: 10948
diff changeset
  2730
    When ``default-push`` is set, it will be used for push and
a0102da324ab commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents: 10948
diff changeset
  2731
    ``default`` will be used for pull; otherwise ``default`` is used
a0102da324ab commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents: 10948
diff changeset
  2732
    as the fallback for both.  When cloning a repository, the clone
a0102da324ab commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents: 10948
diff changeset
  2733
    source is written as ``default`` in ``.hg/hgrc``.  Note that
11009
4d3288197717 commands: better markup in "hg help paths"
Martin Geisler <mg@lazybytes.net>
parents: 11008
diff changeset
  2734
    ``default`` and ``default-push`` apply to all inbound (e.g.
4d3288197717 commands: better markup in "hg help paths"
Martin Geisler <mg@lazybytes.net>
parents: 11008
diff changeset
  2735
    :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
4d3288197717 commands: better markup in "hg help paths"
Martin Geisler <mg@lazybytes.net>
parents: 11008
diff changeset
  2736
    :hg:`bundle`) operations.
10933
e3396b218e10 Document 'default' and 'default-push' in paths docstring
Faheem Mitha <faheem@email.unc.edu>
parents: 10645
diff changeset
  2737
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  2738
    See :hg:`help urls` for more information.
11507
35e2d453cf0d commands: document return values of add and paths commands
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11488
diff changeset
  2739
35e2d453cf0d commands: document return values of add and paths commands
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11488
diff changeset
  2740
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2741
    """
779
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2742
    if search:
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2743
        for name, path in ui.configitems("paths"):
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2744
            if name == search:
7270
2db33c1a5654 factor out the url handling from httprepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7236
diff changeset
  2745
                ui.write("%s\n" % url.hidepassword(path))
779
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2746
                return
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  2747
        ui.warn(_("not found!\n"))
779
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2748
        return 1
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2749
    else:
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2750
        for name, path in ui.configitems("paths"):
7270
2db33c1a5654 factor out the url handling from httprepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7236
diff changeset
  2751
            ui.write("%s = %s\n" % (name, url.hidepassword(path)))
779
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2752
5224
20817af258d8 pull -u: if "url#rev" was given, update to rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5222
diff changeset
  2753
def postincoming(ui, repo, modheads, optupdate, checkout):
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2754
    if modheads == 0:
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2755
        return
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2756
    if optupdate:
7372
e17dbf140035 pull: update to branch tip if there is only one head on the current branch
Benoit Allard <benoit@aeteurope.nl>
parents: 7369
diff changeset
  2757
        if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout:
5224
20817af258d8 pull -u: if "url#rev" was given, update to rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5222
diff changeset
  2758
            return hg.update(repo, checkout)
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2759
        else:
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2760
            ui.status(_("not updating, since new heads added\n"))
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2761
    if modheads > 1:
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2762
        ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2763
    else:
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2764
        ui.status(_("(run 'hg update' to get a working copy)\n"))
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
  2765
404
a1ecef497721 [PATCH] Unintuive use
mpm@selenic.com
parents: 403
diff changeset
  2766
def pull(ui, repo, source="default", **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2767
    """pull changes from the specified source
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2768
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2769
    Pull changes from a remote repository to a local one.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2770
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2771
    This finds all changes from the repository at the specified path
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2772
    or URL and adds them to a local repository (the current one unless
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2773
    -R is specified). By default, this does not update the copy of the
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2774
    project in the working directory.
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2775
11193
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
  2776
    Use :hg:`incoming` if you want to see what would have been added
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
  2777
    by a pull at the time you issued this command. If you then decide
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
  2778
    to add those changes to the repository, you should use :hg:`pull
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
  2779
    -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
7980
3d8252430e17 commands: make pull help point to the incoming command
Martin Geisler <mg@daimi.au.dk>
parents: 7979
diff changeset
  2780
7693
e040f9d6b2f3 consolidated url help into urls help topic and added information about path aliases
Bill Barry <after.fallout@gmail.com>
parents: 7691
diff changeset
  2781
    If SOURCE is omitted, the 'default' path will be used.
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  2782
    See :hg:`help urls` for more information.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2783
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2784
    Returns 0 on success, 1 if an update had unresolved files.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2785
    """
10379
a78bfaf988e1 add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents: 10376
diff changeset
  2786
    source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
11273
d1908cb95a82 remoteui: move from cmdutil to hg
Matt Mackall <mpm@selenic.com>
parents: 11219
diff changeset
  2787
    other = hg.repository(hg.remoteui(repo, opts), source)
7270
2db33c1a5654 factor out the url handling from httprepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7236
diff changeset
  2788
    ui.status(_('pulling from %s\n') % url.hidepassword(source))
10365
d757bc0c7865 interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents: 10364
diff changeset
  2789
    revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
  2790
    if revs:
5259
65dc707606ed Push capability checking into protocol-level code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5248
diff changeset
  2791
        try:
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
  2792
            revs = [other.lookup(rev) for rev in revs]
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
  2793
        except error.CapabilityError:
12128
090dc5eef746 pull: lowercase error message
Martin Geisler <mg@lazybytes.net>
parents: 12083
diff changeset
  2794
            err = _("other repository doesn't support revision lookup, "
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
  2795
                    "so a rev cannot be specified.")
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
  2796
            raise util.Abort(err)
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
  2797
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2798
    modheads = repo.pull(other, heads=revs, force=opts.get('force'))
9645
02f40b2ece3f commands: use rev from remote repo when updating as part of a pull
timeless@mozdev.org
parents: 9644
diff changeset
  2799
    if checkout:
02f40b2ece3f commands: use rev from remote repo when updating as part of a pull
timeless@mozdev.org
parents: 9644
diff changeset
  2800
        checkout = str(repo.changelog.rev(other.lookup(checkout)))
12852
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2801
    repo._subtoppath = source
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2802
    try:
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2803
        return postincoming(ui, repo, modheads, opts.get('update'), checkout)
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2804
    finally:
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2805
        del repo._subtoppath
246
96cde50a746f Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents: 245
diff changeset
  2806
2494
73ac95671788 push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2493
diff changeset
  2807
def push(ui, repo, dest=None, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2808
    """push changes to the specified destination
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2809
11217
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2810
    Push changesets from the local repository to the specified
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2811
    destination.
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2812
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2813
    This operation is symmetrical to pull: it is identical to a pull
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2814
    in the destination repository from the current one.
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2815
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2816
    By default, push will not allow creation of new heads at the
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2817
    destination, since multiple heads would make it unclear which head
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2818
    to use. In this situation, it is recommended to pull and merge
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2819
    before pushing.
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2820
11219
39a7f69a0a9a commands: document --new-branch flag for push
Martin Geisler <mg@aragost.com>
parents: 11218
diff changeset
  2821
    Use --new-branch if you want to allow push to create a new named
39a7f69a0a9a commands: document --new-branch flag for push
Martin Geisler <mg@aragost.com>
parents: 11218
diff changeset
  2822
    branch that is not present at the destination. This allows you to
39a7f69a0a9a commands: document --new-branch flag for push
Martin Geisler <mg@aragost.com>
parents: 11218
diff changeset
  2823
    only create a new branch without forcing other changes.
39a7f69a0a9a commands: document --new-branch flag for push
Martin Geisler <mg@aragost.com>
parents: 11218
diff changeset
  2824
11217
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2825
    Use -f/--force to override the default behavior and push all
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2826
    changesets on all branches.
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2827
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2828
    If -r/--rev is used, the specified revision and all its ancestors
1b8aa9ffa7dc commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents: 11103
diff changeset
  2829
    will be pushed to the remote repository.
7693
e040f9d6b2f3 consolidated url help into urls help topic and added information about path aliases
Bill Barry <after.fallout@gmail.com>
parents: 7691
diff changeset
  2830
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  2831
    Please see :hg:`help urls` for important details about ``ssh://``
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2832
    URLs. If DESTINATION is omitted, a default path will be used.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2833
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2834
    Returns 0 if push was successful, 1 if nothing to push.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2835
    """
10365
d757bc0c7865 interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents: 10364
diff changeset
  2836
    dest = ui.expandpath(dest or 'default-push', dest or 'default')
10379
a78bfaf988e1 add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents: 10376
diff changeset
  2837
    dest, branches = hg.parseurl(dest, opts.get('branch'))
10365
d757bc0c7865 interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents: 10364
diff changeset
  2838
    revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
11273
d1908cb95a82 remoteui: move from cmdutil to hg
Matt Mackall <mpm@selenic.com>
parents: 11219
diff changeset
  2839
    other = hg.repository(hg.remoteui(repo, opts), dest)
7270
2db33c1a5654 factor out the url handling from httprepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7236
diff changeset
  2840
    ui.status(_('pushing to %s\n') % url.hidepassword(dest))
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
  2841
    if revs:
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
  2842
        revs = [repo.lookup(rev) for rev in revs]
8815
e87b0fc4750b subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents: 8812
diff changeset
  2843
12852
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2844
    repo._subtoppath = dest
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2845
    try:
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2846
        # push subrepos depth-first for coherent ordering
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2847
        c = repo['']
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2848
        subs = c.substate # only repos that are committed
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2849
        for s in sorted(subs):
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2850
            if not c.sub(s).push(opts.get('force')):
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2851
                return False
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2852
    finally:
5dbff89cf107 subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents: 12831
diff changeset
  2853
        del repo._subtoppath
11211
e43c23d189a5 push: add --new-branch option to allow intial push of new branches
Sune Foldager <cryo@cyanite.org>
parents: 11193
diff changeset
  2854
    r = repo.push(other, opts.get('force'), revs=revs,
e43c23d189a5 push: add --new-branch option to allow intial push of new branches
Sune Foldager <cryo@cyanite.org>
parents: 11193
diff changeset
  2855
                  newbranch=opts.get('new_branch'))
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2856
    return r == 0
319
9ab17e83bce3 stopgap hg push support
mpm@selenic.com
parents: 317
diff changeset
  2857
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
  2858
def recover(ui, repo):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2859
    """roll back an interrupted transaction
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2860
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2861
    Recover from an interrupted commit or pull.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2862
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2863
    This command tries to fix the repository status after an
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2864
    interrupted operation. It should only be necessary when Mercurial
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2865
    suggests it.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2866
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2867
    Returns 0 if successful, 1 if nothing to recover or verify fails.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2868
    """
1516
0b1b029b4de3 Automatically run "verify" whenever we run "recover"
Matt Mackall <mpm@selenic.com>
parents: 1514
diff changeset
  2869
    if repo.recover():
2778
fdc232d8a193 Move repo.verify
Matt Mackall <mpm@selenic.com>
parents: 2776
diff changeset
  2870
        return hg.verify(repo)
2057
fef2d653beaf Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2056
diff changeset
  2871
    return 1
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
  2872
2179
520dd3d28e9b add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2175
diff changeset
  2873
def remove(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2874
    """remove the specified files on the next commit
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2875
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2876
    Schedule the indicated files for removal from the repository.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2877
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2878
    This only removes files from the current branch, not from the
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  2879
    entire project history. -A/--after can be used to remove only
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  2880
    files that have already been deleted, -f/--force can be used to
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  2881
    force deletion, and -Af can be used to remove files from the next
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2882
    revision without deleting them from the working directory.
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2883
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2884
    The following table details the behavior of remove for different
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2885
    file states (columns) and option combinations (rows). The file
9249
16f4cfc69e4f commands: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9219
diff changeset
  2886
    states are Added [A], Clean [C], Modified [M] and Missing [!] (as
11193
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
  2887
    reported by :hg:`status`). The actions are Warn, Remove (from
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
  2888
    branch) and Delete (from disk)::
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2889
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2890
             A  C  M  !
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2891
      none   W  RD W  R
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2892
      -f     R  RD RD R
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2893
      -A     W  W  W  R
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2894
      -Af    R  R  R  R
2309
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
  2895
3829
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3822
diff changeset
  2896
    This command schedules the files to be removed at the next commit.
11193
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
  2897
    To undo a remove before that, see :hg:`revert`.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2898
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2899
    Returns 0 on success, 1 if any warnings encountered.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2900
    """
6346
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  2901
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2902
    ret = 0
6346
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  2903
    after, force = opts.get('after'), opts.get('force')
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  2904
    if not pats and not after:
2179
520dd3d28e9b add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2175
diff changeset
  2905
        raise util.Abort(_('no files specified'))
6346
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  2906
6582
5acbdd3941c4 walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents: 6579
diff changeset
  2907
    m = cmdutil.match(repo, pats, opts)
6761
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2908
    s = repo.status(match=m, clean=True)
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2909
    modified, added, deleted, clean = s[0], s[1], s[3], s[6]
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2910
8533
6062c6362b2e remove: warn if unversionned files are specified (issue1454)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8464
diff changeset
  2911
    for f in m.files():
6062c6362b2e remove: warn if unversionned files are specified (issue1454)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8464
diff changeset
  2912
        if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
6062c6362b2e remove: warn if unversionned files are specified (issue1454)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8464
diff changeset
  2913
            ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2914
            ret = 1
8533
6062c6362b2e remove: warn if unversionned files are specified (issue1454)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8464
diff changeset
  2915
6761
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2916
    if force:
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2917
        remove, forget = modified + deleted + clean, added
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2918
    elif after:
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2919
        remove, forget = deleted, []
12129
07ac2a560fce remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents: 12128
diff changeset
  2920
        for f in modified + added + clean:
07ac2a560fce remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents: 12128
diff changeset
  2921
            ui.warn(_('not removing %s: file still exists (use -f'
07ac2a560fce remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents: 12128
diff changeset
  2922
                      ' to force removal)\n') % m.rel(f))
07ac2a560fce remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents: 12128
diff changeset
  2923
            ret = 1
6761
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2924
    else:
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2925
        remove, forget = deleted + clean, []
12129
07ac2a560fce remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents: 12128
diff changeset
  2926
        for f in modified:
07ac2a560fce remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents: 12128
diff changeset
  2927
            ui.warn(_('not removing %s: file is modified (use -f'
07ac2a560fce remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents: 12128
diff changeset
  2928
                      ' to force removal)\n') % m.rel(f))
07ac2a560fce remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents: 12128
diff changeset
  2929
            ret = 1
07ac2a560fce remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents: 12128
diff changeset
  2930
        for f in added:
07ac2a560fce remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents: 12128
diff changeset
  2931
            ui.warn(_('not removing %s: file has been marked for add (use -f'
07ac2a560fce remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents: 12128
diff changeset
  2932
                      ' to force removal)\n') % m.rel(f))
07ac2a560fce remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents: 12128
diff changeset
  2933
            ret = 1
6761
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2934
8209
a1a5a57efe90 replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents: 8190
diff changeset
  2935
    for f in sorted(remove + forget):
6761
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2936
        if ui.verbose or not m.exact(f):
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2937
            ui.status(_('removing %s\n') % m.rel(f))
6346
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  2938
11303
a1aad8333864 move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11302
diff changeset
  2939
    repo[None].forget(forget)
a1aad8333864 move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11302
diff changeset
  2940
    repo[None].remove(remove, unlink=not after)
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2941
    return ret
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
  2942
1253
a45e717c61a8 Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1250
diff changeset
  2943
def rename(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2944
    """rename files; equivalent of copy + remove
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2945
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2946
    Mark dest as copies of sources; mark sources for deletion. If dest
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2947
    is a directory, copies are put in that directory. If dest is a
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  2948
    file, there can only be one source.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2949
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2950
    By default, this command copies the contents of files as they
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  2951
    exist in the working directory. If invoked with -A/--after, the
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2952
    operation is recorded, but no copying is performed.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2953
7807
bd8f44638847 help: miscellaneous language fixes
timeless <timeless@gmail.com>
parents: 7765
diff changeset
  2954
    This command takes effect at the next commit. To undo a rename
11193
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 11185
diff changeset
  2955
    before that, see :hg:`revert`.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2956
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2957
    Returns 0 on success, 1 if errors are encountered.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2958
    """
4914
9a2a73ea6135 repo locks: use True/False
Matt Mackall <mpm@selenic.com>
parents: 4906
diff changeset
  2959
    wlock = repo.wlock(False)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2960
    try:
5610
2493a478f395 copy: handle rename internally
Matt Mackall <mpm@selenic.com>
parents: 5589
diff changeset
  2961
        return cmdutil.copy(ui, repo, pats, opts, rename=True)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2962
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
  2963
        wlock.release()
1253
a45e717c61a8 Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1250
diff changeset
  2964
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2965
def resolve(ui, repo, *pats, **opts):
11836
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2966
    """redo merges or set/view the merge status of files
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2967
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2968
    Merges with unresolved conflicts are often the result of
12083
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  2969
    non-interactive merging using the ``internal:merge`` configuration
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  2970
    setting, or a command-line merge tool like ``diff3``. The resolve
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  2971
    command is used to manage the files involved in a merge, after
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  2972
    :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12067
diff changeset
  2973
    working directory must have two parents).
11836
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2974
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2975
    The resolve command can be used in the following ways:
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2976
12809
e5922564ab01 help: improve merge-tools topic, describe --tool and clarify details
Mads Kiilerich <mads@kiilerich.com>
parents: 12803
diff changeset
  2977
    - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
12750
05bd2658bbb3 merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents: 12727
diff changeset
  2978
      files, discarding any previous merge attempts. Re-merging is not
11836
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2979
      performed for files already marked as resolved. Use ``--all/-a``
12750
05bd2658bbb3 merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents: 12727
diff changeset
  2980
      to selects all unresolved files. ``--tool`` can be used to specify
05bd2658bbb3 merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents: 12727
diff changeset
  2981
      the merge tool used for the given files. It overrides the HGMERGE
05bd2658bbb3 merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents: 12727
diff changeset
  2982
      environment variable and your configuration files.
11836
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2983
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2984
    - :hg:`resolve -m [FILE]`: mark a file as having been resolved
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2985
      (e.g. after having manually fixed-up the files). The default is
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2986
      to mark all unresolved files.
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2987
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2988
    - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2989
      default is to mark all resolved files.
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2990
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2991
    - :hg:`resolve -l`: list files which had or still have conflicts.
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2992
      In the printed list, ``U`` = unresolved and ``R`` = resolved.
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2993
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2994
    Note that Mercurial will not let you commit files with unresolved
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2995
    merge conflicts. You must use :hg:`resolve -m ...` before you can
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  2996
    commit after a conflicting merge.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2997
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  2998
    Returns 0 on success, 1 if any files fail a resolve attempt.
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2999
    """
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3000
9646
5b001f534452 commands: adding --no-status to resolve to match status
timeless <timeless@gmail.com>
parents: 9645
diff changeset
  3001
    all, mark, unmark, show, nostatus = \
5b001f534452 commands: adding --no-status to resolve to match status
timeless <timeless@gmail.com>
parents: 9645
diff changeset
  3002
        [opts.get(o) for o in 'all mark unmark list no_status'.split()]
7527
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  3003
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  3004
    if (show and (mark or unmark)) or (mark and unmark):
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3005
        raise util.Abort(_("too many options specified"))
7527
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  3006
    if pats and all:
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  3007
        raise util.Abort(_("can't specify --all and patterns"))
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  3008
    if not (all or pats or show or mark or unmark):
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  3009
        raise util.Abort(_('no files or directories specified; '
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  3010
                           'use --all to remerge all files'))
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3011
10651
5f091fc1bab7 style: use consistent variable names (*mod) with imports which would shadow
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10650
diff changeset
  3012
    ms = mergemod.mergestate(repo)
6594
fca1688f0459 resolve: use cmdutil.match
Matt Mackall <mpm@selenic.com>
parents: 6586
diff changeset
  3013
    m = cmdutil.match(repo, pats, opts)
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3014
    ret = 0
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3015
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3016
    for f in ms:
6594
fca1688f0459 resolve: use cmdutil.match
Matt Mackall <mpm@selenic.com>
parents: 6586
diff changeset
  3017
        if m(f):
7527
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  3018
            if show:
9646
5b001f534452 commands: adding --no-status to resolve to match status
timeless <timeless@gmail.com>
parents: 9645
diff changeset
  3019
                if nostatus:
5b001f534452 commands: adding --no-status to resolve to match status
timeless <timeless@gmail.com>
parents: 9645
diff changeset
  3020
                    ui.write("%s\n" % f)
5b001f534452 commands: adding --no-status to resolve to match status
timeless <timeless@gmail.com>
parents: 9645
diff changeset
  3021
                else:
10817
2096496b40ec status: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10816
diff changeset
  3022
                    ui.write("%s %s\n" % (ms[f].upper(), f),
2096496b40ec status: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10816
diff changeset
  3023
                             label='resolve.' +
2096496b40ec status: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10816
diff changeset
  3024
                             {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
7527
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  3025
            elif mark:
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3026
                ms.mark(f, "r")
7527
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  3027
            elif unmark:
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3028
                ms.mark(f, "u")
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3029
            else:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  3030
                wctx = repo[None]
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3031
                mctx = wctx.parents()[-1]
7847
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  3032
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  3033
                # backup pre-resolve (merge uses .orig for its own purposes)
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  3034
                a = repo.wjoin(f)
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  3035
                util.copyfile(a, a + ".resolve")
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  3036
12788
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  3037
                try:
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  3038
                    # resolve file
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  3039
                    ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  3040
                    if ms.resolve(f, wctx, mctx):
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  3041
                        ret = 1
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  3042
                finally:
de793925862e merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents: 12765
diff changeset
  3043
                    ui.setconfig('ui', 'forcemerge', '')
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3044
7847
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  3045
                # replace filemerge's .orig file with our resolve file
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  3046
                util.rename(a + ".resolve", a + ".orig")
12369
6f0d9d79111f merge: delay writing the mergestate during until commit is called
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 12323
diff changeset
  3047
6f0d9d79111f merge: delay writing the mergestate during until commit is called
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 12323
diff changeset
  3048
    ms.commit()
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3049
    return ret
7847
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  3050
1472
3c909a747d7f make revert use standard matcher
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1470
diff changeset
  3051
def revert(ui, repo, *pats, **opts):
8026
683d8ebcf434 expand "dir" to "directory" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8021
diff changeset
  3052
    """restore individual files or directories to an earlier state
5574
d4ec6d61b3ee imported patch rev-help
Matt Mackall <mpm@selenic.com>
parents: 5573
diff changeset
  3053
12390
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  3054
    .. note::
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  3055
       This command is most likely not what you are looking for.
12754
eaac5e8cb637 Revert: capitalization doc fix
Adrian Buehlmann <adrian@cadifra.com>
parents: 12750
diff changeset
  3056
       Revert will partially overwrite content in the working
12390
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  3057
       directory without changing the working directory parents. Use
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  3058
       :hg:`update -r rev` to check out earlier revisions, or
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  3059
       :hg:`update --clean .` to undo a merge which has added another
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  3060
       parent.
2204
eb5fa83ffcfa fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2189
diff changeset
  3061
2212
8164e3f31638 revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2204
diff changeset
  3062
    With no revision specified, revert the named files or directories
8164e3f31638 revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2204
diff changeset
  3063
    to the contents they had in the parent of the working directory.
8164e3f31638 revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2204
diff changeset
  3064
    This restores the contents of the affected files to an unmodified
3829
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3822
diff changeset
  3065
    state and unschedules adds, removes, copies, and renames. If the
10376
a2950e053614 help: Improved body text
timeless <timeless@mozdev.org>
parents: 10375
diff changeset
  3066
    working directory has two parents, you must explicitly specify a
a2950e053614 help: Improved body text
timeless <timeless@mozdev.org>
parents: 10375
diff changeset
  3067
    revision.
1811
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
  3068
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  3069
    Using the -r/--rev option, revert the given files or directories
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  3070
    to their contents as of a specific revision. This can be helpful
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  3071
    to "roll back" some or all of an earlier change. See :hg:`help
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  3072
    dates` for a list of formats valid for -d/--date.
1811
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
  3073
6448
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
  3074
    Revert modifies the working directory. It does not commit any
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
  3075
    changes, or change the parent of the working directory. If you
2204
eb5fa83ffcfa fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2189
diff changeset
  3076
    revert to a revision other than the parent of the working
eb5fa83ffcfa fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2189
diff changeset
  3077
    directory, the reverted files will thus appear modified
eb5fa83ffcfa fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2189
diff changeset
  3078
    afterwards.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3079
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  3080
    If a file has been deleted, it is restored. If the executable mode
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  3081
    of a file was changed, it is reset.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3082
1472
3c909a747d7f make revert use standard matcher
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1470
diff changeset
  3083
    If names are given, all files matching the names are reverted.
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
  3084
    If no arguments are given, no files are reverted.
5574
d4ec6d61b3ee imported patch rev-help
Matt Mackall <mpm@selenic.com>
parents: 5573
diff changeset
  3085
d4ec6d61b3ee imported patch rev-help
Matt Mackall <mpm@selenic.com>
parents: 5573
diff changeset
  3086
    Modified files are saved with a .orig suffix before reverting.
d4ec6d61b3ee imported patch rev-help
Matt Mackall <mpm@selenic.com>
parents: 5573
diff changeset
  3087
    To disable these backups, use --no-backup.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3088
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3089
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3090
    """
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
  3091
11941
4532c44bb62d revert: use opts.get
Xavier Snelgrove <xs@wxs.ca>
parents: 11886
diff changeset
  3092
    if opts.get("date"):
4532c44bb62d revert: use opts.get
Xavier Snelgrove <xs@wxs.ca>
parents: 11886
diff changeset
  3093
        if opts.get("rev"):
3814
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  3094
            raise util.Abort(_("you can't specify a revision and a date"))
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  3095
        opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  3096
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3097
    if not pats and not opts.get('all'):
3020
ea2a9c13afc6 Add a hint for revert --all when aborting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3016
diff changeset
  3098
        raise util.Abort(_('no files or directories specified; '
ea2a9c13afc6 Add a hint for revert --all when aborting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3016
diff changeset
  3099
                           'use --all to revert the whole repo'))
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
  3100
2212
8164e3f31638 revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2204
diff changeset
  3101
    parent, p2 = repo.dirstate.parents()
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3102
    if not opts.get('rev') and p2 != nullid:
3132
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3095
diff changeset
  3103
        raise util.Abort(_('uncommitted merge - please provide a '
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3095
diff changeset
  3104
                           'specific revision'))
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3105
    ctx = repo[opts.get('rev')]
3972
356e20d46b34 commands.py: use contexts in various places (debug*state, revert)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3951
diff changeset
  3106
    node = ctx.node()
356e20d46b34 commands.py: use contexts in various places (debug*state, revert)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3951
diff changeset
  3107
    mf = ctx.manifest()
2407
8fe3d60b7f19 revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2406
diff changeset
  3108
    if node == parent:
8fe3d60b7f19 revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2406
diff changeset
  3109
        pmf = mf
8fe3d60b7f19 revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2406
diff changeset
  3110
    else:
8fe3d60b7f19 revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2406
diff changeset
  3111
        pmf = None
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
  3112
2042
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
  3113
    # need all matching names in dirstate and manifest of target rev,
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
  3114
    # so have to walk both. do not print errors if files exist in one
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
  3115
    # but not other.
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
  3116
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
  3117
    names = {}
2042
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
  3118
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3119
    wlock = repo.wlock()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3120
    try:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3121
        # walk dirstate.
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  3122
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  3123
        m = cmdutil.match(repo, pats, opts)
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  3124
        m.bad = lambda x, y: False
6586
d3463007d368 walk: return a single value
Matt Mackall <mpm@selenic.com>
parents: 6585
diff changeset
  3125
        for abs in repo.walk(m):
6584
29c77e5dfb3c walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents: 6583
diff changeset
  3126
            names[abs] = m.rel(abs), m.exact(abs)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3127
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3128
        # walk target manifest.
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3129
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  3130
        def badfn(path, msg):
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3131
            if path in names:
8679
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
  3132
                return
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3133
            path_ = path + '/'
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3134
            for f in names:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3135
                if f.startswith(path_):
8679
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
  3136
                    return
8615
94ca38e63576 use ui instead of repo.ui when the former is in scope
Martin Geisler <mg@lazybytes.net>
parents: 8544
diff changeset
  3137
            ui.warn("%s: %s\n" % (m.rel(path), msg))
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3138
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  3139
        m = cmdutil.match(repo, pats, opts)
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  3140
        m.bad = badfn
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
  3141
        for abs in repo[node].walk(m):
6584
29c77e5dfb3c walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents: 6583
diff changeset
  3142
            if abs not in names:
29c77e5dfb3c walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents: 6583
diff changeset
  3143
                names[abs] = m.rel(abs), m.exact(abs)
6031
7383384793fb revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6030
diff changeset
  3144
6599
cd4db3999ef9 status: use match helpers for various users
Matt Mackall <mpm@selenic.com>
parents: 6594
diff changeset
  3145
        m = cmdutil.matchfiles(repo, names)
6603
41eb20cc1c02 match: remove files arg from repo.status and friends
Matt Mackall <mpm@selenic.com>
parents: 6602
diff changeset
  3146
        changes = repo.status(match=m)[:4]
8152
08e1baf924ca replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents: 8150
diff changeset
  3147
        modified, added, removed, deleted = map(set, changes)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3148
5266
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  3149
        # if f is a rename, also revert the source
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  3150
        cwd = repo.getcwd()
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  3151
        for f in added:
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  3152
            src = repo.dirstate.copied(f)
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  3153
            if src and src not in names and repo.dirstate[src] == 'r':
8152
08e1baf924ca replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents: 8150
diff changeset
  3154
                removed.add(src)
5266
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  3155
                names[src] = (repo.pathto(src, cwd), True)
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  3156
6109
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3157
        def removeforget(abs):
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3158
            if repo.dirstate[abs] == 'a':
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3159
                return _('forgetting %s\n')
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3160
            return _('removing %s\n')
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3161
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3162
        revert = ([], _('reverting %s\n'))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3163
        add = ([], _('adding %s\n'))
6109
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3164
        remove = ([], removeforget)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3165
        undelete = ([], _('undeleting %s\n'))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3166
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3167
        disptable = (
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3168
            # dispatch table:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3169
            #   file state
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3170
            #   action if in target manifest
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3171
            #   action if not in target manifest
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3172
            #   make backup if in target manifest
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3173
            #   make backup if not in target manifest
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3174
            (modified, revert, remove, True, True),
6109
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3175
            (added, revert, remove, True, False),
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3176
            (removed, undelete, None, False, False),
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3177
            (deleted, revert, remove, False, False),
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3178
            )
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3179
8209
a1a5a57efe90 replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents: 8190
diff changeset
  3180
        for abs, (rel, exact) in sorted(names.items()):
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3181
            mfentry = mf.get(abs)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3182
            target = repo.wjoin(abs)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3183
            def handle(xlist, dobackup):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3184
                xlist[0].append(abs)
12033
41def6704d01 revert: wrap long line
Martin Geisler <mg@lazybytes.net>
parents: 12032
diff changeset
  3185
                if (dobackup and not opts.get('no_backup') and
41def6704d01 revert: wrap long line
Martin Geisler <mg@lazybytes.net>
parents: 12032
diff changeset
  3186
                    os.path.lexists(target)):
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3187
                    bakname = "%s.orig" % rel
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3188
                    ui.note(_('saving current version of %s as %s\n') %
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3189
                            (rel, bakname))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3190
                    if not opts.get('dry_run'):
11629
9e874ee0fe97 revert: rename original to .orig instead of copying (issue2282)
Mads Kiilerich <mads@kiilerich.com>
parents: 11612
diff changeset
  3191
                        util.rename(target, bakname)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3192
                if ui.verbose or not exact:
6109
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3193
                    msg = xlist[1]
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3194
                    if not isinstance(msg, basestring):
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3195
                        msg = msg(abs)
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3196
                    ui.status(msg % rel)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3197
            for table, hitlist, misslist, backuphit, backupmiss in disptable:
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  3198
                if abs not in table:
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  3199
                    continue
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3200
                # file has changed in dirstate
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3201
                if mfentry:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3202
                    handle(hitlist, backuphit)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3203
                elif misslist is not None:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3204
                    handle(misslist, backupmiss)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3205
                break
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
  3206
            else:
6031
7383384793fb revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6030
diff changeset
  3207
                if abs not in repo.dirstate:
7383384793fb revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6030
diff changeset
  3208
                    if mfentry:
7383384793fb revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6030
diff changeset
  3209
                        handle(add, True)
7383384793fb revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6030
diff changeset
  3210
                    elif exact:
7383384793fb revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6030
diff changeset
  3211
                        ui.warn(_('file not managed: %s\n') % rel)
7383384793fb revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6030
diff changeset
  3212
                    continue
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3213
                # file has not changed in dirstate
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3214
                if node == parent:
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  3215
                    if exact:
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  3216
                        ui.warn(_('no changes needed to %s\n') % rel)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3217
                    continue
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3218
                if pmf is None:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3219
                    # only need parent manifest in this unlikely case,
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3220
                    # so do not read by default
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  3221
                    pmf = repo[parent].manifest()
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3222
                if abs in pmf:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3223
                    if mfentry:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3224
                        # if version of file is same in parent and target
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3225
                        # manifests, do nothing
6030
d0dbae32517c revert: revert clean files when only a change of flags is needed
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5986
diff changeset
  3226
                        if (pmf[abs] != mfentry or
d0dbae32517c revert: revert clean files when only a change of flags is needed
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5986
diff changeset
  3227
                            pmf.flags(abs) != mf.flags(abs)):
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3228
                            handle(revert, False)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3229
                    else:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3230
                        handle(remove, False)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3231
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3232
        if not opts.get('dry_run'):
6107
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  3233
            def checkout(f):
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  3234
                fc = ctx[f]
6743
86e8187b721a simplify flag handling
Matt Mackall <mpm@selenic.com>
parents: 6740
diff changeset
  3235
                repo.wwrite(f, fc.data(), fc.flags())
6107
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  3236
6109
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3237
            audit_path = util.path_auditor(repo.root)
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3238
            for f in remove[0]:
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3239
                if repo.dirstate[f] == 'a':
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3240
                    repo.dirstate.forget(f)
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3241
                    continue
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3242
                audit_path(f)
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3243
                try:
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3244
                    util.unlink(repo.wjoin(f))
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3245
                except OSError:
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3246
                    pass
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  3247
                repo.dirstate.remove(f)
6107
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  3248
6299
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  3249
            normal = None
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  3250
            if node == parent:
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  3251
                # We're reverting to our parent. If possible, we'd like status
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  3252
                # to report the file as clean. We have to use normallookup for
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  3253
                # merges to avoid losing information about merged/dirty files.
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  3254
                if p2 != nullid:
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  3255
                    normal = repo.dirstate.normallookup
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  3256
                else:
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  3257
                    normal = repo.dirstate.normal
6107
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  3258
            for f in revert[0]:
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  3259
                checkout(f)
6299
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  3260
                if normal:
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  3261
                    normal(f)
6107
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  3262
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3263
            for f in add[0]:
6107
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  3264
                checkout(f)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3265
                repo.dirstate.add(f)
6107
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  3266
6108
5086576a2152 revert: only call dirstate.normal when we know the file is clean
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6107
diff changeset
  3267
            normal = repo.dirstate.normallookup
5086576a2152 revert: only call dirstate.normal when we know the file is clean
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6107
diff changeset
  3268
            if node == parent and p2 == nullid:
5086576a2152 revert: only call dirstate.normal when we know the file is clean
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6107
diff changeset
  3269
                normal = repo.dirstate.normal
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3270
            for f in undelete[0]:
6107
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  3271
                checkout(f)
6108
5086576a2152 revert: only call dirstate.normal when we know the file is clean
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6107
diff changeset
  3272
                normal(f)
6107
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  3273
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  3274
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
  3275
        wlock.release()
588
0c3bae18403b [PATCH] hg revert
mpm@selenic.com
parents: 582
diff changeset
  3276
10882
f0bfe42c7b1f rollback: add dry-run argument, emit transaction description
Steve Borho <steve@borho.org>
parents: 10835
diff changeset
  3277
def rollback(ui, repo, **opts):
10889
e25c450c351e commands: improve some command summaries
Matt Mackall <mpm@selenic.com>
parents: 10882
diff changeset
  3278
    """roll back the last transaction (dangerous)
5575
8788ff630c26 imported patch rollback-help
Matt Mackall <mpm@selenic.com>
parents: 5574
diff changeset
  3279
8788ff630c26 imported patch rollback-help
Matt Mackall <mpm@selenic.com>
parents: 5574
diff changeset
  3280
    This command should be used with care. There is only one level of
8788ff630c26 imported patch rollback-help
Matt Mackall <mpm@selenic.com>
parents: 5574
diff changeset
  3281
    rollback, and there is no way to undo a rollback. It will also
8788ff630c26 imported patch rollback-help
Matt Mackall <mpm@selenic.com>
parents: 5574
diff changeset
  3282
    restore the dirstate at the time of the last transaction, losing
8856
f8d00346a62d rollback: minor clarification (issue828)
Matt Mackall <mpm@selenic.com>
parents: 8855
diff changeset
  3283
    any dirstate changes since that time. This command does not alter
f8d00346a62d rollback: minor clarification (issue828)
Matt Mackall <mpm@selenic.com>
parents: 8855
diff changeset
  3284
    the working directory.
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3285
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3286
    Transactions are used to encapsulate the effects of all commands
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3287
    that create new changesets or propagate existing changesets into a
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3288
    repository. For example, the following commands are transactional,
9893
af873901b575 commands, dates: use real lists instead of literal blocks
Martin Geisler <mg@lazybytes.net>
parents: 9892
diff changeset
  3289
    and their effects can be rolled back:
af873901b575 commands, dates: use real lists instead of literal blocks
Martin Geisler <mg@lazybytes.net>
parents: 9892
diff changeset
  3290
af873901b575 commands, dates: use real lists instead of literal blocks
Martin Geisler <mg@lazybytes.net>
parents: 9892
diff changeset
  3291
    - commit
af873901b575 commands, dates: use real lists instead of literal blocks
Martin Geisler <mg@lazybytes.net>
parents: 9892
diff changeset
  3292
    - import
af873901b575 commands, dates: use real lists instead of literal blocks
Martin Geisler <mg@lazybytes.net>
parents: 9892
diff changeset
  3293
    - pull
10376
a2950e053614 help: Improved body text
timeless <timeless@mozdev.org>
parents: 10375
diff changeset
  3294
    - push (with this repository as the destination)
9893
af873901b575 commands, dates: use real lists instead of literal blocks
Martin Geisler <mg@lazybytes.net>
parents: 9892
diff changeset
  3295
    - unbundle
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3296
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3297
    This command is not intended for use on public repositories. Once
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3298
    changes are visible for pull by other users, rolling a transaction
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3299
    back locally is ineffective (someone else may already have pulled
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3300
    the changes). Furthermore, a race is possible with readers of the
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3301
    repository; for example an in-progress pull from the repository
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3302
    may fail if a rollback is performed.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3303
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3304
    Returns 0 on success, 1 if no rollback data is available.
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3305
    """
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3306
    return repo.rollback(opts.get('dry_run'))
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  3307
468
157675add351 [PATCH] add "root" command
mpm@selenic.com
parents: 467
diff changeset
  3308
def root(ui, repo):
8026
683d8ebcf434 expand "dir" to "directory" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8021
diff changeset
  3309
    """print the root (top) of the current working directory
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3310
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3311
    Print the root directory of the current repository.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3312
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3313
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3314
    """
468
157675add351 [PATCH] add "root" command
mpm@selenic.com
parents: 467
diff changeset
  3315
    ui.write(repo.root + "\n")
157675add351 [PATCH] add "root" command
mpm@selenic.com
parents: 467
diff changeset
  3316
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
  3317
def serve(ui, repo, **opts):
10889
e25c450c351e commands: improve some command summaries
Matt Mackall <mpm@selenic.com>
parents: 10882
diff changeset
  3318
    """start stand-alone webserver
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3319
11102
275198bc904a commands: explain that "hg serve" is mostly for ad-hoc sharing
Martin Geisler <mg@lazybytes.net>
parents: 11089
diff changeset
  3320
    Start a local HTTP repository browser and pull server. You can use
13065
de4a18cbfc98 serve: fix doc typo
Adrian Buehlmann <adrian@cadifra.com>
parents: 12965
diff changeset
  3321
    this for ad-hoc sharing and browsing of repositories. It is
11102
275198bc904a commands: explain that "hg serve" is mostly for ad-hoc sharing
Martin Geisler <mg@lazybytes.net>
parents: 11089
diff changeset
  3322
    recommended to use a real web server to serve a repository for
275198bc904a commands: explain that "hg serve" is mostly for ad-hoc sharing
Martin Geisler <mg@lazybytes.net>
parents: 11089
diff changeset
  3323
    longer periods of time.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3324
11103
d29bd98ebff6 commands: explain that "hg serve" does not do authentication
Martin Geisler <mg@lazybytes.net>
parents: 11102
diff changeset
  3325
    Please note that the server does not implement access control.
d29bd98ebff6 commands: explain that "hg serve" does not do authentication
Martin Geisler <mg@lazybytes.net>
parents: 11102
diff changeset
  3326
    This means that, by default, anybody can read from the server and
d29bd98ebff6 commands: explain that "hg serve" does not do authentication
Martin Geisler <mg@lazybytes.net>
parents: 11102
diff changeset
  3327
    nobody can write to it by default. Set the ``web.allow_push``
d29bd98ebff6 commands: explain that "hg serve" does not do authentication
Martin Geisler <mg@lazybytes.net>
parents: 11102
diff changeset
  3328
    option to ``*`` to allow everybody to push to the server. You
d29bd98ebff6 commands: explain that "hg serve" does not do authentication
Martin Geisler <mg@lazybytes.net>
parents: 11102
diff changeset
  3329
    should use a real web server if you need to authenticate users.
d29bd98ebff6 commands: explain that "hg serve" does not do authentication
Martin Geisler <mg@lazybytes.net>
parents: 11102
diff changeset
  3330
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3331
    By default, the server logs accesses to stdout and errors to
8277
b9403042968a write options in "-r/--rev" style in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8225
diff changeset
  3332
    stderr. Use the -A/--accesslog and -E/--errorlog options to log to
b9403042968a write options in "-r/--rev" style in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8225
diff changeset
  3333
    files.
10629
d3f27d15c9cb serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents: 10617
diff changeset
  3334
d3f27d15c9cb serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents: 10617
diff changeset
  3335
    To have the server choose a free port number to listen on, specify
d3f27d15c9cb serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents: 10617
diff changeset
  3336
    a port number of 0; in this case, the server will print the port
d3f27d15c9cb serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents: 10617
diff changeset
  3337
    number it uses.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3338
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3339
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3340
    """
624
876333a295ff Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents: 618
diff changeset
  3341
876333a295ff Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents: 618
diff changeset
  3342
    if opts["stdio"]:
2127
8a85dbbadddf Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2125
diff changeset
  3343
        if repo is None:
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
  3344
            raise error.RepoError(_("There is no Mercurial repository here"
6217
fe8dbbe9520d Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
Joel Rosdahl <joel@rosdahl.net>
parents: 6212
diff changeset
  3345
                              " (.hg not found)"))
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2392
diff changeset
  3346
        s = sshserver.sshserver(ui, repo)
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2392
diff changeset
  3347
        s.serve_forever()
2363
fa4c11751367 Give a response to unknown SSH commands
Matt Mackall <mpm@selenic.com>
parents: 2362
diff changeset
  3348
10635
27027bee318e serve: fix port config
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10632
diff changeset
  3349
    # this way we can check if something was given in the command-line
27027bee318e serve: fix port config
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10632
diff changeset
  3350
    if opts.get('port'):
12076
49463314c24f mail/hgweb: support service names for ports (issue2350)
Brodie Rao <brodie@bitheap.org>
parents: 12070
diff changeset
  3351
        opts['port'] = util.getport(opts.get('port'))
10635
27027bee318e serve: fix port config
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10632
diff changeset
  3352
8190
9b8ac5fb7760 ui: kill most users of parentui name and arg, replace with .copy()
Matt Mackall <mpm@selenic.com>
parents: 8189
diff changeset
  3353
    baseui = repo and repo.baseui or ui
5835
bd34f0ac3cb0 adding "prefix" option to "hg serve" (command line and [web] section)
Michele Cella <michele.cella@gmail.com>
parents: 5811
diff changeset
  3354
    optlist = ("name templates style address port prefix ipv6"
10644
63948e7d37f7 server: initialize wsgi app in command, then wrap server around it
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents: 10635
diff changeset
  3355
               " accesslog errorlog certificate encoding")
987
bfe12654764d hgweb: change startup argument processing
mpm@selenic.com
parents: 981
diff changeset
  3356
    for o in optlist.split():
10630
9947e6b008bb serve: fix options recording, trailing whitespace
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10629
diff changeset
  3357
        val = opts.get(o, '')
10631
5247260cee6a make expression shorter, now the line fits into 80 chars
Thomas Arendsen Hein <thomas@intevation.de>
parents: 10630
diff changeset
  3358
        if val in (None, ''): # should check against default options instead
10630
9947e6b008bb serve: fix options recording, trailing whitespace
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10629
diff changeset
  3359
            continue
9947e6b008bb serve: fix options recording, trailing whitespace
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10629
diff changeset
  3360
        baseui.setconfig("web", o, val)
9947e6b008bb serve: fix options recording, trailing whitespace
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10629
diff changeset
  3361
        if repo and repo.ui != baseui:
9947e6b008bb serve: fix options recording, trailing whitespace
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10629
diff changeset
  3362
            repo.ui.setconfig("web", o, val)
987
bfe12654764d hgweb: change startup argument processing
mpm@selenic.com
parents: 981
diff changeset
  3363
11003
aca9a7cf2c9a serve: webdir_conf -> webconf
Matt Mackall <mpm@selenic.com>
parents: 10993
diff changeset
  3364
    o = opts.get('web_conf') or opts.get('webdir_conf')
11004
7bb10d3dbcd6 hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents: 11003
diff changeset
  3365
    if not o:
7bb10d3dbcd6 hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents: 11003
diff changeset
  3366
        if not repo:
7bb10d3dbcd6 hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents: 11003
diff changeset
  3367
            raise error.RepoError(_("There is no Mercurial repository"
7bb10d3dbcd6 hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents: 11003
diff changeset
  3368
                                    " here (.hg not found)"))
7bb10d3dbcd6 hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents: 11003
diff changeset
  3369
        o = repo.root
7bb10d3dbcd6 hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents: 11003
diff changeset
  3370
7bb10d3dbcd6 hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents: 11003
diff changeset
  3371
    app = hgweb.hgweb(o, baseui=ui)
2127
8a85dbbadddf Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2125
diff changeset
  3372
8778
c5f36402daad use new style classes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8761
diff changeset
  3373
    class service(object):
4380
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  3374
        def init(self):
4672
272c0a09b203 Handle CTRL+C in serve under Windows.
Marcos Chaves <marcos.nospam@gmail.com>
parents: 4659
diff changeset
  3375
            util.set_signal_handler()
11004
7bb10d3dbcd6 hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents: 11003
diff changeset
  3376
            self.httpd = hgweb.server.create_server(ui, app)
4380
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  3377
10629
d3f27d15c9cb serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents: 10617
diff changeset
  3378
            if opts['port'] and not ui.verbose:
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  3379
                return
4380
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  3380
5970
f25070ecf334 hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents: 5953
diff changeset
  3381
            if self.httpd.prefix:
f25070ecf334 hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents: 5953
diff changeset
  3382
                prefix = self.httpd.prefix.strip('/') + '/'
f25070ecf334 hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents: 5953
diff changeset
  3383
            else:
f25070ecf334 hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents: 5953
diff changeset
  3384
                prefix = ''
f25070ecf334 hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents: 5953
diff changeset
  3385
6262
de7256c82fad hgweb: clarify which address and port can/cannot be bound at startup (bug 769)
Stephen Deasey <sdeasey@gmail.com>
parents: 6253
diff changeset
  3386
            port = ':%d' % self.httpd.port
de7256c82fad hgweb: clarify which address and port can/cannot be bound at startup (bug 769)
Stephen Deasey <sdeasey@gmail.com>
parents: 6253
diff changeset
  3387
            if port == ':80':
de7256c82fad hgweb: clarify which address and port can/cannot be bound at startup (bug 769)
Stephen Deasey <sdeasey@gmail.com>
parents: 6253
diff changeset
  3388
                port = ''
de7256c82fad hgweb: clarify which address and port can/cannot be bound at startup (bug 769)
Stephen Deasey <sdeasey@gmail.com>
parents: 6253
diff changeset
  3389
6419
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  3390
            bindaddr = self.httpd.addr
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  3391
            if bindaddr == '0.0.0.0':
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  3392
                bindaddr = '*'
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  3393
            elif ':' in bindaddr: # IPv6
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  3394
                bindaddr = '[%s]' % bindaddr
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  3395
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  3396
            fqaddr = self.httpd.fqaddr
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  3397
            if ':' in fqaddr:
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  3398
                fqaddr = '[%s]' % fqaddr
10629
d3f27d15c9cb serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents: 10617
diff changeset
  3399
            if opts['port']:
10630
9947e6b008bb serve: fix options recording, trailing whitespace
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10629
diff changeset
  3400
                write = ui.status
10629
d3f27d15c9cb serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents: 10617
diff changeset
  3401
            else:
d3f27d15c9cb serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents: 10617
diff changeset
  3402
                write = ui.write
d3f27d15c9cb serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents: 10617
diff changeset
  3403
            write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
d3f27d15c9cb serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents: 10617
diff changeset
  3404
                  (fqaddr, port, prefix, bindaddr, self.httpd.port))
4380
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  3405
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  3406
        def run(self):
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  3407
            self.httpd.serve_forever()
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  3408
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  3409
    service = service()
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  3410
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  3411
    cmdutil.service(opts, initfn=service.init, runfn=service.run)
500
ebc4714a7632 [PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents: 499
diff changeset
  3412
731
91ca3afab8e8 Add name matching to status command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 729
diff changeset
  3413
def status(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3414
    """show changed files in the working directory
213
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 212
diff changeset
  3415
6448
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
  3416
    Show status of files in the repository. If names are given, only
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
  3417
    files that match are shown. Files that are clean or ignored or
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  3418
    the source of a copy/move operation, are not listed unless
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  3419
    -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  3420
    Unless options described with "show only ..." are given, the
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  3421
    options -mardu are used.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3422
6201
305d4450036a Extend/correct acc40572da5b regarding -qA and ignored files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6200
diff changeset
  3423
    Option -q/--quiet hides untracked (unknown and ignored) files
8009
76e4c08a48ad commands: fix typo on flag description
Wagner Bruna <wbruna@yahoo.com>
parents: 8008
diff changeset
  3424
    unless explicitly requested with -u/--unknown or -i/--ignored.
6200
acc40572da5b 'hg status -q' output skips non-tracked files.
Zoran Bosnjak <zoran.bosnjak@via.si>
parents: 6192
diff changeset
  3425
12390
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  3426
    .. note::
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  3427
       status may appear to disagree with diff if permissions have
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  3428
       changed or a merge has occurred. The standard diff format does
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  3429
       not report permission changes and diff only reports changes
aff4afdcfd2b Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents: 12389
diff changeset
  3430
       relative to one merge parent.
3822
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
  3431
3467
2b3b703b3a2b Add --rev option to status
Brendan Cully <brendan@kublai.com>
parents: 3465
diff changeset
  3432
    If one revision is given, it is used as the base revision.
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  3433
    If two revisions are given, the differences between them are
10014
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3434
    shown. The --change option can also be used as a shortcut to list
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3435
    the changed files of a revision from its first parent.
3467
2b3b703b3a2b Add --rev option to status
Brendan Cully <brendan@kublai.com>
parents: 3465
diff changeset
  3436
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  3437
    The codes used to show the status of files are::
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  3438
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  3439
      M = modified
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  3440
      A = added
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  3441
      R = removed
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  3442
      C = clean
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  3443
      ! = missing (deleted by non-hg command, but still tracked)
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  3444
      ? = not tracked
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  3445
      I = ignored
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  3446
        = origin of the previous file listed as A (added)
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3447
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3448
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3449
    """
312
09375250eb31 Optimize diff and status in subdirectories
mpm@selenic.com
parents: 310
diff changeset
  3450
10014
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3451
    revs = opts.get('rev')
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3452
    change = opts.get('change')
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3453
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3454
    if revs and change:
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3455
        msg = _('cannot specify --rev and --change at the same time')
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3456
        raise util.Abort(msg)
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3457
    elif change:
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3458
        node2 = repo.lookup(change)
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3459
        node1 = repo[node2].parents()[0].node()
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3460
    else:
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3461
        node1, node2 = cmdutil.revpair(repo, revs)
54cd28258ea7 status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents: 9983
diff changeset
  3462
1625
e1bcf7fa983f correct the relative path when walking from a subdir
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1622
diff changeset
  3463
    cwd = (pats and repo.getcwd()) or ''
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3464
    end = opts.get('print0') and '\0' or '\n'
6276
c93ca83a3354 status: find copies and renames beyond the working directory
Matt Mackall <mpm@selenic.com>
parents: 6262
diff changeset
  3465
    copy = {}
6605
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3466
    states = 'modified added removed deleted unknown ignored clean'.split()
7684
ee3364d3d859 status: make options optional (issue1481)
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7656
diff changeset
  3467
    show = [k for k in states if opts.get(k)]
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3468
    if opts.get('all'):
6605
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3469
        show += ui.quiet and (states[:4] + ['clean']) or states
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3470
    if not show:
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3471
        show = ui.quiet and states[:4] or states[:5]
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3472
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3473
    stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
12166
441a74b8def1 status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12132
diff changeset
  3474
                       'ignored' in show, 'clean' in show, 'unknown' in show,
441a74b8def1 status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12132
diff changeset
  3475
                       opts.get('subrepos'))
6605
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3476
    changestates = zip(states, 'MAR!?IC', stat)
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3477
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3478
    if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  3479
        ctxn = repo[nullid]
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  3480
        ctx1 = repo[node1]
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  3481
        ctx2 = repo[node2]
6646
9eb274d773d9 copies: teach copies about dirstate.copies
Matt Mackall <mpm@selenic.com>
parents: 6642
diff changeset
  3482
        added = stat[1]
9eb274d773d9 copies: teach copies about dirstate.copies
Matt Mackall <mpm@selenic.com>
parents: 6642
diff changeset
  3483
        if node2 is None:
9eb274d773d9 copies: teach copies about dirstate.copies
Matt Mackall <mpm@selenic.com>
parents: 6642
diff changeset
  3484
            added = stat[0] + stat[1] # merged?
6740
b148e9099133 use repo.changectx(None) to get a workingctx
Matt Mackall <mpm@selenic.com>
parents: 6739
diff changeset
  3485
7622
4dd7b28003d2 use dict.iteritems() rather than dict.items()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7598
diff changeset
  3486
        for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems():
6646
9eb274d773d9 copies: teach copies about dirstate.copies
Matt Mackall <mpm@selenic.com>
parents: 6642
diff changeset
  3487
            if k in added:
9eb274d773d9 copies: teach copies about dirstate.copies
Matt Mackall <mpm@selenic.com>
parents: 6642
diff changeset
  3488
                copy[k] = v
9eb274d773d9 copies: teach copies about dirstate.copies
Matt Mackall <mpm@selenic.com>
parents: 6642
diff changeset
  3489
            elif v in added:
6276
c93ca83a3354 status: find copies and renames beyond the working directory
Matt Mackall <mpm@selenic.com>
parents: 6262
diff changeset
  3490
                copy[v] = k
c93ca83a3354 status: find copies and renames beyond the working directory
Matt Mackall <mpm@selenic.com>
parents: 6262
diff changeset
  3491
6605
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3492
    for state, char, files in changestates:
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3493
        if state in show:
1966
f8b0e73e320f hg status cleanups: Don't translate long options, remove stray semicolon.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1965
diff changeset
  3494
            format = "%s %%s%s" % (char, end)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3495
            if opts.get('no_status'):
6605
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3496
                format = "%%s%s" % end
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3497
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3498
            for f in files:
10817
2096496b40ec status: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10816
diff changeset
  3499
                ui.write(format % repo.pathto(f, cwd),
2096496b40ec status: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10816
diff changeset
  3500
                         label='status.' + state)
6605
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  3501
                if f in copy:
10817
2096496b40ec status: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10816
diff changeset
  3502
                    ui.write('  %s%s' % (repo.pathto(copy[f], cwd), end),
2096496b40ec status: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10816
diff changeset
  3503
                             label='status.copied')
213
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 212
diff changeset
  3504
9620
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3505
def summary(ui, repo, **opts):
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3506
    """summarize working directory state
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3507
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3508
    This generates a brief summary of the working directory state,
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3509
    including parents, branch, commit status, and available updates.
9620
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3510
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3511
    With the --remote option, this will check the default paths for
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3512
    incoming and outgoing changes. This can be time-consuming.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3513
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3514
    Returns 0 on success.
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3515
    """
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3516
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3517
    ctx = repo[None]
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3518
    parents = ctx.parents()
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3519
    pnode = parents[0].node()
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3520
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3521
    for p in parents:
10832
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3522
        # label with log.changeset (instead of log.parent) since this
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3523
        # shows a working directory parent *changeset*:
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3524
        ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3525
                 label='log.changeset')
10833
d7b601f1e02c commands: retrieve tags from context object
Martin Geisler <mg@lazybytes.net>
parents: 10832
diff changeset
  3526
        ui.write(' '.join(p.tags()), label='log.tag')
9618
d75a309a24b1 summary: add empty repository and no revision checked out hints
Matt Mackall <mpm@selenic.com>
parents: 9617
diff changeset
  3527
        if p.rev() == -1:
d75a309a24b1 summary: add empty repository and no revision checked out hints
Matt Mackall <mpm@selenic.com>
parents: 9617
diff changeset
  3528
            if not len(repo):
10834
4ab459a6c25c commands: small refactoring in summary
Martin Geisler <mg@lazybytes.net>
parents: 10833
diff changeset
  3529
                ui.write(_(' (empty repository)'))
9618
d75a309a24b1 summary: add empty repository and no revision checked out hints
Matt Mackall <mpm@selenic.com>
parents: 9617
diff changeset
  3530
            else:
10834
4ab459a6c25c commands: small refactoring in summary
Martin Geisler <mg@lazybytes.net>
parents: 10833
diff changeset
  3531
                ui.write(_(' (no revision checked out)'))
10832
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3532
        ui.write('\n')
9618
d75a309a24b1 summary: add empty repository and no revision checked out hints
Matt Mackall <mpm@selenic.com>
parents: 9617
diff changeset
  3533
        if p.description():
10832
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3534
            ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3535
                      label='log.summary')
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3536
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3537
    branch = ctx.branch()
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3538
    bheads = repo.branchheads(branch)
9873
541218fbad2a summary: note non-default branches with -q
Matt Mackall <mpm@selenic.com>
parents: 9857
diff changeset
  3539
    m = _('branch: %s\n') % branch
541218fbad2a summary: note non-default branches with -q
Matt Mackall <mpm@selenic.com>
parents: 9857
diff changeset
  3540
    if branch != 'default':
10832
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3541
        ui.write(m, label='log.branch')
9873
541218fbad2a summary: note non-default branches with -q
Matt Mackall <mpm@selenic.com>
parents: 9857
diff changeset
  3542
    else:
10832
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3543
        ui.status(m, label='log.branch')
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3544
10390
f163775e36e0 summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents: 10389
diff changeset
  3545
    st = list(repo.status(unknown=True))[:6]
11088
c4347e48b0d0 summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents: 11078
diff changeset
  3546
11331
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3547
    c = repo.dirstate.copies()
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3548
    copied, renamed = [], []
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3549
    for d, s in c.iteritems():
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3550
        if s in st[2]:
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3551
            st[2].remove(s)
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3552
            renamed.append(d)
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3553
        else:
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3554
            copied.append(d)
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3555
        if d in st[1]:
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3556
            st[1].remove(d)
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3557
    st.insert(3, renamed)
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3558
    st.insert(4, copied)
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3559
10651
5f091fc1bab7 style: use consistent variable names (*mod) with imports which would shadow
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10650
diff changeset
  3560
    ms = mergemod.mergestate(repo)
10390
f163775e36e0 summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents: 10389
diff changeset
  3561
    st.append([f for f in ms if ms[f] == 'u'])
11088
c4347e48b0d0 summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents: 11078
diff changeset
  3562
c4347e48b0d0 summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents: 11078
diff changeset
  3563
    subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
c4347e48b0d0 summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents: 11078
diff changeset
  3564
    st.append(subs)
c4347e48b0d0 summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents: 11078
diff changeset
  3565
10832
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3566
    labels = [ui.label(_('%d modified'), 'status.modified'),
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3567
              ui.label(_('%d added'), 'status.added'),
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3568
              ui.label(_('%d removed'), 'status.removed'),
11331
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3569
              ui.label(_('%d renamed'), 'status.copied'),
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3570
              ui.label(_('%d copied'), 'status.copied'),
10832
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3571
              ui.label(_('%d deleted'), 'status.deleted'),
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3572
              ui.label(_('%d unknown'), 'status.unknown'),
420bc8124904 summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents: 10830
diff changeset
  3573
              ui.label(_('%d ignored'), 'status.ignored'),
11088
c4347e48b0d0 summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents: 11078
diff changeset
  3574
              ui.label(_('%d unresolved'), 'resolve.unresolved'),
c4347e48b0d0 summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents: 11078
diff changeset
  3575
              ui.label(_('%d subrepos'), 'status.modified')]
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3576
    t = []
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  3577
    for s, l in zip(st, labels):
9607
8e0e0d854b60 commands: do not split a translated string
Martin Geisler <mg@lazybytes.net>
parents: 9603
diff changeset
  3578
        if s:
8e0e0d854b60 commands: do not split a translated string
Martin Geisler <mg@lazybytes.net>
parents: 9603
diff changeset
  3579
            t.append(l % len(s))
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3580
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3581
    t = ', '.join(t)
10269
acf001ee5ef8 summary: L10N messages hide clean-ness of workdir from 'hg summary'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 10263
diff changeset
  3582
    cleanworkdir = False
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3583
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3584
    if len(parents) > 1:
11310
ac873ecfc3c2 Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents: 11302
diff changeset
  3585
        t += _(' (merge)')
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3586
    elif branch != parents[0].branch():
11310
ac873ecfc3c2 Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents: 11302
diff changeset
  3587
        t += _(' (new branch)')
11165
e8915e19205a summary: show if commit will be from a closed head
Gilles Moris <gilles.moris@free.fr>
parents: 11164
diff changeset
  3588
    elif (parents[0].extra().get('close') and
e8915e19205a summary: show if commit will be from a closed head
Gilles Moris <gilles.moris@free.fr>
parents: 11164
diff changeset
  3589
          pnode in repo.branchheads(branch, closed=True)):
11310
ac873ecfc3c2 Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents: 11302
diff changeset
  3590
        t += _(' (head closed)')
11331
997ab9af81df summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents: 11321
diff changeset
  3591
    elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]):
11310
ac873ecfc3c2 Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents: 11302
diff changeset
  3592
        t += _(' (clean)')
10269
acf001ee5ef8 summary: L10N messages hide clean-ness of workdir from 'hg summary'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 10263
diff changeset
  3593
        cleanworkdir = True
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3594
    elif pnode not in bheads:
11310
ac873ecfc3c2 Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents: 11302
diff changeset
  3595
        t += _(' (new branch head)')
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3596
10269
acf001ee5ef8 summary: L10N messages hide clean-ness of workdir from 'hg summary'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 10263
diff changeset
  3597
    if cleanworkdir:
11310
ac873ecfc3c2 Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents: 11302
diff changeset
  3598
        ui.status(_('commit: %s\n') % t.strip())
9605
3194227a4158 summary: quieter with -q
Matt Mackall <mpm@selenic.com>
parents: 9604
diff changeset
  3599
    else:
11310
ac873ecfc3c2 Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents: 11302
diff changeset
  3600
        ui.write(_('commit: %s\n') % t.strip())
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3601
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3602
    # all ancestors of branch heads - all ancestors of parent = new csets
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3603
    new = [0] * len(repo)
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3604
    cl = repo.changelog
10390
f163775e36e0 summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents: 10389
diff changeset
  3605
    for a in [cl.rev(n) for n in bheads]:
f163775e36e0 summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents: 10389
diff changeset
  3606
        new[a] = 1
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3607
    for a in cl.ancestors(*[cl.rev(n) for n in bheads]):
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3608
        new[a] = 1
10390
f163775e36e0 summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents: 10389
diff changeset
  3609
    for a in [p.rev() for p in parents]:
f163775e36e0 summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents: 10389
diff changeset
  3610
        if a >= 0:
f163775e36e0 summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents: 10389
diff changeset
  3611
            new[a] = 0
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3612
    for a in cl.ancestors(*[p.rev() for p in parents]):
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3613
        new[a] = 0
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3614
    new = sum(new)
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3615
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3616
    if new == 0:
9605
3194227a4158 summary: quieter with -q
Matt Mackall <mpm@selenic.com>
parents: 9604
diff changeset
  3617
        ui.status(_('update: (current)\n'))
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3618
    elif pnode not in bheads:
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3619
        ui.write(_('update: %d new changesets (update)\n') % new)
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3620
    else:
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3621
        ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3622
                 (new, len(bheads)))
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  3623
9620
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3624
    if opts.get('remote'):
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3625
        t = []
10389
6dc25b01e170 fix remaining hg.parseurl uses
Sune Foldager <cryo@cyanite.org>
parents: 10384
diff changeset
  3626
        source, branches = hg.parseurl(ui.expandpath('default'))
11273
d1908cb95a82 remoteui: move from cmdutil to hg
Matt Mackall <mpm@selenic.com>
parents: 11219
diff changeset
  3627
        other = hg.repository(hg.remoteui(repo, {}), source)
10389
6dc25b01e170 fix remaining hg.parseurl uses
Sune Foldager <cryo@cyanite.org>
parents: 10384
diff changeset
  3628
        revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
9620
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3629
        ui.debug('comparing with %s\n' % url.hidepassword(source))
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3630
        repo.ui.pushbuffer()
11301
3d0591a66118 move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11297
diff changeset
  3631
        common, incoming, rheads = discovery.findcommonincoming(repo, other)
9620
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3632
        repo.ui.popbuffer()
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3633
        if incoming:
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3634
            t.append(_('1 or more incoming'))
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3635
10389
6dc25b01e170 fix remaining hg.parseurl uses
Sune Foldager <cryo@cyanite.org>
parents: 10384
diff changeset
  3636
        dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
6dc25b01e170 fix remaining hg.parseurl uses
Sune Foldager <cryo@cyanite.org>
parents: 10384
diff changeset
  3637
        revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
11273
d1908cb95a82 remoteui: move from cmdutil to hg
Matt Mackall <mpm@selenic.com>
parents: 11219
diff changeset
  3638
        other = hg.repository(hg.remoteui(repo, {}), dest)
9620
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3639
        ui.debug('comparing with %s\n' % url.hidepassword(dest))
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3640
        repo.ui.pushbuffer()
11301
3d0591a66118 move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11297
diff changeset
  3641
        o = discovery.findoutgoing(repo, other)
9620
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3642
        repo.ui.popbuffer()
10390
f163775e36e0 summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents: 10389
diff changeset
  3643
        o = repo.changelog.nodesbetween(o, None)[0]
9620
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3644
        if o:
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3645
            t.append(_('%d outgoing') % len(o))
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3646
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3647
        if t:
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3648
            ui.write(_('remote: %s\n') % (', '.join(t)))
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3649
        else:
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3650
            ui.status(_('remote: (synced)\n'))
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  3651
6321
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3652
def tag(ui, repo, name1, *names, **opts):
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3653
    """add one or more tags for the current or given revision
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3654
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3655
    Name a particular revision using <name>.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3656
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3657
    Tags are used to name particular revisions of the repository and are
6220
1939e29151ca Fixed typo in tag help, found by John Coomes
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6217
diff changeset
  3658
    very useful to compare different revisions, to go back to significant
13135
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3659
    earlier versions or to mark branch points as releases, etc. Changing
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3660
    an existing tag is normally disallowed; use -f/--force to override.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3661
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  3662
    If no revision is given, the parent of the working directory is
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  3663
    used, or tip if no revision is checked out.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3664
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3665
    To facilitate version control, distribution, and merging of tags,
13135
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3666
    they are stored as a file named ".hgtags" which is managed similarly
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3667
    to other project files and can be hand-edited if necessary. This
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3668
    also means that tagging creates a new commit. The file
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3669
    ".hg/localtags" is used for local tags (not shared among
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3670
    repositories).
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3671
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3672
    Tag commits are usually made at the head of a branch. If the parent
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3673
    of the working directory is not a branch head, :hg:`tag` aborts; use
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3674
    -f/--force to force the tag commit to be based on a non-head
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3675
    changeset.
6163
1f733c2f0165 Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6161
diff changeset
  3676
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  3677
    See :hg:`help dates` for a list of formats valid for -d/--date.
11063
eb23c876c111 tag: warn users about tag/branch possible name conflicts
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11061
diff changeset
  3678
eb23c876c111 tag: warn users about tag/branch possible name conflicts
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11061
diff changeset
  3679
    Since tag names have priority over branch names during revision
eb23c876c111 tag: warn users about tag/branch possible name conflicts
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11061
diff changeset
  3680
    lookup, using an existing branch name as a tag name is discouraged.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3681
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3682
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3683
    """
6321
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3684
6739
c9fbd6ec3489 context: avoid using None for working parent
Matt Mackall <mpm@selenic.com>
parents: 6723
diff changeset
  3685
    rev_ = "."
11169
3d0a9c8d7184 tag: strip whitespace from tag names (issue2174)
Matt Mackall <mpm@selenic.com>
parents: 11165
diff changeset
  3686
    names = [t.strip() for t in (name1,) + names]
8152
08e1baf924ca replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents: 8150
diff changeset
  3687
    if len(names) != len(set(names)):
6321
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3688
        raise util.Abort(_('tag names must be unique'))
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3689
    for n in names:
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3690
        if n in ['tip', '.', 'null']:
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3691
            raise util.Abort(_('the name \'%s\' is reserved') % n)
11692
52e4ac3e63f7 tag: do not allow tag names to consist solely of whitespace (issue2307)
Benjamin Pollack <benjamin@bitquabit.com>
parents: 11636
diff changeset
  3692
        if not n:
52e4ac3e63f7 tag: do not allow tag names to consist solely of whitespace (issue2307)
Benjamin Pollack <benjamin@bitquabit.com>
parents: 11636
diff changeset
  3693
            raise util.Abort(_('tag names cannot consist entirely of whitespace'))
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3694
    if opts.get('rev') and opts.get('remove'):
4213
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4179
diff changeset
  3695
        raise util.Abort(_("--rev and --remove are incompatible"))
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3696
    if opts.get('rev'):
1596
41366b7d6709 fix 'hg tag <tagname> <revision>
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1589
diff changeset
  3697
        rev_ = opts['rev']
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3698
    message = opts.get('message')
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3699
    if opts.get('remove'):
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3700
        expectedtype = opts.get('local') and 'local' or 'global'
6321
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3701
        for n in names:
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3702
            if not repo.tagtype(n):
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3703
                raise util.Abort(_('tag \'%s\' does not exist') % n)
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3704
            if repo.tagtype(n) != expectedtype:
8008
36924a4711e9 commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8007
diff changeset
  3705
                if expectedtype == 'global':
36924a4711e9 commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8007
diff changeset
  3706
                    raise util.Abort(_('tag \'%s\' is not a global tag') % n)
36924a4711e9 commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8007
diff changeset
  3707
                else:
36924a4711e9 commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8007
diff changeset
  3708
                    raise util.Abort(_('tag \'%s\' is not a local tag') % n)
4213
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4179
diff changeset
  3709
        rev_ = nullid
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4179
diff changeset
  3710
        if not message:
9183
d0225fa2f6c4 do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents: 9128
diff changeset
  3711
            # we don't translate commit messages
d0225fa2f6c4 do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents: 9128
diff changeset
  3712
            message = 'Removed tag %s' % ', '.join(names)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3713
    elif not opts.get('force'):
6321
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3714
        for n in names:
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3715
            if n in repo.tags():
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3716
                raise util.Abort(_('tag \'%s\' already exists '
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3717
                                   '(use -f to force)') % n)
13135
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3718
    if not opts.get('local'):
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3719
        p1, p2 = repo.dirstate.parents()
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3720
        if p2 != nullid:
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3721
            raise util.Abort(_('uncommitted merge'))
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3722
        bheads = repo.branchheads()
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3723
        if not opts.get('force') and bheads and p1 not in bheads:
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  3724
            raise util.Abort(_('not at a branch head (use -f to force)'))
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  3725
    r = repo[rev_].node()
2967
eef469259745 tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents: 2966
diff changeset
  3726
eef469259745 tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents: 2966
diff changeset
  3727
    if not message:
9183
d0225fa2f6c4 do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents: 9128
diff changeset
  3728
        # we don't translate commit messages
d0225fa2f6c4 do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents: 9128
diff changeset
  3729
        message = ('Added tag %s for changeset %s' %
6321
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  3730
                   (', '.join(names), short(r)))
2967
eef469259745 tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents: 2966
diff changeset
  3731
6243
437eef39458d fix incorrect date when committing a tag
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6234
diff changeset
  3732
    date = opts.get('date')
437eef39458d fix incorrect date when committing a tag
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6234
diff changeset
  3733
    if date:
437eef39458d fix incorrect date when committing a tag
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6234
diff changeset
  3734
        date = util.parsedate(date)
437eef39458d fix incorrect date when committing a tag
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6234
diff changeset
  3735
11185
6d7cf82453be tag: add -e/--edit option for modifying the commit message
Steve Losh <steve@stevelosh.com>
parents: 11181
diff changeset
  3736
    if opts.get('edit'):
6d7cf82453be tag: add -e/--edit option for modifying the commit message
Steve Losh <steve@stevelosh.com>
parents: 11181
diff changeset
  3737
        message = ui.edit(message, ui.username())
6d7cf82453be tag: add -e/--edit option for modifying the commit message
Steve Losh <steve@stevelosh.com>
parents: 11181
diff changeset
  3738
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3739
    repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
401
af4848f83e68 From: Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl>
mpm@selenic.com
parents: 396
diff changeset
  3740
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
  3741
def tags(ui, repo):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3742
    """list repository tags
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3743
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  3744
    This lists both regular and local tags. When the -v/--verbose
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  3745
    switch is used, a third column "local" is printed for local tags.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3746
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3747
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3748
    """
477
520540fd6b64 Handle errors in .hgtags or hgrc [tags] section more gracefully.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 470
diff changeset
  3749
2966
fb493241d7f6 Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents: 2963
diff changeset
  3750
    hexfunc = ui.debugflag and hex or short
5658
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3751
    tagtype = ""
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3752
8210
344751cd8cb8 replace various uses of list.reverse()
Matt Mackall <mpm@selenic.com>
parents: 8209
diff changeset
  3753
    for t, n in reversed(repo.tagslist()):
5658
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3754
        if ui.quiet:
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3755
            ui.write("%s\n" % t)
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3756
            continue
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3757
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
  3758
        try:
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4505
diff changeset
  3759
            hn = hexfunc(n)
5658
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3760
            r = "%5d:%s" % (repo.changelog.rev(n), hn)
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents: 7632
diff changeset
  3761
        except error.LookupError:
3930
01d98d68d697 Add revlog.LookupError exception, and use it instead of RevlogError.
Brendan Cully <brendan@kublai.com>
parents: 3920
diff changeset
  3762
            r = "    ?:%s" % hn
2035
107dc72880f8 Make 'hg tags -q' only list tag names without revision numbers and hashes,
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2034
diff changeset
  3763
        else:
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
  3764
            spaces = " " * (30 - encoding.colwidth(t))
5658
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3765
            if ui.verbose:
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3766
                if repo.tagtype(t) == 'local':
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3767
                    tagtype = " local"
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3768
                else:
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3769
                    tagtype = ""
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  3770
            ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype))
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
  3771
1731
251729df9cc6 add -p option to tip. for issue 64.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1728
diff changeset
  3772
def tip(ui, repo, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3773
    """show the tip revision
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3774
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  3775
    The tip revision (usually just called the tip) is the changeset
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  3776
    most recently added to the repository (and therefore the most
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  3777
    recently changed head).
6364
b22b39059722 Make tip help more helpful
Patrick Mezard <pmezard@gmail.com>
parents: 6353
diff changeset
  3778
6367
51984a2413f2 Remove unexpected "Alternately" word from tip help.
Patrick Mezard <pmezard@gmail.com>
parents: 6364
diff changeset
  3779
    If you have just made a commit, that commit will be the tip. If
51984a2413f2 Remove unexpected "Alternately" word from tip help.
Patrick Mezard <pmezard@gmail.com>
parents: 6364
diff changeset
  3780
    you have just pulled changes from another repository, the tip of
51984a2413f2 Remove unexpected "Alternately" word from tip help.
Patrick Mezard <pmezard@gmail.com>
parents: 6364
diff changeset
  3781
    that repository becomes the current tip. The "tip" tag is special
51984a2413f2 Remove unexpected "Alternately" word from tip help.
Patrick Mezard <pmezard@gmail.com>
parents: 6364
diff changeset
  3782
    and cannot be renamed or assigned to a different changeset.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3783
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3784
    Returns 0 on success.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3785
    """
10152
56284451a22c Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents: 10111
diff changeset
  3786
    displayer = cmdutil.show_changeset(ui, repo, opts)
56284451a22c Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents: 10111
diff changeset
  3787
    displayer.show(repo[len(repo) - 1])
56284451a22c Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents: 10111
diff changeset
  3788
    displayer.close()
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
  3789
4699
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
  3790
def unbundle(ui, repo, fname1, *fnames, **opts):
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
  3791
    """apply one or more changegroup files
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
  3792
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
  3793
    Apply one or more compressed changegroup files generated by the
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
  3794
    bundle command.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3795
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3796
    Returns 0 on success, 1 if an update has unresolved files.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3797
    """
4699
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
  3798
    fnames = (fname1,) + fnames
6180
d98ef03893e6 commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents: 6178
diff changeset
  3799
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
  3800
    lock = repo.lock()
6180
d98ef03893e6 commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents: 6178
diff changeset
  3801
    try:
d98ef03893e6 commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents: 6178
diff changeset
  3802
        for fname in fnames:
7271
8046f0a070a6 use our urlopener (proxy handling, etc) instead of urllib
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7270
diff changeset
  3803
            f = url.open(ui, fname)
6180
d98ef03893e6 commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents: 6178
diff changeset
  3804
            gen = changegroup.readbundle(f, fname)
11442
ee1ed6afac21 addchangegroup: pass in lock to release it before changegroup hook is called
Matt Mackall <mpm@selenic.com>
parents: 11384
diff changeset
  3805
            modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname,
ee1ed6afac21 addchangegroup: pass in lock to release it before changegroup hook is called
Matt Mackall <mpm@selenic.com>
parents: 11384
diff changeset
  3806
                                           lock=lock)
6180
d98ef03893e6 commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents: 6178
diff changeset
  3807
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
  3808
        lock.release()
4699
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
  3809
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  3810
    return postincoming(ui, repo, modheads, opts.get('update'), None)
1218
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
  3811
8855
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  3812
def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
10889
e25c450c351e commands: improve some command summaries
Matt Mackall <mpm@selenic.com>
parents: 10882
diff changeset
  3813
    """update working directory (or switch revisions)
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3814
8004
d5b1b846f277 commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents: 7983
diff changeset
  3815
    Update the repository's working directory to the specified
12688
8c034a825cfe help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents: 12618
diff changeset
  3816
    changeset. If no changeset is specified, update to the tip of the
8c034a825cfe help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents: 12618
diff changeset
  3817
    current named branch.
8c034a825cfe help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents: 12618
diff changeset
  3818
8c034a825cfe help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents: 12618
diff changeset
  3819
    If the changeset is not a descendant of the working directory's
8c034a825cfe help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents: 12618
diff changeset
  3820
    parent, the update is aborted. With the -c/--check option, the
8c034a825cfe help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents: 12618
diff changeset
  3821
    working directory is checked for uncommitted changes; if none are
8c034a825cfe help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents: 12618
diff changeset
  3822
    found, the working directory is updated to the specified
9718
fe1b19bfe75b help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents: 9714
diff changeset
  3823
    changeset.
fe1b19bfe75b help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents: 9714
diff changeset
  3824
fe1b19bfe75b help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents: 9714
diff changeset
  3825
    The following rules apply when the working directory contains
fe1b19bfe75b help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents: 9714
diff changeset
  3826
    uncommitted changes:
fe1b19bfe75b help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents: 9714
diff changeset
  3827
9831
9ebad1b93456 help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents: 9806
diff changeset
  3828
    1. If neither -c/--check nor -C/--clean is specified, and if
9ebad1b93456 help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents: 9806
diff changeset
  3829
       the requested changeset is an ancestor or descendant of
9ebad1b93456 help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents: 9806
diff changeset
  3830
       the working directory's parent, the uncommitted changes
9ebad1b93456 help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents: 9806
diff changeset
  3831
       are merged into the requested changeset and the merged
9ebad1b93456 help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents: 9806
diff changeset
  3832
       result is left uncommitted. If the requested changeset is
9ebad1b93456 help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents: 9806
diff changeset
  3833
       not an ancestor or descendant (that is, it is on another
9ebad1b93456 help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents: 9806
diff changeset
  3834
       branch), the update is aborted and the uncommitted changes
9740
2ebe679fec21 commands: use enumerated lists in help texts
Martin Geisler <mg@lazybytes.net>
parents: 9734
diff changeset
  3835
       are preserved.
9718
fe1b19bfe75b help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents: 9714
diff changeset
  3836
fe1b19bfe75b help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents: 9714
diff changeset
  3837
    2. With the -c/--check option, the update is aborted and the
9740
2ebe679fec21 commands: use enumerated lists in help texts
Martin Geisler <mg@lazybytes.net>
parents: 9734
diff changeset
  3838
       uncommitted changes are preserved.
9718
fe1b19bfe75b help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents: 9714
diff changeset
  3839
fe1b19bfe75b help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents: 9714
diff changeset
  3840
    3. With the -C/--clean option, uncommitted changes are discarded and
9740
2ebe679fec21 commands: use enumerated lists in help texts
Martin Geisler <mg@lazybytes.net>
parents: 9734
diff changeset
  3841
       the working directory is updated to the requested changeset.
9718
fe1b19bfe75b help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents: 9714
diff changeset
  3842
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  3843
    Use null as the changeset to remove the working directory (like
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  3844
    :hg:`clone -U`).
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  3845
12688
8c034a825cfe help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents: 12618
diff changeset
  3846
    If you want to update just one file to an older changeset, use
8c034a825cfe help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents: 12618
diff changeset
  3847
    :hg:`revert`.
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  3848
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10963
diff changeset
  3849
    See :hg:`help dates` for a list of formats valid for -d/--date.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3850
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3851
    Returns 0 on success, 1 if there are unresolved files.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3852
    """
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3853
    if rev and node:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3854
        raise util.Abort(_("please specify just one revision"))
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3855
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3856
    if not rev:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3857
        rev = node
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3858
12726
61c0df2b089a update: use revsingle to enable use of revsets as update targets (issue1993)
Augie Fackler <durin42@gmail.com>
parents: 12705
diff changeset
  3859
    rev = cmdutil.revsingle(repo, rev, rev).rev()
61c0df2b089a update: use revsingle to enable use of revsets as update targets (issue1993)
Augie Fackler <durin42@gmail.com>
parents: 12705
diff changeset
  3860
9450
e78967d3dd6f commands: forbid 'hg update --check --clean'
Stuart W Marks <smarks@smarks.org>
parents: 9429
diff changeset
  3861
    if check and clean:
9451
3e673c988c85 commands: expand -c and -C in update error message
Martin Geisler <mg@lazybytes.net>
parents: 9450
diff changeset
  3862
        raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
9450
e78967d3dd6f commands: forbid 'hg update --check --clean'
Stuart W Marks <smarks@smarks.org>
parents: 9429
diff changeset
  3863
e78967d3dd6f commands: forbid 'hg update --check --clean'
Stuart W Marks <smarks@smarks.org>
parents: 9429
diff changeset
  3864
    if check:
8855
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  3865
        # we could use dirty() but we can ignore merge and branch trivia
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  3866
        c = repo[None]
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  3867
        if c.modified() or c.added() or c.removed():
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  3868
            raise util.Abort(_("uncommitted local changes"))
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  3869
3814
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  3870
    if date:
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3871
        if rev:
3814
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  3872
            raise util.Abort(_("you can't specify a revision and a date"))
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3873
        rev = cmdutil.finddate(ui, repo, date)
3814
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  3874
9187
7bb1dbfd3082 update: allow -c to jump branches if clean
Matt Mackall <mpm@selenic.com>
parents: 9128
diff changeset
  3875
    if clean or check:
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3876
        return hg.clean(repo, rev)
2808
30f59f4a327e Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents: 2806
diff changeset
  3877
    else:
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3878
        return hg.update(repo, rev)
254
c03f58e5fd2d unify checkout and resolve into update
mpm@selenic.com
parents: 252
diff changeset
  3879
247
863b508c5b36 migrate verify
mpm@selenic.com
parents: 246
diff changeset
  3880
def verify(ui, repo):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3881
    """verify the integrity of the repository
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3882
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3883
    Verify the integrity of the current repository.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3884
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3885
    This will perform an extensive check of the repository's
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3886
    integrity, validating the hashes and checksums of each entry in
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3887
    the changelog, manifest, and tracked files, as well as the
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3888
    integrity of their crosslinks and indices.
11177
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3889
6a64813276ed commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents: 11173
diff changeset
  3890
    Returns 0 on success, 1 if errors are encountered.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3891
    """
2778
fdc232d8a193 Move repo.verify
Matt Mackall <mpm@selenic.com>
parents: 2776
diff changeset
  3892
    return hg.verify(repo)
247
863b508c5b36 migrate verify
mpm@selenic.com
parents: 246
diff changeset
  3893
3651
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3894
def version_(ui):
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3895
    """output version and copyright information"""
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3896
    ui.write(_("Mercurial Distributed SCM (version %s)\n")
7632
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7628
diff changeset
  3897
             % util.version())
3651
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3898
    ui.status(_(
12829
01145ee78c53 version: replace email address with url to reduce private mail
Matt Mackall <mpm@selenic.com>
parents: 12821
diff changeset
  3899
        "(see http://mercurial.selenic.com for more information)\n"
01145ee78c53 version: replace email address with url to reduce private mail
Matt Mackall <mpm@selenic.com>
parents: 12821
diff changeset
  3900
        "\nCopyright (C) 2005-2010 Matt Mackall and others\n"
3651
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3901
        "This is free software; see the source for copying conditions. "
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3902
        "There is NO\nwarranty; "
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3903
        "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3904
    ))
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3905
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  3906
# Command options and aliases are listed here, alphabetically
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  3907
3187
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3908
globalopts = [
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3909
    ('R', 'repository', '',
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3910
     _('repository root directory or name of overlay bundle file'),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3911
     _('REPO')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3912
    ('', 'cwd', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3913
     _('change working directory'), _('DIR')),
3187
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3914
    ('y', 'noninteractive', None,
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3915
     _('do not prompt, assume \'yes\' for any required answers')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3916
    ('q', 'quiet', None, _('suppress output')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3917
    ('v', 'verbose', None, _('enable additional output')),
10541
fac67f0bfbb2 commands: clarify --config syntax
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 10527
diff changeset
  3918
    ('', 'config', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3919
     _('set/override config option (use \'section.name=value\')'),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3920
     _('CONFIG')),
3187
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3921
    ('', 'debug', None, _('enable debugging output')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3922
    ('', 'debugger', None, _('start debugger')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3923
    ('', 'encoding', encoding.encoding, _('set the charset encoding'),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3924
     _('ENCODE')),
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
  3925
    ('', 'encodingmode', encoding.encodingmode,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3926
     _('set the charset encoding mode'), _('MODE')),
9698
3bbc6bc62809 commands: slightly better help for --traceback
Martin Geisler <mg@lazybytes.net>
parents: 9689
diff changeset
  3927
    ('', 'traceback', None, _('always print a traceback on exception')),
3187
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3928
    ('', 'time', None, _('time how long the command takes')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3929
    ('', 'profile', None, _('print command execution profile')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3930
    ('', 'version', None, _('output version information and exit')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3931
    ('h', 'help', None, _('display help and exit')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3932
]
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3933
3189
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3188
diff changeset
  3934
dryrunopts = [('n', 'dry-run', None,
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3188
diff changeset
  3935
               _('do not perform actions, just print output'))]
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3188
diff changeset
  3936
3190
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  3937
remoteopts = [
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3938
    ('e', 'ssh', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3939
     _('specify ssh command to use'), _('CMD')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3940
    ('', 'remotecmd', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3941
     _('specify hg command to run on the remote side'), _('CMD')),
13328
a939f08fae9c url: add --insecure option to bypass verification of ssl certificates
Yuya Nishihara <yuya@tcha.org>
parents: 13230
diff changeset
  3942
    ('', 'insecure', None,
a939f08fae9c url: add --insecure option to bypass verification of ssl certificates
Yuya Nishihara <yuya@tcha.org>
parents: 13230
diff changeset
  3943
     _('do not verify server certificate (ignoring web.cacerts config)')),
3190
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  3944
]
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  3945
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3946
walkopts = [
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3947
    ('I', 'include', [],
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3948
     _('include names matching the given patterns'), _('PATTERN')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3949
    ('X', 'exclude', [],
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3950
     _('exclude names matching the given patterns'), _('PATTERN')),
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3951
]
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3952
3857
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
  3953
commitopts = [
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3954
    ('m', 'message', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3955
     _('use text as commit message'), _('TEXT')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3956
    ('l', 'logfile', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3957
     _('read commit message from file'), _('FILE')),
3857
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
  3958
]
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
  3959
5147
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  3960
commitopts2 = [
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3961
    ('d', 'date', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3962
     _('record datecode as commit date'), _('DATE')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3963
    ('u', 'user', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3964
     _('record the specified user as committer'), _('USER')),
5147
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  3965
]
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  3966
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3967
templateopts = [
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3968
    ('', 'style', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3969
     _('display using template map file'), _('STYLE')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3970
    ('', 'template', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3971
     _('display with template'), _('TEMPLATE')),
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3972
]
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3973
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3974
logopts = [
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3975
    ('p', 'patch', None, _('show patch')),
7763
cdc913e7fc5f log-like commands now use -G for --graph, -g for --git
Jim Correia <jim.correia@pobox.com>
parents: 7762
diff changeset
  3976
    ('g', 'git', None, _('use git extended diff format')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3977
    ('l', 'limit', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3978
     _('limit number of changes displayed'), _('NUM')),
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3979
    ('M', 'no-merges', None, _('do not show merges')),
11061
51d0387523c6 log: add --stat for diffstat output
Yuya Nishihara <yuya@tcha.org>
parents: 11050
diff changeset
  3980
    ('', 'stat', None, _('output diffstat-style summary of changes')),
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3981
] + templateopts
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3982
6668
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3983
diffopts = [
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3984
    ('a', 'text', None, _('treat all files as text')),
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3985
    ('g', 'git', None, _('use git extended diff format')),
10375
adf9505e8888 commands: Try to improve help options text for basic commands
timeless@mozdev.org
parents: 10369
diff changeset
  3986
    ('', 'nodates', None, _('omit dates from diff headers'))
6668
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3987
]
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3988
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3989
diffopts2 = [
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3990
    ('p', 'show-function', None, _('show which function each change is in')),
9857
24bc6e414610 diff: change --inverse to --reverse
Martin Geisler <mg@lazybytes.net>
parents: 9839
diff changeset
  3991
    ('', 'reverse', None, _('produce a diff that undoes the changes')),
6668
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3992
    ('w', 'ignore-all-space', None,
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3993
     _('ignore white space when comparing lines')),
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3994
    ('b', 'ignore-space-change', None,
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3995
     _('ignore changes in the amount of white space')),
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3996
    ('B', 'ignore-blank-lines', None,
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3997
     _('ignore changes whose lines are all blank')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3998
    ('U', 'unified', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  3999
     _('number of lines of context to show'), _('NUM')),
9640
9e76232fbfbe diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents: 9636
diff changeset
  4000
    ('', 'stat', None, _('output diffstat-style summary of changes')),
6668
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  4001
]
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  4002
7402
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  4003
similarityopts = [
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  4004
    ('s', 'similarity', '',
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4005
     _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
7402
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  4006
]
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  4007
12166
441a74b8def1 status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12132
diff changeset
  4008
subrepoopts = [
441a74b8def1 status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12132
diff changeset
  4009
    ('S', 'subrepos', None,
441a74b8def1 status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12132
diff changeset
  4010
     _('recurse into subrepositories'))
441a74b8def1 status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12132
diff changeset
  4011
]
441a74b8def1 status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12132
diff changeset
  4012
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
  4013
table = {
12270
166b9866580a add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12269
diff changeset
  4014
    "^add": (add, walkopts + subrepoopts + dryrunopts,
166b9866580a add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12269
diff changeset
  4015
             _('[OPTION]... [FILE]...')),
2955
9d1c3529ebbc addremove: do not deprecate.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
  4016
    "addremove":
7402
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  4017
        (addremove, similarityopts + walkopts + dryrunopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4018
         _('[OPTION]... [FILE]...')),
6182
07f2236c4dee add a blame alias for annotate
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6180
diff changeset
  4019
    "^annotate|blame":
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4020
        (annotate,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4021
         [('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4022
           _('annotate the specified revision'), _('REV')),
10579
f142fa3c0a8c Make annotate --follow an alias for -f/--file to behave like in older versions
Thomas Arendsen Hein <thomas@intevation.de>
parents: 10564
diff changeset
  4023
          ('', 'follow', None,
f142fa3c0a8c Make annotate --follow an alias for -f/--file to behave like in older versions
Thomas Arendsen Hein <thomas@intevation.de>
parents: 10564
diff changeset
  4024
           _('follow copies/renames and list the filename (DEPRECATED)')),
10369
98a0421b9e52 commands: annotate follows by default, separate -f/--file option
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10365
diff changeset
  4025
          ('', 'no-follow', None, _("don't follow copies and renames")),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  4026
          ('a', 'text', None, _('treat all files as text')),
6134
7b937b26adf7 Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6133
diff changeset
  4027
          ('u', 'user', None, _('list the author (long with -v)')),
10369
98a0421b9e52 commands: annotate follows by default, separate -f/--file option
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10365
diff changeset
  4028
          ('f', 'file', None, _('list the filename')),
6134
7b937b26adf7 Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6133
diff changeset
  4029
          ('d', 'date', None, _('list the date (short with -q)')),
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  4030
          ('n', 'number', None, _('list the revision number (default)')),
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  4031
          ('c', 'changeset', None, _('list the changeset')),
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
  4032
          ('l', 'line-number', None,
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
  4033
           _('show line number at the first appearance'))
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  4034
         ] + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4035
         _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')),
2160
858df1f354c1 Cleanup archive command: Don't overwrite gettext, quoting in cmd table entry.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2159
diff changeset
  4036
    "archive":
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
  4037
        (archive,
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
  4038
         [('', 'no-decode', None, _('do not pass files through decoders')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4039
          ('p', 'prefix', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4040
           _('directory prefix for files in archive'), _('PREFIX')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4041
          ('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4042
           _('revision to distribute'), _('REV')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4043
          ('t', 'type', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4044
           _('type of distribution to create'), _('TYPE')),
12323
f00953d9533c subrepo: add support for 'hg archive'
Martin Geisler <mg@aragost.com>
parents: 12274
diff changeset
  4045
         ] + subrepoopts + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4046
         _('[OPTION]... DEST')),
2159
5c34b98ad6b1 Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2158
diff changeset
  4047
    "backout":
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
  4048
        (backout,
2159
5c34b98ad6b1 Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2158
diff changeset
  4049
         [('', 'merge', None,
5c34b98ad6b1 Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2158
diff changeset
  4050
           _('merge with old dirstate parent after backout')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4051
          ('', 'parent', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4052
           _('parent to choose when backing out merge'), _('REV')),
12810
a68ccfd9c7be backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents: 12809
diff changeset
  4053
          ('t', 'tool', '',
a68ccfd9c7be backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents: 12809
diff changeset
  4054
           _('specify merge tool')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4055
          ('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4056
           _('revision to backout'), _('REV')),
5147
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  4057
         ] + walkopts + commitopts + commitopts2,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4058
         _('[OPTION]... [-r] REV')),
5778
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4059
    "bisect":
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4060
        (bisect,
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4061
         [('r', 'reset', False, _('reset bisect state')),
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4062
          ('g', 'good', False, _('mark changeset good')),
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4063
          ('b', 'bad', False, _('mark changeset bad')),
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4064
          ('s', 'skip', False, _('skip testing changeset')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4065
          ('c', 'command', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4066
           _('use command to check changeset state'), _('CMD')),
5778
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4067
          ('U', 'noupdate', False, _('do not update to target'))],
9952
5b149c88d9e8 commands: add missing options in command line help
timeless@mozdev.org
parents: 9951
diff changeset
  4068
         _("[-gbsr] [-U] [-c CMD] [REV]")),
4730
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  4069
    "branch":
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  4070
        (branch,
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  4071
         [('f', 'force', None,
7006
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
  4072
           _('set branch name even if it shadows an existing branch')),
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
  4073
          ('C', 'clean', None, _('reset branch name to parent branch name'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4074
         _('[-fC] [NAME]')),
4730
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  4075
    "branches":
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  4076
        (branches,
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  4077
         [('a', 'active', False,
8991
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
  4078
           _('show only branches that have unmerged heads')),
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
  4079
          ('c', 'closed', False,
9189
c2041f80f22a heads: more clarity for --closed
Matt Mackall <mpm@selenic.com>
parents: 9188
diff changeset
  4080
           _('show normal and closed branches'))],
9952
5b149c88d9e8 commands: add missing options in command line help
timeless@mozdev.org
parents: 9951
diff changeset
  4081
         _('[-ac]')),
1218
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
  4082
    "bundle":
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
  4083
        (bundle,
1959
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
  4084
         [('f', 'force', None,
10375
adf9505e8888 commands: Try to improve help options text for basic commands
timeless@mozdev.org
parents: 10369
diff changeset
  4085
           _('run even when the destination is unrelated')),
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
  4086
          ('r', 'rev', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4087
           _('a changeset intended to be added to the destination'),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4088
           _('REV')),
10379
a78bfaf988e1 add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents: 10376
diff changeset
  4089
          ('b', 'branch', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4090
           _('a specific branch you would like to bundle'),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4091
           _('BRANCH')),
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
  4092
          ('', 'base', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4093
           _('a base changeset assumed to be available at the destination'),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4094
           _('REV')),
6570
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
  4095
          ('a', 'all', None, _('bundle all changesets in the repository')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4096
          ('t', 'type', 'bzip2',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4097
           _('bundle compression type to use'), _('TYPE')),
3191
545b6d718593 add remoteopts to bundle command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3190
diff changeset
  4098
         ] + remoteopts,
9952
5b149c88d9e8 commands: add missing options in command line help
timeless@mozdev.org
parents: 9951
diff changeset
  4099
         _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4100
    "cat":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4101
        (cat,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4102
         [('o', 'output', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4103
          _('print output to file with formatted name'), _('FORMAT')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4104
          ('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4105
           _('print the given revision'), _('REV')),
6094
3998c1b0828f cat --decode: Drop short option, use opts.get() instead of opts[]
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6093
diff changeset
  4106
          ('', 'decode', None, _('apply any matching decode filter')),
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  4107
         ] + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4108
         _('[OPTION]... FILE...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4109
    "^clone":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4110
        (clone,
6625
4d3a60d5c490 improve help text for clone -U
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6620
diff changeset
  4111
         [('U', 'noupdate', None,
10375
adf9505e8888 commands: Try to improve help options text for basic commands
timeless@mozdev.org
parents: 10369
diff changeset
  4112
          _('the clone will include an empty working copy (only a repository)')),
9714
2f1ab7f77ddc clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents: 9698
diff changeset
  4113
          ('u', 'updaterev', '',
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4114
           _('revision, tag or branch to check out'), _('REV')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  4115
          ('r', 'rev', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4116
           _('include the specified changeset'), _('REV')),
10379
a78bfaf988e1 add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents: 10376
diff changeset
  4117
          ('b', 'branch', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4118
           _('clone only the specified branch'), _('BRANCH')),
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
  4119
          ('', 'pull', None, _('use pull protocol to copy metadata')),
2620
de82749d3a71 clone: change name of --stream to --uncompressed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2618
diff changeset
  4120
          ('', 'uncompressed', None,
de82749d3a71 clone: change name of --stream to --uncompressed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2618
diff changeset
  4121
           _('use uncompressed transfer (fast over LAN)')),
3190
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  4122
         ] + remoteopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4123
         _('[OPTION]... SOURCE [DEST]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4124
    "^commit|ci":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4125
        (commit,
2184
2477a7183a6f Add debugaddremove alias to addremove, so it doesn't show up in 'hg help'.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2181
diff changeset
  4126
         [('A', 'addremove', None,
2477a7183a6f Add debugaddremove alias to addremove, so it doesn't show up in 'hg help'.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2181
diff changeset
  4127
           _('mark new/missing files as added/removed before committing')),
7655
cce37dab7ad6 branch closing: mark closed branches with a 'close' extra
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7643
diff changeset
  4128
          ('', 'close-branch', None,
cce37dab7ad6 branch closing: mark closed branches with a 'close' extra
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7643
diff changeset
  4129
           _('mark a branch as closed, hiding it from the branch list')),
5147
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  4130
         ] + walkopts + commitopts + commitopts2,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4131
         _('[OPTION]... [FILE]...')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  4132
    "copy|cp":
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  4133
        (copy,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
  4134
         [('A', 'after', None, _('record a copy that has already occurred')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  4135
          ('f', 'force', None,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
  4136
           _('forcibly copy over an existing managed file')),
3189
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3188
diff changeset
  4137
         ] + walkopts + dryrunopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4138
         _('[OPTION]... [SOURCE]... DEST')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4139
    "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
11337
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
  4140
    "debugbuilddag":
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
  4141
        (debugbuilddag,
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
  4142
         [('m', 'mergeable-file', None, _('add single file mergeable changes')),
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
  4143
          ('a', 'appended-file', None, _('add single file all revs append to')),
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
  4144
          ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
  4145
          ('n', 'new-file', None, _('add new file at each rev')),
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
  4146
         ],
0f3c8a47960e debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11336
diff changeset
  4147
         _('[OPTION]... TEXT')),
9604
fcc85abc762e commands: fix missing empty synopses
Matt Mackall <mpm@selenic.com>
parents: 9603
diff changeset
  4148
    "debugcheckstate": (debugcheckstate, [], ''),
7880
7ca2be800804 add debugcommands command: an easy to parse command + option index
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7875
diff changeset
  4149
    "debugcommands": (debugcommands, [], _('[COMMAND]')),
2034
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
  4150
    "debugcomplete":
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
  4151
        (debugcomplete,
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
  4152
         [('o', 'options', None, _('show the command options'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4153
         _('[-o] CMD')),
11336
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  4154
    "debugdag":
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  4155
        (debugdag,
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  4156
         [('t', 'tags', None, _('use tags as labels')),
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  4157
          ('b', 'branches', None, _('annotate with branch names')),
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  4158
          ('', 'dots', None, _('use dots for runs')),
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  4159
          ('s', 'spaces', None, _('separate elements by spaces')),
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  4160
         ],
3dfbe26cfded debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 11331
diff changeset
  4161
         _('[OPTION]... [FILE [REV]...]')),
5781
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  4162
    "debugdate":
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  4163
        (debugdate,
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  4164
         [('e', 'extended', None, _('try extended date formats'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4165
         _('[-e] DATE [RANGE]')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4166
    "debugdata": (debugdata, [], _('FILE REV')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4167
    "debugfsinfo": (debugfsinfo, [], _('[PATH]')),
12893
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  4168
    "debugindex": (debugindex,
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  4169
                   [('f', 'format', 0, _('revlog format'), _('FORMAT'))],
15ca4bfecfe3 debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents: 12863
diff changeset
  4170
                   _('FILE')),
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4171
    "debugindexdot": (debugindexdot, [], _('FILE')),
9604
fcc85abc762e commands: fix missing empty synopses
Matt Mackall <mpm@selenic.com>
parents: 9603
diff changeset
  4172
    "debuginstall": (debuginstall, [], ''),
11371
4c8842ee97ff pushkey: add debugpushkey command for testing
Matt Mackall <mpm@selenic.com>
parents: 11353
diff changeset
  4173
    "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')),
1755
a8f7791e3680 add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1754
diff changeset
  4174
    "debugrebuildstate":
a8f7791e3680 add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1754
diff changeset
  4175
        (debugrebuildstate,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4176
         [('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4177
           _('revision to rebuild to'), _('REV'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4178
         _('[-r REV] [REV]')),
4730
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  4179
    "debugrename":
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  4180
        (debugrename,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4181
         [('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4182
           _('revision to debug'), _('REV'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4183
         _('[-r REV] FILE')),
11276
f28b58e35768 revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents: 11273
diff changeset
  4184
    "debugrevspec":
f28b58e35768 revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents: 11273
diff changeset
  4185
        (debugrevspec, [], ('REVSPEC')),
5781
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  4186
    "debugsetparents":
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4187
        (debugsetparents, [], _('REV1 [REV2]')),
6296
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  4188
    "debugstate":
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  4189
        (debugstate,
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  4190
         [('', 'nodates', None, _('do not display the saved mtime'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4191
         _('[OPTION]...')),
8812
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  4192
    "debugsub":
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  4193
        (debugsub,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4194
         [('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4195
           _('revision to check'), _('REV'))],
8812
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  4196
         _('[-r REV] [REV]')),
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4197
    "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4198
    "^diff":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4199
        (diff,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4200
         [('r', 'rev', [],
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4201
           _('revision'), _('REV')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4202
          ('c', 'change', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4203
           _('change made by revision'), _('REV'))
12167
d2c5b0927c28 diff: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12166
diff changeset
  4204
         ] + diffopts + diffopts2 + walkopts + subrepoopts,
10520
75361931884d commands: mention diff -c
timeless <timeless@mozdev.org>
parents: 10515
diff changeset
  4205
         _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4206
    "^export":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4207
        (export,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4208
         [('o', 'output', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4209
           _('print output to file with formatted name'), _('FORMAT')),
10015
b5f352f33520 commands.export: accept -r option as revision specification
Alexander Solovyov <piranha@piranha.org.ua>
parents: 10014
diff changeset
  4210
          ('', 'switch-parent', None, _('diff against the second parent')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4211
          ('r', 'rev', [],
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4212
           _('revisions to export'), _('REV')),
6668
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  4213
          ] + diffopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4214
         _('[OPTION]... [-o OUTFILESPEC] REV...')),
8902
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  4215
    "^forget":
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  4216
        (forget,
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  4217
         [] + walkopts,
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  4218
         _('[OPTION]... FILE...')),
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  4219
    "grep":
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  4220
        (grep,
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  4221
         [('0', 'print0', None, _('end fields with NUL')),
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  4222
          ('', 'all', None, _('print all revisions that match')),
2870
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
  4223
          ('f', 'follow', None,
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  4224
           _('follow changeset history,'
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  4225
             ' or file history across copies and renames')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  4226
          ('i', 'ignore-case', None, _('ignore case when matching')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  4227
          ('l', 'files-with-matches', None,
8028
3aaca5901ade expand "rev" to "revision" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8027
diff changeset
  4228
           _('print only filenames and revisions that match')),
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  4229
          ('n', 'line-number', None, _('print matching line numbers')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4230
          ('r', 'rev', [],
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4231
           _('only search files changed within revision range'), _('REV')),
6134
7b937b26adf7 Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6133
diff changeset
  4232
          ('u', 'user', None, _('list the author (long with -v)')),
7b937b26adf7 Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6133
diff changeset
  4233
          ('d', 'date', None, _('list the date (short with -q)')),
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  4234
         ] + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4235
         _('[OPTION]... PATTERN [FILE]...')),
905
65763ff9fa53 Update online help of hg heads for new --branches option.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 904
diff changeset
  4236
    "heads":
65763ff9fa53 Update online help of hg heads for new --branches option.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 904
diff changeset
  4237
        (heads,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4238
         [('r', 'rev', '',
12613
f365aed7cc5b heads: mention STARTREV in synopsis and help for --rev
Martin Geisler <mg@lazybytes.net>
parents: 12584
diff changeset
  4239
           _('show only heads which are descendants of STARTREV'),
f365aed7cc5b heads: mention STARTREV in synopsis and help for --rev
Martin Geisler <mg@lazybytes.net>
parents: 12584
diff changeset
  4240
           _('STARTREV')),
10350
fd511e9eeea6 commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10349
diff changeset
  4241
          ('t', 'topo', False, _('show topological heads only')),
7656
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
  4242
          ('a', 'active', False,
11777
9299b98041e8 commands: use round parenthesis in 'hg head --active' help
Martin Geisler <mg@aragost.com>
parents: 11692
diff changeset
  4243
           _('show active branchheads only (DEPRECATED)')),
8695
9a89253a32e6 heads: show closed heads only when --closed is passed
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8679
diff changeset
  4244
          ('c', 'closed', False,
9189
c2041f80f22a heads: more clarity for --closed
Matt Mackall <mpm@selenic.com>
parents: 9188
diff changeset
  4245
           _('show normal and closed branch heads')),
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  4246
         ] + templateopts,
12613
f365aed7cc5b heads: mention STARTREV in synopsis and help for --rev
Martin Geisler <mg@lazybytes.net>
parents: 12584
diff changeset
  4247
         _('[-ac] [-r STARTREV] [REV]...')),
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4248
    "help": (help_, [], _('[TOPIC]')),
4665
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
  4249
    "identify|id":
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
  4250
        (identify,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4251
         [('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4252
           _('identify the specified revision'), _('REV')),
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  4253
          ('n', 'num', None, _('show local revision number')),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  4254
          ('i', 'id', None, _('show global revision id')),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  4255
          ('b', 'branch', None, _('show branch')),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  4256
          ('t', 'tags', None, _('show tags'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4257
         _('[-nibt] [-r REV] [SOURCE]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4258
    "import|patch":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4259
        (import_,
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  4260
         [('p', 'strip', 1,
8038
2ee6769afe82 commands: removed bad linebreak in import help
Martin Geisler <mg@lazybytes.net>
parents: 8034
diff changeset
  4261
           _('directory strip option for patch. This has the same '
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4262
             'meaning as the corresponding patch option'),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4263
           _('NUM')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4264
          ('b', 'base', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4265
           _('base path'), _('PATH')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  4266
          ('f', 'force', None,
4263
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
  4267
           _('skip check for outstanding uncommitted changes')),
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  4268
          ('', 'no-commit', None,
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  4269
           _("don't commit, just update the working directory")),
4263
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
  4270
          ('', 'exact', None,
4592
5243cece3d97 Add --import-branch option to hg import to pull in branch information without --exact
Eric Hopper <hopper@omnifarious.org>
parents: 4587
diff changeset
  4271
           _('apply patch to the nodes from which it was generated')),
5243cece3d97 Add --import-branch option to hg import to pull in branch information without --exact
Eric Hopper <hopper@omnifarious.org>
parents: 4587
diff changeset
  4272
          ('', 'import-branch', None,
8034
15725dbc900f commands: lower-case --import-branch help text
Martin Geisler <mg@lazybytes.net>
parents: 8033
diff changeset
  4273
           _('use any branch information in patch (implied by --exact)'))] +
7402
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  4274
         commitopts + commitopts2 + similarityopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4275
         _('[OPTION]... PATCH...')),
5778
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4276
    "incoming|in":
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4277
        (incoming,
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  4278
         [('f', 'force', None,
10375
adf9505e8888 commands: Try to improve help options text for basic commands
timeless@mozdev.org
parents: 10369
diff changeset
  4279
           _('run even if remote repository is unrelated')),
1907
7718885070b1 let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1800
diff changeset
  4280
          ('n', 'newest-first', None, _('show newest record first')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4281
          ('', 'bundle', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4282
           _('file to store the bundles into'), _('FILE')),
6304
d99b4e8652b3 Make clear that for a changegroup '-r' pulls "up to" a revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6299
diff changeset
  4283
          ('r', 'rev', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4284
           _('a remote changeset intended to be added'), _('REV')),
10379
a78bfaf988e1 add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents: 10376
diff changeset
  4285
          ('b', 'branch', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4286
           _('a specific branch you would like to pull'), _('BRANCH')),
12274
c02e1ed3d407 incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12273
diff changeset
  4287
         ] + logopts + remoteopts + subrepoopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4288
         _('[-p] [-n] [-M] [-f] [-r REV]...'
2544
0ab63318bc36 Added missing space in continued string.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2521
diff changeset
  4289
           ' [--bundle FILENAME] [SOURCE]')),
2598
b898afee9d0d Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2597
diff changeset
  4290
    "^init":
3885
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
  4291
        (init,
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
  4292
         remoteopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4293
         _('[-e CMD] [--remotecmd CMD] [DEST]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4294
    "locate":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4295
        (locate,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4296
         [('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4297
           _('search the repository as it is in REV'), _('REV')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  4298
          ('0', 'print0', None,
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  4299
           _('end filenames with NUL, for use with xargs')),
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  4300
          ('f', 'fullpath', None,
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  4301
           _('print complete paths from the filesystem root')),
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  4302
         ] + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4303
         _('[OPTION]... [PATTERN]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4304
    "^log|history":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4305
        (log,
3876
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
  4306
         [('f', 'follow', None,
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  4307
           _('follow changeset history,'
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  4308
             ' or file history across copies and renames')),
2784
12a7bfcafd8f Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents: 2783
diff changeset
  4309
          ('', 'follow-first', None,
12a7bfcafd8f Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents: 2783
diff changeset
  4310
           _('only follow the first parent of merge changesets')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4311
          ('d', 'date', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4312
           _('show revisions matching date spec'), _('DATE')),
3197
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  4313
          ('C', 'copies', None, _('show copied files')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4314
          ('k', 'keyword', [],
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4315
           _('do case-insensitive search for a given text'), _('TEXT')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4316
          ('r', 'rev', [],
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4317
           _('show the specified revision or range'), _('REV')),
8028
3aaca5901ade expand "rev" to "revision" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8027
diff changeset
  4318
          ('', 'removed', None, _('include revisions where files were removed')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  4319
          ('m', 'only-merges', None, _('show only merges')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4320
          ('u', 'user', [],
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4321
           _('revisions committed by user'), _('USER')),
10957
0d5f139b23c1 commands: Add 'hg log --branch' and deprecate 'hg log --only-branch'
Steve Losh <steve@stevelosh.com>
parents: 10934
diff changeset
  4322
          ('', 'only-branch', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4323
           _('show only changesets within the given named branch (DEPRECATED)'),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4324
           _('BRANCH')),
10957
0d5f139b23c1 commands: Add 'hg log --branch' and deprecate 'hg log --only-branch'
Steve Losh <steve@stevelosh.com>
parents: 10934
diff changeset
  4325
          ('b', 'branch', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4326
           _('show changesets within the given named branch'), _('BRANCH')),
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  4327
          ('P', 'prune', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4328
           _('do not display revision or any of its ancestors'), _('REV')),
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  4329
         ] + logopts + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4330
         _('[OPTION]... [FILE]')),
5778
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4331
    "manifest":
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4332
        (manifest,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4333
         [('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4334
           _('revision to display'), _('REV'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4335
         _('[-r REV]')),
4014
509342f95564 various doc fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4013
diff changeset
  4336
    "^merge":
2044
b343e7d454b4 Don't allow --style and --template for hg update and hg merge.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2043
diff changeset
  4337
        (merge,
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  4338
         [('f', 'force', None, _('force a merge with outstanding changes')),
12750
05bd2658bbb3 merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents: 12727
diff changeset
  4339
          ('t', 'tool', '', _('specify merge tool')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4340
          ('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4341
           _('revision to merge'), _('REV')),
8834
6d36fc70754e merge: rename -S/--show option to -P/--preview
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8815
diff changeset
  4342
          ('P', 'preview', None,
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  4343
           _('review revisions to merge (no merge is performed)'))],
9952
5b149c88d9e8 commands: add missing options in command line help
timeless@mozdev.org
parents: 9951
diff changeset
  4344
         _('[-P] [-f] [[-r] REV]')),
5778
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4345
    "outgoing|out":
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  4346
        (outgoing,
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  4347
         [('f', 'force', None,
10375
adf9505e8888 commands: Try to improve help options text for basic commands
timeless@mozdev.org
parents: 10369
diff changeset
  4348
           _('run even when the destination is unrelated')),
6304
d99b4e8652b3 Make clear that for a changegroup '-r' pulls "up to" a revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6299
diff changeset
  4349
          ('r', 'rev', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4350
           _('a changeset intended to be included in the destination'),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4351
           _('REV')),
1907
7718885070b1 let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1800
diff changeset
  4352
          ('n', 'newest-first', None, _('show newest record first')),
10379
a78bfaf988e1 add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents: 10376
diff changeset
  4353
          ('b', 'branch', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4354
           _('a specific branch you would like to push'), _('BRANCH')),
12272
42ecd56399d7 outgoing: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12271
diff changeset
  4355
         ] + logopts + remoteopts + subrepoopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4356
         _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')),
9606
69f8ac71ded1 Remove parents from default help in favor of summary
Matt Mackall <mpm@selenic.com>
parents: 9605
diff changeset
  4357
    "parents":
1724
5a36609f73a7 add a -b/--branch option to 'hg parents'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1720
diff changeset
  4358
        (parents,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4359
         [('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4360
           _('show parents of the specified revision'), _('REV')),
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  4361
         ] + templateopts,
8544
48dd8a93d6db commands: standardize parents command meta data
Ori Avtalion <ori@avtalion.name>
parents: 8540
diff changeset
  4362
         _('[-r REV] [FILE]')),
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4363
    "paths": (paths, [], _('[NAME]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4364
    "^pull":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4365
        (pull,
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  4366
         [('u', 'update', None,
10210
43f8abcec42d commands: fix help string for pull -u and unbundle -u.
Greg Ward <greg-hg@gerg.ca>
parents: 10206
diff changeset
  4367
           _('update to new branch head if changesets were pulled')),
1959
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
  4368
          ('f', 'force', None,
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
  4369
           _('run even when remote repository is unrelated')),
3885
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
  4370
          ('r', 'rev', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4371
           _('a remote changeset intended to be added'), _('REV')),
10379
a78bfaf988e1 add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents: 10376
diff changeset
  4372
          ('b', 'branch', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4373
           _('a specific branch you would like to pull'), _('BRANCH')),
3190
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  4374
         ] + remoteopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4375
         _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')),
818
eef752151556 Actually implement the -f switch for push
mpm@selenic.com
parents: 815
diff changeset
  4376
    "^push":
eef752151556 Actually implement the -f switch for push
mpm@selenic.com
parents: 815
diff changeset
  4377
        (push,
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  4378
         [('f', 'force', None, _('force push')),
6304
d99b4e8652b3 Make clear that for a changegroup '-r' pulls "up to" a revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6299
diff changeset
  4379
          ('r', 'rev', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4380
           _('a changeset intended to be included in the destination'),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4381
           _('REV')),
10379
a78bfaf988e1 add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents: 10376
diff changeset
  4382
          ('b', 'branch', [],
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4383
           _('a specific branch you would like to push'), _('BRANCH')),
11211
e43c23d189a5 push: add --new-branch option to allow intial push of new branches
Sune Foldager <cryo@cyanite.org>
parents: 11193
diff changeset
  4384
          ('', 'new-branch', False, _('allow pushing a new branch')),
3190
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  4385
         ] + remoteopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4386
         _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4387
    "recover": (recover, []),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  4388
    "^remove|rm":
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  4389
        (remove,
6346
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  4390
         [('A', 'after', None, _('record delete for missing files')),
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  4391
          ('f', 'force', None,
6347
3b42f7ac6916 tiny tab cleanup
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6346
diff changeset
  4392
           _('remove (and delete) file even if added or modified')),
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  4393
         ] + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4394
         _('[OPTION]... FILE...')),
12699
0159a674a7bc commands: add move alias for the rename command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 12697
diff changeset
  4395
    "rename|move|mv":
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  4396
        (rename,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
  4397
         [('A', 'after', None, _('record a rename that has already occurred')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  4398
          ('f', 'force', None,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
  4399
           _('forcibly copy over an existing managed file')),
3189
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3188
diff changeset
  4400
         ] + walkopts + dryrunopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4401
         _('[OPTION]... SOURCE... DEST')),
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  4402
    "resolve":
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  4403
        (resolve,
9747
85a3285860d3 hg help resolve grossly mischaracterizes the --all switch
timeless@mozdev.org
parents: 9740
diff changeset
  4404
         [('a', 'all', None, _('select all unresolved files')),
7527
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  4405
          ('l', 'list', None, _('list state of files needing merge')),
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  4406
          ('m', 'mark', None, _('mark files as resolved')),
11836
53fdc0989047 resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents: 11777
diff changeset
  4407
          ('u', 'unmark', None, _('mark files as unresolved')),
12750
05bd2658bbb3 merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents: 12727
diff changeset
  4408
          ('t', 'tool', '', _('specify merge tool')),
9646
5b001f534452 commands: adding --no-status to resolve to match status
timeless <timeless@gmail.com>
parents: 9645
diff changeset
  4409
          ('n', 'no-status', None, _('hide status prefix'))]
7765
da9acc68b1dd resolve: accepts walkopts (-I and -X)
Simon Heimberg <simohe@besonet.ch>
parents: 7763
diff changeset
  4410
          + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4411
          _('[OPTION]... [FILE]...')),
5574
d4ec6d61b3ee imported patch rev-help
Matt Mackall <mpm@selenic.com>
parents: 5573
diff changeset
  4412
    "revert":
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4413
        (revert,
2983
3b7626b861f8 revert: add -a as alias for --all
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2982
diff changeset
  4414
         [('a', 'all', None, _('revert all changes when no arguments given')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4415
          ('d', 'date', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4416
           _('tipmost revision matching date'), _('DATE')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4417
          ('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4418
           _('revert to the specified revision'), _('REV')),
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
  4419
          ('', 'no-backup', None, _('do not save backup copies of files')),
3189
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3188
diff changeset
  4420
         ] + walkopts + dryrunopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4421
         _('[OPTION]... [-r REV] [NAME]...')),
10882
f0bfe42c7b1f rollback: add dry-run argument, emit transaction description
Steve Borho <steve@borho.org>
parents: 10835
diff changeset
  4422
    "rollback": (rollback, dryrunopts),
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4423
    "root": (root, []),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4424
    "^serve":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4425
        (serve,
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4426
         [('A', 'accesslog', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4427
           _('name of access log file to write to'), _('FILE')),
1740
f95654385065 add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1736
diff changeset
  4428
          ('d', 'daemon', None, _('run server in background')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4429
          ('', 'daemon-pipefds', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4430
           _('used internally by daemon mode'), _('NUM')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4431
          ('E', 'errorlog', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4432
           _('name of error log file to write to'), _('FILE')),
10635
27027bee318e serve: fix port config
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10632
diff changeset
  4433
          # use string type, then we can check if something was passed
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4434
          ('p', 'port', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4435
           _('port to listen on (default: 8000)'), _('PORT')),
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  4436
          ('a', 'address', '',
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4437
           _('address to listen on (default: all interfaces)'), _('ADDR')),
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10270
diff changeset
  4438
          ('', 'prefix', '',
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4439
           _('prefix path to serve from (default: server root)'), _('PREFIX')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  4440
          ('n', 'name', '',
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4441
           _('name to show in web pages (default: working directory)'),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4442
           _('NAME')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4443
          ('', 'web-conf', '',
12582
18c79cef795c serve: let --web-conf help reference hgweb
Mads Kiilerich <mads@kiilerich.com>
parents: 12400
diff changeset
  4444
           _('name of the hgweb config file (see "hg help hgweb")'),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4445
           _('FILE')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4446
          ('', 'webdir-conf', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4447
           _('name of the hgweb config file (DEPRECATED)'), _('FILE')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4448
          ('', 'pid-file', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4449
           _('name of file to write process ID to'), _('FILE')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  4450
          ('', 'stdio', None, _('for remote clients')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4451
          ('t', 'templates', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4452
           _('web templates to use'), _('TEMPLATE')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4453
          ('', 'style', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4454
           _('template style to use'), _('STYLE')),
4860
f3802f9f1840 Add SSL support to hg serve, activated via --certificate option
Brendan Cully <brendan@kublai.com>
parents: 4857
diff changeset
  4455
          ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4456
          ('', 'certificate', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4457
           _('SSL certificate file'), _('FILE'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4458
         _('[OPTION]...')),
5781
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  4459
    "showconfig|debugconfig":
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  4460
        (showconfig,
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  4461
         [('u', 'untrusted', None, _('show untrusted configuration options'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4462
         _('[-u] [NAME]...')),
9603
220d39af2e57 Introduce summary command
Matt Mackall <mpm@selenic.com>
parents: 9584
diff changeset
  4463
    "^summary|sum":
9620
a7ef354da662 summary: add --remote
Matt Mackall <mpm@selenic.com>
parents: 9619
diff changeset
  4464
        (summary,
9625
022b15b9ec8c summary: remove reference to -p
Matt Mackall <mpm@selenic.com>
parents: 9620
diff changeset
  4465
         [('', 'remote', None, _('check for push and pull'))], '[--remote]'),
1507
cd8fadd8c689 Add explicit 'st' alias for status
Matt Mackall <mpm@selenic.com>
parents: 1506
diff changeset
  4466
    "^status|st":
840
141744605b51 hg status: added options to select files by status.
tksoh@users.sourceforge.net
parents: 839
diff changeset
  4467
        (status,
2661
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
  4468
         [('A', 'all', None, _('show status of all files')),
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
  4469
          ('m', 'modified', None, _('show only modified files')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  4470
          ('a', 'added', None, _('show only added files')),
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  4471
          ('r', 'removed', None, _('show only removed files')),
1619
1ba0d7041ac4 Distinguish removed and deleted files. Tests are not fixed yet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1618
diff changeset
  4472
          ('d', 'deleted', None, _('show only deleted (but tracked) files')),
2661
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
  4473
          ('c', 'clean', None, _('show only files without changes')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  4474
          ('u', 'unknown', None, _('show only unknown (not tracked) files')),
4156
30857b5779f8 Fix help text for hg status -i
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4143
diff changeset
  4475
          ('i', 'ignored', None, _('show only ignored files')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
  4476
          ('n', 'no-status', None, _('hide status prefix')),
2639
001703ec311d Add an option '-C|--copies' to hg status to show the source of copied files.
Brendan Cully <brendan@kublai.com>
parents: 2630
diff changeset
  4477
          ('C', 'copies', None, _('show source of copied files')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  4478
          ('0', 'print0', None,
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  4479
           _('end filenames with NUL, for use with xargs')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4480
          ('', 'rev', [],
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4481
           _('show difference from revision'), _('REV')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4482
          ('', 'change', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4483
           _('list the changed files of a revision'), _('REV')),
12166
441a74b8def1 status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents: 12132
diff changeset
  4484
         ] + walkopts + subrepoopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4485
         _('[OPTION]... [FILE]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4486
    "tag":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4487
        (tag,
13135
1c1ca9d393f4 tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents: 13134
diff changeset
  4488
         [('f', 'force', None, _('force tag')),
4267
8185a1ca8628 tags: require -f to replace an existing tag
Matt Mackall <mpm@selenic.com>
parents: 4247
diff changeset
  4489
          ('l', 'local', None, _('make the tag local')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4490
          ('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4491
           _('revision to tag'), _('REV')),
5147
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  4492
          ('', 'remove', None, _('remove a tag')),
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  4493
          # -l/--local is already there, commitopts cannot be used
11185
6d7cf82453be tag: add -e/--edit option for modifying the commit message
Steve Losh <steve@stevelosh.com>
parents: 11181
diff changeset
  4494
          ('e', 'edit', None, _('edit commit message')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4495
          ('m', 'message', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4496
           _('use <text> as commit message'), _('TEXT')),
5147
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  4497
         ] + commitopts2,
9952
5b149c88d9e8 commands: add missing options in command line help
timeless@mozdev.org
parents: 9951
diff changeset
  4498
         _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')),
9604
fcc85abc762e commands: fix missing empty synopses
Matt Mackall <mpm@selenic.com>
parents: 9603
diff changeset
  4499
    "tags": (tags, [], ''),
1762
8eaa8e06a364 Add option -b/--branch to hg tip (as done for hg parents).
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1761
diff changeset
  4500
    "tip":
8eaa8e06a364 Add option -b/--branch to hg tip (as done for hg parents).
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1761
diff changeset
  4501
        (tip,
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  4502
         [('p', 'patch', None, _('show patch')),
7763
cdc913e7fc5f log-like commands now use -G for --graph, -g for --git
Jim Correia <jim.correia@pobox.com>
parents: 7762
diff changeset
  4503
          ('g', 'git', None, _('use git extended diff format')),
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  4504
         ] + templateopts,
9952
5b149c88d9e8 commands: add missing options in command line help
timeless@mozdev.org
parents: 9951
diff changeset
  4505
         _('[-p] [-g]')),
1218
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
  4506
    "unbundle":
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
  4507
        (unbundle,
1601
a1b25fb2e764 Error handling for unbundle, fix option line wrapping
Matt Mackall <mpm@selenic.com>
parents: 1600
diff changeset
  4508
         [('u', 'update', None,
10210
43f8abcec42d commands: fix help string for pull -u and unbundle -u.
Greg Ward <greg-hg@gerg.ca>
parents: 10206
diff changeset
  4509
           _('update to new branch head if changesets were unbundled'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4510
         _('[-u] FILE...')),
593
ca3c499e94c6 Shorten help
mpm@selenic.com
parents: 592
diff changeset
  4511
    "^update|up|checkout|co":
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  4512
        (update,
9718
fe1b19bfe75b help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents: 9714
diff changeset
  4513
         [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
12688
8c034a825cfe help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents: 12618
diff changeset
  4514
          ('c', 'check', None,
8c034a825cfe help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents: 12618
diff changeset
  4515
           _('update across branches if no uncommitted changes')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4516
          ('d', 'date', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4517
           _('tipmost revision matching date'), _('DATE')),
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4518
          ('r', 'rev', '',
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11317
diff changeset
  4519
           _('revision'), _('REV'))],
9718
fe1b19bfe75b help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents: 9714
diff changeset
  4520
         _('[-c] [-C] [-d DATE] [[-r] REV]')),
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4521
    "verify": (verify, []),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  4522
    "version": (version_, []),
1046
772507daaa17 Sort global options by topic: directories, ui, timing, other
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1044
diff changeset
  4523
}
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
  4524
12131
c061f9882ff7 debugdata: try to access filelogs through repo, if possible
Sune Foldager <cryo@cyanite.org>
parents: 12130
diff changeset
  4525
norepo = ("clone init version help debugcommands debugcomplete"
12132
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  4526
          " debugdate debuginstall debugfsinfo debugpushkey")
12131
c061f9882ff7 debugdata: try to access filelogs through repo, if possible
Sune Foldager <cryo@cyanite.org>
parents: 12130
diff changeset
  4527
optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
12132
8a0e5b0c0ba9 debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents: 12131
diff changeset
  4528
                " debugdata debugindex debugindexdot")