mercurial/commands.py
author Martin Geisler <mg@lazybytes.net>
Wed, 22 Jul 2009 23:08:32 +0200
changeset 9197 a05aa192a00a
parent 9196 07d127e771a1
child 9198 061eeb602354
permissions -rw-r--r--
commands: remove ineffective parenthesis
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
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8210
diff changeset
     6
# GNU General Public License version 2, incorporated herein by reference.
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
9036
32e678f9045f split local and stdlib module imports (eases migration issues)
Alejandro Santos <alejolp@alejolp.com>
parents: 9035
diff changeset
    11
import os, re, sys, subprocess, difflib, time, tempfile
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents: 7632
diff changeset
    12
import hg, util, revlog, bundlerepo, extensions, copies, context, error
9036
32e678f9045f split local and stdlib module imports (eases migration issues)
Alejandro Santos <alejolp@alejolp.com>
parents: 9035
diff changeset
    13
import patch, help, mdiff, url, encoding
8312
b87a50b7125c separate import lines from mercurial and general python modules
Simon Heimberg <simohe@besonet.ch>
parents: 8287
diff changeset
    14
import archival, changegroup, cmdutil, sshserver, hbisect
b87a50b7125c separate import lines from mercurial and general python modules
Simon Heimberg <simohe@besonet.ch>
parents: 8287
diff changeset
    15
from hgweb import server
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
    16
import merge as merge_
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
    17
import minirst
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
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    24
    Schedule files to be version controlled and added to the repository.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    25
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    26
    The files will be added to the repository at the next commit. To undo an
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    27
    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
    28
7807
bd8f44638847 help: miscellaneous language fixes
timeless <timeless@gmail.com>
parents: 7765
diff changeset
    29
    If no names are given, add all files to the repository.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    30
    """
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    31
8679
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
    32
    bad = []
5688
883d887c6408 commands: add exits(1) if a specified file cannot be added (issue 891)
Patrick Mezard <pmezard@gmail.com>
parents: 5660
diff changeset
    33
    exacts = {}
724
1c0c413cccdd Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 723
diff changeset
    34
    names = []
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
    35
    m = cmdutil.match(repo, pats, opts)
8679
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
    36
    oldbad = m.bad
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
    37
    m.bad = lambda x,y: bad.append(x) or oldbad(x,y)
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
    38
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
    39
    for f in repo.walk(m):
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
    40
        exact = m.exact(f)
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
    41
        if exact or f not in repo.dirstate:
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
    42
            names.append(f)
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
    43
            if ui.verbose or not exact:
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
    44
                ui.status(_('adding %s\n') % m.rel(f))
2503
37655f10ced6 Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2494
diff changeset
    45
    if not opts.get('dry_run'):
8679
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
    46
        bad += [f for f in repo.add(names) if f in m.files()]
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
    47
    return bad and 1 or 0
213
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 212
diff changeset
    48
766
b444a7e053f1 Get addremove to use new walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 764
diff changeset
    49
def addremove(ui, repo, *pats, **opts):
3181
3637d5d17cbc Documentation fixes for addremove.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3172
diff changeset
    50
    """add all new files, delete all missing files
2181
690da72b0b16 deprecate addremove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2179
diff changeset
    51
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    52
    Add all new files and remove all missing files from the repository.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    53
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    54
    New files are ignored if they match any of the patterns in .hgignore. As
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    55
    with add, these changes take effect at the next commit.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    56
9080
5d6c42f33b71 commands: avoid bad linebreak in addremove docstring
Martin Geisler <mg@lazybytes.net>
parents: 9051
diff changeset
    57
    Use the -s/--similarity option to detect renamed files. With a parameter
5d6c42f33b71 commands: avoid bad linebreak in addremove docstring
Martin Geisler <mg@lazybytes.net>
parents: 9051
diff changeset
    58
    greater than 0, this compares every removed file with every added file and
5d6c42f33b71 commands: avoid bad linebreak in addremove docstring
Martin Geisler <mg@lazybytes.net>
parents: 9051
diff changeset
    59
    records those similar enough as renames. This option takes a percentage
5d6c42f33b71 commands: avoid bad linebreak in addremove docstring
Martin Geisler <mg@lazybytes.net>
parents: 9051
diff changeset
    60
    between 0 (disabled) and 100 (files must be identical) as its parameter.
5d6c42f33b71 commands: avoid bad linebreak in addremove docstring
Martin Geisler <mg@lazybytes.net>
parents: 9051
diff changeset
    61
    Detecting renamed files this way can be expensive.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    62
    """
4966
8d982aef0be1 addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents: 4950
diff changeset
    63
    try:
8d982aef0be1 addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents: 4950
diff changeset
    64
        sim = float(opts.get('similarity') or 0)
8d982aef0be1 addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents: 4950
diff changeset
    65
    except ValueError:
8d982aef0be1 addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents: 4950
diff changeset
    66
        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
    67
    if sim < 0 or sim > 100:
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
    68
        raise util.Abort(_('similarity must be between 0 and 100'))
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
    69
    return cmdutil.addremove(repo, pats, opts, similarity=sim/100.)
219
8ff4532376a4 hg checkout: refuse to checkout if there are outstanding changes
mpm@selenic.com
parents: 214
diff changeset
    70
733
1966c553f652 Convert annotate over to walk interface.
Bryan O'Sullivan <bos@serpentine.com>
parents: 732
diff changeset
    71
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
    72
    """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
    73
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    74
    List changes in files, showing the revision id responsible for each line
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    75
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    76
    This command is useful for discovering when a change was made and by whom.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    77
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    78
    Without the -a/--text option, annotate will avoid processing files it
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    79
    detects as binary. With -a, annotate will annotate the file anyway,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
    80
    although the results will probably be neither useful nor desirable.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
    81
    """
6134
7b937b26adf7 Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6133
diff changeset
    82
    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
    83
    getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
1522
d07d729ce306 Added --date option to annotate.
lupus@debian.org
parents: 1519
diff changeset
    84
744
3d88f6dd1ed4 Handle empty file list for annotate
mpm@selenic.com
parents: 743
diff changeset
    85
    if not pats:
8761
0289f384e1e5 Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents: 8760
diff changeset
    86
        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
    87
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
    88
    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
    89
             ('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
    90
             ('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
    91
             ('date', getdate),
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
    92
             ('follow', lambda x: x[0].path()),
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
    93
            ]
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
    94
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
    95
    if (not opts.get('user') and not opts.get('changeset') and not opts.get('date')
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
    96
        and not opts.get('follow')):
714
29fcd195e056 Some cleanups in commands.annotate().
Thomas Arendsen Hein <thomas@intevation.de>
parents: 712
diff changeset
    97
        opts['number'] = 1
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
    98
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
    99
    linenumber = opts.get('line_number') is not None
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   100
    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
   101
        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
   102
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   103
    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
   104
    if linenumber:
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   105
        lastfunc = funcmap[-1]
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   106
        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
   107
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   108
    ctx = repo[opts.get('rev')]
1016
836667830fee Teach annotate about binary files
mpm@selenic.com
parents: 1015
diff changeset
   109
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
   110
    m = cmdutil.match(repo, pats, opts)
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
   111
    for abs in ctx.walk(m):
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
   112
        fctx = ctx[abs]
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   113
        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
   114
            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
   115
            continue
836667830fee Teach annotate about binary files
mpm@selenic.com
parents: 1015
diff changeset
   116
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   117
        lines = fctx.annotate(follow=opts.get('follow'),
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   118
                              linenumber=linenumber)
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
   119
        pieces = []
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
   120
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   121
        for f in funcmap:
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
   122
            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
   123
            if l:
7094
a4769dec7773 annotate: fix bug when annotating multiple files
Matt Mackall <mpm@selenic.com>
parents: 7040
diff changeset
   124
                ml = max(map(len, l))
a4769dec7773 annotate: fix bug when annotating multiple files
Matt Mackall <mpm@selenic.com>
parents: 7040
diff changeset
   125
                pieces.append(["%*s" % (ml, x) for x in l])
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
   126
771
0de223012086 Fixes for annotate
mpm@selenic.com
parents: 770
diff changeset
   127
        if pieces:
0de223012086 Fixes for annotate
mpm@selenic.com
parents: 770
diff changeset
   128
            for p, l in zip(zip(*pieces), lines):
0de223012086 Fixes for annotate
mpm@selenic.com
parents: 770
diff changeset
   129
                ui.write("%s: %s" % (" ".join(p), l[1]))
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
   130
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   131
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
   132
    '''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
   133
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   134
    By default, the revision used is the parent of the working directory; use
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   135
    -r/--rev to specify a different revision.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   136
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   137
    To specify the type of archive to create, use -t/--type. Valid types are::
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   138
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   139
      "files" (default): a directory full of files
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   140
      "tar": tar archive, uncompressed
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   141
      "tbz2": tar archive, compressed using bzip2
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   142
      "tgz": tar archive, compressed using gzip
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   143
      "uzip": zip archive, uncompressed
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   144
      "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
   145
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   146
    The exact name of the destination archive or directory is given using a
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   147
    format string; see 'hg help export' for details.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   148
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   149
    Each member added to an archive file has a directory prefix prepended. Use
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   150
    -p/--prefix to specify a format string for the prefix. The default is the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   151
    basename of the archive, with suffixes removed.
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   152
    '''
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   153
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   154
    ctx = repo[opts.get('rev')]
5061
a49f2a4d5ff7 archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents: 4966
diff changeset
   155
    if not ctx:
7528
eadcc075967e archive: fix bogus error message with no working directory
Matt Mackall <mpm@selenic.com>
parents: 7527
diff changeset
   156
        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
   157
    node = ctx.node()
2874
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2871
diff changeset
   158
    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
   159
    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
   160
        raise util.Abort(_('repository root cannot be destination'))
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
   161
    matchfn = cmdutil.match(repo, [], opts)
2476
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
   162
    kind = opts.get('type') or 'files'
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   163
    prefix = opts.get('prefix')
2476
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
   164
    if dest == '-':
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
   165
        if kind == 'files':
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
   166
            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
   167
        dest = sys.stdout
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
   168
        if not prefix: prefix = os.path.basename(repo.root) + '-%h'
2874
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2871
diff changeset
   169
    prefix = cmdutil.make_filename(repo, prefix, node)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   170
    archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
2476
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
   171
                     matchfn, prefix)
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
   172
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
   173
def backout(ui, repo, node=None, rev=None, **opts):
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   174
    '''reverse effect of earlier changeset
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   175
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   176
    Commit the backed out changes as a new changeset. The new changeset is a
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   177
    child of the backed out changeset.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   178
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   179
    If you backout a changeset other than the tip, a new head is created. This
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   180
    head will be the new tip and you should merge this backout changeset with
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   181
    another head.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   182
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   183
    The --merge option remembers the parent of the working directory before
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   184
    starting the backout, then merges the new head with that changeset
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   185
    afterwards. This saves you from doing the merge by hand. The result of
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   186
    this merge is not committed, as with a normal merge.
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
   187
8540
f0733f11b566 commands: remove unnecessary quotes in backout help
Martin Geisler <mg@lazybytes.net>
parents: 8533
diff changeset
   188
    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
   189
    '''
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
   190
    if rev and node:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
   191
        raise util.Abort(_("please specify just one revision"))
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
   192
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
   193
    if not rev:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
   194
        rev = node
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   195
4726
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4718
diff changeset
   196
    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
   197
        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
   198
6139
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
   199
    date = opts.get('date')
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
   200
    if date:
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
   201
        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
   202
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
   203
    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
   204
    node = repo.lookup(rev)
be367cbafe70 cmdutil: make bail_if_changed bail on uncommitted merge
Matt Mackall <mpm@selenic.com>
parents: 5688
diff changeset
   205
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   206
    op1, op2 = repo.dirstate.parents()
5568
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 5542
diff changeset
   207
    a = repo.changelog.ancestor(op1, node)
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 5542
diff changeset
   208
    if a != node:
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   209
        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
   210
2614
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
   211
    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
   212
    if p1 == nullid:
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   213
        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
   214
    if p2 != nullid:
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   215
        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
   216
            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
   217
                               '--parent'))
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
   218
        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
   219
        if p not in (p1, p2):
3679
2956948b81f3 fix warnings generated by pygettext.py.
Marcos Chaves <marcos.nospam@gmail.com>
parents: 3673
diff changeset
   220
            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
   221
                             (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
   222
        parent = p
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
   223
    else:
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   224
        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
   225
            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
   226
        parent = p1
5568
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 5542
diff changeset
   227
6423
fb374b1b3911 backout: reverse changeset belongs on current branch
Matt Mackall <mpm@selenic.com>
parents: 6385
diff changeset
   228
    # 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
   229
    branch = repo.dirstate.branch()
2808
30f59f4a327e Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents: 2806
diff changeset
   230
    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
   231
    repo.dirstate.setbranch(branch)
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   232
    revert_opts = opts.copy()
3814
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
   233
    revert_opts['date'] = None
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
   234
    revert_opts['all'] = True
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   235
    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
   236
    revert_opts['no_backup'] = None
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   237
    revert(ui, repo, **revert_opts)
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   238
    commit_opts = opts.copy()
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   239
    commit_opts['addremove'] = False
2159
5c34b98ad6b1 Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2158
diff changeset
   240
    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
   241
        # we don't translate commit messages
9197
a05aa192a00a commands: remove ineffective parenthesis
Martin Geisler <mg@lazybytes.net>
parents: 9196
diff changeset
   242
        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
   243
        commit_opts['force_editor'] = True
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   244
    commit(ui, repo, **commit_opts)
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   245
    def nice(node):
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   246
        return '%d:%s' % (repo.changelog.rev(node), short(node))
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   247
    ui.status(_('changeset %s backs out changeset %s\n') %
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   248
              (nice(repo.changelog.tip()), nice(node)))
2493
9c660e691e90 print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2482
diff changeset
   249
    if op1 != node:
6161
bc1ba9124799 Reverse the way backout is doing the merge
Gilles Moris <gilles.moris@free.fr>
parents: 6146
diff changeset
   250
        hg.clean(repo, op1, show_stats=False)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   251
        if opts.get('merge'):
6161
bc1ba9124799 Reverse the way backout is doing the merge
Gilles Moris <gilles.moris@free.fr>
parents: 6146
diff changeset
   252
            ui.status(_('merging with changeset %s\n') % nice(repo.changelog.tip()))
bc1ba9124799 Reverse the way backout is doing the merge
Gilles Moris <gilles.moris@free.fr>
parents: 6146
diff changeset
   253
            hg.merge(repo, hex(repo.changelog.tip()))
2493
9c660e691e90 print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2482
diff changeset
   254
        else:
9c660e691e90 print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2482
diff changeset
   255
            ui.status(_('the backout changeset is a new head - '
9c660e691e90 print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2482
diff changeset
   256
                        'do not forget to merge\n'))
2761
0aa458261901 fix hg backup option recommendation for auto-merge
Christian Ebert <blacktrash@gmx.net>
parents: 2760
diff changeset
   257
            ui.status(_('(use "backout --merge" '
0aa458261901 fix hg backup option recommendation for auto-merge
Christian Ebert <blacktrash@gmx.net>
parents: 2760
diff changeset
   258
                        'if you want to auto-merge)\n'))
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
   259
7227
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   260
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
   261
               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
   262
    """subdivision search of changesets
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   263
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   264
    This command helps to find changesets which introduce problems. To use,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   265
    mark the earliest changeset you know exhibits the problem as bad, then
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   266
    mark the latest changeset which is free from the problem as good. Bisect
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   267
    will update your working directory to a revision for testing (unless the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   268
    -U/--noupdate option is specified). Once you have performed tests, mark
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   269
    the working directory as good or bad, and bisect will either update to
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   270
    another candidate changeset or announce that it has found the bad
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   271
    revision.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   272
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   273
    As a shortcut, you can also use the revision argument to mark a revision
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   274
    as good or bad without checking it out first.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   275
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   276
    If you supply a command, it will be used for automatic bisection. Its exit
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   277
    status will be used to mark revisions as good or bad: status 0 means good,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   278
    125 means to skip the revision, 127 (command not found) will abort the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   279
    bisection, and any other non-zero exit status means the revision is bad.
5775
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   280
    """
7227
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   281
    def print_result(nodes, good):
5775
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   282
        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
   283
        if len(nodes) == 1:
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   284
            # 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
   285
            if good:
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   286
                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
   287
            else:
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   288
                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
   289
            displayer.show(repo[nodes[0]])
6858
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   290
        else:
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   291
            # multiple possible revisions
8088
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   292
            if good:
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   293
                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
   294
                        "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
   295
            else:
bdeb380a10de commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8042
diff changeset
   296
                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
   297
                        "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
   298
            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
   299
                displayer.show(repo[n])
7227
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   300
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   301
    def check_state(state, interactive=True):
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   302
        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
   303
            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
   304
                return
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   305
            if not state['good']:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   306
                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
   307
            else:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   308
                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
   309
        return True
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   310
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   311
    # backward compatibility
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   312
    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
   313
        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
   314
        cmd, rev, extra = rev, extra, None
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   315
        if cmd == "good":
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   316
            good = True
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   317
        elif cmd == "bad":
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   318
            bad = True
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   319
        else:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   320
            reset = True
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   321
    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
   322
        raise util.Abort(_('incompatible arguments'))
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   323
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   324
    if reset:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   325
        p = repo.join("bisect.state")
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   326
        if os.path.exists(p):
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   327
            os.unlink(p)
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   328
        return
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   329
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   330
    state = hbisect.load_state(repo)
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   331
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   332
    if command:
7590
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   333
        commandpath = util.find_exe(command)
8802
ca14b3982ffe bisect: fix traceback when command executable is not found
Patrick Mezard <pmezard@gmail.com>
parents: 8779
diff changeset
   334
        if commandpath is None:
ca14b3982ffe bisect: fix traceback when command executable is not found
Patrick Mezard <pmezard@gmail.com>
parents: 8779
diff changeset
   335
            raise util.Abort(_("cannot find executable: %s") % command)
7227
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   336
        changesets = 1
7590
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   337
        try:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   338
            while changesets:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   339
                # update state
8284
36c704b0e7ab bisect: use subprocess to get command return code
Alexander Solovyov <piranha@piranha.org.ua>
parents: 8279
diff changeset
   340
                status = subprocess.call([commandpath])
7590
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   341
                if status == 125:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   342
                    transition = "skip"
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   343
                elif status == 0:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   344
                    transition = "good"
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   345
                # 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
   346
                elif status == 127:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   347
                    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
   348
                elif status < 0:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   349
                    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
   350
                else:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   351
                    transition = "bad"
8805
2726a6df11e9 bisect: improve --command output
Patrick Mezard <pmezard@gmail.com>
parents: 8802
diff changeset
   352
                ctx = repo[rev or '.']
2726a6df11e9 bisect: improve --command output
Patrick Mezard <pmezard@gmail.com>
parents: 8802
diff changeset
   353
                state[transition].append(ctx.node())
2726a6df11e9 bisect: improve --command output
Patrick Mezard <pmezard@gmail.com>
parents: 8802
diff changeset
   354
                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
   355
                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
   356
                # bisect
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   357
                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
   358
                # 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
   359
                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
   360
                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
   361
        finally:
e5703ec08e64 bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7570
diff changeset
   362
            hbisect.save_state(repo, state)
7227
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   363
        return print_result(nodes, not status)
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   364
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   365
    # update state
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   366
    node = repo.lookup(rev or '.')
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   367
    if good:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   368
        state['good'].append(node)
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   369
    elif bad:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   370
        state['bad'].append(node)
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   371
    elif skip:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   372
        state['skip'].append(node)
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   373
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   374
    hbisect.save_state(repo, state)
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   375
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   376
    if not check_state(state):
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   377
        return
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   378
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   379
    # actually bisect
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   380
    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
   381
    if changesets == 0:
e1afb50ec2aa bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7213
diff changeset
   382
        print_result(nodes, good)
6858
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   383
    else:
8f256bf98219 Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents: 6842
diff changeset
   384
        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
   385
        node = nodes[0]
5775
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   386
        # compute the approximate number of remaining tests
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   387
        tests, size = 0, 2
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   388
        while size <= changesets:
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   389
            tests, size = tests + 1, size * 2
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   390
        rev = repo.changelog.rev(node)
9012
ada93c6bf554 bisect: fix format specifiers for integers
Cédric Duval <cedricduval@free.fr>
parents: 8995
diff changeset
   391
        ui.write(_("Testing changeset %d:%s "
ada93c6bf554 bisect: fix format specifiers for integers
Cédric Duval <cedricduval@free.fr>
parents: 8995
diff changeset
   392
                   "(%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
   393
                 % (rev, short(node), changesets, tests))
5775
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   394
        if not noupdate:
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   395
            cmdutil.bail_if_changed(repo)
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   396
            return hg.clean(repo, node)
2dd202a6e15b bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents: 5764
diff changeset
   397
4202
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4200
diff changeset
   398
def branch(ui, repo, label=None, **opts):
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   399
    """set or show the current branch name
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   400
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   401
    With no argument, show the current branch name. With one argument, set the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   402
    working directory branch name (the branch will not exist in the repository
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   403
    until the next commit). Standard practice recommends that primary
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   404
    development take place on the 'default' branch.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   405
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   406
    Unless -f/--force is specified, branch will not let you set a branch name
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   407
    that already exists, even if it's inactive.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   408
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   409
    Use -C/--clean to reset the working directory branch to that of the parent
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   410
    of the working directory, negating a previous branch change.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   411
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   412
    Use the command 'hg update' to switch to an existing branch. Use 'hg
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   413
    commit --close-branch' to mark this branch as closed.
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   414
    """
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   415
7006
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
   416
    if opts.get('clean'):
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
   417
        label = repo[None].parents()[0].branch()
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
   418
        repo.dirstate.setbranch(label)
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
   419
        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
   420
    elif label:
4202
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4200
diff changeset
   421
        if not opts.get('force') and label in repo.branchtags():
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
   422
            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
   423
                raise util.Abort(_('a branch of the same name already exists'
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4200
diff changeset
   424
                                   ' (use --force to override)'))
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
   425
        repo.dirstate.setbranch(encoding.fromlocal(label))
4601
e69da61e467e Notify the user that hg branch does not create a branch until commit
Brendan Cully <brendan@kublai.com>
parents: 4593
diff changeset
   426
        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
   427
    else:
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
   428
        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
   429
8991
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
   430
def branches(ui, repo, active=False, closed=False):
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   431
    """list repository named branches
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   432
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   433
    List the repository's named branches, indicating which ones are inactive.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   434
    If -c/--closed is specified, also list branches which have been marked
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   435
    closed (see hg commit --close-branch).
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   436
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   437
    If -a/--active is specified, only show active branches. A branch is
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   438
    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
   439
d1fe1a4eb2b7 Mention 'hg update' to switch branches in help for branch and branches.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5998
diff changeset
   440
    Use the command 'hg update' to switch to an existing branch.
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   441
    """
8991
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
   442
6631
a2b13cac0922 Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6625
diff changeset
   443
    hexfunc = ui.debugflag and hex or short
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
   444
    activebranches = [encoding.tolocal(repo[n].branch())
8796
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
   445
                            for n in repo.heads()]
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
   446
    def testactive(tag, node):
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
   447
        realhead = tag in activebranches
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
   448
        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
   449
        return realhead and open
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
   450
    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
   451
                          for tag, node in repo.branchtags().items()],
344751cd8cb8 replace various uses of list.reverse()
Matt Mackall <mpm@selenic.com>
parents: 8209
diff changeset
   452
                      reverse=True)
6631
a2b13cac0922 Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6625
diff changeset
   453
a2b13cac0922 Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6625
diff changeset
   454
    for isactive, node, tag in branches:
a2b13cac0922 Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6625
diff changeset
   455
        if (not active) or isactive:
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
   456
            if ui.quiet:
6631
a2b13cac0922 Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6625
diff changeset
   457
                ui.write("%s\n" % 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
   458
            else:
7656
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   459
                hn = repo.lookup(node)
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   460
                if isactive:
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   461
                    notice = ''
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   462
                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
   463
                    if not closed:
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
   464
                        continue
7656
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   465
                    notice = ' (closed)'
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   466
                else:
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   467
                    notice = ' (inactive)'
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
   468
                rev = str(node).rjust(31 - encoding.colwidth(tag))
7656
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
   469
                data = tag, rev, hexfunc(hn), notice
6814
88804fad71bc branches unparseable output fix (issue1230)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6682
diff changeset
   470
                ui.write("%s %s:%s%s\n" % data)
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3472
diff changeset
   471
2494
73ac95671788 push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2493
diff changeset
   472
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
   473
    """create a changegroup file
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   474
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   475
    Generate a compressed changegroup file collecting changesets not known to
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   476
    be in another repository.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   477
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   478
    If no destination repository is specified the destination is assumed to
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   479
    have all the nodes specified by one or more --base parameters. To create a
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   480
    bundle containing all changesets, use -a/--all (or --base null).
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   481
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   482
    You can change compression method with the -t/--type option. The available
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   483
    compression methods are: none, bzip2, and gzip (by default, bundles are
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   484
    compressed using bzip2).
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   485
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   486
    The bundle file can then be transferred using conventional means and
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   487
    applied to another repository with the unbundle or pull command. This is
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   488
    useful when direct push and pull are not available or when exporting an
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   489
    entire repository is undesirable.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   490
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   491
    Applying bundles preserves all changeset contents including permissions,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   492
    copy/rename information, and revision history.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   493
    """
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   494
    revs = opts.get('rev') or None
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   495
    if revs:
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   496
        revs = [repo.lookup(rev) for rev in revs]
6171
73b1de288801 Add --all option to bundle command
John Mulligan <phlogistonjohn@yahoo.com>
parents: 6163
diff changeset
   497
    if opts.get('all'):
73b1de288801 Add --all option to bundle command
John Mulligan <phlogistonjohn@yahoo.com>
parents: 6163
diff changeset
   498
        base = ['null']
73b1de288801 Add --all option to bundle command
John Mulligan <phlogistonjohn@yahoo.com>
parents: 6163
diff changeset
   499
    else:
73b1de288801 Add --all option to bundle command
John Mulligan <phlogistonjohn@yahoo.com>
parents: 6163
diff changeset
   500
        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
   501
    if base:
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   502
        if dest:
8669
6f0f69da003e commands: typo in bundle abort message
Martin Geisler <mg@lazybytes.net>
parents: 8664
diff changeset
   503
            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
   504
                               "a destination"))
3318
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   505
        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
   506
        # 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
   507
        # 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
   508
        o = []
8464
7af92e70bb25 revlog: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8408
diff changeset
   509
        has = set((nullid,))
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   510
        for n in base:
3631
770c4fc03b8e bundle: don't use sets.Set
Matt Mackall <mpm@selenic.com>
parents: 3629
diff changeset
   511
            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
   512
        if revs:
3318
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   513
            visit = list(revs)
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   514
        else:
3318
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   515
            visit = repo.changelog.heads()
3631
770c4fc03b8e bundle: don't use sets.Set
Matt Mackall <mpm@selenic.com>
parents: 3629
diff changeset
   516
        seen = {}
3318
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   517
        while visit:
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   518
            n = visit.pop(0)
3631
770c4fc03b8e bundle: don't use sets.Set
Matt Mackall <mpm@selenic.com>
parents: 3629
diff changeset
   519
            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
   520
            if len(parents) == 0:
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   521
                o.insert(0, n)
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3284
diff changeset
   522
            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
   523
                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
   524
                    if p not in seen:
3631
770c4fc03b8e bundle: don't use sets.Set
Matt Mackall <mpm@selenic.com>
parents: 3629
diff changeset
   525
                        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
   526
                        visit.append(p)
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   527
    else:
5248
5517aa5aafb0 Merge with crew-stable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5242 5224
diff changeset
   528
        dest, revs, checkout = hg.parseurl(
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
   529
            ui.expandpath(dest or 'default-push', dest or 'default'), revs)
8188
f3abe032fc89 add cmdutil.remoteui
Matt Mackall <mpm@selenic.com>
parents: 8182
diff changeset
   530
        other = hg.repository(cmdutil.remoteui(repo, opts), dest)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   531
        o = repo.findoutgoing(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
   532
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   533
    if revs:
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   534
        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
   535
    else:
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
   536
        cg = repo.changegroup(o, 'bundle')
6570
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   537
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   538
    bundletype = opts.get('type', 'bzip2').lower()
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   539
    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
   540
    bundletype = btypes.get(bundletype)
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   541
    if bundletype not in changegroup.bundletypes:
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   542
        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
   543
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
   544
    changegroup.writebundle(cg, fname, bundletype)
1218
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
   545
1254
e6560042b7b8 Switch cat command to use walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1253
diff changeset
   546
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
   547
    """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
   548
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   549
    Print the specified files as they were at the given revision. If no
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   550
    revision is given, the parent of the working directory is used, or tip if
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   551
    no revision is checked out.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   552
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   553
    Output may be to a file, in which case the name of the file is given using
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   554
    a format string. The formatting rules are the same as for the export
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   555
    command, with the following additions::
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   556
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   557
      %s   basename of file being printed
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   558
      %d   dirname of file being printed, or '.' if in repository root
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   559
      %p   root-relative path name of file being printed
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   560
    """
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   561
    ctx = repo[opts.get('rev')]
4697
5b2d986de0f8 cat: return an error on failure
Matt Mackall <mpm@selenic.com>
parents: 4692
diff changeset
   562
    err = 1
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
   563
    m = cmdutil.match(repo, (file1,) + pats, opts)
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
   564
    for abs in ctx.walk(m):
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   565
        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
   566
        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
   567
        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
   568
            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
   569
        fp.write(data)
4697
5b2d986de0f8 cat: return an error on failure
Matt Mackall <mpm@selenic.com>
parents: 4692
diff changeset
   570
        err = 0
5b2d986de0f8 cat: return an error on failure
Matt Mackall <mpm@selenic.com>
parents: 4692
diff changeset
   571
    return err
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
   572
698
df78d8ccac4c Use python function instead of external 'cp' command when cloning repos.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 697
diff changeset
   573
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
   574
    """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
   575
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   576
    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
   577
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   578
    If no destination directory name is specified, it defaults to the basename
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   579
    of the source.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   580
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   581
    The location of the source is added to the new repository's .hg/hgrc file,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   582
    as the default to be used for future pulls.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   583
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   584
    If you use the -r/--rev option to clone up to a specific revision, no
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   585
    subsequent revisions (including subsequent tags) will be present in the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   586
    cloned repository. This option implies --pull, even on local repositories.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   587
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   588
    By default, clone will check out the head of the 'default' branch. If the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   589
    -U/--noupdate option is used, the new clone will contain only a repository
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   590
    (.hg) and no working copy (the working copy parent is the null revision).
7942
553cef16031f mention default branch in branch and clone help
Matt Mackall <mpm@selenic.com>
parents: 7880
diff changeset
   591
553cef16031f mention default branch in branch and clone help
Matt Mackall <mpm@selenic.com>
parents: 7880
diff changeset
   592
    See 'hg help urls' for valid source format details.
553cef16031f mention default branch in branch and clone help
Matt Mackall <mpm@selenic.com>
parents: 7880
diff changeset
   593
553cef16031f mention default branch in branch and clone help
Matt Mackall <mpm@selenic.com>
parents: 7880
diff changeset
   594
    It is possible to specify an ssh:// URL as the destination, but no
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   595
    .hg/hgrc and working directory will be created on the remote side. Please
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   596
    see 'hg help urls' for important details about ssh:// URLs.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   597
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   598
    For efficiency, hardlinks are used for cloning whenever the source and
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   599
    destination are on the same filesystem (note this applies only to the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   600
    repository data, not to the checked out files). Some filesystems, such as
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   601
    AFS, implement hardlinking incorrectly, but do not report errors. In these
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   602
    cases, use the --pull option to avoid hardlinking.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   603
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   604
    In some cases, you can clone repositories and checked out files using full
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
   605
    hardlinks with ::
2762
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
   606
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
   607
      $ cp -al REPO REPOCLONE
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
   608
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   609
    This is the fastest way to clone, but it is not always safe. The operation
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   610
    is not atomic (making sure REPO is not modified during the operation is up
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   611
    to you) and you have to make sure your editor breaks hardlinks (Emacs and
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   612
    most Linux Kernel tools do so). Also, this is not compatible with certain
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   613
    extensions that place their metadata under the .hg directory, such as mq.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   614
    """
8188
f3abe032fc89 add cmdutil.remoteui
Matt Mackall <mpm@selenic.com>
parents: 8182
diff changeset
   615
    hg.clone(cmdutil.remoteui(ui, opts), source, dest,
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   616
             pull=opts.get('pull'),
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   617
             stream=opts.get('uncompressed'),
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   618
             rev=opts.get('rev'),
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   619
             update=not opts.get('noupdate'))
515
03f27b1381f9 Whitespace cleanups
mpm@selenic.com
parents: 513
diff changeset
   620
813
80fd2958235a Adapt commit to use file matching code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 812
diff changeset
   621
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
   622
    """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
   623
7983
7b813bdbd5d0 Change double spaces to single spaces in help texts.
Martin Geisler <mg@daimi.au.dk>
parents: 7982
diff changeset
   624
    Commit changes to the given files into the repository. Unlike a
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   625
    centralized RCS, this operation is a local operation. See hg push for a
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   626
    way to actively distribute your changes.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   627
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   628
    If a list of files is omitted, all changes reported by "hg status" will be
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   629
    committed.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   630
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   631
    If you are committing the result of a merge, do not provide any filenames
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   632
    or -I/-X filters.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   633
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   634
    If no commit message is specified, the configured editor is started to
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   635
    prompt you for a message.
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
   636
1f733c2f0165 Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6161
diff changeset
   637
    See 'hg help dates' for a list of formats valid for -d/--date.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   638
    """
7655
cce37dab7ad6 branch closing: mark closed branches with a 'close' extra
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7643
diff changeset
   639
    extra = {}
cce37dab7ad6 branch closing: mark closed branches with a 'close' extra
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7643
diff changeset
   640
    if opts.get('close_branch'):
cce37dab7ad6 branch closing: mark closed branches with a 'close' extra
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7643
diff changeset
   641
        extra['close'] = 1
8407
223000a687b0 commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents: 8397
diff changeset
   642
    e = cmdutil.commiteditor
223000a687b0 commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents: 8397
diff changeset
   643
    if opts.get('force_editor'):
223000a687b0 commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents: 8397
diff changeset
   644
        e = cmdutil.commitforceeditor
223000a687b0 commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents: 8397
diff changeset
   645
6600
b822a379860b match: stop passing files through commitfunc
Matt Mackall <mpm@selenic.com>
parents: 6599
diff changeset
   646
    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
   647
        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
   648
                           editor=e, extra=extra)
6336
4b0c9c674707 warn about new heads on commit (issue842)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6321
diff changeset
   649
6369
53912d30ac40 Avoid calling heads() twice on every hg commit.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6367
diff changeset
   650
    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
   651
    if not node:
8995
7b19cda0fa10 commit: lose some pointless 'nothing changed' messages
Matt Mackall <mpm@selenic.com>
parents: 8992
diff changeset
   652
        ui.status(_("nothing changed\n"))
6369
53912d30ac40 Avoid calling heads() twice on every hg commit.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6367
diff changeset
   653
        return
53912d30ac40 Avoid calling heads() twice on every hg commit.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6367
diff changeset
   654
    cl = repo.changelog
53912d30ac40 Avoid calling heads() twice on every hg commit.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6367
diff changeset
   655
    rev = cl.rev(node)
53912d30ac40 Avoid calling heads() twice on every hg commit.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6367
diff changeset
   656
    parents = cl.parentrevs(rev)
53912d30ac40 Avoid calling heads() twice on every hg commit.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6367
diff changeset
   657
    if rev - 1 in parents:
53912d30ac40 Avoid calling heads() twice on every hg commit.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6367
diff changeset
   658
        # one of the parents was the old tip
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
   659
        pass
03916abdfb64 Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents: 6934
diff changeset
   660
    elif (parents == (nullrev, nullrev) or
03916abdfb64 Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents: 6934
diff changeset
   661
          len(cl.heads(cl.node(parents[0]))) > 1 and
03916abdfb64 Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents: 6934
diff changeset
   662
          (parents[1] == nullrev or len(cl.heads(cl.node(parents[1]))) > 1)):
6336
4b0c9c674707 warn about new heads on commit (issue842)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6321
diff changeset
   663
        ui.status(_('created new head\n'))
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
   664
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
   665
    if ui.debugflag:
03916abdfb64 Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents: 6934
diff changeset
   666
        ui.write(_('committed changeset %d:%s\n') % (rev,hex(node)))
03916abdfb64 Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents: 6934
diff changeset
   667
    elif ui.verbose:
03916abdfb64 Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents: 6934
diff changeset
   668
        ui.write(_('committed changeset %d:%s\n') % (rev,short(node)))
03916abdfb64 Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents: 6934
diff changeset
   669
1253
a45e717c61a8 Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1250
diff changeset
   670
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
   671
    """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
   672
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   673
    Mark dest as having copies of source files. If dest is a directory, copies
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   674
    are put in that directory. If dest is a file, the source must be a single
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   675
    file.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   676
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   677
    By default, this command copies the contents of files as they exist in the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   678
    working directory. If invoked with -A/--after, the operation is recorded,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   679
    but no copying is performed.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   680
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   681
    This command takes effect with the next commit. To undo a copy before
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   682
    that, see hg revert.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
   683
    """
4914
9a2a73ea6135 repo locks: use True/False
Matt Mackall <mpm@selenic.com>
parents: 4906
diff changeset
   684
    wlock = repo.wlock(False)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
   685
    try:
5610
2493a478f395 copy: handle rename internally
Matt Mackall <mpm@selenic.com>
parents: 5589
diff changeset
   686
        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
   687
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
   688
        wlock.release()
363
ae96b7e1318d Add hg copy
mpm@selenic.com
parents: 355
diff changeset
   689
6189
81cbb5dfdec0 Make hg debugancestor accept -R by making it an optionalrepo command.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6188
diff changeset
   690
def debugancestor(ui, repo, *args):
1262
325c07fd2ebd Add debugancestor command
mpm@selenic.com
parents: 1257
diff changeset
   691
    """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
   692
    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
   693
        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
   694
        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
   695
        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
   696
    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
   697
        if not repo:
81cbb5dfdec0 Make hg debugancestor accept -R by making it an optionalrepo command.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6188
diff changeset
   698
            raise util.Abort(_("There is no Mercurial repository here "
81cbb5dfdec0 Make hg debugancestor accept -R by making it an optionalrepo command.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6188
diff changeset
   699
                               "(.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
   700
        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
   701
        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
   702
        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
   703
    else:
81afdd016867 debugancestor: make the index argument optional, defaulting to 00changelog.i
Bryan O'Sullivan <bos@serpentine.com>
parents: 6171
diff changeset
   704
        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
   705
    a = r.ancestor(lookup(rev1), lookup(rev2))
1262
325c07fd2ebd Add debugancestor command
mpm@selenic.com
parents: 1257
diff changeset
   706
    ui.write("%d:%s\n" % (r.rev(a), hex(a)))
325c07fd2ebd Add debugancestor command
mpm@selenic.com
parents: 1257
diff changeset
   707
7880
7ca2be800804 add debugcommands command: an easy to parse command + option index
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7875
diff changeset
   708
def debugcommands(ui, cmd='', *args):
8209
a1a5a57efe90 replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents: 8190
diff changeset
   709
    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
   710
        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
   711
        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
   712
        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
   713
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
   714
def debugcomplete(ui, cmd='', **opts):
1887
913397c27cd8 new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1875
diff changeset
   715
    """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
   716
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
   717
    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
   718
        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
   719
        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
   720
        if cmd:
7213
b4c035057d34 findcmd: have dispatch look up strict flag
Matt Mackall <mpm@selenic.com>
parents: 7212
diff changeset
   721
            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
   722
            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
   723
        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
   724
            for o in t:
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
   725
                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
   726
                    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
   727
                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
   728
        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
   729
        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
   730
7509
62e5d41b0a8b Make debugcomplete -v print aliases as well as commands
Brendan Cully <brendan@kublai.com>
parents: 7449
diff changeset
   731
    cmdlist = cmdutil.findpossible(cmd, table)
62e5d41b0a8b Make debugcomplete -v print aliases as well as commands
Brendan Cully <brendan@kublai.com>
parents: 7449
diff changeset
   732
    if ui.verbose:
62e5d41b0a8b Make debugcomplete -v print aliases as well as commands
Brendan Cully <brendan@kublai.com>
parents: 7449
diff changeset
   733
        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
   734
    ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1887
913397c27cd8 new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1875
diff changeset
   735
5741
8ee0de123989 add debugfsinfo to check fs capabilities
Matt Mackall <mpm@selenic.com>
parents: 5716
diff changeset
   736
def debugfsinfo(ui, path = "."):
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 9012
diff changeset
   737
    open('.debugfsinfo', 'w').write('')
5741
8ee0de123989 add debugfsinfo to check fs capabilities
Matt Mackall <mpm@selenic.com>
parents: 5716
diff changeset
   738
    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
   739
    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
   740
    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
   741
                                and 'yes' or 'no'))
8ee0de123989 add debugfsinfo to check fs capabilities
Matt Mackall <mpm@selenic.com>
parents: 5716
diff changeset
   742
    os.unlink('.debugfsinfo')
8ee0de123989 add debugfsinfo to check fs capabilities
Matt Mackall <mpm@selenic.com>
parents: 5716
diff changeset
   743
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
   744
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
   745
    """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
   746
    ctx = repo[rev]
1760
13f8e068d13c fix typo in debugrebuildstate
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1755
diff changeset
   747
    wlock = repo.wlock()
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
   748
    try:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
   749
        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
   750
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
   751
        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
   752
596
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
   753
def debugcheckstate(ui, repo):
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
   754
    """validate the correctness of the current dirstate"""
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
   755
    parent1, parent2 = repo.dirstate.parents()
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
   756
    m1 = repo[parent1].manifest()
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
   757
    m2 = repo[parent2].manifest()
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
   758
    errors = 0
4906
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4904
diff changeset
   759
    for f in repo.dirstate:
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4904
diff changeset
   760
        state = repo.dirstate[f]
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
   761
        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
   762
            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
   763
            errors += 1
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
   764
        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
   765
            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
   766
            errors += 1
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
   767
        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
   768
            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
   769
                    (f, state))
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
   770
            errors += 1
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
   771
    for f in m1:
4906
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4904
diff changeset
   772
        state = repo.dirstate[f]
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
   773
        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
   774
            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
   775
            errors += 1
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
   776
    if errors:
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
   777
        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
   778
        raise util.Abort(error)
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
   779
3553
e1508621e9ef add --untrusted to showconfig
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3521
diff changeset
   780
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
   781
    """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
   782
8664
f265106ccb53 commands: expand "arg" -> "argument" in showconfig help strings
Martin Geisler <mg@lazybytes.net>
parents: 8636
diff changeset
   783
    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
   784
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   785
    With one argument of the form section.name, print just the value of that
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   786
    config item.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   787
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   788
    With multiple arguments, print names and values of all config items with
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   789
    matching section names.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   790
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   791
    With --debug, the source (filename and line number) is printed for each
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   792
    config item.
8279
602ed4982f36 commands: describe --debug in showconfig help
Martin Geisler <mg@lazybytes.net>
parents: 8277
diff changeset
   793
    """
2410
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
   794
3553
e1508621e9ef add --untrusted to showconfig
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3521
diff changeset
   795
    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
   796
    if values:
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
   797
        if len([v for v in values if '.' in v]) > 1:
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
   798
            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
   799
    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
   800
        sectname = section + '.' + name
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
   801
        if values:
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
   802
            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
   803
                if v == section:
8182
b97abc7c1135 showconfig: show source file and line with --debug
Matt Mackall <mpm@selenic.com>
parents: 8152
diff changeset
   804
                    ui.debug('%s: ' %
b97abc7c1135 showconfig: show source file and line with --debug
Matt Mackall <mpm@selenic.com>
parents: 8152
diff changeset
   805
                             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
   806
                    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
   807
                elif v == sectname:
8182
b97abc7c1135 showconfig: show source file and line with --debug
Matt Mackall <mpm@selenic.com>
parents: 8152
diff changeset
   808
                    ui.debug('%s: ' %
b97abc7c1135 showconfig: show source file and line with --debug
Matt Mackall <mpm@selenic.com>
parents: 8152
diff changeset
   809
                             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
   810
                    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
   811
        else:
8182
b97abc7c1135 showconfig: show source file and line with --debug
Matt Mackall <mpm@selenic.com>
parents: 8152
diff changeset
   812
            ui.debug('%s: ' %
b97abc7c1135 showconfig: show source file and line with --debug
Matt Mackall <mpm@selenic.com>
parents: 8152
diff changeset
   813
                     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
   814
            ui.write('%s=%s\n' % (sectname, value))
1028
25e7ea0f2cff Add commands.debugconfig.
Bryan O'Sullivan <bos@serpentine.com>
parents: 989
diff changeset
   815
1395
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
   816
def debugsetparents(ui, repo, rev1, rev2=None):
1470
fb9b84c91222 minor fix on command help docstrings
TK Soh <teekaysoh@yahoo.com>
parents: 1469
diff changeset
   817
    """manually set the parents of the current working directory
1395
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
   818
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   819
    This is useful for writing repository conversion tools, but should be used
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
   820
    with care.
1395
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
   821
    """
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
   822
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
   823
    if not rev2:
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
   824
        rev2 = hex(nullid)
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
   825
4247
89075f106414 debugsetparents: wlock the repo before updating the dirstate
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4231
diff changeset
   826
    wlock = repo.wlock()
89075f106414 debugsetparents: wlock the repo before updating the dirstate
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4231
diff changeset
   827
    try:
89075f106414 debugsetparents: wlock the repo before updating the dirstate
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4231
diff changeset
   828
        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
   829
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
   830
        wlock.release()
1395
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
   831
6296
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
   832
def debugstate(ui, repo, nodates=None):
596
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
   833
    """show the contents of the current dirstate"""
6296
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
   834
    timestr = ""
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
   835
    showdate = not nodates
8209
a1a5a57efe90 replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents: 8190
diff changeset
   836
    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
   837
        if showdate:
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
   838
            if ent[3] == -1:
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
   839
                # Pad or slice to locale representation
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
   840
                locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(0)))
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
   841
                timestr = 'unset'
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
   842
                timestr = timestr[:locale_len] + ' '*(locale_len - len(timestr))
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
   843
            else:
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
   844
                timestr = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(ent[3]))
5156
49554ba98951 debugstate: print symlinks as 'lnk', not '777'
Bryan O'Sullivan <bos@serpentine.com>
parents: 5155
diff changeset
   845
        if ent[1] & 020000:
49554ba98951 debugstate: print symlinks as 'lnk', not '777'
Bryan O'Sullivan <bos@serpentine.com>
parents: 5155
diff changeset
   846
            mode = 'lnk'
49554ba98951 debugstate: print symlinks as 'lnk', not '777'
Bryan O'Sullivan <bos@serpentine.com>
parents: 5155
diff changeset
   847
        else:
49554ba98951 debugstate: print symlinks as 'lnk', not '777'
Bryan O'Sullivan <bos@serpentine.com>
parents: 5155
diff changeset
   848
            mode = '%3o' % (ent[1] & 0777)
6296
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
   849
        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
   850
    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
   851
        ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
   852
8812
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
   853
def debugsub(ui, repo, rev=None):
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
   854
    if rev == '':
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
   855
        rev = None
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
   856
    for k,v in sorted(repo[rev].substate.items()):
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
   857
        ui.write('path %s\n' % k)
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
   858
        ui.write(' source   %s\n' % v[0])
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
   859
        ui.write(' revision %s\n' % v[1])
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
   860
1039
4296754ba7b4 Add debugdata for dumping revlog revision data
mpm@selenic.com
parents: 1037
diff changeset
   861
def debugdata(ui, file_, rev):
4258
b11a2fb59cf5 revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents: 4257
diff changeset
   862
    """dump the contents of a data file revision"""
b11a2fb59cf5 revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents: 4257
diff changeset
   863
    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
   864
    try:
1cc7c0cbc30b Fix traceback during invalid rev identifier for debugdata
Anupam Kapoor<anupam.kapoor@gmail.com>
parents: 1312
diff changeset
   865
        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
   866
    except KeyError:
3072
bc3fe3b5b785 Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3071
diff changeset
   867
        raise util.Abort(_('invalid revision identifier %s') % rev)
1039
4296754ba7b4 Add debugdata for dumping revlog revision data
mpm@selenic.com
parents: 1037
diff changeset
   868
3812
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
   869
def debugdate(ui, date, range=None, **opts):
3805
299d6cce6c0b add debugdate command
Matt Mackall <mpm@selenic.com>
parents: 3804
diff changeset
   870
    """parse and display a date"""
3812
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
   871
    if opts["extended"]:
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
   872
        d = util.parsedate(date, util.extendeddateformats)
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
   873
    else:
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
   874
        d = util.parsedate(date)
3805
299d6cce6c0b add debugdate command
Matt Mackall <mpm@selenic.com>
parents: 3804
diff changeset
   875
    ui.write("internal: %s %s\n" % d)
299d6cce6c0b add debugdate command
Matt Mackall <mpm@selenic.com>
parents: 3804
diff changeset
   876
    ui.write("standard: %s\n" % util.datestr(d))
3812
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
   877
    if range:
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
   878
        m = util.matchdate(range)
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3805
diff changeset
   879
        ui.write("match: %s\n" % m(d[0]))
3805
299d6cce6c0b add debugdate command
Matt Mackall <mpm@selenic.com>
parents: 3804
diff changeset
   880
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
   881
def debugindex(ui, file_):
596
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
   882
    """dump the contents of an index file"""
4258
b11a2fb59cf5 revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents: 4257
diff changeset
   883
    r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
7737
26bdb7109170 commands: removed unnecessary string concatenation
Martin Geisler <mg@daimi.au.dk>
parents: 7695
diff changeset
   884
    ui.write("   rev    offset  length   base linkrev"
989
1b6eb272b238 Reformat debugindex output
mpm@selenic.com
parents: 988
diff changeset
   885
             " nodeid       p1           p2\n")
6750
fb42030d79d6 add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents: 6749
diff changeset
   886
    for i in r:
2072
74d3f5336b66 Implement revlogng.
mason@suse.com
parents: 2042
diff changeset
   887
        node = r.node(i)
5311
599f3a690d8f debugindex: more robust for damaged indexes
Matt Mackall <mpm@selenic.com>
parents: 5310
diff changeset
   888
        try:
599f3a690d8f debugindex: more robust for damaged indexes
Matt Mackall <mpm@selenic.com>
parents: 5310
diff changeset
   889
            pp = r.parents(node)
599f3a690d8f debugindex: more robust for damaged indexes
Matt Mackall <mpm@selenic.com>
parents: 5310
diff changeset
   890
        except:
599f3a690d8f debugindex: more robust for damaged indexes
Matt Mackall <mpm@selenic.com>
parents: 5310
diff changeset
   891
            pp = [nullid, nullid]
989
1b6eb272b238 Reformat debugindex output
mpm@selenic.com
parents: 988
diff changeset
   892
        ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
7361
9fe97eea5510 linkrev: take a revision number rather than a hash
Matt Mackall <mpm@selenic.com>
parents: 7308
diff changeset
   893
                i, r.start(i), r.length(i), r.base(i), r.linkrev(i),
2072
74d3f5336b66 Implement revlogng.
mason@suse.com
parents: 2042
diff changeset
   894
            short(node), short(pp[0]), short(pp[1])))
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
   895
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
   896
def debugindexdot(ui, file_):
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
   897
    """dump an index DAG as a graphviz dot file"""
4258
b11a2fb59cf5 revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents: 4257
diff changeset
   898
    r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
582
df8a5a0098d4 Remove all remaining print statements
mpm@selenic.com
parents: 580
diff changeset
   899
    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
   900
    for i in r:
2287
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
   901
        node = r.node(i)
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
   902
        pp = r.parents(node)
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
   903
        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
   904
        if pp[1] != nullid:
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
   905
            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
   906
    ui.write("}\n")
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
   907
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   908
def debuginstall(ui):
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   909
    '''test Mercurial installation'''
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   910
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
   911
    def writetemp(contents):
4849
035489f60842 Use a prefix for debuginstall tempfiles.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4818
diff changeset
   912
        (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
   913
        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
   914
        f.write(contents)
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
   915
        f.close()
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
   916
        return name
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
   917
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   918
    problems = 0
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   919
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   920
    # encoding
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
   921
    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
   922
    try:
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
   923
        encoding.fromlocal("test")
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   924
    except util.Abort, inst:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   925
        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
   926
        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
   927
        problems += 1
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   928
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   929
    # compiled modules
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   930
    ui.status(_("Checking extensions...\n"))
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   931
    try:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   932
        import bdiff, mpatch, base85
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   933
    except Exception, inst:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   934
        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
   935
        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
   936
        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
   937
        problems += 1
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   938
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   939
    # templates
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   940
    ui.status(_("Checking templates...\n"))
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   941
    try:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   942
        import templater
7874
d812029cda85 cleanup: drop variables for unused return values
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 7850
diff changeset
   943
        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
   944
    except Exception, inst:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   945
        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
   946
        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
   947
        problems += 1
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   948
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   949
    # patch
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   950
    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
   951
    patchproblems = 0
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   952
    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
   953
    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
   954
    fa = writetemp(a)
5482
e5eedd74e70f Use both the from and to name in mdiff.unidiff.
Dustin Sallings <dustin@spy.net>
parents: 5405
diff changeset
   955
    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
   956
        os.path.basename(fa))
5310
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   957
    fd = writetemp(d)
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   958
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   959
    files = {}
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   960
    try:
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   961
        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
   962
    except util.Abort, e:
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   963
        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
   964
        ui.write(" " + str(e) + "\n")
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   965
        patchproblems += 1
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
   966
    else:
5310
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   967
        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
   968
            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
   969
            patchproblems += 1
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 9012
diff changeset
   970
        a = open(fa).read()
5310
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   971
        if a != b:
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   972
            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
   973
            patchproblems += 1
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   974
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   975
    if patchproblems:
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   976
        if ui.config('ui', 'patch'):
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   977
            ui.write(_(" (Current patch tool may be incompatible with patch,"
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   978
                       " or misconfigured. Please check your .hgrc file)\n"))
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4505
diff changeset
   979
        else:
5760
0145f9afb0e7 Removed tabs and trailing whitespace in python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5741
diff changeset
   980
            ui.write(_(" Internal patcher failure, please report this error"
8936
1de6e7e1bb9f change wiki/bts URLs to point to new hostname
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8931
diff changeset
   981
                       " to http://mercurial.selenic.com/bts/\n"))
5310
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   982
    problems += patchproblems
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   983
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   984
    os.unlink(fa)
ba3dc7883968 debuginstall: stop looking for patch utility, just test it
Patrick Mezard <pmezard@gmail.com>
parents: 5300
diff changeset
   985
    os.unlink(fd)
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   986
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   987
    # editor
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   988
    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
   989
    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
   990
    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
   991
    if not cmdpath:
3855
b9cdd6f2aa43 debuginstall: fix a copy/paste error
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3848
diff changeset
   992
        if editor == 'vi':
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   993
            ui.write(_(" No commit editor set and can't find vi in PATH\n"))
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
   994
            ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   995
        else:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   996
            ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
   997
            ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   998
            problems += 1
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
   999
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1000
    # check username
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1001
    ui.status(_("Checking username...\n"))
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1002
    user = os.environ.get("HGUSER")
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1003
    if user is None:
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1004
        user = ui.config("ui", "username")
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1005
    if user is None:
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1006
        user = os.environ.get("EMAIL")
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1007
    if not user:
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1008
        ui.warn(" ")
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1009
        ui.username()
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1010
        ui.write(_(" (specify a username in your .hgrc file)\n"))
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
  1011
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1012
    if not problems:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1013
        ui.status(_("No problems detected\n"))
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1014
    else:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1015
        ui.write(_("%s problems detected,"
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1016
                   " please check your install!\n") % problems)
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1017
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1018
    return problems
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
  1019
3652
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3651
diff changeset
  1020
def debugrename(ui, repo, file1, *pats, **opts):
1194
c165cbf56bb1 Add doc string for debugrename.
bos@serpentine.internal.keyresearch.com
parents: 1193
diff changeset
  1021
    """dump rename information"""
3652
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3651
diff changeset
  1022
6748
c6cc35a3d1de make debugrename work on p1, not tip
Matt Mackall <mpm@selenic.com>
parents: 6747
diff changeset
  1023
    ctx = repo[opts.get('rev')]
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  1024
    m = cmdutil.match(repo, (file1,) + pats, opts)
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
  1025
    for abs in ctx.walk(m):
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
  1026
        fctx = ctx[abs]
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  1027
        o = fctx.filelog().renamed(fctx.filenode())
6584
29c77e5dfb3c walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents: 6583
diff changeset
  1028
        rel = m.rel(abs)
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  1029
        if o:
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  1030
            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
  1031
        else:
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3651
diff changeset
  1032
            ui.write(_("%s not renamed\n") % rel)
1116
0cdd73b0767c Add some rename debugging support
mpm@selenic.com
parents: 1114
diff changeset
  1033
820
89985a1b3427 Clean up walk and changes code to use normalised names properly.
Bryan O'Sullivan <bos@serpentine.com>
parents: 815
diff changeset
  1034
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
  1035
    """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
  1036
    m = cmdutil.match(repo, pats, opts)
6585
d3d1d39da2fa walk: remove cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6584
diff changeset
  1037
    items = list(repo.walk(m))
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1038
    if not items:
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1039
        return
6586
d3463007d368 walk: return a single value
Matt Mackall <mpm@selenic.com>
parents: 6585
diff changeset
  1040
    fmt = 'f  %%-%ds  %%-%ds  %%s' % (
d3463007d368 walk: return a single value
Matt Mackall <mpm@selenic.com>
parents: 6585
diff changeset
  1041
        max([len(abs) for abs in items]),
d3463007d368 walk: return a single value
Matt Mackall <mpm@selenic.com>
parents: 6585
diff changeset
  1042
        max([len(m.rel(abs)) for abs in items]))
d3463007d368 walk: return a single value
Matt Mackall <mpm@selenic.com>
parents: 6585
diff changeset
  1043
    for abs in items:
d3463007d368 walk: return a single value
Matt Mackall <mpm@selenic.com>
parents: 6585
diff changeset
  1044
        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
  1045
        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
  1046
732
ba0b6d17a6de Convert diff command over to using walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 731
diff changeset
  1047
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
  1048
    """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
  1049
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1050
    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
  1051
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1052
    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
  1053
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1054
    NOTE: diff may generate unexpected results for merges, as it will default
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1055
    to comparing against the working directory's first parent changeset if no
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1056
    revisions are specified.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1057
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1058
    When two revision arguments are given, then changes are shown between
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1059
    those revisions. If only one revision is specified then that revision is
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1060
    compared to the working directory, and, when no revisions are specified,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1061
    the working directory files are compared to its parent.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1062
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1063
    Without the -a/--text option, diff will avoid generating diffs of files it
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1064
    detects as binary. With -a, diff will generate a diff anyway, probably
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1065
    with undesirable results.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1066
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1067
    Use the -g/--git option to generate diffs in the git extended diff format.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1068
    For more information, read 'hg help diffs'.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1069
    """
7628
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1070
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1071
    revs = opts.get('rev')
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1072
    change = opts.get('change')
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1073
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1074
    if revs and change:
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1075
        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
  1076
        raise util.Abort(msg)
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1077
    elif change:
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1078
        node2 = repo.lookup(change)
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1079
        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
  1080
    else:
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  1081
        node1, node2 = cmdutil.revpair(repo, revs)
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
  1082
6582
5acbdd3941c4 walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents: 6579
diff changeset
  1083
    m = cmdutil.match(repo, pats, opts)
7308
b6f5490effbf patch: turn patch.diff() into a generator
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7307
diff changeset
  1084
    it = patch.diff(repo, node1, node2, match=m, opts=patch.diffopts(ui, opts))
b6f5490effbf patch: turn patch.diff() into a generator
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7307
diff changeset
  1085
    for chunk in it:
8615
94ca38e63576 use ui instead of repo.ui when the former is in scope
Martin Geisler <mg@lazybytes.net>
parents: 8544
diff changeset
  1086
        ui.write(chunk)
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
  1087
580
353a2ce50423 [PATCH] New export patch
mpm@selenic.com
parents: 577
diff changeset
  1088
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
  1089
    """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
  1090
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1091
    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
  1092
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1093
    The information shown in the changeset header is: author, changeset hash,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1094
    parent(s) and commit comment.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1095
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1096
    NOTE: export may generate unexpected diff output for merge changesets, as
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1097
    it will compare the merge changeset against its first parent only.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1098
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1099
    Output may be to a file, in which case the name of the file is given using
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1100
    a format string. The formatting rules are as follows::
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1101
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1102
      %%   literal "%" character
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1103
      %H   changeset hash (40 bytes of hexadecimal)
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1104
      %N   number of patches being generated
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1105
      %R   changeset revision number
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1106
      %b   basename of the exporting repository
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1107
      %h   short-form changeset hash (12 bytes of hexadecimal)
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1108
      %n   zero-padded sequence number, starting at 1
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1109
      %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
  1110
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1111
    Without the -a/--text option, export will avoid generating diffs of files
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1112
    it detects as binary. With -a, export will generate a diff anyway,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1113
    probably with undesirable results.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1114
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1115
    Use the -g/--git option to generate diffs in the git extended diff format.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1116
    See 'hg help diffs' for more information.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1117
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1118
    With the --switch-parent option, the diff will be against the second
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1119
    parent. It can be useful to review a merge.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1120
    """
610
4c02464cb9f0 check export options for changeset before running
shaleh@speakeasy.net
parents: 609
diff changeset
  1121
    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
  1122
        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
  1123
    revs = cmdutil.revrange(repo, changesets)
2874
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2871
diff changeset
  1124
    if len(revs) > 1:
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2871
diff changeset
  1125
        ui.note(_('exporting patches:\n'))
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2871
diff changeset
  1126
    else:
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2871
diff changeset
  1127
        ui.note(_('exporting patch:\n'))
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1128
    patch.export(repo, revs, template=opts.get('output'),
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1129
                 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
  1130
                 opts=patch.diffopts(ui, opts))
246
96cde50a746f Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents: 245
diff changeset
  1131
8902
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1132
def forget(ui, repo, *pats, **opts):
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1133
    """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
  1134
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1135
    Mark the specified files so they will no longer be tracked after the next
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1136
    commit.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1137
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1138
    This only removes files from the current branch, not from the entire
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1139
    project history, and it does not delete them from the working directory.
8902
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1140
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1141
    To undo a forget before the next commit, see hg add.
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1142
    """
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1143
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1144
    if not pats:
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1145
        raise util.Abort(_('no files specified'))
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1146
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1147
    m = cmdutil.match(repo, pats, opts)
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1148
    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
  1149
    forget = sorted(s[0] + s[1] + s[3] + s[6])
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1150
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1151
    for f in m.files():
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1152
        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
  1153
            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
  1154
                    % m.rel(f))
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1155
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1156
    for f in forget:
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1157
        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
  1158
            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
  1159
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1160
    repo.remove(forget, unlink=False)
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  1161
1108
7a75d8fbbdaf Remove some options from 'hg grep':
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1106
diff changeset
  1162
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
  1163
    """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
  1164
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1165
    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
  1166
6448
cd3d49ffc6f6 Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents: 6442
diff changeset
  1167
    This command behaves differently than Unix grep. It only accepts
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1168
    Python/Perl regexps. It searches repository history, not the working
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1169
    directory. It always prints the revision number in which a match appears.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1170
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1171
    By default, grep only prints output for the first revision of a file in
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1172
    which it finds a match. To get it to print every revision that contains a
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1173
    change in match status ("-" for a match that becomes a non-match, or "+"
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1174
    for a non-match that becomes a match), use the --all flag.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1175
    """
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1176
    reflags = 0
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1177
    if opts.get('ignore_case'):
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1178
        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
  1179
    try:
242026115e6a hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4835
diff changeset
  1180
        regexp = re.compile(pattern, reflags)
242026115e6a hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4835
diff changeset
  1181
    except Exception, inst:
6057
218d5b9aa466 Remove trailing ! from two error messages as this was confusing.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6048
diff changeset
  1182
        ui.warn(_("grep: invalid match pattern: %s\n") % inst)
4877
242026115e6a hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4835
diff changeset
  1183
        return None
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  1184
    sep, eol = ':', '\n'
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1185
    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
  1186
        sep = eol = '\0'
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1187
9097
431462bd8478 fix memory usage of revlog caches by limiting cache size [issue1639]
Matt Mackall <mpm@selenic.com>
parents: 8995
diff changeset
  1188
    getfile = util.lrucachefunc(repo.file)
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1189
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1190
    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
  1191
        begin = 0
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
  1192
        linenum = 0
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
  1193
        while True:
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
  1194
            match = regexp.search(body, begin)
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1195
            if not match:
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1196
                break
1059
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
  1197
            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
  1198
            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
  1199
            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
  1200
            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
  1201
            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
  1202
            yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1203
1559
59b3639df0a9 Convert all classes to new-style classes by deriving them from object.
Eric Hopper <hopper@omnifarious.org>
parents: 1552
diff changeset
  1204
    class linestate(object):
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1205
        def __init__(self, line, linenum, colstart, colend):
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1206
            self.line = line
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1207
            self.linenum = linenum
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1208
            self.colstart = colstart
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1209
            self.colend = colend
2869
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1210
6469
fb502719c75c python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents: 6468
diff changeset
  1211
        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
  1212
            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
  1213
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1214
        def __eq__(self, other):
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  1215
            return self.line == other.line
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1216
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1217
    matches = {}
2870
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
  1218
    copies = {}
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1219
    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
  1220
        matches[rev].setdefault(fn, [])
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1221
        m = matches[rev][fn]
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1222
        for lnum, cstart, cend, line in matchlines(body):
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1223
            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
  1224
            m.append(s)
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1225
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1226
    def difflinestates(a, b):
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1227
        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
  1228
        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
  1229
            if tag == 'insert':
3472
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3471
diff changeset
  1230
                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
  1231
                    yield ('+', b[i])
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1232
            elif tag == 'delete':
3472
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3471
diff changeset
  1233
                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
  1234
                    yield ('-', a[i])
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1235
            elif tag == 'replace':
3472
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3471
diff changeset
  1236
                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
  1237
                    yield ('-', a[i])
3472
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3471
diff changeset
  1238
                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
  1239
                    yield ('+', b[i])
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1240
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1241
    def display(fn, r, pstates, states):
6134
7b937b26adf7 Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6133
diff changeset
  1242
        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
  1243
        found = False
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  1244
        filerevmatches = {}
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1245
        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
  1246
            iter = difflinestates(pstates, states)
2869
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1247
        else:
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1248
            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
  1249
        for change, l in iter:
2869
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2854
diff changeset
  1250
            cols = [fn, str(r)]
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1251
            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
  1252
                cols.append(str(l.linenum))
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1253
            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
  1254
                cols.append(change)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1255
            if opts.get('user'):
3650
731e739b8659 move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3649
diff changeset
  1256
                cols.append(ui.shortuser(get(r)[1]))
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
  1257
            if opts.get('date'):
6134
7b937b26adf7 Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6133
diff changeset
  1258
                cols.append(datefunc(get(r)[2]))
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1259
            if opts.get('files_with_matches'):
3523
7ed86c28f1ae Fixups for hg grep
Matt Mackall <mpm@selenic.com>
parents: 3521
diff changeset
  1260
                c = (fn, r)
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  1261
                if c in filerevmatches:
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  1262
                    continue
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  1263
                filerevmatches[c] = 1
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  1264
            else:
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  1265
                cols.append(l.line)
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  1266
            ui.write(sep.join(cols), eol)
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
  1267
            found = True
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
  1268
        return found
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1269
1145
bd917e1a26dd grep: change default to printing first matching rev.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1116
diff changeset
  1270
    skip = {}
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1271
    revfiles = {}
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1272
    get = util.cachefunc(lambda r: repo[r].changeset())
3650
731e739b8659 move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3649
diff changeset
  1273
    changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
  1274
    found = False
2870
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
  1275
    follow = opts.get('follow')
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  1276
    for st, rev, fns in changeiter:
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1277
        if st == 'window':
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1278
            matches.clear()
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1279
            revfiles.clear()
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1280
        elif st == 'add':
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1281
            ctx = repo[rev]
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1282
            pctx = ctx.parents()[0]
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1283
            parent = pctx.rev()
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1284
            matches.setdefault(rev, {})
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1285
            matches.setdefault(parent, {})
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1286
            files = revfiles.setdefault(rev, [])
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1287
            for fn in fns:
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1288
                flog = getfile(fn)
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1289
                try:
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1290
                    fnode = ctx.filenode(fn)
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents: 7632
diff changeset
  1291
                except error.LookupError:
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1292
                    continue
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1293
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1294
                copied = flog.renamed(fnode)
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1295
                copy = follow and copied and copied[0]
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1296
                if copy:
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1297
                    copies.setdefault(rev, {})[fn] = copy
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1298
                if fn in skip:
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1299
                    if copy:
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1300
                        skip[copy] = True
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1301
                    continue
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1302
                files.append(fn)
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1303
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1304
                if not matches[rev].has_key(fn):
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1305
                    grepbody(fn, rev, flog.read(fnode))
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1306
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1307
                pfn = copy or fn
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1308
                if not matches[parent].has_key(pfn):
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1309
                    try:
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1310
                        fnode = pctx.filenode(pfn)
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1311
                        grepbody(pfn, parent, flog.read(fnode))
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1312
                    except error.LookupError:
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1313
                        pass
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1314
        elif st == 'iter':
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1315
            parent = repo[rev].parents()[0].rev()
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1316
            for fn in sorted(revfiles.get(rev, [])):
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1317
                states = matches[rev][fn]
2931
0843bd53dcff Fix bug #345.
Brendan Cully <brendan@kublai.com>
parents: 2922
diff changeset
  1318
                copy = copies.get(rev, {}).get(fn)
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  1319
                if fn in skip:
2870
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
  1320
                    if copy:
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
  1321
                        skip[copy] = True
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  1322
                    continue
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1323
                pstates = matches.get(parent, {}).get(copy or fn, [])
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1324
                if pstates or states:
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8834
diff changeset
  1325
                    r = display(fn, rev, pstates, states)
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
  1326
                    found = found or r
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1327
                    if r and not opts.get('all'):
1145
bd917e1a26dd grep: change default to printing first matching rev.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1116
diff changeset
  1328
                        skip[fn] = True
2870
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
  1329
                        if copy:
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
  1330
                            skip[copy] = True
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  1331
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1332
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
  1333
    """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
  1334
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1335
    With no arguments, show all repository head changesets.
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1336
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1337
    Repository "heads" are changesets that don't have child changesets. They
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1338
    are where development generally takes place and are the usual targets for
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1339
    update and merge operations.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1340
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1341
    If one or more REV is given, the "branch heads" will be shown for the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1342
    named branch associated with that revision. The name of the branch is
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1343
    called the revision's branch tag.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1344
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1345
    Branch heads are revisions on a given named branch that do not have any
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1346
    descendants on the same branch. A branch head could be a true head or it
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1347
    could be the last changeset on a branch before a new branch was created.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1348
    If none of the branch heads are true heads, the branch is considered
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1349
    inactive. If -c/--closed is specified, also show branch heads marked
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1350
    closed (see hg commit --close-branch).
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1351
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1352
    If STARTREV is specified only those heads (or branch heads) that are
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1353
    descendants of STARTREV will be displayed.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1354
    """
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1355
    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
  1356
        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
  1357
    else:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1358
        start = None
8695
9a89253a32e6 heads: show closed heads only when --closed is passed
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8679
diff changeset
  1359
    closed = opts.get('closed')
9a89253a32e6 heads: show closed heads only when --closed is passed
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8679
diff changeset
  1360
    hideinactive, _heads = opts.get('active'), None
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1361
    if not branchrevs:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1362
        # Assume we're looking repo-wide heads if no revs were specified.
8796
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
  1363
        heads = 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
  1364
    else:
8695
9a89253a32e6 heads: show closed heads only when --closed is passed
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8679
diff changeset
  1365
        if hideinactive:
8796
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
  1366
            _heads = repo.heads(start)
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1367
        heads = []
8150
bbc24c0753a0 util: use built-in set and frozenset
Martin Geisler <mg@lazybytes.net>
parents: 8109
diff changeset
  1368
        visitedset = set()
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1369
        for branchrev in branchrevs:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1370
            branch = repo[branchrev].branch()
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1371
            if branch in visitedset:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1372
                continue
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1373
            visitedset.add(branch)
7656
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
  1374
            bheads = repo.branchheads(branch, start, closed=closed)
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1375
            if not bheads:
8796
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
  1376
                if not opts.get('rev'):
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
  1377
                    ui.warn(_("no open branch heads on branch %s\n") % branch)
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
  1378
                elif branch != branchrev:
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1379
                    ui.warn(_("no changes on branch %s containing %s are "
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1380
                              "reachable from %s\n")
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1381
                            % (branch, branchrev, 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
  1382
                else:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1383
                    ui.warn(_("no changes on branch %s are reachable from %s\n")
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1384
                            % (branch, opts.get('rev')))
8695
9a89253a32e6 heads: show closed heads only when --closed is passed
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8679
diff changeset
  1385
            if hideinactive:
9a89253a32e6 heads: show closed heads only when --closed is passed
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8679
diff changeset
  1386
                bheads = [bhead for bhead in bheads if bhead in _heads]
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1387
            heads.extend(bheads)
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1388
    if not heads:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
  1389
        return 1
3643
b4ad640a3bcf templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3631
diff changeset
  1390
    displayer = cmdutil.show_changeset(ui, repo, opts)
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
  1391
    for n in heads:
7369
87158be081b8 cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7364
diff changeset
  1392
        displayer.show(repo[n])
221
2bfe525ef6ca Beginning of multi-head support
mpm@selenic.com
parents: 220
diff changeset
  1393
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1394
def help_(ui, name=None, with_version=False):
7210
833d1250ce00 help: update help
Matt Mackall <mpm@selenic.com>
parents: 7197
diff changeset
  1395
    """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
  1396
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  1397
    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
  1398
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1399
    Given a topic, extension, or command name, print help for that topic.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1400
    """
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1401
    option_lists = []
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1402
    textwidth = util.termwidth() - 2
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1403
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
  1404
    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
  1405
        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
  1406
            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
  1407
            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
  1408
                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
  1409
                                       '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
  1410
        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
  1411
            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
  1412
                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
  1413
                        '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
  1414
            elif 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
  1415
                msg = _('use "hg -v help%s" to show aliases and '
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
  1416
                        '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
  1417
            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
  1418
                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
  1419
            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
  1420
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1421
    def helpcmd(name):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1422
        if with_version:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1423
            version_(ui)
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1424
            ui.write('\n')
6652
ffcf8e82f647 help: enable listing of a subset of the command list
Johannes Stezenbach <js@sig21.net>
parents: 6642
diff changeset
  1425
ffcf8e82f647 help: enable listing of a subset of the command list
Johannes Stezenbach <js@sig21.net>
parents: 6642
diff changeset
  1426
        try:
7213
b4c035057d34 findcmd: have dispatch look up strict flag
Matt Mackall <mpm@selenic.com>
parents: 7212
diff changeset
  1427
            aliases, i = cmdutil.findcmd(name, table, False)
7643
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
  1428
        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
  1429
            # 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
  1430
            # 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
  1431
            prefix = inst.args[0]
8e34f363dd77 compat: don't reference an exception var inside a lambda
Alejandro Santos <alejolp@alejolp.com>
parents: 9031
diff changeset
  1432
            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
  1433
            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
  1434
            return
ffcf8e82f647 help: enable listing of a subset of the command list
Johannes Stezenbach <js@sig21.net>
parents: 6642
diff changeset
  1435
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1436
        # synopsis
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  1437
        if len(i) > 2:
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  1438
            if i[2].startswith('hg'):
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  1439
                ui.write("%s\n" % i[2])
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  1440
            else:
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  1441
                ui.write('hg %s %s\n' % (aliases[0], i[2]))
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  1442
        else:
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  1443
            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
  1444
28d9f8cd02f2 Move aliases section in help below synopsis (issue362)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5781
diff changeset
  1445
        # aliases
28d9f8cd02f2 Move aliases section in help below synopsis (issue362)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5781
diff changeset
  1446
        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
  1447
            ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1448
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1449
        # description
7013
f56e788fa292 i18n: mark help strings for translation
Martin Geisler <mg@daimi.au.dk>
parents: 7012
diff changeset
  1450
        doc = gettext(i[0].__doc__)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1451
        if not doc:
7598
26adfaccdf73 lowercase help output
Martin Geisler <mg@daimi.au.dk>
parents: 7596
diff changeset
  1452
            doc = _("(no help text available)")
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1453
        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
  1454
            doc = doc.splitlines()[0]
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1455
        ui.write("\n%s\n" % minirst.format(doc, textwidth))
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1456
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1457
        if not ui.quiet:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1458
            # options
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1459
            if i[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
  1460
                option_lists.append((_("options:\n"), i[1]))
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
  1461
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
  1462
            addglobalopts(False)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1463
4950
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1464
    def helplist(header, select=None):
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1465
        h = {}
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1466
        cmds = {}
7622
4dd7b28003d2 use dict.iteritems() rather than dict.items()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7598
diff changeset
  1467
        for c, e in table.iteritems():
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1468
            f = c.split("|", 1)[0]
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1469
            if select and not select(f):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1470
                continue
7197
f60730693efc help: show extension commands in short list, separate extension list in help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7196
diff changeset
  1471
            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
  1472
                e[0].__module__ != __name__):
7126
111813de4188 remove extension commands from global help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7125
diff changeset
  1473
                continue
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1474
            if name == "shortlist" and not f.startswith("^"):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1475
                continue
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1476
            f = f.lstrip("^")
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1477
            if not ui.debugflag and f.startswith("debug"):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1478
                continue
9128
98d90ad54749 commands: hide deprecated commands.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9097
diff changeset
  1479
            doc = e[0].__doc__
98d90ad54749 commands: hide deprecated commands.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9097
diff changeset
  1480
            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
  1481
                continue
98d90ad54749 commands: hide deprecated commands.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9097
diff changeset
  1482
            doc = gettext(doc)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1483
            if not doc:
7598
26adfaccdf73 lowercase help output
Martin Geisler <mg@daimi.au.dk>
parents: 7596
diff changeset
  1484
                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
  1485
            h[f] = doc.splitlines()[0].rstrip()
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1486
            cmds[f] = c.lstrip("^")
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1487
4950
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1488
        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
  1489
            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
  1490
            return
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1491
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1492
        ui.status(header)
8209
a1a5a57efe90 replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents: 8190
diff changeset
  1493
        fns = sorted(h)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1494
        m = max(map(len, fns))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1495
        for f in fns:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1496
            if ui.verbose:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1497
                commands = cmds[f].replace("|",", ")
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1498
                ui.write(" %s:\n      %s\n"%(commands, h[f]))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1499
            else:
8938
9b8c9266c59d commands: wrap short descriptions in 'hg help'
Martin Geisler <mg@lazybytes.net>
parents: 8937
diff changeset
  1500
                ui.write(' %-*s   %s\n' % (m, f, util.wrap(h[f], m + 4)))
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1501
8864
cad6370a15cb help: refactor extensions listing, and show enabled ones in the dedicated topic
Cédric Duval <cedricduval@free.fr>
parents: 8856
diff changeset
  1502
        if name != 'shortlist':
8871
20a25042fadc extensions: move extensions listing functions from mercurial.help
Cédric Duval <cedricduval@free.fr>
parents: 8870
diff changeset
  1503
            exts, maxlength = extensions.enabled()
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1504
            text = help.listexts(_('enabled extensions:'), exts, maxlength)
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1505
            if text:
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1506
                ui.write("\n%s\n" % minirst.format(text, textwidth))
7125
4a1ac535be1d show enabled extensions in hg help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7094
diff changeset
  1507
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
  1508
        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
  1509
            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
  1510
3795
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1511
    def helptopic(name):
7012
78341ea65d16 restructure helptable
Martin Geisler <mg@daimi.au.dk>
parents: 7006
diff changeset
  1512
        for names, header, doc in help.helptable:
78341ea65d16 restructure helptable
Martin Geisler <mg@daimi.au.dk>
parents: 7006
diff changeset
  1513
            if name in names:
78341ea65d16 restructure helptable
Martin Geisler <mg@daimi.au.dk>
parents: 7006
diff changeset
  1514
                break
78341ea65d16 restructure helptable
Martin Geisler <mg@daimi.au.dk>
parents: 7006
diff changeset
  1515
        else:
7643
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
  1516
            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
  1517
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1518
        # description
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1519
        if not doc:
7598
26adfaccdf73 lowercase help output
Martin Geisler <mg@daimi.au.dk>
parents: 7596
diff changeset
  1520
            doc = _("(no help text available)")
8366
0bf0045000b5 some modernization cleanups, forward compatibility
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8313
diff changeset
  1521
        if hasattr(doc, '__call__'):
3796
58133ba5847d Allow topics to be callables
Matt Mackall <mpm@selenic.com>
parents: 3795
diff changeset
  1522
            doc = doc()
3795
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1523
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1524
        ui.write("%s\n\n" % header)
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1525
        ui.write("%s\n" % minirst.format(doc, textwidth))
3795
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1526
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1527
    def helpext(name):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1528
        try:
4544
930ed513c864 Create a separate module for managing extensions
Matt Mackall <mpm@selenic.com>
parents: 4543
diff changeset
  1529
            mod = extensions.find(name)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1530
        except KeyError:
7643
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
  1531
            raise error.UnknownCommand(name)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1532
7598
26adfaccdf73 lowercase help output
Martin Geisler <mg@daimi.au.dk>
parents: 7596
diff changeset
  1533
        doc = gettext(mod.__doc__) or _('no help text available')
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1534
        head, tail = doc.split('\n', 1)
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1535
        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
  1536
        if tail:
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1537
            ui.write(minirst.format(tail, textwidth))
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  1538
            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
  1539
86098ec4b77a fix hg help <ext> for extension that do not define any command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3915
diff changeset
  1540
        try:
86098ec4b77a fix hg help <ext> for extension that do not define any command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3915
diff changeset
  1541
            ct = mod.cmdtable
86098ec4b77a fix hg help <ext> for extension that do not define any command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3915
diff changeset
  1542
        except AttributeError:
4950
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1543
            ct = {}
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1544
8152
08e1baf924ca replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents: 8150
diff changeset
  1545
        modcmds = set([c.split('|', 1)[0] for c in ct])
08e1baf924ca replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents: 8150
diff changeset
  1546
        helplist(_('list of commands:\n\n'), modcmds.__contains__)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1547
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1548
    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
  1549
        i = None
7449
f848d7f96195 help: try topics before commands to avoid "diffs" showing help for diffstat
Georg Brandl <georg@python.org>
parents: 7415
diff changeset
  1550
        for f in (helptopic, helpcmd, helpext):
3795
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1551
            try:
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1552
                f(name)
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1553
                i = None
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1554
                break
7643
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
  1555
            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
  1556
                i = inst
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1557
        if i:
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3786
diff changeset
  1558
            raise i
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1559
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1560
    else:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1561
        # program name
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1562
        if ui.verbose or with_version:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1563
            version_(ui)
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1564
        else:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1565
            ui.status(_("Mercurial Distributed SCM\n"))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1566
        ui.status('\n')
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1567
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1568
        # list of commands
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1569
        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
  1570
            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
  1571
        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
  1572
            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
  1573
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4942
diff changeset
  1574
        helplist(header)
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1575
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1576
    # list all option lists
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1577
    opt_output = []
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1578
    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
  1579
        opt_output.append(("\n%s" % title, None))
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1580
        for shortopt, longopt, default, desc in options:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1581
            if "DEPRECATED" in desc and not ui.verbose: continue
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1582
            opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt,
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1583
                                          longopt and " --%s" % longopt),
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1584
                               "%s%s" % (desc,
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1585
                                         default
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1586
                                         and _(" (default: %s)") % default
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1587
                                         or "")))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1588
7196
3f6a4f1de43f help: show help topics by default in 'hg help', with longest available id
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7185
diff changeset
  1589
    if not name:
7210
833d1250ce00 help: update help
Matt Mackall <mpm@selenic.com>
parents: 7197
diff changeset
  1590
        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
  1591
        topics = []
7012
78341ea65d16 restructure helptable
Martin Geisler <mg@daimi.au.dk>
parents: 7006
diff changeset
  1592
        for names, header, doc in help.helptable:
7196
3f6a4f1de43f help: show help topics by default in 'hg help', with longest available id
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7185
diff changeset
  1593
            names = [(-len(name), name) for name in names]
3f6a4f1de43f help: show help topics by default in 'hg help', with longest available id
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7185
diff changeset
  1594
            names.sort()
3f6a4f1de43f help: show help topics by default in 'hg help', with longest available id
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7185
diff changeset
  1595
            topics.append((names[0][1], header))
6653
a78d8edaeedd help: list special help topics with -v
Johannes Stezenbach <js@sig21.net>
parents: 6652
diff changeset
  1596
        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
  1597
        for t, desc in topics:
a78d8edaeedd help: list special help topics with -v
Johannes Stezenbach <js@sig21.net>
parents: 6652
diff changeset
  1598
            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
  1599
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1600
    if opt_output:
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
  1601
        opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0])
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1602
        for first, second in opt_output:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1603
            if second:
8938
9b8c9266c59d commands: wrap short descriptions in 'hg help'
Martin Geisler <mg@lazybytes.net>
parents: 8937
diff changeset
  1604
                second = util.wrap(second, opts_len + 3)
9b8c9266c59d commands: wrap short descriptions in 'hg help'
Martin Geisler <mg@lazybytes.net>
parents: 8937
diff changeset
  1605
                ui.write(" %-*s  %s\n" % (opts_len, first, second))
3655
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1606
            else:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3654
diff changeset
  1607
                ui.write("%s\n" % first)
221
2bfe525ef6ca Beginning of multi-head support
mpm@selenic.com
parents: 220
diff changeset
  1608
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
  1609
def identify(ui, repo, source=None,
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
  1610
             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
  1611
    """identify the working copy or specified revision
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
  1612
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1613
    With no revision, print a summary of the current state of the repository.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1614
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1615
    Specifying a path to a repository root or Mercurial bundle will cause
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1616
    lookup to operate on that repository/bundle.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1617
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1618
    This summary identifies the repository state using one or two parent hash
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1619
    identifiers, followed by a "+" if there are uncommitted changes in the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1620
    working directory, a list of tags for this revision and a branch name for
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1621
    non-default branches.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1622
    """
4662
f9b8ea362b49 identify: show nullid for empty repo
Matt Mackall <mpm@selenic.com>
parents: 4659
diff changeset
  1623
5330
4528858e7202 make identify an optionalrepo command
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5329
diff changeset
  1624
    if not repo and not source:
4528858e7202 make identify an optionalrepo command
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5329
diff changeset
  1625
        raise util.Abort(_("There is no Mercurial repository here "
4528858e7202 make identify an optionalrepo command
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5329
diff changeset
  1626
                           "(.hg not found)"))
4528858e7202 make identify an optionalrepo command
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5329
diff changeset
  1627
2966
fb493241d7f6 Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents: 2963
diff changeset
  1628
    hexfunc = ui.debugflag and hex or short
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1629
    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
  1630
    output = []
4664
dedb8abfd0e1 identify: use contexts
Matt Mackall <mpm@selenic.com>
parents: 4662
diff changeset
  1631
7757
af6a63438a8a identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7743
diff changeset
  1632
    revs = []
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
  1633
    if source:
5248
5517aa5aafb0 Merge with crew-stable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5242 5224
diff changeset
  1634
        source, revs, checkout = hg.parseurl(ui.expandpath(source), [])
7757
af6a63438a8a identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7743
diff changeset
  1635
        repo = hg.repository(ui, source)
af6a63438a8a identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7743
diff changeset
  1636
af6a63438a8a identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7743
diff changeset
  1637
    if not repo.local():
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
  1638
        if not rev and revs:
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
  1639
            rev = revs[0]
4667
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
  1640
        if not rev:
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
  1641
            rev = "tip"
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
  1642
        if num or branch or tags:
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
  1643
            raise util.Abort(
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
  1644
                "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
  1645
        output = [hexfunc(repo.lookup(rev))]
4667
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
  1646
    elif not rev:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1647
        ctx = repo[None]
4665
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
  1648
        parents = ctx.parents()
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1649
        changed = False
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1650
        if default or id or num:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1651
            changed = ctx.files() + ctx.deleted()
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1652
        if default or id:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1653
            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
  1654
                                (changed) and "+" or "")]
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1655
        if num:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1656
            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
  1657
                                    (changed) and "+" or ""))
4665
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
  1658
    else:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1659
        ctx = repo[rev]
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1660
        if default or id:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1661
            output = [hexfunc(ctx.node())]
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1662
        if num:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1663
            output.append(str(ctx.rev()))
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1664
7757
af6a63438a8a identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7743
diff changeset
  1665
    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
  1666
        b = encoding.tolocal(ctx.branch())
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1667
        if b != 'default':
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1668
            output.append("(%s)" % b)
3415
9a6491770b04 Report branch for hg id
Matt Mackall <mpm@selenic.com>
parents: 3414
diff changeset
  1669
386
494c8e3f47f3 Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 371
diff changeset
  1670
        # 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
  1671
        t = "/".join(ctx.tags())
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1672
        if t:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1673
            output.append(t)
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1674
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1675
    if branch:
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
  1676
        output.append(encoding.tolocal(ctx.branch()))
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1677
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1678
    if tags:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  1679
        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
  1680
386
494c8e3f47f3 Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 371
diff changeset
  1681
    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
  1682
437
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
  1683
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
  1684
    """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
  1685
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1686
    Import a list of patches and commit them individually.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1687
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1688
    If there are outstanding changes in the working directory, import will
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1689
    abort unless given the -f/--force flag.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1690
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1691
    You can import a patch straight from a mail message. Even patches as
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1692
    attachments work (to use the body part, it must have type text/plain or
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1693
    text/x-patch). From and Subject headers of email message are used as
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1694
    default committer and commit message. All text/plain body parts before
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1695
    first diff are added to commit message.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1696
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1697
    If the imported patch was generated by hg export, user and description
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1698
    from patch override values from message headers and body. Values given on
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1699
    command line with -m/--message and -u/--user override these.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1700
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1701
    If --exact is specified, import will set the working directory to the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1702
    parent of each patch before applying it, and will abort if the resulting
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1703
    changeset has a different ID than the one recorded in the patch. This may
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1704
    happen due to character set problems or other deficiencies in the text
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1705
    patch format.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1706
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1707
    With -s/--similarity, hg will attempt to discover renames and copies in
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1708
    the patch in the same way as 'addremove'.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1709
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1710
    To read a patch from standard input, use "-" as the patch name. If a URL
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1711
    is specified, the patch will be downloaded from it. See 'hg help dates'
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1712
    for a list of formats valid for -d/--date.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1713
    """
437
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
  1714
    patches = (patch1,) + patches
500
ebc4714a7632 [PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents: 499
diff changeset
  1715
6139
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
  1716
    date = opts.get('date')
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
  1717
    if date:
989467e8e3a9 Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6134
diff changeset
  1718
        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
  1719
7402
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  1720
    try:
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  1721
        sim = float(opts.get('similarity') or 0)
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  1722
    except ValueError:
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  1723
        raise util.Abort(_('similarity must be a number'))
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  1724
    if sim < 0 or sim > 100:
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  1725
        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
  1726
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1727
    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
  1728
        cmdutil.bail_if_changed(repo)
966
022bcc738389 hg import: abort with uncommitted changes, override with --force
mpm@selenic.com
parents: 965
diff changeset
  1729
437
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
  1730
    d = opts["base"]
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
  1731
    strip = opts["strip"]
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1732
    wlock = lock = None
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1733
    try:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1734
        wlock = repo.wlock()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1735
        lock = repo.lock()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1736
        for p in patches:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1737
            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
  1738
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1739
            if pf == '-':
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1740
                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
  1741
                pf = sys.stdin
2400
2e90024e1471 import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2397
diff changeset
  1742
            else:
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1743
                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
  1744
                pf = url.open(ui, pf)
8046f0a070a6 use our urlopener (proxy handling, etc) instead of urllib
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7270
diff changeset
  1745
            data = patch.extract(ui, pf)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1746
            tmpname, message, user, date, branch, nodeid, p1, p2 = data
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1747
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1748
            if tmpname is None:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1749
                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
  1750
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1751
            try:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1752
                cmdline_message = cmdutil.logmessage(opts)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1753
                if cmdline_message:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1754
                    # pickup the cmdline msg
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1755
                    message = cmdline_message
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1756
                elif message:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1757
                    # pickup the patch msg
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1758
                    message = message.strip()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1759
                else:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1760
                    # launch the editor
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1761
                    message = None
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1762
                ui.debug(_('message:\n%s\n') % message)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1763
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1764
                wp = repo.parents()
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1765
                if opts.get('exact'):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1766
                    if not nodeid or not p1:
8760
bf17aeafb869 Spell Mercurial as a proper noun
timeless <timeless@gmail.com>
parents: 8706
diff changeset
  1767
                        raise util.Abort(_('not a Mercurial patch'))
4264
bda63383d529 Make import opportunistically use merge information
Brendan Cully <brendan@kublai.com>
parents: 4263
diff changeset
  1768
                    p1 = repo.lookup(p1)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1769
                    p2 = repo.lookup(p2 or hex(nullid))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1770
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1771
                    if p1 != wp[0].node():
4917
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4915
diff changeset
  1772
                        hg.clean(repo, p1)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1773
                    repo.dirstate.setparents(p1, p2)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1774
                elif p2:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1775
                    try:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1776
                        p1 = repo.lookup(p1)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1777
                        p2 = repo.lookup(p2)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1778
                        if p1 == wp[0].node():
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1779
                            repo.dirstate.setparents(p1, p2)
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
  1780
                    except error.RepoError:
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1781
                        pass
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1782
                if opts.get('exact') or opts.get('import_branch'):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1783
                    repo.dirstate.setbranch(branch or 'default')
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1784
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1785
                files = {}
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1786
                try:
7874
d812029cda85 cleanup: drop variables for unused return values
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 7850
diff changeset
  1787
                    patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
8810
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents: 8806
diff changeset
  1788
                                files=files, eolmode=None)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1789
                finally:
7402
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  1790
                    files = patch.updatedir(ui, repo, files, similarity=sim/100.)
5936
00dfc810dae4 Add --no-commit option to import command
Joel Rosdahl <joel@rosdahl.net>
parents: 5858
diff changeset
  1791
                if not opts.get('no_commit'):
8704
27a103df29b7 commands: drop files arg for commit calls
Matt Mackall <mpm@selenic.com>
parents: 8695
diff changeset
  1792
                    m = cmdutil.matchfiles(repo, files or [])
8706
25e9c71b89de commit: drop the now-unused files parameter
Matt Mackall <mpm@selenic.com>
parents: 8704
diff changeset
  1793
                    n = repo.commit(message, opts.get('user') or user,
8704
27a103df29b7 commands: drop files arg for commit calls
Matt Mackall <mpm@selenic.com>
parents: 8695
diff changeset
  1794
                                    opts.get('date') or date, match=m,
8407
223000a687b0 commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents: 8397
diff changeset
  1795
                                    editor=cmdutil.commiteditor)
5936
00dfc810dae4 Add --no-commit option to import command
Joel Rosdahl <joel@rosdahl.net>
parents: 5858
diff changeset
  1796
                    if opts.get('exact'):
00dfc810dae4 Add --no-commit option to import command
Joel Rosdahl <joel@rosdahl.net>
parents: 5858
diff changeset
  1797
                        if hex(n) != nodeid:
00dfc810dae4 Add --no-commit option to import command
Joel Rosdahl <joel@rosdahl.net>
parents: 5858
diff changeset
  1798
                            repo.rollback()
00dfc810dae4 Add --no-commit option to import command
Joel Rosdahl <joel@rosdahl.net>
parents: 5858
diff changeset
  1799
                            raise util.Abort(_('patch is damaged'
00dfc810dae4 Add --no-commit option to import command
Joel Rosdahl <joel@rosdahl.net>
parents: 5858
diff changeset
  1800
                                               ' or loses information'))
6001
30d2fecaab76 merge with crew-stable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5999 5986
diff changeset
  1801
                    # Force a dirstate write so that the next transaction
30d2fecaab76 merge with crew-stable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5999 5986
diff changeset
  1802
                    # backups an up-do-date file.
30d2fecaab76 merge with crew-stable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5999 5986
diff changeset
  1803
                    repo.dirstate.write()
3465
2d35a8d2b32d patch: return list of modified files even when an exception is raised
Brendan Cully <brendan@kublai.com>
parents: 3460
diff changeset
  1804
            finally:
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1805
                os.unlink(tmpname)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  1806
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
  1807
        release(lock, wlock)
437
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
  1808
1192
6e165de907c5 Add -p to incoming and outgoing commands to show patch
TK Soh <teekaysoh@yahoo.com>
parents: 1191
diff changeset
  1809
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
  1810
    """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
  1811
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1812
    Show new changesets found in the specified path/URL or the default pull
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1813
    location. These are the changesets that would have been pulled if a pull
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1814
    at the time you issued this command.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1815
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1816
    For remote repository, using --bundle avoids downloading the changesets
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1817
    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
  1818
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
  1819
    See pull for valid source format details.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1820
    """
6191
01594b0c86e2 Add option -l/--limit to hg incoming and hg outgoing.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6190
diff changeset
  1821
    limit = cmdutil.loglimit(opts)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1822
    source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
8188
f3abe032fc89 add cmdutil.remoteui
Matt Mackall <mpm@selenic.com>
parents: 8182
diff changeset
  1823
    other = hg.repository(cmdutil.remoteui(repo, opts), source)
7270
2db33c1a5654 factor out the url handling from httprepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7236
diff changeset
  1824
    ui.status(_('comparing with %s\n') % url.hidepassword(source))
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
  1825
    if revs:
5259
65dc707606ed Push capability checking into protocol-level code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5248
diff changeset
  1826
        revs = [other.lookup(rev) for rev in revs]
7415
6163ef936a00 protocol: use changegroupsubset() if possible (issue1389)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7414
diff changeset
  1827
    common, incoming, rheads = repo.findcommonincoming(other, heads=revs,
6163ef936a00 protocol: use changegroupsubset() if possible (issue1389)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7414
diff changeset
  1828
                                                       force=opts["force"])
1944
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
  1829
    if not incoming:
3933
7997c0e01bfc hg in: if no incoming csets, remove existing bundle
Matt Mackall <mpm@selenic.com>
parents: 3931
diff changeset
  1830
        try:
7997c0e01bfc hg in: if no incoming csets, remove existing bundle
Matt Mackall <mpm@selenic.com>
parents: 3931
diff changeset
  1831
            os.unlink(opts["bundle"])
7997c0e01bfc hg in: if no incoming csets, remove existing bundle
Matt Mackall <mpm@selenic.com>
parents: 3931
diff changeset
  1832
        except:
7997c0e01bfc hg in: if no incoming csets, remove existing bundle
Matt Mackall <mpm@selenic.com>
parents: 3931
diff changeset
  1833
            pass
1993
fb6ca9801d04 show message if no changes found on incoming
TK Soh <teekaysoh@yahoo.com>
parents: 1981
diff changeset
  1834
        ui.status(_("no changes found\n"))
3931
f2cbcf1e98b2 incoming/outgoing: return failure if no changes found
Matt Mackall <mpm@selenic.com>
parents: 3930
diff changeset
  1835
        return 1
1944
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
  1836
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
  1837
    cleanup = None
1974
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1838
    try:
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1839
        fname = opts["bundle"]
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1840
        if fname or not other.local():
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1841
            # create a bundle (uncompressed if other repo is not local)
7415
6163ef936a00 protocol: use changegroupsubset() if possible (issue1389)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7414
diff changeset
  1842
6163ef936a00 protocol: use changegroupsubset() if possible (issue1389)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7414
diff changeset
  1843
            if revs is None and other.capable('changegroupsubset'):
6163ef936a00 protocol: use changegroupsubset() if possible (issue1389)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7414
diff changeset
  1844
                revs = rheads
6163ef936a00 protocol: use changegroupsubset() if possible (issue1389)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7414
diff changeset
  1845
4451
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
  1846
            if revs is None:
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
  1847
                cg = other.changegroup(incoming, "incoming")
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
  1848
            else:
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
  1849
                cg = other.changegroupsubset(incoming, revs, 'incoming')
3706
0d810798acb1 Use 'bundletype' instead of 'type' to not shadow built-in function.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3704
diff changeset
  1850
            bundletype = other.local() and "HG10BZ" or "HG10UN"
0d810798acb1 Use 'bundletype' instead of 'type' to not shadow built-in function.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3704
diff changeset
  1851
            fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
1974
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1852
            # keep written bundle?
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1853
            if opts["bundle"]:
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1854
                cleanup = None
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1855
            if not other.local():
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1856
                # use the created uncompressed bundlerepo
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1857
                other = bundlerepo.bundlerepository(ui, repo.root, fname)
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1858
2521
9cceb439048b add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2515
diff changeset
  1859
        o = other.changelog.nodesbetween(incoming, revs)[0]
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1860
        if opts.get('newest_first'):
1974
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1861
            o.reverse()
3643
b4ad640a3bcf templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3631
diff changeset
  1862
        displayer = cmdutil.show_changeset(ui, other, opts)
6191
01594b0c86e2 Add option -l/--limit to hg incoming and hg outgoing.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6190
diff changeset
  1863
        count = 0
1974
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1864
        for n in o:
6191
01594b0c86e2 Add option -l/--limit to hg incoming and hg outgoing.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6190
diff changeset
  1865
            if count >= limit:
01594b0c86e2 Add option -l/--limit to hg incoming and hg outgoing.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6190
diff changeset
  1866
                break
1974
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1867
            parents = [p for p in other.changelog.parents(n) if p != nullid]
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1868
            if opts.get('no_merges') and len(parents) == 2:
1974
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1869
                continue
6191
01594b0c86e2 Add option -l/--limit to hg incoming and hg outgoing.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6190
diff changeset
  1870
            count += 1
7369
87158be081b8 cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7364
diff changeset
  1871
            displayer.show(other[n])
1974
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1872
    finally:
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1873
        if hasattr(other, 'close'):
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1874
            other.close()
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1875
        if cleanup:
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
  1876
            os.unlink(cleanup)
1944
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
  1877
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
  1878
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
  1879
    """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
  1880
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1881
    Initialize a new repository in the given directory. If the given directory
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1882
    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
  1883
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1884
    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
  1885
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1886
    It is possible to specify an ssh:// URL as the destination. See 'hg help
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1887
    urls' for more information.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1888
    """
8188
f3abe032fc89 add cmdutil.remoteui
Matt Mackall <mpm@selenic.com>
parents: 8182
diff changeset
  1889
    hg.repository(cmdutil.remoteui(ui, opts), dest, create=1)
338
1e091b3293d5 default path support with .hg/hgrc
mpm@selenic.com
parents: 335
diff changeset
  1890
627
b6c42714d900 Add locate command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 625
diff changeset
  1891
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
  1892
    """locate files matching specific patterns
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1893
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1894
    Print files under Mercurial control in the working directory whose names
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1895
    match the given patterns.
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  1896
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  1897
    By default, this command searches all directories in the working
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1898
    directory. To search just the current directory and its subdirectories,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1899
    use "--include .".
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1900
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1901
    If no patterns are given to match, this command prints the names of all
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1902
    files under Mercurial control in the working directory.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1903
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1904
    If you want to feed the output of this command into the "xargs" command,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1905
    use the -0 option to both this command and "xargs". This will avoid the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1906
    problem of "xargs" treating single filenames that contain whitespace as
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1907
    multiple filenames.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1908
    """
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1909
    end = opts.get('print0') and '\0' or '\n'
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
  1910
    rev = opts.get('rev') or None
742
092937de2ad7 Refactor matchpats and walk
mpm@selenic.com
parents: 740
diff changeset
  1911
4196
1c69c73d85d9 locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4195
diff changeset
  1912
    ret = 1
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  1913
    m = cmdutil.match(repo, pats, opts, default='relglob')
6583
3951e04ea989 walk: remove more old badmatch logic
Matt Mackall <mpm@selenic.com>
parents: 6582
diff changeset
  1914
    m.bad = lambda x,y: False
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
  1915
    for abs in repo[rev].walk(m):
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
  1916
        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
  1917
            continue
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1918
        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
  1919
            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
  1920
        else:
6584
29c77e5dfb3c walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents: 6583
diff changeset
  1921
            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
  1922
        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
  1923
1c69c73d85d9 locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4195
diff changeset
  1924
    return ret
627
b6c42714d900 Add locate command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 625
diff changeset
  1925
1031
503aaf19a040 Rewrite log command. New version is faster and more featureful.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1030
diff changeset
  1926
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
  1927
    """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
  1928
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1929
    Print the revision history of the specified files or the entire project.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1930
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1931
    File history is shown without following rename or copy history of files.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1932
    Use -f/--follow with a filename to follow history across renames and
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1933
    copies. --follow without a filename will only show ancestors or
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1934
    descendants of the starting revision. --follow-first only follows the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1935
    first parent of merge revisions.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1936
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1937
    If no revision range is specified, the default is tip:0 unless --follow is
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1938
    set, in which case the working directory parent is used as the starting
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1939
    revision.
2783
2e0cd25fe4ac Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents: 2782
diff changeset
  1940
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
  1941
    See 'hg help dates' for a list of formats valid for -d/--date.
1f733c2f0165 Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6161
diff changeset
  1942
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1943
    By default this command prints revision number and changeset id, tags,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1944
    non-trivial parents, user, date and time, and a summary for each commit.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1945
    When the -v/--verbose switch is used, the list of changed files and full
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1946
    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
  1947
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  1948
    NOTE: log -p/--patch may generate unexpected diff output for merge
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1949
    changesets, as it will only compare the merge changeset against its first
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1950
    parent. Also, only files different from BOTH parents will appear in
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  1951
    files:.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  1952
    """
1756
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
  1953
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1954
    get = util.cachefunc(lambda r: repo[r].changeset())
3650
731e739b8659 move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3649
diff changeset
  1955
    changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
3518
467d923e4e3d Fix excessive complaining from hg log -b
Matt Mackall <mpm@selenic.com>
parents: 3517
diff changeset
  1956
6190
a79d9408806f Move finding/checking the log limit to cmdutil
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6189
diff changeset
  1957
    limit = cmdutil.loglimit(opts)
1756
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
  1958
    count = 0
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
  1959
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1960
    if opts.get('copies') and opts.get('rev'):
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  1961
        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
  1962
    else:
6750
fb42030d79d6 add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents: 6749
diff changeset
  1963
        endrev = len(repo)
3197
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1964
    rcache = {}
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1965
    ncache = {}
5811
180a3eee4b75 Fix copies reporting in log and convert.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5783
diff changeset
  1966
    def getrenamed(fn, rev):
3197
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1967
        '''looks up all renames for a file (up to endrev) the first
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1968
        time the file is given. It indexes on the changerev and only
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1969
        parses the manifest if linkrev != changerev.
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1970
        Returns rename info for fn at changerev rev.'''
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1971
        if fn not in rcache:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1972
            rcache[fn] = {}
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1973
            ncache[fn] = {}
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1974
            fl = repo.file(fn)
6750
fb42030d79d6 add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents: 6749
diff changeset
  1975
            for i in fl:
3197
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1976
                node = fl.node(i)
7361
9fe97eea5510 linkrev: take a revision number rather than a hash
Matt Mackall <mpm@selenic.com>
parents: 7308
diff changeset
  1977
                lr = fl.linkrev(i)
3197
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1978
                renamed = fl.renamed(node)
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1979
                rcache[fn][lr] = renamed
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1980
                if renamed:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1981
                    ncache[fn][node] = renamed
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1982
                if lr >= endrev:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1983
                    break
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1984
        if rev in rcache[fn]:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1985
            return rcache[fn][rev]
5811
180a3eee4b75 Fix copies reporting in log and convert.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5783
diff changeset
  1986
180a3eee4b75 Fix copies reporting in log and convert.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5783
diff changeset
  1987
        # If linkrev != rev (i.e. rev not found in rcache) fallback to
180a3eee4b75 Fix copies reporting in log and convert.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5783
diff changeset
  1988
        # filectx logic.
180a3eee4b75 Fix copies reporting in log and convert.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5783
diff changeset
  1989
180a3eee4b75 Fix copies reporting in log and convert.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5783
diff changeset
  1990
        try:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  1991
            return repo[rev][fn].renamed()
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents: 7632
diff changeset
  1992
        except error.LookupError:
5811
180a3eee4b75 Fix copies reporting in log and convert.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5783
diff changeset
  1993
            pass
3197
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1994
        return None
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  1995
3813
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  1996
    df = False
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  1997
    if opts["date"]:
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  1998
        df = util.matchdate(opts["date"])
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  1999
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2000
    only_branches = opts.get('only_branch')
6067
57c1a7052982 Option to log to only show changesets within a specified branch.
Dustin Sallings <dustin@spy.net>
parents: 6048
diff changeset
  2001
3837
7df171ea50cd Fix log regression where log -p file showed diffs for other files
Matt Mackall <mpm@selenic.com>
parents: 3833
diff changeset
  2002
    displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
  2003
    for st, rev, fns in changeiter:
3645
b984dcb1df71 Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents: 3643
diff changeset
  2004
        if st == 'add':
3578
3b4e00cba57a Define and use nullrev (revision of nullid) instead of -1.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3576
diff changeset
  2005
            parents = [p for p in repo.changelog.parentrevs(rev)
3b4e00cba57a Define and use nullrev (revision of nullid) instead of -1.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3576
diff changeset
  2006
                       if p != nullrev]
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2007
            if opts.get('no_merges') and len(parents) == 2:
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  2008
                continue
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2009
            if opts.get('only_merges') and len(parents) != 2:
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  2010
                continue
1435
22b44fd9a166 add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1431
diff changeset
  2011
6067
57c1a7052982 Option to log to only show changesets within a specified branch.
Dustin Sallings <dustin@spy.net>
parents: 6048
diff changeset
  2012
            if only_branches:
57c1a7052982 Option to log to only show changesets within a specified branch.
Dustin Sallings <dustin@spy.net>
parents: 6048
diff changeset
  2013
                revbranch = get(rev)[5]['branch']
57c1a7052982 Option to log to only show changesets within a specified branch.
Dustin Sallings <dustin@spy.net>
parents: 6048
diff changeset
  2014
                if revbranch not in only_branches:
57c1a7052982 Option to log to only show changesets within a specified branch.
Dustin Sallings <dustin@spy.net>
parents: 6048
diff changeset
  2015
                    continue
57c1a7052982 Option to log to only show changesets within a specified branch.
Dustin Sallings <dustin@spy.net>
parents: 6048
diff changeset
  2016
3813
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  2017
            if df:
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  2018
                changes = get(rev)
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  2019
                if not df(changes[2][0]):
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  2020
                    continue
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3812
diff changeset
  2021
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2022
            if opts.get('keyword'):
3650
731e739b8659 move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3649
diff changeset
  2023
                changes = get(rev)
1373
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
  2024
                miss = 0
1404
67e20e27d8df log: make keyword search truly case-insensitive
TK Soh <teekaysoh@yahoo.com>
parents: 1402
diff changeset
  2025
                for k in [kw.lower() for kw in opts['keyword']]:
1373
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
  2026
                    if not (k in changes[1].lower() or
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
  2027
                            k in changes[4].lower() or
4322
38922a13101e log: expand keyword search to full list of files
TK Soh <teekaysoh@yahoo.com>
parents: 4315
diff changeset
  2028
                            k in " ".join(changes[3]).lower()):
1373
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
  2029
                        miss = 1
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
  2030
                        break
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
  2031
                if miss:
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
  2032
                    continue
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
  2033
7212
402d317778d3 imported patch filteruser.patch
Matt Mackall <mpm@selenic.com>
parents: 7211
diff changeset
  2034
            if opts['user']:
402d317778d3 imported patch filteruser.patch
Matt Mackall <mpm@selenic.com>
parents: 7211
diff changeset
  2035
                changes = get(rev)
8020
777a9efdae2d log: fix broken multiple user search
Henrik Stuart <hg@hstuart.dk>
parents: 8018
diff changeset
  2036
                if not [k for k in opts['user'] if k in changes[1]]:
7212
402d317778d3 imported patch filteruser.patch
Matt Mackall <mpm@selenic.com>
parents: 7211
diff changeset
  2037
                    continue
7236
db6fbb785800 Remove trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 7230
diff changeset
  2038
3197
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  2039
            copies = []
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  2040
            if opts.get('copies') and rev:
3650
731e739b8659 move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3649
diff changeset
  2041
                for fn in get(rev)[3]:
5811
180a3eee4b75 Fix copies reporting in log and convert.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5783
diff changeset
  2042
                    rename = getrenamed(fn, rev)
3197
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  2043
                    if rename:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  2044
                        copies.append((fn, rename[0]))
7369
87158be081b8 cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7364
diff changeset
  2045
            displayer.show(context.changectx(repo, rev), copies=copies)
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
  2046
        elif st == 'iter':
1756
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
  2047
            if count == limit: break
3645
b984dcb1df71 Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents: 3643
diff changeset
  2048
            if displayer.flush(rev):
1765
b9fac31f34c9 hg log --limit shouldn't count unprinted revisions (found by TK Soh)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1764
diff changeset
  2049
                count += 1
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  2050
5155
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2051
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
  2052
    """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
  2053
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2054
    Print a list of version controlled files for the given revision. If no
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2055
    revision is given, the first parent of the working directory is used, or
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2056
    the null revision if no revision is checked out.
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2057
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2058
    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
  2059
    With --debug, print file revision hashes.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2060
    """
3736
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
  2061
5155
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2062
    if rev and node:
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2063
        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
  2064
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2065
    if not node:
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2066
        node = rev
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents: 5148
diff changeset
  2067
6749
51b0e799352f manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents: 6748
diff changeset
  2068
    decor = {'l':'644 @ ', 'x':'755 * ', '':'644   '}
51b0e799352f manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents: 6748
diff changeset
  2069
    ctx = repo[node]
51b0e799352f manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents: 6748
diff changeset
  2070
    for f in ctx:
3736
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
  2071
        if ui.debugflag:
6749
51b0e799352f manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents: 6748
diff changeset
  2072
            ui.write("%40s " % hex(ctx.manifest()[f]))
3736
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
  2073
        if ui.verbose:
6749
51b0e799352f manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents: 6748
diff changeset
  2074
            ui.write(decor[ctx.flags(f)])
3736
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
  2075
        ui.write("%s\n" % f)
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  2076
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2077
def merge(ui, repo, node=None, **opts):
4014
509342f95564 various doc fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4013
diff changeset
  2078
    """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
  2079
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2080
    The current working directory is updated with all changes made in the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2081
    requested revision since the last common predecessor revision.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2082
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2083
    Files that changed between either parent are marked as changed for the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2084
    next commit and a commit must be performed before any further updates to
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2085
    the repository are allowed. The next commit will have two parents.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2086
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2087
    If no revision is specified, the working directory's parent is a head
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2088
    revision, and the current branch contains exactly one other head, the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2089
    other head is merged with by default. Otherwise, an explicit revision with
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2090
    which to merge with must be provided.
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2091
    """
2806
0bf22c109cc3 Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents: 2803
diff changeset
  2092
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2093
    if opts.get('rev') and node:
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  2094
        raise util.Abort(_("please specify just one revision"))
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  2095
    if not node:
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2096
        node = opts.get('rev')
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  2097
3876
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
  2098
    if not node:
6740
b148e9099133 use repo.changectx(None) to get a workingctx
Matt Mackall <mpm@selenic.com>
parents: 6739
diff changeset
  2099
        branch = repo.changectx(None).branch()
6844
a38dff85d31f merge: use correct branch name for counting heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6843
diff changeset
  2100
        bheads = repo.branchheads(branch)
6723
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2101
        if len(bheads) > 2:
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2102
            raise util.Abort(_("branch '%s' has %d heads - "
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2103
                               "please merge with an explicit rev") %
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2104
                             (branch, len(bheads)))
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2105
5242
9cd6578750b9 improve error message for 'hg merge' when repo already at branchtip
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5205
diff changeset
  2106
        parent = repo.dirstate.parents()[0]
6723
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2107
        if len(bheads) == 1:
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2108
            if len(repo.heads()) > 1:
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2109
                raise util.Abort(_("branch '%s' has one head - "
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2110
                                   "please merge with an explicit rev") %
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2111
                                 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
  2112
            msg = _('there is nothing to merge')
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2113
            if parent != repo.lookup(repo[None].branch()):
5542
253736bb0dc9 i18n: fix complaints from pygettext
Matt Mackall <mpm@selenic.com>
parents: 5525
diff changeset
  2114
                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
  2115
            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
  2116
6723
1fe6f365df2e merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6686
diff changeset
  2117
        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
  2118
            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
  2119
                               '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
  2120
        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
  2121
8834
6d36fc70754e merge: rename -S/--show option to -P/--preview
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8815
diff changeset
  2122
    if opts.get('preview'):
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2123
        p1 = repo['.']
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2124
        p2 = repo[node]
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2125
        common = p1.ancestor(p2)
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2126
        roots, heads = [common.node()], [p2.node()]
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2127
        displayer = cmdutil.show_changeset(ui, repo, opts)
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2128
        for node in repo.changelog.nodesbetween(roots=roots, heads=heads)[0]:
8636
7aa1526d4fc5 merge: whitespace cleanup
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 8615
diff changeset
  2129
            displayer.show(repo[node])
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2130
        return 0
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2131
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  2132
    return hg.merge(repo, node, force=opts.get('force'))
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
  2133
2494
73ac95671788 push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2493
diff changeset
  2134
def outgoing(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
  2135
    """show changesets not found in destination
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2136
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2137
    Show changesets not found in the specified destination repository or the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2138
    default push location. These are the changesets that would be pushed if a
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2139
    push was requested.
1811
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
  2140
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
  2141
    See pull for valid destination format details.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2142
    """
6191
01594b0c86e2 Add option -l/--limit to hg incoming and hg outgoing.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6190
diff changeset
  2143
    limit = cmdutil.loglimit(opts)
5248
5517aa5aafb0 Merge with crew-stable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5242 5224
diff changeset
  2144
    dest, revs, checkout = hg.parseurl(
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2145
        ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev'))
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
  2146
    if revs:
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
  2147
        revs = [repo.lookup(rev) for rev in revs]
1965
62aa1b90414f add remotecmd/ssh option support to incoming/outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1959
diff changeset
  2148
8188
f3abe032fc89 add cmdutil.remoteui
Matt Mackall <mpm@selenic.com>
parents: 8182
diff changeset
  2149
    other = hg.repository(cmdutil.remoteui(repo, opts), dest)
7270
2db33c1a5654 factor out the url handling from httprepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7236
diff changeset
  2150
    ui.status(_('comparing with %s\n') % url.hidepassword(dest))
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2151
    o = repo.findoutgoing(other, force=opts.get('force'))
1994
78ef83c9e9e1 show message if no changes found on outgoing
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1993
diff changeset
  2152
    if not o:
78ef83c9e9e1 show message if no changes found on outgoing
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1993
diff changeset
  2153
        ui.status(_("no changes found\n"))
3931
f2cbcf1e98b2 incoming/outgoing: return failure if no changes found
Matt Mackall <mpm@selenic.com>
parents: 3930
diff changeset
  2154
        return 1
2521
9cceb439048b add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2515
diff changeset
  2155
    o = repo.changelog.nodesbetween(o, revs)[0]
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2156
    if opts.get('newest_first'):
1439
65cbe22b03fa allow 'hg out' / 'hg in' to show newest commit first
Michal Kvasnica <kvasnica@gmail.com>
parents: 1437
diff changeset
  2157
        o.reverse()
3643
b4ad640a3bcf templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3631
diff changeset
  2158
    displayer = cmdutil.show_changeset(ui, repo, opts)
6191
01594b0c86e2 Add option -l/--limit to hg incoming and hg outgoing.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6190
diff changeset
  2159
    count = 0
920
270756aa29d5 Add hg outgoing command
mpm@selenic.com
parents: 918
diff changeset
  2160
    for n in o:
6191
01594b0c86e2 Add option -l/--limit to hg incoming and hg outgoing.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6190
diff changeset
  2161
        if count >= limit:
01594b0c86e2 Add option -l/--limit to hg incoming and hg outgoing.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6190
diff changeset
  2162
            break
1435
22b44fd9a166 add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1431
diff changeset
  2163
        parents = [p for p in repo.changelog.parents(n) if p != nullid]
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2164
        if opts.get('no_merges') and len(parents) == 2:
1435
22b44fd9a166 add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1431
diff changeset
  2165
            continue
6191
01594b0c86e2 Add option -l/--limit to hg incoming and hg outgoing.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6190
diff changeset
  2166
        count += 1
7369
87158be081b8 cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7364
diff changeset
  2167
        displayer.show(repo[n])
920
270756aa29d5 Add hg outgoing command
mpm@selenic.com
parents: 918
diff changeset
  2168
3658
d12c8668b102 remove legacy hg parents REV syntax
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
  2169
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
  2170
    """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
  2171
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2172
    Print the working directory's parent revisions. If a revision is given via
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2173
    -r/--rev, the parent of that revision will be printed. If a file argument
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2174
    is given, the revision in which the file was last changed (before the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2175
    working directory revision or the argument to --rev if given) is printed.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2176
    """
3658
d12c8668b102 remove legacy hg parents REV syntax
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
  2177
    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
  2178
    if rev:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2179
        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
  2180
    else:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2181
        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
  2182
4586
1fcc076fcb17 Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents: 4451
diff changeset
  2183
    if file_:
6582
5acbdd3941c4 walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents: 6579
diff changeset
  2184
        m = cmdutil.match(repo, (file_,), opts)
5acbdd3941c4 walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents: 6579
diff changeset
  2185
        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
  2186
            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
  2187
        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
  2188
        filenodes = []
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2189
        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
  2190
            if not cp:
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2191
                continue
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2192
            try:
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2193
                filenodes.append(cp.filenode(file_))
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents: 7632
diff changeset
  2194
            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
  2195
                pass
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2196
        if not filenodes:
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2197
            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
  2198
        fl = repo.file(file_)
7361
9fe97eea5510 linkrev: take a revision number rather than a hash
Matt Mackall <mpm@selenic.com>
parents: 7308
diff changeset
  2199
        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
  2200
    else:
5298
cba2a689117d parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents: 5230
diff changeset
  2201
        p = [cp.node() for cp in ctx.parents()]
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  2202
3643
b4ad640a3bcf templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3631
diff changeset
  2203
    displayer = cmdutil.show_changeset(ui, repo, opts)
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  2204
    for n in p:
1092
0a02315976ff commands: use node functions directly
mpm@selenic.com
parents: 1090
diff changeset
  2205
        if n != nullid:
7743
ec9b726a9428 commands: fix paths command docstring indention
Martin Geisler <mg@daimi.au.dk>
parents: 7739
diff changeset
  2206
            displayer.show(repo[n])
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  2207
1858
9fab6e903bae Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1857
diff changeset
  2208
def paths(ui, repo, search=None):
7691
bcdc2fe3fd07 Clarified 'hg paths' command help
Bill Barry <after.fallout@gmail.com>
parents: 7684
diff changeset
  2209
    """show aliases for remote repositories
bcdc2fe3fd07 Clarified 'hg paths' command help
Bill Barry <after.fallout@gmail.com>
parents: 7684
diff changeset
  2210
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2211
    Show definition of symbolic path name NAME. If no name is given, show
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2212
    definition of all available names.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2213
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2214
    Path names are defined in the [paths] section of /etc/mercurial/hgrc and
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2215
    $HOME/.hgrc. If run inside a 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
  2216
e040f9d6b2f3 consolidated url help into urls help topic and added information about path aliases
Bill Barry <after.fallout@gmail.com>
parents: 7691
diff changeset
  2217
    See 'hg help urls' for more information.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2218
    """
779
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2219
    if search:
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2220
        for name, path in ui.configitems("paths"):
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2221
            if name == search:
7270
2db33c1a5654 factor out the url handling from httprepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7236
diff changeset
  2222
                ui.write("%s\n" % url.hidepassword(path))
779
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2223
                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
  2224
        ui.warn(_("not found!\n"))
779
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2225
        return 1
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2226
    else:
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2227
        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
  2228
            ui.write("%s = %s\n" % (name, url.hidepassword(path)))
779
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
  2229
5224
20817af258d8 pull -u: if "url#rev" was given, update to rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5222
diff changeset
  2230
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
  2231
    if modheads == 0:
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2232
        return
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2233
    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
  2234
        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
  2235
            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
  2236
        else:
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2237
            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
  2238
    if modheads > 1:
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2239
        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
  2240
    else:
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2241
        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
  2242
404
a1ecef497721 [PATCH] Unintuive use
mpm@selenic.com
parents: 403
diff changeset
  2243
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
  2244
    """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
  2245
8779
708938509732 Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents: 8778
diff changeset
  2246
    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
  2247
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2248
    This finds all changes from the repository at the specified path or URL
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2249
    and adds them to a local repository (the current one unless -R is
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2250
    specified). By default, this does not update the copy of the project in
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2251
    the working directory.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2252
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2253
    Use hg incoming if you want to see what would have been added by a pull at
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2254
    the time you issued this command. If you then decide to added those
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2255
    changes to the repository, you should use pull -r X where X is the last
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2256
    changeset listed by hg incoming.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2257
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2258
    If SOURCE is omitted, the 'default' path will be used. See 'hg help urls'
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2259
    for more information.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2260
    """
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2261
    source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
8188
f3abe032fc89 add cmdutil.remoteui
Matt Mackall <mpm@selenic.com>
parents: 8182
diff changeset
  2262
    other = hg.repository(cmdutil.remoteui(repo, opts), source)
7270
2db33c1a5654 factor out the url handling from httprepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7236
diff changeset
  2263
    ui.status(_('pulling from %s\n') % url.hidepassword(source))
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
  2264
    if revs:
5259
65dc707606ed Push capability checking into protocol-level code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5248
diff changeset
  2265
        try:
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
  2266
            revs = [other.lookup(rev) for rev in revs]
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
  2267
        except error.CapabilityError:
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
  2268
            err = _("Other repository doesn't support revision lookup, "
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
  2269
                    "so a rev cannot be specified.")
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
  2270
            raise util.Abort(err)
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
  2271
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2272
    modheads = repo.pull(other, heads=revs, force=opts.get('force'))
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2273
    return postincoming(ui, repo, modheads, opts.get('update'), checkout)
246
96cde50a746f Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents: 245
diff changeset
  2274
2494
73ac95671788 push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2493
diff changeset
  2275
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
  2276
    """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
  2277
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2278
    Push changes from the local repository to the given destination.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2279
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2280
    This is the symmetrical operation for pull. It moves changes from the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2281
    current repository to a different one. If the destination is local this is
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2282
    identical to a pull in that directory from the current one.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2283
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2284
    By default, push will refuse to run if it detects the result would
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2285
    increase the number of remote heads. This generally indicates the user
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2286
    forgot to pull and merge before pushing.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2287
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2288
    If -r/--rev is used, the named revision and all its ancestors will be
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2289
    pushed to the remote repository.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2290
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2291
    Please see 'hg help urls' for important details about ssh:// URLs. If
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2292
    DESTINATION is omitted, a default path will be used.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2293
    """
5248
5517aa5aafb0 Merge with crew-stable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5242 5224
diff changeset
  2294
    dest, revs, checkout = hg.parseurl(
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2295
        ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev'))
8188
f3abe032fc89 add cmdutil.remoteui
Matt Mackall <mpm@selenic.com>
parents: 8182
diff changeset
  2296
    other = hg.repository(cmdutil.remoteui(repo, opts), dest)
7270
2db33c1a5654 factor out the url handling from httprepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7236
diff changeset
  2297
    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
  2298
    if revs:
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
  2299
        revs = [repo.lookup(rev) for rev in revs]
8815
e87b0fc4750b subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents: 8812
diff changeset
  2300
e87b0fc4750b subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents: 8812
diff changeset
  2301
    # push subrepos depth-first for coherent ordering
e87b0fc4750b subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents: 8812
diff changeset
  2302
    c = repo['']
e87b0fc4750b subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents: 8812
diff changeset
  2303
    subs = c.substate # only repos that are committed
e87b0fc4750b subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents: 8812
diff changeset
  2304
    for s in sorted(subs):
e87b0fc4750b subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents: 8812
diff changeset
  2305
        c.sub(s).push(opts.get('force'))
e87b0fc4750b subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents: 8812
diff changeset
  2306
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2307
    r = repo.push(other, opts.get('force'), revs=revs)
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
  2308
    return r == 0
319
9ab17e83bce3 stopgap hg push support
mpm@selenic.com
parents: 317
diff changeset
  2309
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
  2310
def recover(ui, repo):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2311
    """roll back an interrupted transaction
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2312
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2313
    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
  2314
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2315
    This command tries to fix the repository status after an interrupted
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2316
    operation. It should only be necessary when Mercurial suggests it.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2317
    """
1516
0b1b029b4de3 Automatically run "verify" whenever we run "recover"
Matt Mackall <mpm@selenic.com>
parents: 1514
diff changeset
  2318
    if repo.recover():
2778
fdc232d8a193 Move repo.verify
Matt Mackall <mpm@selenic.com>
parents: 2776
diff changeset
  2319
        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
  2320
    return 1
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
  2321
2179
520dd3d28e9b add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2175
diff changeset
  2322
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
  2323
    """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
  2324
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2325
    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
  2326
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2327
    This only removes files from the current branch, not from the entire
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2328
    project history. -A/--after can be used to remove only files that have
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2329
    already been deleted, -f/--force can be used to force deletion, and -Af
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2330
    can be used to remove files from the next revision without deleting them
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2331
    from the working directory.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2332
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2333
    The following table details the behavior of remove for different file
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2334
    states (columns) and option combinations (rows). The file states are Added
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2335
    [A], Clean [C], Modified [M] and Missing [!] (as reported by hg status).
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2336
    The actions are Warn, Remove (from branch) and Delete (from disk)::
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2337
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2338
             A  C  M  !
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2339
      none   W  RD W  R
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2340
      -f     R  RD RD R
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2341
      -A     W  W  W  R
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2342
      -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
  2343
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2344
    This command schedules the files to be removed at the next commit. To undo
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2345
    a remove before that, see hg revert.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2346
    """
6346
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  2347
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  2348
    after, force = opts.get('after'), opts.get('force')
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  2349
    if not pats and not after:
2179
520dd3d28e9b add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2175
diff changeset
  2350
        raise util.Abort(_('no files specified'))
6346
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  2351
6582
5acbdd3941c4 walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents: 6579
diff changeset
  2352
    m = cmdutil.match(repo, pats, opts)
6761
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2353
    s = repo.status(match=m, clean=True)
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2354
    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
  2355
8533
6062c6362b2e remove: warn if unversionned files are specified (issue1454)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8464
diff changeset
  2356
    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
  2357
        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
  2358
            ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
6062c6362b2e remove: warn if unversionned files are specified (issue1454)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8464
diff changeset
  2359
6761
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2360
    def warn(files, reason):
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2361
        for f in files:
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2362
            ui.warn(_('not removing %s: file %s (use -f to force removal)\n')
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2363
                    % (m.rel(f), reason))
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2364
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2365
    if force:
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2366
        remove, forget = modified + deleted + clean, added
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2367
    elif after:
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2368
        remove, forget = deleted, []
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2369
        warn(modified + added + clean, _('still exists'))
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2370
    else:
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2371
        remove, forget = deleted + clean, []
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2372
        warn(modified, _('is modified'))
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2373
        warn(added, _('has been marked for add'))
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2374
8209
a1a5a57efe90 replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents: 8190
diff changeset
  2375
    for f in sorted(remove + forget):
6761
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2376
        if ui.verbose or not m.exact(f):
cb981fc955fb remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents: 6760
diff changeset
  2377
            ui.status(_('removing %s\n') % m.rel(f))
6346
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  2378
2309
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
  2379
    repo.forget(forget)
6346
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  2380
    repo.remove(remove, unlink=not after)
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
  2381
1253
a45e717c61a8 Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1250
diff changeset
  2382
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
  2383
    """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
  2384
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2385
    Mark dest as copies of sources; mark sources for deletion. If dest is a
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2386
    directory, copies are put in that directory. If dest is a file, there can
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2387
    only be one source.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2388
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2389
    By default, this command copies the contents of files as they exist in the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2390
    working directory. If invoked with -A/--after, the operation is recorded,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2391
    but no copying is performed.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2392
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2393
    This command takes effect at the next commit. To undo a rename before
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2394
    that, see hg revert.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2395
    """
4914
9a2a73ea6135 repo locks: use True/False
Matt Mackall <mpm@selenic.com>
parents: 4906
diff changeset
  2396
    wlock = repo.wlock(False)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2397
    try:
5610
2493a478f395 copy: handle rename internally
Matt Mackall <mpm@selenic.com>
parents: 5589
diff changeset
  2398
        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
  2399
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
  2400
        wlock.release()
1253
a45e717c61a8 Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1250
diff changeset
  2401
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2402
def resolve(ui, repo, *pats, **opts):
7530
3773e510d433 resolve: clarify and simplify help
Matt Mackall <mpm@selenic.com>
parents: 7528
diff changeset
  2403
    """retry file merges from a merge or update
3773e510d433 resolve: clarify and simplify help
Matt Mackall <mpm@selenic.com>
parents: 7528
diff changeset
  2404
3773e510d433 resolve: clarify and simplify help
Matt Mackall <mpm@selenic.com>
parents: 7528
diff changeset
  2405
    This command will cleanly retry unresolved file merges using file
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2406
    revisions preserved from the last update or merge. To attempt to resolve
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2407
    all unresolved files, use the -a/--all switch.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2408
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2409
    If a conflict is resolved manually, please note that the changes will be
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2410
    overwritten if the merge is retried with resolve. The -m/--mark switch
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2411
    should be used to mark the file as resolved.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2412
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2413
    This command also allows listing resolved files and manually indicating
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2414
    whether or not files are resolved. All files must be marked as resolved
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2415
    before a commit is permitted.
6642
c8c7248f6172 resolve: add file codes to doc string
Adrian Buehlmann <adrian@cadifra.com>
parents: 6641
diff changeset
  2416
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2417
    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
  2418
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2419
      U = unresolved
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2420
      R = resolved
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2421
    """
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2422
7527
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  2423
    all, mark, unmark, show = [opts.get(o) for o in 'all mark unmark list'.split()]
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  2424
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  2425
    if (show and (mark or unmark)) or (mark and unmark):
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2426
        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
  2427
    if pats and all:
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  2428
        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
  2429
    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
  2430
        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
  2431
                           'use --all to remerge all files'))
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2432
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2433
    ms = merge_.mergestate(repo)
6594
fca1688f0459 resolve: use cmdutil.match
Matt Mackall <mpm@selenic.com>
parents: 6586
diff changeset
  2434
    m = cmdutil.match(repo, pats, opts)
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2435
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2436
    for f in ms:
6594
fca1688f0459 resolve: use cmdutil.match
Matt Mackall <mpm@selenic.com>
parents: 6586
diff changeset
  2437
        if m(f):
7527
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  2438
            if show:
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2439
                ui.write("%s %s\n" % (ms[f].upper(), f))
7527
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  2440
            elif mark:
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2441
                ms.mark(f, "r")
7527
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  2442
            elif unmark:
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2443
                ms.mark(f, "u")
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2444
            else:
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2445
                wctx = repo[None]
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2446
                mctx = wctx.parents()[-1]
7847
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  2447
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  2448
                # backup pre-resolve (merge uses .orig for its own purposes)
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  2449
                a = repo.wjoin(f)
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  2450
                util.copyfile(a, a + ".resolve")
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  2451
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  2452
                # resolve file
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2453
                ms.resolve(f, wctx, mctx)
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  2454
7847
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  2455
                # replace filemerge's .orig file with our resolve file
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  2456
                util.rename(a + ".resolve", a + ".orig")
30cb79d84352 resolve: keep .orig files
Matt Mackall <mpm@selenic.com>
parents: 7829
diff changeset
  2457
1472
3c909a747d7f make revert use standard matcher
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1470
diff changeset
  2458
def revert(ui, repo, *pats, **opts):
8026
683d8ebcf434 expand "dir" to "directory" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8021
diff changeset
  2459
    """restore individual files or directories to an earlier state
5574
d4ec6d61b3ee imported patch rev-help
Matt Mackall <mpm@selenic.com>
parents: 5573
diff changeset
  2460
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2461
    (Use update -r to check out earlier revisions, revert does not change the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2462
    working directory parents.)
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2463
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2464
    With no revision specified, revert the named files or directories to the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2465
    contents they had in the parent of the working directory. This restores
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2466
    the contents of the affected files to an unmodified state and unschedules
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2467
    adds, removes, copies, and renames. If the working directory has two
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2468
    parents, you must explicitly specify the revision to revert to.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2469
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2470
    Using the -r/--rev option, revert the given files or directories to their
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2471
    contents as of a specific revision. This can be helpful to "roll back"
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2472
    some or all of an earlier change. See 'hg help dates' for a list of
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2473
    formats valid for -d/--date.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2474
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2475
    Revert modifies the working directory. It does not commit any changes, or
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2476
    change the parent of the working directory. If you revert to a revision
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2477
    other than the parent of the working directory, the reverted files will
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2478
    thus appear modified afterwards.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2479
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2480
    If a file has been deleted, it is restored. If the executable mode of a
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2481
    file was changed, it is reset.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2482
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2483
    If names are given, all files matching the names are reverted. If no
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2484
    arguments are given, no files are reverted.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2485
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2486
    Modified files are saved with a .orig suffix before reverting. To disable
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2487
    these backups, use --no-backup.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2488
    """
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
  2489
3814
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  2490
    if opts["date"]:
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  2491
        if opts["rev"]:
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  2492
            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
  2493
        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
  2494
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2495
    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
  2496
        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
  2497
                           '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
  2498
2212
8164e3f31638 revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2204
diff changeset
  2499
    parent, p2 = repo.dirstate.parents()
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2500
    if not opts.get('rev') and p2 != nullid:
3132
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3095
diff changeset
  2501
        raise util.Abort(_('uncommitted merge - please provide a '
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3095
diff changeset
  2502
                           'specific revision'))
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2503
    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
  2504
    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
  2505
    mf = ctx.manifest()
2407
8fe3d60b7f19 revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2406
diff changeset
  2506
    if node == parent:
8fe3d60b7f19 revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2406
diff changeset
  2507
        pmf = mf
8fe3d60b7f19 revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2406
diff changeset
  2508
    else:
8fe3d60b7f19 revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2406
diff changeset
  2509
        pmf = None
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
  2510
2042
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
  2511
    # 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
  2512
    # 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
  2513
    # but not other.
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
  2514
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
  2515
    names = {}
2042
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
  2516
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2517
    wlock = repo.wlock()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2518
    try:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2519
        # walk dirstate.
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  2520
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  2521
        m = cmdutil.match(repo, pats, opts)
6583
3951e04ea989 walk: remove more old badmatch logic
Matt Mackall <mpm@selenic.com>
parents: 6582
diff changeset
  2522
        m.bad = lambda x,y: False
6586
d3463007d368 walk: return a single value
Matt Mackall <mpm@selenic.com>
parents: 6585
diff changeset
  2523
        for abs in repo.walk(m):
6584
29c77e5dfb3c walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents: 6583
diff changeset
  2524
            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
  2525
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2526
        # walk target manifest.
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2527
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  2528
        def badfn(path, msg):
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2529
            if path in names:
8679
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
  2530
                return
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2531
            path_ = path + '/'
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2532
            for f in names:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2533
                if f.startswith(path_):
8679
32537b12e091 add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents: 8669
diff changeset
  2534
                    return
8615
94ca38e63576 use ui instead of repo.ui when the former is in scope
Martin Geisler <mg@lazybytes.net>
parents: 8544
diff changeset
  2535
            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
  2536
6579
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  2537
        m = cmdutil.match(repo, pats, opts)
0159b7a36184 walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents: 6578
diff changeset
  2538
        m.bad = badfn
6764
8db64464d136 context: add walk method
Matt Mackall <mpm@selenic.com>
parents: 6762
diff changeset
  2539
        for abs in repo[node].walk(m):
6584
29c77e5dfb3c walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents: 6583
diff changeset
  2540
            if abs not in names:
29c77e5dfb3c walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents: 6583
diff changeset
  2541
                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
  2542
6599
cd4db3999ef9 status: use match helpers for various users
Matt Mackall <mpm@selenic.com>
parents: 6594
diff changeset
  2543
        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
  2544
        changes = repo.status(match=m)[:4]
8152
08e1baf924ca replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents: 8150
diff changeset
  2545
        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
  2546
5266
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  2547
        # if f is a rename, also revert the source
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  2548
        cwd = repo.getcwd()
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  2549
        for f in added:
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  2550
            src = repo.dirstate.copied(f)
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  2551
            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
  2552
                removed.add(src)
5266
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  2553
                names[src] = (repo.pathto(src, cwd), True)
d59ed18ec2d0 Merge with crew-stable
Brendan Cully <brendan@kublai.com>
parents: 5259 5230
diff changeset
  2554
6109
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2555
        def removeforget(abs):
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2556
            if repo.dirstate[abs] == 'a':
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2557
                return _('forgetting %s\n')
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2558
            return _('removing %s\n')
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2559
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2560
        revert = ([], _('reverting %s\n'))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2561
        add = ([], _('adding %s\n'))
6109
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2562
        remove = ([], removeforget)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2563
        undelete = ([], _('undeleting %s\n'))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2564
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2565
        disptable = (
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2566
            # dispatch table:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2567
            #   file state
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2568
            #   action if in target manifest
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2569
            #   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
  2570
            #   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
  2571
            #   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
  2572
            (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
  2573
            (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
  2574
            (removed, undelete, None, False, False),
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2575
            (deleted, revert, remove, False, False),
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2576
            )
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2577
8209
a1a5a57efe90 replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents: 8190
diff changeset
  2578
        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
  2579
            mfentry = mf.get(abs)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2580
            target = repo.wjoin(abs)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2581
            def handle(xlist, dobackup):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2582
                xlist[0].append(abs)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2583
                if dobackup and not opts.get('no_backup') and util.lexists(target):
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2584
                    bakname = "%s.orig" % rel
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2585
                    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
  2586
                            (rel, bakname))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2587
                    if not opts.get('dry_run'):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2588
                        util.copyfile(target, bakname)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2589
                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
  2590
                    msg = xlist[1]
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2591
                    if not isinstance(msg, basestring):
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2592
                        msg = msg(abs)
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2593
                    ui.status(msg % rel)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2594
            for table, hitlist, misslist, backuphit, backupmiss in disptable:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2595
                if abs not in table: continue
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2596
                # file has changed in dirstate
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2597
                if mfentry:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2598
                    handle(hitlist, backuphit)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2599
                elif misslist is not None:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2600
                    handle(misslist, backupmiss)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2601
                break
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
  2602
            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
  2603
                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
  2604
                    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
  2605
                        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
  2606
                    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
  2607
                        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
  2608
                    continue
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2609
                # 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
  2610
                if node == parent:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2611
                    if exact: ui.warn(_('no changes needed to %s\n') % rel)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2612
                    continue
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2613
                if pmf is None:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2614
                    # 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
  2615
                    # so do not read by default
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2616
                    pmf = repo[parent].manifest()
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2617
                if abs in pmf:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2618
                    if mfentry:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2619
                        # 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
  2620
                        # 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
  2621
                        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
  2622
                            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
  2623
                            handle(revert, False)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2624
                    else:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2625
                        handle(remove, False)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2626
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2627
        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
  2628
            def checkout(f):
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  2629
                fc = ctx[f]
6743
86e8187b721a simplify flag handling
Matt Mackall <mpm@selenic.com>
parents: 6740
diff changeset
  2630
                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
  2631
6109
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2632
            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
  2633
            for f in remove[0]:
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2634
                if repo.dirstate[f] == 'a':
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2635
                    repo.dirstate.forget(f)
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2636
                    continue
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2637
                audit_path(f)
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2638
                try:
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2639
                    util.unlink(repo.wjoin(f))
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2640
                except OSError:
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2641
                    pass
242595e612ed revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6108
diff changeset
  2642
                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
  2643
6299
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  2644
            normal = None
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  2645
            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
  2646
                # 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
  2647
                # 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
  2648
                # 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
  2649
                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
  2650
                    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
  2651
                else:
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  2652
                    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
  2653
            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
  2654
                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
  2655
                if normal:
653ddd1d7cd7 revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6296
diff changeset
  2656
                    normal(f)
6107
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  2657
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2658
            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
  2659
                checkout(f)
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2660
                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
  2661
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
  2662
            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
  2663
            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
  2664
                normal = repo.dirstate.normal
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2665
            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
  2666
                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
  2667
                normal(f)
6107
41bb88cb913e commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6106
diff changeset
  2668
4915
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4914
diff changeset
  2669
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
  2670
        wlock.release()
588
0c3bae18403b [PATCH] hg revert
mpm@selenic.com
parents: 582
diff changeset
  2671
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  2672
def rollback(ui, repo):
5575
8788ff630c26 imported patch rollback-help
Matt Mackall <mpm@selenic.com>
parents: 5574
diff changeset
  2673
    """roll back the last transaction
8788ff630c26 imported patch rollback-help
Matt Mackall <mpm@selenic.com>
parents: 5574
diff changeset
  2674
8788ff630c26 imported patch rollback-help
Matt Mackall <mpm@selenic.com>
parents: 5574
diff changeset
  2675
    This command should be used with care. There is only one level of
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2676
    rollback, and there is no way to undo a rollback. It will also restore the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2677
    dirstate at the time of the last transaction, losing any dirstate changes
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2678
    since that time. This command does not alter the working directory.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2679
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2680
    Transactions are used to encapsulate the effects of all commands that
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2681
    create new changesets or propagate existing changesets into a repository.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2682
    For example, the following commands are transactional, and their effects
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2683
    can be rolled back::
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  2684
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  2685
      commit
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  2686
      import
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  2687
      pull
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  2688
      push (with this repository as destination)
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  2689
      unbundle
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  2690
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2691
    This command is not intended for use on public repositories. Once changes
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2692
    are visible for pull by other users, rolling a transaction back locally is
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2693
    ineffective (someone else may already have pulled the changes).
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2694
    Furthermore, a race is possible with readers of the repository; for
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2695
    example an in-progress pull from the repository may fail if a rollback is
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2696
    performed.
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  2697
    """
2362
482d3fb47d80 Renamed localrepo.undo() to rollback() and talk about "rollback information".
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2356
diff changeset
  2698
    repo.rollback()
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
  2699
468
157675add351 [PATCH] add "root" command
mpm@selenic.com
parents: 467
diff changeset
  2700
def root(ui, repo):
8026
683d8ebcf434 expand "dir" to "directory" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8021
diff changeset
  2701
    """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
  2702
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2703
    Print the root directory of the current repository.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2704
    """
468
157675add351 [PATCH] add "root" command
mpm@selenic.com
parents: 467
diff changeset
  2705
    ui.write(repo.root + "\n")
157675add351 [PATCH] add "root" command
mpm@selenic.com
parents: 467
diff changeset
  2706
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
  2707
def serve(ui, repo, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2708
    """export the repository via HTTP
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2709
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2710
    Start a local HTTP repository browser and pull server.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2711
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2712
    By default, the server logs accesses to stdout and errors to stderr. Use
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2713
    the -A/--accesslog and -E/--errorlog options to log to files.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2714
    """
624
876333a295ff Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents: 618
diff changeset
  2715
876333a295ff Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents: 618
diff changeset
  2716
    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
  2717
        if repo is None:
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
  2718
            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
  2719
                              " (.hg not found)"))
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2392
diff changeset
  2720
        s = sshserver.sshserver(ui, repo)
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2392
diff changeset
  2721
        s.serve_forever()
2363
fa4c11751367 Give a response to unknown SSH commands
Matt Mackall <mpm@selenic.com>
parents: 2362
diff changeset
  2722
8190
9b8ac5fb7760 ui: kill most users of parentui name and arg, replace with .copy()
Matt Mackall <mpm@selenic.com>
parents: 8189
diff changeset
  2723
    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
  2724
    optlist = ("name templates style address port prefix ipv6"
8870
c3e4d3c1d48b serve: obey the --encoding option
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8864
diff changeset
  2725
               " accesslog errorlog webdir_conf certificate encoding")
987
bfe12654764d hgweb: change startup argument processing
mpm@selenic.com
parents: 981
diff changeset
  2726
    for o in optlist.split():
8870
c3e4d3c1d48b serve: obey the --encoding option
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8864
diff changeset
  2727
        if opts.get(o, None):
8190
9b8ac5fb7760 ui: kill most users of parentui name and arg, replace with .copy()
Matt Mackall <mpm@selenic.com>
parents: 8189
diff changeset
  2728
            baseui.setconfig("web", o, str(opts[o]))
9b8ac5fb7760 ui: kill most users of parentui name and arg, replace with .copy()
Matt Mackall <mpm@selenic.com>
parents: 8189
diff changeset
  2729
            if (repo is not None) and (repo.ui != baseui):
4835
9858477ed74c serve: respect settings from .hg/hgrc
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4833
diff changeset
  2730
                repo.ui.setconfig("web", o, str(opts[o]))
987
bfe12654764d hgweb: change startup argument processing
mpm@selenic.com
parents: 981
diff changeset
  2731
2127
8a85dbbadddf Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2125
diff changeset
  2732
    if repo is None and not ui.config("web", "webdir_conf"):
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
  2733
        raise error.RepoError(_("There is no Mercurial repository here"
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
  2734
                                " (.hg not found)"))
2127
8a85dbbadddf Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2125
diff changeset
  2735
8778
c5f36402daad use new style classes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8761
diff changeset
  2736
    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
  2737
        def init(self):
4672
272c0a09b203 Handle CTRL+C in serve under Windows.
Marcos Chaves <marcos.nospam@gmail.com>
parents: 4659
diff changeset
  2738
            util.set_signal_handler()
8312
b87a50b7125c separate import lines from mercurial and general python modules
Simon Heimberg <simohe@besonet.ch>
parents: 8287
diff changeset
  2739
            self.httpd = server.create_server(baseui, repo)
4380
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  2740
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  2741
            if not ui.verbose: return
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  2742
5970
f25070ecf334 hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents: 5953
diff changeset
  2743
            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
  2744
                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
  2745
            else:
f25070ecf334 hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents: 5953
diff changeset
  2746
                prefix = ''
f25070ecf334 hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents: 5953
diff changeset
  2747
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
  2748
            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
  2749
            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
  2750
                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
  2751
6419
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  2752
            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
  2753
            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
  2754
                bindaddr = '*'
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  2755
            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
  2756
                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
  2757
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  2758
            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
  2759
            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
  2760
                fqaddr = '[%s]' % fqaddr
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  2761
            ui.status(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
7c36aee46bf5 hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6405
diff changeset
  2762
                      (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
  2763
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  2764
        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
  2765
            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
  2766
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  2767
    service = service()
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  2768
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4376
diff changeset
  2769
    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
  2770
731
91ca3afab8e8 Add name matching to status command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 729
diff changeset
  2771
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
  2772
    """show changed files in the working directory
213
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 212
diff changeset
  2773
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2774
    Show status of files in the repository. If names are given, only files
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2775
    that match are shown. Files that are clean or ignored or the source of a
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2776
    copy/move operation, are not listed unless -c/--clean, -i/--ignored,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2777
    -C/--copies or -A/--all are given. Unless options described with "show
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2778
    only ..." are given, the options -mardu are used.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2779
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2780
    Option -q/--quiet hides untracked (unknown and ignored) files unless
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2781
    explicitly requested with -u/--unknown or -i/--ignored.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2782
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2783
    NOTE: status may appear to disagree with diff if permissions have changed
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2784
    or a merge has occurred. The standard diff format does not report
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2785
    permission changes and diff only reports changes relative to one merge
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2786
    parent.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2787
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2788
    If one revision is given, it is used as the base revision. If two
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2789
    revisions are given, the differences between them are shown.
3467
2b3b703b3a2b Add --rev option to status
Brendan Cully <brendan@kublai.com>
parents: 3465
diff changeset
  2790
9157
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2791
    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
  2792
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2793
      M = modified
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2794
      A = added
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2795
      R = removed
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2796
      C = clean
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2797
      ! = 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
  2798
      ? = not tracked
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2799
      I = ignored
9261667e9b82 commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents: 9142
diff changeset
  2800
        = origin of the previous file listed as A (added)
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2801
    """
312
09375250eb31 Optimize diff and status in subdirectories
mpm@selenic.com
parents: 310
diff changeset
  2802
3707
67f44b825784 Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3706
diff changeset
  2803
    node1, node2 = cmdutil.revpair(repo, opts.get('rev'))
1625
e1bcf7fa983f correct the relative path when walking from a subdir
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1622
diff changeset
  2804
    cwd = (pats and repo.getcwd()) or ''
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2805
    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
  2806
    copy = {}
6605
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2807
    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
  2808
    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
  2809
    if opts.get('all'):
6605
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2810
        show += ui.quiet and (states[:4] + ['clean']) or states
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2811
    if not show:
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2812
        show = ui.quiet and states[:4] or states[:5]
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2813
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2814
    stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2815
                       'ignored' in show, 'clean' in show, 'unknown' in show)
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2816
    changestates = zip(states, 'MAR!?IC', stat)
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2817
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2818
    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
  2819
        ctxn = repo[nullid]
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2820
        ctx1 = repo[node1]
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2821
        ctx2 = repo[node2]
6646
9eb274d773d9 copies: teach copies about dirstate.copies
Matt Mackall <mpm@selenic.com>
parents: 6642
diff changeset
  2822
        added = stat[1]
9eb274d773d9 copies: teach copies about dirstate.copies
Matt Mackall <mpm@selenic.com>
parents: 6642
diff changeset
  2823
        if node2 is None:
9eb274d773d9 copies: teach copies about dirstate.copies
Matt Mackall <mpm@selenic.com>
parents: 6642
diff changeset
  2824
            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
  2825
7622
4dd7b28003d2 use dict.iteritems() rather than dict.items()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7598
diff changeset
  2826
        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
  2827
            if k in added:
9eb274d773d9 copies: teach copies about dirstate.copies
Matt Mackall <mpm@selenic.com>
parents: 6642
diff changeset
  2828
                copy[k] = v
9eb274d773d9 copies: teach copies about dirstate.copies
Matt Mackall <mpm@selenic.com>
parents: 6642
diff changeset
  2829
            elif v in added:
6276
c93ca83a3354 status: find copies and renames beyond the working directory
Matt Mackall <mpm@selenic.com>
parents: 6262
diff changeset
  2830
                copy[v] = k
c93ca83a3354 status: find copies and renames beyond the working directory
Matt Mackall <mpm@selenic.com>
parents: 6262
diff changeset
  2831
6605
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2832
    for state, char, files in changestates:
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2833
        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
  2834
            format = "%s %%s%s" % (char, end)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2835
            if opts.get('no_status'):
6605
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2836
                format = "%%s%s" % end
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2837
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2838
            for f in files:
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2839
                ui.write(format % repo.pathto(f, cwd))
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2840
                if f in copy:
bf2bf986ff87 status: refactor status command
Matt Mackall <mpm@selenic.com>
parents: 6603
diff changeset
  2841
                    ui.write('  %s%s' % (repo.pathto(copy[f], cwd), end))
213
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 212
diff changeset
  2842
6321
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  2843
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
  2844
    """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
  2845
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2846
    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
  2847
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2848
    Tags are used to name particular revisions of the repository and are very
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2849
    useful to compare different revisions, to go back to significant earlier
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2850
    versions or to mark branch points as releases, etc.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2851
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2852
    If no revision is given, the parent of the working directory is used, or
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2853
    tip if no revision is checked out.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2854
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2855
    To facilitate version control, distribution, and merging of tags, they are
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2856
    stored as a file named ".hgtags" which is managed similarly to other
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2857
    project files and can be hand-edited if necessary. The file
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2858
    '.hg/localtags' is used for local tags (not shared among repositories).
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
  2859
1f733c2f0165 Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6161
diff changeset
  2860
    See 'hg help dates' for a list of formats valid for -d/--date.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2861
    """
6321
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  2862
6739
c9fbd6ec3489 context: avoid using None for working parent
Matt Mackall <mpm@selenic.com>
parents: 6723
diff changeset
  2863
    rev_ = "."
6321
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  2864
    names = (name1,) + names
8152
08e1baf924ca replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents: 8150
diff changeset
  2865
    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
  2866
        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
  2867
    for n in names:
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  2868
        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
  2869
            raise util.Abort(_('the name \'%s\' is reserved') % n)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2870
    if opts.get('rev') and opts.get('remove'):
4213
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4179
diff changeset
  2871
        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
  2872
    if opts.get('rev'):
1596
41366b7d6709 fix 'hg tag <tagname> <revision>
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1589
diff changeset
  2873
        rev_ = opts['rev']
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2874
    message = opts.get('message')
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2875
    if opts.get('remove'):
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2876
        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
  2877
        for n in names:
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  2878
            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
  2879
                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
  2880
            if repo.tagtype(n) != expectedtype:
8008
36924a4711e9 commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8007
diff changeset
  2881
                if expectedtype == 'global':
36924a4711e9 commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8007
diff changeset
  2882
                    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
  2883
                else:
36924a4711e9 commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents: 8007
diff changeset
  2884
                    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
  2885
        rev_ = nullid
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4179
diff changeset
  2886
        if not message:
9183
d0225fa2f6c4 do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents: 9128
diff changeset
  2887
            # we don't translate commit messages
d0225fa2f6c4 do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents: 9128
diff changeset
  2888
            message = 'Removed tag %s' % ', '.join(names)
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2889
    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
  2890
        for n in names:
55ba3bc5b8fd tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents: 6304
diff changeset
  2891
            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
  2892
                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
  2893
                                   '(use -f to force)') % n)
3132
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3095
diff changeset
  2894
    if not rev_ and repo.dirstate.parents()[1] != nullid:
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3095
diff changeset
  2895
        raise util.Abort(_('uncommitted merge - please provide a '
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3095
diff changeset
  2896
                           'specific revision'))
6747
f6c00b17387c use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents: 6746
diff changeset
  2897
    r = repo[rev_].node()
2967
eef469259745 tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents: 2966
diff changeset
  2898
eef469259745 tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents: 2966
diff changeset
  2899
    if not message:
9183
d0225fa2f6c4 do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents: 9128
diff changeset
  2900
        # we don't translate commit messages
d0225fa2f6c4 do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents: 9128
diff changeset
  2901
        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
  2902
                   (', '.join(names), short(r)))
2967
eef469259745 tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents: 2966
diff changeset
  2903
6243
437eef39458d fix incorrect date when committing a tag
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6234
diff changeset
  2904
    date = opts.get('date')
437eef39458d fix incorrect date when committing a tag
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6234
diff changeset
  2905
    if date:
437eef39458d fix incorrect date when committing a tag
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6234
diff changeset
  2906
        date = util.parsedate(date)
437eef39458d fix incorrect date when committing a tag
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6234
diff changeset
  2907
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2908
    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
  2909
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
  2910
def tags(ui, repo):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2911
    """list repository tags
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2912
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2913
    This lists both regular and local tags. When the -v/--verbose switch is
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2914
    used, a third column "local" is printed for local tags.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2915
    """
477
520540fd6b64 Handle errors in .hgtags or hgrc [tags] section more gracefully.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 470
diff changeset
  2916
2966
fb493241d7f6 Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents: 2963
diff changeset
  2917
    hexfunc = ui.debugflag and hex or short
5658
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2918
    tagtype = ""
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2919
8210
344751cd8cb8 replace various uses of list.reverse()
Matt Mackall <mpm@selenic.com>
parents: 8209
diff changeset
  2920
    for t, n in reversed(repo.tagslist()):
5658
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2921
        if ui.quiet:
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2922
            ui.write("%s\n" % t)
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2923
            continue
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2924
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
  2925
        try:
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4505
diff changeset
  2926
            hn = hexfunc(n)
5658
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2927
            r = "%5d:%s" % (repo.changelog.rev(n), hn)
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents: 7632
diff changeset
  2928
        except error.LookupError:
3930
01d98d68d697 Add revlog.LookupError exception, and use it instead of RevlogError.
Brendan Cully <brendan@kublai.com>
parents: 3920
diff changeset
  2929
            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
  2930
        else:
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
  2931
            spaces = " " * (30 - encoding.colwidth(t))
5658
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2932
            if ui.verbose:
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2933
                if repo.tagtype(t) == 'local':
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2934
                    tagtype = " local"
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2935
                else:
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2936
                    tagtype = ""
ae3089cefaab Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents: 5657
diff changeset
  2937
            ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype))
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
  2938
1731
251729df9cc6 add -p option to tip. for issue 64.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1728
diff changeset
  2939
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
  2940
    """show the tip revision
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2941
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2942
    The tip revision (usually just called the tip) is the changeset most
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2943
    recently added to the repository (and therefore the most recently changed
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2944
    head).
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2945
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2946
    If you have just made a commit, that commit will be the tip. If you have
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2947
    just pulled changes from another repository, the tip of that repository
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2948
    becomes the current tip. The "tip" tag is special and cannot be renamed or
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2949
    assigned to a different changeset.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2950
    """
7369
87158be081b8 cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7364
diff changeset
  2951
    cmdutil.show_changeset(ui, repo, opts).show(repo[len(repo) - 1])
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
  2952
4699
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
  2953
def unbundle(ui, repo, fname1, *fnames, **opts):
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
  2954
    """apply one or more changegroup files
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
  2955
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2956
    Apply one or more compressed changegroup files generated by the bundle
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2957
    command.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2958
    """
4699
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
  2959
    fnames = (fname1,) + fnames
6180
d98ef03893e6 commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents: 6178
diff changeset
  2960
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
  2961
    lock = repo.lock()
6180
d98ef03893e6 commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents: 6178
diff changeset
  2962
    try:
d98ef03893e6 commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents: 6178
diff changeset
  2963
        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
  2964
            f = url.open(ui, fname)
6180
d98ef03893e6 commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents: 6178
diff changeset
  2965
            gen = changegroup.readbundle(f, fname)
d98ef03893e6 commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents: 6178
diff changeset
  2966
            modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
d98ef03893e6 commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents: 6178
diff changeset
  2967
    finally:
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8088
diff changeset
  2968
        lock.release()
4699
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
  2969
7131
23bd7383891c commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7126
diff changeset
  2970
    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
  2971
8855
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  2972
def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
4014
509342f95564 various doc fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4013
diff changeset
  2973
    """update working directory
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2974
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2975
    Update the repository's working directory to the specified revision, or
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2976
    the tip of the current branch if none is specified. Use null as the
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2977
    revision to remove the working copy (like 'hg clone -U').
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2978
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2979
    When the working directory contains no uncommitted changes, it will be
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2980
    replaced by the state of the requested revision from the repository. When
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2981
    the requested revision is on a different branch, the working directory
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2982
    will additionally be switched to that branch.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2983
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2984
    When there are uncommitted changes, use option -C/--clean to discard them,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2985
    forcibly replacing the state of the working directory with the requested
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2986
    revision. Alternately, use -c/--check to abort.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2987
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2988
    When there are uncommitted changes and option -C/--clean is not used, and
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2989
    the parent revision and requested revision are on the same branch, and one
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2990
    of them is an ancestor of the other, then the new working directory will
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2991
    contain the requested revision merged with the uncommitted changes.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2992
    Otherwise, the update will fail with a suggestion to use 'merge' or
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2993
    'update -C' instead.
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2994
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  2995
    If you want to update just one file to an older revision, use revert.
6842
e37fa751182a add note about updating one file to update help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6814
diff changeset
  2996
8033
aeb4a5c7a28e commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents: 8032
diff changeset
  2997
    See 'hg help dates' for a list of formats valid for -d/--date.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  2998
    """
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  2999
    if rev and node:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3000
        raise util.Abort(_("please specify just one revision"))
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3001
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3002
    if not rev:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3003
        rev = node
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3004
8855
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  3005
    if not clean and check:
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  3006
        # 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
  3007
        c = repo[None]
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  3008
        if c.modified() or c.added() or c.removed():
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  3009
            raise util.Abort(_("uncommitted local changes"))
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  3010
3814
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  3011
    if date:
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3012
        if rev:
3814
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  3013
            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
  3014
        rev = cmdutil.finddate(ui, repo, date)
3814
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  3015
3521
ba94e80e5540 Remove update -m, deprecated for 0.9.1
Matt Mackall <mpm@selenic.com>
parents: 3520
diff changeset
  3016
    if clean:
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3017
        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
  3018
    else:
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3019
        return hg.update(repo, rev)
254
c03f58e5fd2d unify checkout and resolve into update
mpm@selenic.com
parents: 252
diff changeset
  3020
247
863b508c5b36 migrate verify
mpm@selenic.com
parents: 246
diff changeset
  3021
def verify(ui, repo):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3022
    """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
  3023
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3024
    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
  3025
9051
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  3026
    This will perform an extensive check of the repository's integrity,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  3027
    validating the hashes and checksums of each entry in the changelog,
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  3028
    manifest, and tracked files, as well as the integrity of their crosslinks
f8e25885d975 commands: wrapped docstrings at 78 characters
Martin Geisler <mg@lazybytes.net>
parents: 9036
diff changeset
  3029
    and indices.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3030
    """
2778
fdc232d8a193 Move repo.verify
Matt Mackall <mpm@selenic.com>
parents: 2776
diff changeset
  3031
    return hg.verify(repo)
247
863b508c5b36 migrate verify
mpm@selenic.com
parents: 246
diff changeset
  3032
3651
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3033
def version_(ui):
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3034
    """output version and copyright information"""
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3035
    ui.write(_("Mercurial Distributed SCM (version %s)\n")
7632
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7628
diff changeset
  3036
             % util.version())
3651
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3037
    ui.status(_(
7829
b61e918ea767 update copyright date in version information
Benoit Allard <benoit@aeteurope.nl>
parents: 7807
diff changeset
  3038
        "\nCopyright (C) 2005-2009 Matt Mackall <mpm@selenic.com> and others\n"
3651
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3039
        "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
  3040
        "There is NO\nwarranty; "
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3041
        "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
  3042
    ))
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3650
diff changeset
  3043
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  3044
# Command options and aliases are listed here, alphabetically
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
  3045
3187
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3046
globalopts = [
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3047
    ('R', 'repository', '',
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3048
     _('repository root directory or symbolic path name')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3049
    ('', 'cwd', '', _('change working directory')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3050
    ('y', 'noninteractive', None,
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3051
     _('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
  3052
    ('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
  3053
    ('v', 'verbose', None, _('enable additional output')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3054
    ('', 'config', [], _('set/override config option')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3055
    ('', '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
  3056
    ('', 'debugger', None, _('start debugger')),
7948
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
  3057
    ('', 'encoding', encoding.encoding, _('set the charset encoding')),
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
  3058
    ('', 'encodingmode', encoding.encodingmode,
de377b1a9a84 move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents: 7942
diff changeset
  3059
     _('set the charset encoding mode')),
3187
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3060
    ('', 'traceback', None, _('print traceback on exception')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3061
    ('', '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
  3062
    ('', '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
  3063
    ('', '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
  3064
    ('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
  3065
]
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
  3066
3189
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3188
diff changeset
  3067
dryrunopts = [('n', 'dry-run', None,
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3188
diff changeset
  3068
               _('do not perform actions, just print output'))]
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3188
diff changeset
  3069
3190
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  3070
remoteopts = [
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  3071
    ('e', 'ssh', '', _('specify ssh command to use')),
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  3072
    ('', 'remotecmd', '', _('specify hg command to run on the remote side')),
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  3073
]
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  3074
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3075
walkopts = [
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3076
    ('I', 'include', [], _('include names matching the given patterns')),
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3077
    ('X', 'exclude', [], _('exclude names matching the given patterns')),
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3078
]
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3079
3857
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
  3080
commitopts = [
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
  3081
    ('m', 'message', '', _('use <text> as commit message')),
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
  3082
    ('l', 'logfile', '', _('read commit message from <file>')),
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
  3083
]
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
  3084
5147
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  3085
commitopts2 = [
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  3086
    ('d', 'date', '', _('record datecode as commit date')),
8313
b695392491e7 commit: be more verbose in the -u help text
Sverre Rabbelier <sverre@rabbelier.nl>
parents: 8312
diff changeset
  3087
    ('u', 'user', '', _('record the specified user as committer')),
5147
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  3088
]
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  3089
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3090
templateopts = [
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3091
    ('', 'style', '', _('display using template map file')),
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3092
    ('', 'template', '', _('display with template')),
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3093
]
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3094
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3095
logopts = [
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3096
    ('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
  3097
    ('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
  3098
    ('l', 'limit', '', _('limit number of changes displayed')),
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3099
    ('M', 'no-merges', None, _('do not show merges')),
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3100
] + templateopts
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3101
6668
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3102
diffopts = [
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3103
    ('a', 'text', None, _('treat all files as text')),
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3104
    ('g', 'git', None, _('use git extended diff format')),
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3105
    ('', 'nodates', None, _("don't include dates in diff headers"))
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3106
]
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3107
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3108
diffopts2 = [
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3109
    ('p', 'show-function', None, _('show which function each change is in')),
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3110
    ('w', 'ignore-all-space', None,
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3111
     _('ignore white space when comparing lines')),
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3112
    ('b', 'ignore-space-change', None,
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3113
     _('ignore changes in the amount of white space')),
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3114
    ('B', 'ignore-blank-lines', None,
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3115
     _('ignore changes whose lines are all blank')),
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3116
    ('U', 'unified', '', _('number of lines of context to show'))
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3117
]
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3118
7402
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  3119
similarityopts = [
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  3120
    ('s', 'similarity', '',
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  3121
           _('guess renamed files by similarity (0<=s<=100)'))
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  3122
]
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  3123
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
  3124
table = {
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3125
    "^add": (add, walkopts + dryrunopts, _('[OPTION]... [FILE]...')),
2955
9d1c3529ebbc addremove: do not deprecate.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
  3126
    "addremove":
7402
bffdab64dfbb import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents: 7372
diff changeset
  3127
        (addremove, similarityopts + walkopts + dryrunopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3128
         _('[OPTION]... [FILE]...')),
6182
07f2236c4dee add a blame alias for annotate
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6180
diff changeset
  3129
    "^annotate|blame":
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3130
        (annotate,
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3131
         [('r', 'rev', '', _('annotate the specified revision')),
3172
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 3159
diff changeset
  3132
          ('f', 'follow', None, _('follow file 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
  3133
          ('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
  3134
          ('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
  3135
          ('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
  3136
          ('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
  3137
          ('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
  3138
          ('l', 'line-number', None,
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4849
diff changeset
  3139
           _('show line number at the first appearance'))
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3140
         ] + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3141
         _('[-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
  3142
    "archive":
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
  3143
        (archive,
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
  3144
         [('', 'no-decode', None, _('do not pass files through decoders')),
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
  3145
          ('p', 'prefix', '', _('directory prefix for files in archive')),
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
  3146
          ('r', 'rev', '', _('revision to distribute')),
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
  3147
          ('t', 'type', '', _('type of distribution to create')),
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3148
         ] + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3149
         _('[OPTION]... DEST')),
2159
5c34b98ad6b1 Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2158
diff changeset
  3150
    "backout":
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
  3151
        (backout,
2159
5c34b98ad6b1 Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2158
diff changeset
  3152
         [('', 'merge', None,
5c34b98ad6b1 Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2158
diff changeset
  3153
           _('merge with old dirstate parent after backout')),
2614
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
  3154
          ('', 'parent', '', _('parent to choose when backing out merge')),
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3155
          ('r', 'rev', '', _('revision to backout')),
5147
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  3156
         ] + walkopts + commitopts + commitopts2,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3157
         _('[OPTION]... [-r] REV')),
5778
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3158
    "bisect":
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3159
        (bisect,
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3160
         [('r', 'reset', False, _('reset bisect state')),
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3161
          ('g', 'good', False, _('mark changeset good')),
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3162
          ('b', 'bad', False, _('mark changeset bad')),
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3163
          ('s', 'skip', False, _('skip testing changeset')),
7598
26adfaccdf73 lowercase help output
Martin Geisler <mg@daimi.au.dk>
parents: 7596
diff changeset
  3164
          ('c', 'command', '', _('use command to check changeset state')),
5778
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3165
          ('U', 'noupdate', False, _('do not update to target'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3166
         _("[-gbsr] [-c CMD] [REV]")),
4730
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  3167
    "branch":
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  3168
        (branch,
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  3169
         [('f', 'force', None,
7006
92d44ec32430 branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents: 7003
diff changeset
  3170
           _('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
  3171
          ('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
  3172
         _('[-fC] [NAME]')),
4730
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  3173
    "branches":
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  3174
        (branches,
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  3175
         [('a', 'active', False,
8991
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
  3176
           _('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
  3177
          ('c', 'closed', False,
7e0b31dfc66f branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents: 8958
diff changeset
  3178
           _('show normal and closed heads'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3179
         _('[-a]')),
1218
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
  3180
    "bundle":
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
  3181
        (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
  3182
         [('f', 'force', None,
3191
545b6d718593 add remoteopts to bundle command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3190
diff changeset
  3183
           _('run even when remote repository is unrelated')),
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
  3184
          ('r', 'rev', [],
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
  3185
           _('a changeset up to which you would like to bundle')),
3284
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
  3186
          ('', 'base', [],
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3278
diff changeset
  3187
           _('a base changeset to specify instead of a destination')),
6570
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
  3188
          ('a', 'all', None, _('bundle all changesets in the repository')),
626cb86a6523 add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents: 6518
diff changeset
  3189
          ('t', 'type', 'bzip2', _('bundle compression type to use')),
3191
545b6d718593 add remoteopts to bundle command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3190
diff changeset
  3190
         ] + remoteopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3191
         _('[-f] [-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
  3192
    "cat":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3193
        (cat,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
  3194
         [('o', 'output', '', _('print output to file with formatted name')),
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
  3195
          ('r', 'rev', '', _('print the given revision')),
6094
3998c1b0828f cat --decode: Drop short option, use opts.get() instead of opts[]
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6093
diff changeset
  3196
          ('', 'decode', None, _('apply any matching decode filter')),
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3197
         ] + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3198
         _('[OPTION]... FILE...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3199
    "^clone":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3200
        (clone,
6625
4d3a60d5c490 improve help text for clone -U
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6620
diff changeset
  3201
         [('U', 'noupdate', None,
4d3a60d5c490 improve help text for clone -U
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6620
diff changeset
  3202
          _('the clone will only contain a repository (no working copy)')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  3203
          ('r', 'rev', [],
2764
71029a3247cb clone: replace long help string of inaky with doc comment.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2763
diff changeset
  3204
           _('a changeset you would like to have after cloning')),
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
  3205
          ('', '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
  3206
          ('', 'uncompressed', None,
de82749d3a71 clone: change name of --stream to --uncompressed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2618
diff changeset
  3207
           _('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
  3208
         ] + remoteopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3209
         _('[OPTION]... SOURCE [DEST]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3210
    "^commit|ci":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3211
        (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
  3212
         [('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
  3213
           _('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
  3214
          ('', 'close-branch', None,
cce37dab7ad6 branch closing: mark closed branches with a 'close' extra
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7643
diff changeset
  3215
           _('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
  3216
         ] + walkopts + commitopts + commitopts2,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3217
         _('[OPTION]... [FILE]...')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  3218
    "copy|cp":
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  3219
        (copy,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
  3220
         [('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
  3221
          ('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
  3222
           _('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
  3223
         ] + walkopts + dryrunopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3224
         _('[OPTION]... [SOURCE]... DEST')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3225
    "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3226
    "debugcheckstate": (debugcheckstate, []),
7880
7ca2be800804 add debugcommands command: an easy to parse command + option index
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7875
diff changeset
  3227
    "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
  3228
    "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
  3229
        (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
  3230
         [('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
  3231
         _('[-o] CMD')),
5781
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  3232
    "debugdate":
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  3233
        (debugdate,
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  3234
         [('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
  3235
         _('[-e] DATE [RANGE]')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3236
    "debugdata": (debugdata, [], _('FILE REV')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3237
    "debugfsinfo": (debugfsinfo, [], _('[PATH]')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3238
    "debugindex": (debugindex, [], _('FILE')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3239
    "debugindexdot": (debugindexdot, [], _('FILE')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3240
    "debuginstall": (debuginstall, []),
1755
a8f7791e3680 add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1754
diff changeset
  3241
    "debugrebuildstate":
a8f7791e3680 add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1754
diff changeset
  3242
        (debugrebuildstate,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
  3243
         [('r', 'rev', '', _('revision to rebuild to'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3244
         _('[-r REV] [REV]')),
4730
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  3245
    "debugrename":
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  3246
        (debugrename,
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
  3247
         [('r', 'rev', '', _('revision to debug'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3248
         _('[-r REV] FILE')),
5781
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  3249
    "debugsetparents":
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3250
        (debugsetparents, [], _('REV1 [REV2]')),
6296
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  3251
    "debugstate":
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  3252
        (debugstate,
a9e6b8875805 debugstate: add --nodates
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6276
diff changeset
  3253
         [('', '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
  3254
         _('[OPTION]...')),
8812
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  3255
    "debugsub":
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  3256
        (debugsub,
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  3257
         [('r', 'rev', '', _('revision to check'))],
859f841937d0 subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents: 8810
diff changeset
  3258
         _('[-r REV] [REV]')),
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3259
    "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3260
    "^diff":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3261
        (diff,
7628
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  3262
         [('r', 'rev', [], _('revision')),
9c6ae2e09e11 diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents: 7622
diff changeset
  3263
          ('c', 'change', '', _('change made by revision'))
6668
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3264
         ] + diffopts + diffopts2 + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3265
         _('[OPTION]... [-r REV1 [-r REV2]] [FILE]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3266
    "^export":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3267
        (export,
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  3268
         [('o', 'output', '', _('print output to file with formatted name')),
6668
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3269
          ('', 'switch-parent', None, _('diff against the second parent'))
034f444902d9 mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents: 6658
diff changeset
  3270
          ] + diffopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3271
         _('[OPTION]... [-o OUTFILESPEC] REV...')),
8902
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  3272
    "^forget":
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  3273
        (forget,
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  3274
         [] + walkopts,
b9a8b616521d Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents: 8879
diff changeset
  3275
         _('[OPTION]... FILE...')),
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  3276
    "grep":
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
  3277
        (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
  3278
         [('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
  3279
          ('', 'all', None, _('print all revisions that match')),
2870
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
  3280
          ('f', 'follow', None,
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
  3281
           _('follow changeset history, 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
  3282
          ('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
  3283
          ('l', 'files-with-matches', None,
8028
3aaca5901ade expand "rev" to "revision" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8027
diff changeset
  3284
           _('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
  3285
          ('n', 'line-number', None, _('print matching line numbers')),
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3286
          ('r', 'rev', [], _('search in given revision range')),
6134
7b937b26adf7 Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6133
diff changeset
  3287
          ('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
  3288
          ('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
  3289
         ] + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3290
         _('[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
  3291
    "heads":
65763ff9fa53 Update online help of hg heads for new --branches option.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 904
diff changeset
  3292
        (heads,
8031
813a02a4eda2 upper-case command line meta variables
Martin Geisler <mg@lazybytes.net>
parents: 8029
diff changeset
  3293
         [('r', 'rev', '', _('show only heads which are descendants of REV')),
7656
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
  3294
          ('a', 'active', False,
6a24fb994701 branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 7655
diff changeset
  3295
           _('show only the active heads from open branches')),
8695
9a89253a32e6 heads: show closed heads only when --closed is passed
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8679
diff changeset
  3296
          ('c', 'closed', False,
9a89253a32e6 heads: show closed heads only when --closed is passed
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8679
diff changeset
  3297
           _('show normal and closed heads')),
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3298
         ] + templateopts,
8796
2bcef677a6c3 localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents: 8779
diff changeset
  3299
         _('[-r STARTREV] [REV]...')),
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3300
    "help": (help_, [], _('[TOPIC]')),
4665
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
  3301
    "identify|id":
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
  3302
        (identify,
8028
3aaca5901ade expand "rev" to "revision" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8027
diff changeset
  3303
         [('r', 'rev', '', _('identify the specified revision')),
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  3304
          ('n', 'num', None, _('show local revision number')),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  3305
          ('i', 'id', None, _('show global revision id')),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  3306
          ('b', 'branch', None, _('show branch')),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
  3307
          ('t', 'tags', None, _('show tags'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3308
         _('[-nibt] [-r REV] [SOURCE]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3309
    "import|patch":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3310
        (import_,
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  3311
         [('p', 'strip', 1,
8038
2ee6769afe82 commands: removed bad linebreak in import help
Martin Geisler <mg@lazybytes.net>
parents: 8034
diff changeset
  3312
           _('directory strip option for patch. This has the same '
2125
3610d9468b1e Use string literal concatenation for optlist and import -p option
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2124
diff changeset
  3313
             'meaning as the corresponding patch option')),
3876
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
  3314
          ('b', 'base', '', _('base path')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  3315
          ('f', 'force', None,
4263
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
  3316
           _('skip check for outstanding uncommitted changes')),
5936
00dfc810dae4 Add --no-commit option to import command
Joel Rosdahl <joel@rosdahl.net>
parents: 5858
diff changeset
  3317
          ('', 'no-commit', None, _("don't commit, just update the working directory")),
4263
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
  3318
          ('', '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
  3319
           _('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
  3320
          ('', 'import-branch', None,
8034
15725dbc900f commands: lower-case --import-branch help text
Martin Geisler <mg@lazybytes.net>
parents: 8033
diff changeset
  3321
           _('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
  3322
         commitopts + commitopts2 + similarityopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3323
         _('[OPTION]... PATCH...')),
5778
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3324
    "incoming|in":
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3325
        (incoming,
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3326
         [('f', 'force', None,
1959
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
  3327
           _('run even when remote repository is unrelated')),
1907
7718885070b1 let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1800
diff changeset
  3328
          ('n', 'newest-first', None, _('show newest record first')),
1944
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
  3329
          ('', 'bundle', '', _('file to store the bundles into')),
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
  3330
          ('r', 'rev', [],
d99b4e8652b3 Make clear that for a changegroup '-r' pulls "up to" a revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6299
diff changeset
  3331
           _('a specific revision up to which you would like to pull')),
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3332
         ] + logopts + remoteopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3333
         _('[-p] [-n] [-M] [-f] [-r REV]...'
2544
0ab63318bc36 Added missing space in continued string.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2521
diff changeset
  3334
           ' [--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
  3335
    "^init":
3885
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
  3336
        (init,
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
  3337
         remoteopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3338
         _('[-e CMD] [--remotecmd CMD] [DEST]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3339
    "locate":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3340
        (locate,
8031
813a02a4eda2 upper-case command line meta variables
Martin Geisler <mg@lazybytes.net>
parents: 8029
diff changeset
  3341
         [('r', 'rev', '', _('search the repository as it stood at REV')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  3342
          ('0', 'print0', None,
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  3343
           _('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
  3344
          ('f', 'fullpath', None,
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  3345
           _('print complete paths from the filesystem root')),
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3346
         ] + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3347
         _('[OPTION]... [PATTERN]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3348
    "^log|history":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3349
        (log,
3876
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
  3350
         [('f', 'follow', None,
2782
21e571c21a6b Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents: 2764
diff changeset
  3351
           _('follow changeset history, 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
  3352
          ('', '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
  3353
           _('only follow the first parent of merge changesets')),
8028
3aaca5901ade expand "rev" to "revision" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8027
diff changeset
  3354
          ('d', 'date', '', _('show revisions matching date spec')),
3197
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3194
diff changeset
  3355
          ('C', 'copies', None, _('show copied files')),
4324
cd650cd61b06 help: log --keyword is case-insensitive
TK Soh <teekaysoh@yahoo.com>
parents: 4322
diff changeset
  3356
          ('k', 'keyword', [], _('do case-insensitive search for a keyword')),
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3357
          ('r', 'rev', [], _('show the specified revision or range')),
8028
3aaca5901ade expand "rev" to "revision" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8027
diff changeset
  3358
          ('', '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
  3359
          ('m', 'only-merges', None, _('show only merges')),
8028
3aaca5901ade expand "rev" to "revision" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8027
diff changeset
  3360
          ('u', 'user', [], _('revisions committed by user')),
6067
57c1a7052982 Option to log to only show changesets within a specified branch.
Dustin Sallings <dustin@spy.net>
parents: 6048
diff changeset
  3361
          ('b', 'only-branch', [],
57c1a7052982 Option to log to only show changesets within a specified branch.
Dustin Sallings <dustin@spy.net>
parents: 6048
diff changeset
  3362
            _('show only changesets within the given named branch')),
2901
9826af4841ef Test for log --prune.
Brendan Cully <brendan@kublai.com>
parents: 2883
diff changeset
  3363
          ('P', 'prune', [], _('do not display revision or any of its ancestors')),
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3364
         ] + logopts + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3365
         _('[OPTION]... [FILE]')),
5778
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3366
    "manifest":
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3367
        (manifest,
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3368
         [('r', 'rev', '', _('revision to display'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3369
         _('[-r REV]')),
4014
509342f95564 various doc fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4013
diff changeset
  3370
    "^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
  3371
        (merge,
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3372
         [('f', 'force', None, _('force a merge with outstanding changes')),
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3373
          ('r', 'rev', '', _('revision to merge')),
8834
6d36fc70754e merge: rename -S/--show option to -P/--preview
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8815
diff changeset
  3374
          ('P', 'preview', None,
8387
50b6af595e0c merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8366
diff changeset
  3375
           _('review revisions to merge (no merge is performed)'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3376
         _('[-f] [[-r] REV]')),
5778
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3377
    "outgoing|out":
9e97a7a0bb82 realign commands table
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5776
diff changeset
  3378
        (outgoing,
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3379
         [('f', 'force', None,
1959
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
  3380
           _('run even when remote repository 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
  3381
          ('r', 'rev', [],
d99b4e8652b3 Make clear that for a changegroup '-r' pulls "up to" a revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6299
diff changeset
  3382
           _('a specific revision up to which you would like to push')),
1907
7718885070b1 let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1800
diff changeset
  3383
          ('n', 'newest-first', None, _('show newest record first')),
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3384
         ] + logopts + remoteopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3385
         _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')),
1724
5a36609f73a7 add a -b/--branch option to 'hg parents'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1720
diff changeset
  3386
    "^parents":
5a36609f73a7 add a -b/--branch option to 'hg parents'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1720
diff changeset
  3387
        (parents,
8028
3aaca5901ade expand "rev" to "revision" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8027
diff changeset
  3388
         [('r', 'rev', '', _('show parents from the specified revision')),
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3389
         ] + templateopts,
8544
48dd8a93d6db commands: standardize parents command meta data
Ori Avtalion <ori@avtalion.name>
parents: 8540
diff changeset
  3390
         _('[-r REV] [FILE]')),
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3391
    "paths": (paths, [], _('[NAME]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3392
    "^pull":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3393
        (pull,
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  3394
         [('u', 'update', None,
3198
a32f65549b9e Documentation clarification for --update option to pull and unbundle
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3197
diff changeset
  3395
           _('update to new tip 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
  3396
          ('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
  3397
           _('run even when remote repository is unrelated')),
3885
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
  3398
          ('r', 'rev', [],
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
  3399
           _('a specific revision up to which you would like to pull')),
3190
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  3400
         ] + remoteopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3401
         _('[-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
  3402
    "^push":
eef752151556 Actually implement the -f switch for push
mpm@selenic.com
parents: 815
diff changeset
  3403
        (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
  3404
         [('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
  3405
          ('r', 'rev', [],
d99b4e8652b3 Make clear that for a changegroup '-r' pulls "up to" a revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6299
diff changeset
  3406
           _('a specific revision up to which you would like to push')),
3190
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3189
diff changeset
  3407
         ] + remoteopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3408
         _('[-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
  3409
    "recover": (recover, []),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  3410
    "^remove|rm":
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  3411
        (remove,
6346
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  3412
         [('A', 'after', None, _('record delete for missing files')),
8e3b651382f5 improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6336
diff changeset
  3413
          ('f', 'force', None,
6347
3b42f7ac6916 tiny tab cleanup
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6346
diff changeset
  3414
           _('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
  3415
         ] + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3416
         _('[OPTION]... FILE...')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  3417
    "rename|mv":
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  3418
        (rename,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
  3419
         [('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
  3420
          ('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
  3421
           _('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
  3422
         ] + walkopts + dryrunopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3423
         _('[OPTION]... SOURCE... DEST')),
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3424
    "resolve":
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3425
        (resolve,
7527
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  3426
         [('a', 'all', None, _('remerge all unresolved files')),
5a14a8f3b909 resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents: 7449
diff changeset
  3427
          ('l', 'list', None, _('list state of files needing merge')),
6518
92ccccb55ba3 resolve: new command
Matt Mackall <mpm@selenic.com>
parents: 6509
diff changeset
  3428
          ('m', 'mark', None, _('mark files as resolved')),
7765
da9acc68b1dd resolve: accepts walkopts (-I and -X)
Simon Heimberg <simohe@besonet.ch>
parents: 7763
diff changeset
  3429
          ('u', 'unmark', None, _('unmark files as resolved'))]
da9acc68b1dd resolve: accepts walkopts (-I and -X)
Simon Heimberg <simohe@besonet.ch>
parents: 7763
diff changeset
  3430
          + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3431
          _('[OPTION]... [FILE]...')),
5574
d4ec6d61b3ee imported patch rev-help
Matt Mackall <mpm@selenic.com>
parents: 5573
diff changeset
  3432
    "revert":
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3433
        (revert,
2983
3b7626b861f8 revert: add -a as alias for --all
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2982
diff changeset
  3434
         [('a', 'all', None, _('revert all changes when no arguments given')),
3814
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3813
diff changeset
  3435
          ('d', 'date', '', _('tipmost revision matching date')),
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
  3436
          ('r', 'rev', '', _('revision to revert to')),
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
  3437
          ('', '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
  3438
         ] + walkopts + dryrunopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3439
         _('[OPTION]... [-r REV] [NAME]...')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3440
    "rollback": (rollback, []),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3441
    "root": (root, []),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3442
    "^serve":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3443
        (serve,
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3444
         [('A', 'accesslog', '', _('name of access log file to write to')),
1740
f95654385065 add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1736
diff changeset
  3445
          ('d', 'daemon', None, _('run server in background')),
1742
1e5bb6c929cd Added help string for --daemon-pipefds
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1741
diff changeset
  3446
          ('', 'daemon-pipefds', '', _('used internally by daemon mode')),
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
  3447
          ('E', 'errorlog', '', _('name of error log file to write to')),
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
  3448
          ('p', 'port', 0, _('port to listen on (default: 8000)')),
de7256c82fad hgweb: clarify which address and port can/cannot be bound at startup (bug 769)
Stephen Deasey <sdeasey@gmail.com>
parents: 6253
diff changeset
  3449
          ('a', 'address', '', _('address to listen on (default: all interfaces)')),
5835
bd34f0ac3cb0 adding "prefix" option to "hg serve" (command line and [web] section)
Michele Cella <michele.cella@gmail.com>
parents: 5811
diff changeset
  3450
          ('', 'prefix', '', _('prefix path to serve from (default: server root)')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  3451
          ('n', 'name', '',
8026
683d8ebcf434 expand "dir" to "directory" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8021
diff changeset
  3452
           _('name to show in web pages (default: working directory)')),
2124
27fd8b7a6c51 Cleaned trailing whitespace in hgweb.py, removed command line shortcut for webdir-conf.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2122
diff changeset
  3453
          ('', 'webdir-conf', '', _('name of the webdir config file'
8027
9c7ca86fc658 expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents: 8026
diff changeset
  3454
                                    ' (serve more than one repository)')),
1740
f95654385065 add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1736
diff changeset
  3455
          ('', 'pid-file', '', _('name of file to write process ID to')),
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
  3456
          ('', 'stdio', None, _('for remote clients')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  3457
          ('t', 'templates', '', _('web templates to use')),
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
  3458
          ('', 'style', '', _('template style to use')),
4860
f3802f9f1840 Add SSL support to hg serve, activated via --certificate option
Brendan Cully <brendan@kublai.com>
parents: 4857
diff changeset
  3459
          ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
f3802f9f1840 Add SSL support to hg serve, activated via --certificate option
Brendan Cully <brendan@kublai.com>
parents: 4857
diff changeset
  3460
          ('', 'certificate', '', _('SSL certificate file'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3461
         _('[OPTION]...')),
5781
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  3462
    "showconfig|debugconfig":
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  3463
        (showconfig,
45d034c79ece Sort commands table again and add some missing 'hg' in synopsises.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5778
diff changeset
  3464
         [('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
  3465
         _('[-u] [NAME]...')),
1507
cd8fadd8c689 Add explicit 'st' alias for status
Matt Mackall <mpm@selenic.com>
parents: 1506
diff changeset
  3466
    "^status|st":
840
141744605b51 hg status: added options to select files by status.
tksoh@users.sourceforge.net
parents: 839
diff changeset
  3467
        (status,
2661
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
  3468
         [('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
  3469
          ('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
  3470
          ('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
  3471
          ('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
  3472
          ('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
  3473
          ('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
  3474
          ('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
  3475
          ('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
  3476
          ('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
  3477
          ('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
  3478
          ('0', 'print0', None,
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
  3479
           _('end filenames with NUL, for use with xargs')),
3467
2b3b703b3a2b Add --rev option to status
Brendan Cully <brendan@kublai.com>
parents: 3465
diff changeset
  3480
          ('', 'rev', [], _('show difference from revision')),
3188
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3187
diff changeset
  3481
         ] + walkopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3482
         _('[OPTION]... [FILE]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3483
    "tag":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3484
        (tag,
4267
8185a1ca8628 tags: require -f to replace an existing tag
Matt Mackall <mpm@selenic.com>
parents: 4247
diff changeset
  3485
         [('f', 'force', None, _('replace existing tag')),
8185a1ca8628 tags: require -f to replace an existing tag
Matt Mackall <mpm@selenic.com>
parents: 4247
diff changeset
  3486
          ('l', 'local', None, _('make the tag local')),
4213
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4179
diff changeset
  3487
          ('r', 'rev', '', _('revision to tag')),
5147
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  3488
          ('', 'remove', None, _('remove a tag')),
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  3489
          # -l/--local is already there, commitopts cannot be used
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  3490
          ('m', 'message', '', _('use <text> as commit message')),
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5125
diff changeset
  3491
         ] + commitopts2,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3492
         _('[-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3493
    "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
  3494
    "tip":
8eaa8e06a364 Add option -b/--branch to hg tip (as done for hg parents).
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1761
diff changeset
  3495
        (tip,
6192
cd65a67aff31 Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6191
diff changeset
  3496
         [('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
  3497
          ('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
  3498
         ] + templateopts,
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3499
         _('[-p]')),
1218
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
  3500
    "unbundle":
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
  3501
        (unbundle,
1601
a1b25fb2e764 Error handling for unbundle, fix option line wrapping
Matt Mackall <mpm@selenic.com>
parents: 1600
diff changeset
  3502
         [('u', 'update', None,
3198
a32f65549b9e Documentation clarification for --update option to pull and unbundle
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3197
diff changeset
  3503
           _('update to new tip if changesets were unbundled'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3504
         _('[-u] FILE...')),
593
ca3c499e94c6 Shorten help
mpm@selenic.com
parents: 592
diff changeset
  3505
    "^update|up|checkout|co":
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
  3506
        (update,
6674
3101e30fd762 update: add "(nobackup)" to help text of option --clean
Adrian Buehlmann <adrian@cadifra.com>
parents: 6673
diff changeset
  3507
         [('C', 'clean', None, _('overwrite locally modified files (no backup)')),
8855
f331de880cbb update: add --check option
Matt Mackall <mpm@selenic.com>
parents: 8849
diff changeset
  3508
          ('c', 'check', None, _('check for uncommitted changes')),
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3509
          ('d', 'date', '', _('tipmost revision matching date')),
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4445
diff changeset
  3510
          ('r', 'rev', '', _('revision'))],
7364
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3511
         _('[-C] [-d DATE] [[-r] REV]')),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3512
    "verify": (verify, []),
ad7f736f3214 help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents: 7361
diff changeset
  3513
    "version": (version_, []),
1046
772507daaa17 Sort global options by topic: directories, ui, timing, other
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1044
diff changeset
  3514
}
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
  3515
7880
7ca2be800804 add debugcommands command: an easy to parse command + option index
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7875
diff changeset
  3516
norepo = ("clone init version help debugcommands debugcomplete debugdata"
5741
8ee0de123989 add debugfsinfo to check fs capabilities
Matt Mackall <mpm@selenic.com>
parents: 5716
diff changeset
  3517
          " debugindex debugindexdot debugdate debuginstall debugfsinfo")
6189
81cbb5dfdec0 Make hg debugancestor accept -R by making it an optionalrepo command.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6188
diff changeset
  3518
optionalrepo = ("identify paths serve showconfig debugancestor")