author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
Tue, 17 Jul 2007 09:08:29 -0300 | |
changeset 4894 | be5dc5e3ab2d |
parent 4836 | 0e2d0a78f81a |
child 4906 | 30847b8af7ca |
child 4962 | 10afa3fab6b4 |
permissions | -rw-r--r-- |
2957 | 1 |
# cmdutil.py - help for command processing in mercurial |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
2 |
# |
4635
63b9d2deed48
Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4633
diff
changeset
|
3 |
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
4 |
# |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
5 |
# This software may be used and distributed according to the terms |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
6 |
# of the GNU General Public License, incorporated herein by reference. |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
7 |
|
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
8 |
from node import * |
3891 | 9 |
from i18n import _ |
4563
8044be585b91
dispatch: restore a dropped shlex import
Brendan Cully <brendan@kublai.com>
parents:
4557
diff
changeset
|
10 |
import os, sys, atexit, signal, pdb, traceback, socket, errno, shlex |
4598
b25ee3f8f714
cmdutil: add missing "time" import.
Patrick Mezard <pmezard@gmail.com>
parents:
4573
diff
changeset
|
11 |
import mdiff, bdiff, util, templater, patch, commands, hg, lock, time |
4630
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4621
diff
changeset
|
12 |
import fancyopts, revlog, version, extensions, hook |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
13 |
|
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
14 |
revrangesep = ':' |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
15 |
|
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
16 |
class UnknownCommand(Exception): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
17 |
"""Exception raised if command is not in the command table.""" |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
18 |
class AmbiguousCommand(Exception): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
19 |
"""Exception raised if command shortcut matches more than one command.""" |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
20 |
class ParseError(Exception): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
21 |
"""Exception raised on errors in parsing the command line.""" |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
22 |
|
4686
849f011dbf79
Remember path to 'hg' executable and pass to external tools and hooks as $HG.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4671
diff
changeset
|
23 |
def runcatch(ui, args, argv0=None): |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
24 |
def catchterm(*args): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
25 |
raise util.SignalInterrupt |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
26 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
27 |
for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
28 |
num = getattr(signal, name, None) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
29 |
if num: signal.signal(num, catchterm) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
30 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
31 |
try: |
4550
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
32 |
try: |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
33 |
# enter the debugger before command execution |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
34 |
if '--debugger' in args: |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
35 |
pdb.set_trace() |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
36 |
try: |
4686
849f011dbf79
Remember path to 'hg' executable and pass to external tools and hooks as $HG.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4671
diff
changeset
|
37 |
return dispatch(ui, args, argv0=argv0) |
4550
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
38 |
finally: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
39 |
ui.flush() |
4550
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
40 |
except: |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
41 |
# enter the debugger when we hit an exception |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
42 |
if '--debugger' in args: |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
43 |
pdb.post_mortem(sys.exc_info()[2]) |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
44 |
ui.print_exc() |
4550
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
45 |
raise |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
46 |
|
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
47 |
except ParseError, inst: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
48 |
if inst.args[0]: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
49 |
ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1])) |
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
50 |
commands.help_(ui, inst.args[0]) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
51 |
else: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
52 |
ui.warn(_("hg: %s\n") % inst.args[1]) |
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
53 |
commands.help_(ui, 'shortlist') |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
54 |
except AmbiguousCommand, inst: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
55 |
ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") % |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
56 |
(inst.args[0], " ".join(inst.args[1]))) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
57 |
except UnknownCommand, inst: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
58 |
ui.warn(_("hg: unknown command '%s'\n") % inst.args[0]) |
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
59 |
commands.help_(ui, 'shortlist') |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
60 |
except hg.RepoError, inst: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
61 |
ui.warn(_("abort: %s!\n") % inst) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
62 |
except lock.LockHeld, inst: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
63 |
if inst.errno == errno.ETIMEDOUT: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
64 |
reason = _('timed out waiting for lock held by %s') % inst.locker |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
65 |
else: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
66 |
reason = _('lock held by %s') % inst.locker |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
67 |
ui.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason)) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
68 |
except lock.LockUnavailable, inst: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
69 |
ui.warn(_("abort: could not lock %s: %s\n") % |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
70 |
(inst.desc or inst.filename, inst.strerror)) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
71 |
except revlog.RevlogError, inst: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
72 |
ui.warn(_("abort: %s!\n") % inst) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
73 |
except util.SignalInterrupt: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
74 |
ui.warn(_("killed!\n")) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
75 |
except KeyboardInterrupt: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
76 |
try: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
77 |
ui.warn(_("interrupted!\n")) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
78 |
except IOError, inst: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
79 |
if inst.errno == errno.EPIPE: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
80 |
if ui.debugflag: |
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
81 |
ui.warn(_("\nbroken pipe\n")) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
82 |
else: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
83 |
raise |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
84 |
except socket.error, inst: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
85 |
ui.warn(_("abort: %s\n") % inst[1]) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
86 |
except IOError, inst: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
87 |
if hasattr(inst, "code"): |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
88 |
ui.warn(_("abort: %s\n") % inst) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
89 |
elif hasattr(inst, "reason"): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
90 |
try: # usually it is in the form (errno, strerror) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
91 |
reason = inst.reason.args[1] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
92 |
except: # it might be anything, for example a string |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
93 |
reason = inst.reason |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
94 |
ui.warn(_("abort: error: %s\n") % reason) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
95 |
elif hasattr(inst, "args") and inst[0] == errno.EPIPE: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
96 |
if ui.debugflag: |
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
97 |
ui.warn(_("broken pipe\n")) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
98 |
elif getattr(inst, "strerror", None): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
99 |
if getattr(inst, "filename", None): |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
100 |
ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
101 |
else: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
102 |
ui.warn(_("abort: %s\n") % inst.strerror) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
103 |
else: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
104 |
raise |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
105 |
except OSError, inst: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
106 |
if getattr(inst, "filename", None): |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
107 |
ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
108 |
else: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
109 |
ui.warn(_("abort: %s\n") % inst.strerror) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
110 |
except util.UnexpectedOutput, inst: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
111 |
ui.warn(_("abort: %s") % inst[0]) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
112 |
if not isinstance(inst[1], basestring): |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
113 |
ui.warn(" %r\n" % (inst[1],)) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
114 |
elif not inst[1]: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
115 |
ui.warn(_(" empty string\n")) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
116 |
else: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
117 |
ui.warn("\n%r\n" % util.ellipsis(inst[1])) |
4632
8d46056960ab
dispatch: report failed imports nicely
Matt Mackall <mpm@selenic.com>
parents:
4630
diff
changeset
|
118 |
except ImportError, inst: |
8d46056960ab
dispatch: report failed imports nicely
Matt Mackall <mpm@selenic.com>
parents:
4630
diff
changeset
|
119 |
m = str(inst).split()[-1] |
8d46056960ab
dispatch: report failed imports nicely
Matt Mackall <mpm@selenic.com>
parents:
4630
diff
changeset
|
120 |
ui.warn(_("abort: could not import module %s!\n" % m)) |
8d46056960ab
dispatch: report failed imports nicely
Matt Mackall <mpm@selenic.com>
parents:
4630
diff
changeset
|
121 |
if m in "mpatch bdiff".split(): |
8d46056960ab
dispatch: report failed imports nicely
Matt Mackall <mpm@selenic.com>
parents:
4630
diff
changeset
|
122 |
ui.warn(_("(did you forget to compile extensions?)\n")) |
8d46056960ab
dispatch: report failed imports nicely
Matt Mackall <mpm@selenic.com>
parents:
4630
diff
changeset
|
123 |
elif m in "zlib".split(): |
8d46056960ab
dispatch: report failed imports nicely
Matt Mackall <mpm@selenic.com>
parents:
4630
diff
changeset
|
124 |
ui.warn(_("(is your Python install correct?)\n")) |
4633
ff7253a0d1da
Cleanup of whitespace, indentation and line continuation.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4632
diff
changeset
|
125 |
|
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
126 |
except util.Abort, inst: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
127 |
ui.warn(_("abort: %s\n") % inst) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
128 |
except SystemExit, inst: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
129 |
# Commands shouldn't sys.exit directly, but give a return code. |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
130 |
# Just in case catch this and and pass exit code to caller. |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
131 |
return inst.code |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
132 |
except: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
133 |
ui.warn(_("** unknown exception encountered, details follow\n")) |
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
134 |
ui.warn(_("** report bug details to " |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
135 |
"http://www.selenic.com/mercurial/bts\n")) |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
136 |
ui.warn(_("** or mercurial@selenic.com\n")) |
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
137 |
ui.warn(_("** Mercurial Distributed SCM (version %s)\n") |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
138 |
% version.get_version()) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
139 |
raise |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
140 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
141 |
return -1 |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
142 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
143 |
def findpossible(ui, cmd): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
144 |
""" |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
145 |
Return cmd -> (aliases, command table entry) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
146 |
for each matching command. |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
147 |
Return debug commands (or their aliases) only if no normal command matches. |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
148 |
""" |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
149 |
choice = {} |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
150 |
debugchoice = {} |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
151 |
for e in commands.table.keys(): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
152 |
aliases = e.lstrip("^").split("|") |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
153 |
found = None |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
154 |
if cmd in aliases: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
155 |
found = cmd |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
156 |
elif not ui.config("ui", "strict"): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
157 |
for a in aliases: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
158 |
if a.startswith(cmd): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
159 |
found = a |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
160 |
break |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
161 |
if found is not None: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
162 |
if aliases[0].startswith("debug") or found.startswith("debug"): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
163 |
debugchoice[found] = (aliases, commands.table[e]) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
164 |
else: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
165 |
choice[found] = (aliases, commands.table[e]) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
166 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
167 |
if not choice and debugchoice: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
168 |
choice = debugchoice |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
169 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
170 |
return choice |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
171 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
172 |
def findcmd(ui, cmd): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
173 |
"""Return (aliases, command table entry) for command string.""" |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
174 |
choice = findpossible(ui, cmd) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
175 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
176 |
if choice.has_key(cmd): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
177 |
return choice[cmd] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
178 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
179 |
if len(choice) > 1: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
180 |
clist = choice.keys() |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
181 |
clist.sort() |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
182 |
raise AmbiguousCommand(cmd, clist) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
183 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
184 |
if choice: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
185 |
return choice.values()[0] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
186 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
187 |
raise UnknownCommand(cmd) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
188 |
|
4556
30bc57094bfc
dispatch: move findrepo to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4555
diff
changeset
|
189 |
def findrepo(): |
30bc57094bfc
dispatch: move findrepo to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4555
diff
changeset
|
190 |
p = os.getcwd() |
30bc57094bfc
dispatch: move findrepo to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4555
diff
changeset
|
191 |
while not os.path.isdir(os.path.join(p, ".hg")): |
30bc57094bfc
dispatch: move findrepo to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4555
diff
changeset
|
192 |
oldp, p = p, os.path.dirname(p) |
30bc57094bfc
dispatch: move findrepo to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4555
diff
changeset
|
193 |
if p == oldp: |
30bc57094bfc
dispatch: move findrepo to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4555
diff
changeset
|
194 |
return None |
30bc57094bfc
dispatch: move findrepo to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4555
diff
changeset
|
195 |
|
30bc57094bfc
dispatch: move findrepo to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4555
diff
changeset
|
196 |
return p |
30bc57094bfc
dispatch: move findrepo to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4555
diff
changeset
|
197 |
|
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
198 |
def parse(ui, args): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
199 |
options = {} |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
200 |
cmdoptions = {} |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
201 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
202 |
try: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
203 |
args = fancyopts.fancyopts(args, commands.globalopts, options) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
204 |
except fancyopts.getopt.GetoptError, inst: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
205 |
raise ParseError(None, inst) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
206 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
207 |
if args: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
208 |
cmd, args = args[0], args[1:] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
209 |
aliases, i = findcmd(ui, cmd) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
210 |
cmd = aliases[0] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
211 |
defaults = ui.config("defaults", cmd) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
212 |
if defaults: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
213 |
args = shlex.split(defaults) + args |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
214 |
c = list(i[1]) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
215 |
else: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
216 |
cmd = None |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
217 |
c = [] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
218 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
219 |
# combine global options into local |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
220 |
for o in commands.globalopts: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
221 |
c.append((o[0], o[1], options[o[1]], o[3])) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
222 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
223 |
try: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
224 |
args = fancyopts.fancyopts(args, c, cmdoptions) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
225 |
except fancyopts.getopt.GetoptError, inst: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
226 |
raise ParseError(cmd, inst) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
227 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
228 |
# separate global options back out |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
229 |
for o in commands.globalopts: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
230 |
n = o[1] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
231 |
options[n] = cmdoptions[n] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
232 |
del cmdoptions[n] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
233 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
234 |
return (cmd, cmd and i[0] or None, args, options, cmdoptions) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
235 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
236 |
def parseconfig(config): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
237 |
"""parse the --config options from the command line""" |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
238 |
parsed = [] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
239 |
for cfg in config: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
240 |
try: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
241 |
name, value = cfg.split('=', 1) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
242 |
section, name = name.split('.', 1) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
243 |
if not section or not name: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
244 |
raise IndexError |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
245 |
parsed.append((section, name, value)) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
246 |
except (IndexError, ValueError): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
247 |
raise util.Abort(_('malformed --config option: %s') % cfg) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
248 |
return parsed |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
249 |
|
4552
38cdee6b6675
dispatch: parse and apply cwd opt early
Matt Mackall <mpm@selenic.com>
parents:
4551
diff
changeset
|
250 |
def earlygetopt(aliases, args): |
4733
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
251 |
"""Return list of values for an option (or aliases). |
4727
79cc512a34ed
Fix earlygetop for short options with unnecessary spaces removed
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4717
diff
changeset
|
252 |
|
4733
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
253 |
The values are listed in the order they appear in args. |
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
254 |
The options and values are removed from args. |
4727
79cc512a34ed
Fix earlygetop for short options with unnecessary spaces removed
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4717
diff
changeset
|
255 |
""" |
4716
36d23de02da1
Make earlygetopt return a list of all option values, use the last value.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4714
diff
changeset
|
256 |
try: |
36d23de02da1
Make earlygetopt return a list of all option values, use the last value.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4714
diff
changeset
|
257 |
argcount = args.index("--") |
36d23de02da1
Make earlygetopt return a list of all option values, use the last value.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4714
diff
changeset
|
258 |
except ValueError: |
36d23de02da1
Make earlygetopt return a list of all option values, use the last value.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4714
diff
changeset
|
259 |
argcount = len(args) |
4733
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
260 |
shortopts = [opt for opt in aliases if len(opt) == 2] |
4716
36d23de02da1
Make earlygetopt return a list of all option values, use the last value.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4714
diff
changeset
|
261 |
values = [] |
36d23de02da1
Make earlygetopt return a list of all option values, use the last value.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4714
diff
changeset
|
262 |
pos = 0 |
36d23de02da1
Make earlygetopt return a list of all option values, use the last value.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4714
diff
changeset
|
263 |
while pos < argcount: |
4733
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
264 |
if args[pos] in aliases: |
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
265 |
if pos + 1 >= argcount: |
4716
36d23de02da1
Make earlygetopt return a list of all option values, use the last value.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4714
diff
changeset
|
266 |
# ignore and let getopt report an error if there is no value |
4733
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
267 |
break |
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
268 |
del args[pos] |
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
269 |
values.append(args.pop(pos)) |
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
270 |
argcount -= 2 |
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
271 |
elif args[pos][:2] in shortopts: |
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
272 |
# short option can have no following space, e.g. hg log -Rfoo |
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
273 |
values.append(args.pop(pos)[2:]) |
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
274 |
argcount -= 1 |
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
275 |
else: |
0ecfc3b3f072
Simplified earlygetopt and made it remove parsed options and values.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4732
diff
changeset
|
276 |
pos += 1 |
4716
36d23de02da1
Make earlygetopt return a list of all option values, use the last value.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4714
diff
changeset
|
277 |
return values |
4552
38cdee6b6675
dispatch: parse and apply cwd opt early
Matt Mackall <mpm@selenic.com>
parents:
4551
diff
changeset
|
278 |
|
4686
849f011dbf79
Remember path to 'hg' executable and pass to external tools and hooks as $HG.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4671
diff
changeset
|
279 |
def dispatch(ui, args, argv0=None): |
849f011dbf79
Remember path to 'hg' executable and pass to external tools and hooks as $HG.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4671
diff
changeset
|
280 |
# remember how to call 'hg' before changing the working dir |
849f011dbf79
Remember path to 'hg' executable and pass to external tools and hooks as $HG.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4671
diff
changeset
|
281 |
util.set_hgexecutable(argv0) |
849f011dbf79
Remember path to 'hg' executable and pass to external tools and hooks as $HG.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4671
diff
changeset
|
282 |
|
4717
97369f6a6bb6
New config option: ui.report_untrusted (defaults to True)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4716
diff
changeset
|
283 |
# read --config before doing anything else |
97369f6a6bb6
New config option: ui.report_untrusted (defaults to True)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4716
diff
changeset
|
284 |
# (e.g. to change trust settings for reading .hg/hgrc) |
97369f6a6bb6
New config option: ui.report_untrusted (defaults to True)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4716
diff
changeset
|
285 |
config = earlygetopt(['--config'], args) |
97369f6a6bb6
New config option: ui.report_untrusted (defaults to True)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4716
diff
changeset
|
286 |
if config: |
97369f6a6bb6
New config option: ui.report_untrusted (defaults to True)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4716
diff
changeset
|
287 |
ui.updateopts(config=parseconfig(config)) |
97369f6a6bb6
New config option: ui.report_untrusted (defaults to True)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4716
diff
changeset
|
288 |
|
97369f6a6bb6
New config option: ui.report_untrusted (defaults to True)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4716
diff
changeset
|
289 |
# check for cwd |
4552
38cdee6b6675
dispatch: parse and apply cwd opt early
Matt Mackall <mpm@selenic.com>
parents:
4551
diff
changeset
|
290 |
cwd = earlygetopt(['--cwd'], args) |
38cdee6b6675
dispatch: parse and apply cwd opt early
Matt Mackall <mpm@selenic.com>
parents:
4551
diff
changeset
|
291 |
if cwd: |
4716
36d23de02da1
Make earlygetopt return a list of all option values, use the last value.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4714
diff
changeset
|
292 |
os.chdir(cwd[-1]) |
4552
38cdee6b6675
dispatch: parse and apply cwd opt early
Matt Mackall <mpm@selenic.com>
parents:
4551
diff
changeset
|
293 |
|
4555
1843d31bfdbf
localrepo: don't search from path
Matt Mackall <mpm@selenic.com>
parents:
4554
diff
changeset
|
294 |
# read the local repository .hgrc into a local ui object |
4670
850950e59b52
dispatch: parse local hgrc for paths
Matt Mackall <mpm@selenic.com>
parents:
4667
diff
changeset
|
295 |
path = findrepo() or "" |
4555
1843d31bfdbf
localrepo: don't search from path
Matt Mackall <mpm@selenic.com>
parents:
4554
diff
changeset
|
296 |
if not path: |
4670
850950e59b52
dispatch: parse local hgrc for paths
Matt Mackall <mpm@selenic.com>
parents:
4667
diff
changeset
|
297 |
lui = ui |
4554
9dbabb9d466c
dispatch: use the repo path found by early parsing
Matt Mackall <mpm@selenic.com>
parents:
4553
diff
changeset
|
298 |
if path: |
4553
741f64dfc04d
dispatch: parse and apply -R early
Matt Mackall <mpm@selenic.com>
parents:
4552
diff
changeset
|
299 |
try: |
741f64dfc04d
dispatch: parse and apply -R early
Matt Mackall <mpm@selenic.com>
parents:
4552
diff
changeset
|
300 |
lui = commands.ui.ui(parentui=ui) |
4554
9dbabb9d466c
dispatch: use the repo path found by early parsing
Matt Mackall <mpm@selenic.com>
parents:
4553
diff
changeset
|
301 |
lui.readconfig(os.path.join(path, ".hg", "hgrc")) |
4553
741f64dfc04d
dispatch: parse and apply -R early
Matt Mackall <mpm@selenic.com>
parents:
4552
diff
changeset
|
302 |
except IOError: |
4619
5fd7cc897542
encoding: pull fallbackencoding out of localrepo into early parsing
Matt Mackall <mpm@selenic.com>
parents:
4618
diff
changeset
|
303 |
pass |
5fd7cc897542
encoding: pull fallbackencoding out of localrepo into early parsing
Matt Mackall <mpm@selenic.com>
parents:
4618
diff
changeset
|
304 |
|
4670
850950e59b52
dispatch: parse local hgrc for paths
Matt Mackall <mpm@selenic.com>
parents:
4667
diff
changeset
|
305 |
# now we can expand paths, even ones in .hg/hgrc |
850950e59b52
dispatch: parse local hgrc for paths
Matt Mackall <mpm@selenic.com>
parents:
4667
diff
changeset
|
306 |
rpath = earlygetopt(["-R", "--repository", "--repo"], args) |
850950e59b52
dispatch: parse local hgrc for paths
Matt Mackall <mpm@selenic.com>
parents:
4667
diff
changeset
|
307 |
if rpath: |
4716
36d23de02da1
Make earlygetopt return a list of all option values, use the last value.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4714
diff
changeset
|
308 |
path = lui.expandpath(rpath[-1]) |
4670
850950e59b52
dispatch: parse local hgrc for paths
Matt Mackall <mpm@selenic.com>
parents:
4667
diff
changeset
|
309 |
lui = commands.ui.ui(parentui=ui) |
850950e59b52
dispatch: parse local hgrc for paths
Matt Mackall <mpm@selenic.com>
parents:
4667
diff
changeset
|
310 |
lui.readconfig(os.path.join(path, ".hg", "hgrc")) |
850950e59b52
dispatch: parse local hgrc for paths
Matt Mackall <mpm@selenic.com>
parents:
4667
diff
changeset
|
311 |
|
4619
5fd7cc897542
encoding: pull fallbackencoding out of localrepo into early parsing
Matt Mackall <mpm@selenic.com>
parents:
4618
diff
changeset
|
312 |
extensions.loadall(lui) |
5fd7cc897542
encoding: pull fallbackencoding out of localrepo into early parsing
Matt Mackall <mpm@selenic.com>
parents:
4618
diff
changeset
|
313 |
# check for fallback encoding |
5fd7cc897542
encoding: pull fallbackencoding out of localrepo into early parsing
Matt Mackall <mpm@selenic.com>
parents:
4618
diff
changeset
|
314 |
fallback = lui.config('ui', 'fallbackencoding') |
5fd7cc897542
encoding: pull fallbackencoding out of localrepo into early parsing
Matt Mackall <mpm@selenic.com>
parents:
4618
diff
changeset
|
315 |
if fallback: |
5fd7cc897542
encoding: pull fallbackencoding out of localrepo into early parsing
Matt Mackall <mpm@selenic.com>
parents:
4618
diff
changeset
|
316 |
util._fallbackencoding = fallback |
4553
741f64dfc04d
dispatch: parse and apply -R early
Matt Mackall <mpm@selenic.com>
parents:
4552
diff
changeset
|
317 |
|
4630
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4621
diff
changeset
|
318 |
fullargs = args |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
319 |
cmd, func, args, options, cmdoptions = parse(ui, args) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
320 |
|
4734
9ac493f12901
Abort if earlygetopt fails to detect an option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4733
diff
changeset
|
321 |
if options["config"]: |
9ac493f12901
Abort if earlygetopt fails to detect an option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4733
diff
changeset
|
322 |
raise util.Abort(_("Option --config may not be abbreviated!")) |
9ac493f12901
Abort if earlygetopt fails to detect an option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4733
diff
changeset
|
323 |
if options["cwd"]: |
9ac493f12901
Abort if earlygetopt fails to detect an option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4733
diff
changeset
|
324 |
raise util.Abort(_("Option --cwd may not be abbreviated!")) |
9ac493f12901
Abort if earlygetopt fails to detect an option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4733
diff
changeset
|
325 |
if options["repository"]: |
9ac493f12901
Abort if earlygetopt fails to detect an option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4733
diff
changeset
|
326 |
raise util.Abort(_( |
9ac493f12901
Abort if earlygetopt fails to detect an option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4733
diff
changeset
|
327 |
"Option -R has to be separated from other options (i.e. not -qR) " |
9ac493f12901
Abort if earlygetopt fails to detect an option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4733
diff
changeset
|
328 |
"and --repository may only be abbreviated as --repo!")) |
9ac493f12901
Abort if earlygetopt fails to detect an option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4733
diff
changeset
|
329 |
|
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
330 |
if options["encoding"]: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
331 |
util._encoding = options["encoding"] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
332 |
if options["encodingmode"]: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
333 |
util._encodingmode = options["encodingmode"] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
334 |
if options["time"]: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
335 |
def get_times(): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
336 |
t = os.times() |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
337 |
if t[4] == 0.0: # Windows leaves this as zero, so use time.clock() |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
338 |
t = (t[0], t[1], t[2], t[3], time.clock()) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
339 |
return t |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
340 |
s = get_times() |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
341 |
def print_time(): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
342 |
t = get_times() |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
343 |
ui.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
344 |
(t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
345 |
atexit.register(print_time) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
346 |
|
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
347 |
ui.updateopts(options["verbose"], options["debug"], options["quiet"], |
4717
97369f6a6bb6
New config option: ui.report_untrusted (defaults to True)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4716
diff
changeset
|
348 |
not options["noninteractive"], options["traceback"]) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
349 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
350 |
if options['help']: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
351 |
return commands.help_(ui, cmd, options['version']) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
352 |
elif options['version']: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
353 |
return commands.version_(ui) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
354 |
elif not cmd: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
355 |
return commands.help_(ui, 'shortlist') |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
356 |
|
4630
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4621
diff
changeset
|
357 |
repo = None |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
358 |
if cmd not in commands.norepo.split(): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
359 |
try: |
4554
9dbabb9d466c
dispatch: use the repo path found by early parsing
Matt Mackall <mpm@selenic.com>
parents:
4553
diff
changeset
|
360 |
repo = hg.repository(ui, path=path) |
4555
1843d31bfdbf
localrepo: don't search from path
Matt Mackall <mpm@selenic.com>
parents:
4554
diff
changeset
|
361 |
ui = repo.ui |
4671
150afe6becf6
identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents:
4670
diff
changeset
|
362 |
if not repo.local(): |
4554
9dbabb9d466c
dispatch: use the repo path found by early parsing
Matt Mackall <mpm@selenic.com>
parents:
4553
diff
changeset
|
363 |
raise util.Abort(_("repository '%s' is not local") % path) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
364 |
except hg.RepoError: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
365 |
if cmd not in commands.optionalrepo.split(): |
4654
e0e73ba37983
Fix dispatch error message when not in a repo
Brendan Cully <brendan@kublai.com>
parents:
4635
diff
changeset
|
366 |
if not path: |
e0e73ba37983
Fix dispatch error message when not in a repo
Brendan Cully <brendan@kublai.com>
parents:
4635
diff
changeset
|
367 |
raise hg.RepoError(_("There is no Mercurial repository here" |
e0e73ba37983
Fix dispatch error message when not in a repo
Brendan Cully <brendan@kublai.com>
parents:
4635
diff
changeset
|
368 |
" (.hg not found)")) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
369 |
raise |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
370 |
d = lambda: func(ui, repo, *args, **cmdoptions) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
371 |
else: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
372 |
d = lambda: func(ui, *args, **cmdoptions) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
373 |
|
4630
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4621
diff
changeset
|
374 |
# run pre-hook, and abort if it fails |
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4621
diff
changeset
|
375 |
ret = hook.hook(ui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs)) |
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4621
diff
changeset
|
376 |
if ret: |
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4621
diff
changeset
|
377 |
return ret |
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4621
diff
changeset
|
378 |
ret = runcommand(ui, options, cmd, d) |
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4621
diff
changeset
|
379 |
# run post-hook, passing command result |
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4621
diff
changeset
|
380 |
hook.hook(ui, repo, "post-%s" % cmd, False, args=" ".join(fullargs), |
4633
ff7253a0d1da
Cleanup of whitespace, indentation and line continuation.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4632
diff
changeset
|
381 |
result = ret) |
4630
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4621
diff
changeset
|
382 |
return ret |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
383 |
|
4621
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
384 |
def runcommand(ui, options, cmd, cmdfunc): |
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
385 |
def checkargs(): |
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
386 |
try: |
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
387 |
return cmdfunc() |
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
388 |
except TypeError, inst: |
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
389 |
# was this an argument error? |
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
390 |
tb = traceback.extract_tb(sys.exc_info()[2]) |
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
391 |
if len(tb) != 2: # no |
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
392 |
raise |
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
393 |
raise ParseError(cmd, _("invalid arguments")) |
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
394 |
|
4550
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
395 |
if options['profile']: |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
396 |
import hotshot, hotshot.stats |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
397 |
prof = hotshot.Profile("hg.prof") |
4548
c9fcebbfc422
dispatch: move runcommand to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4525
diff
changeset
|
398 |
try: |
4550
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
399 |
try: |
4621
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
400 |
return prof.runcall(checkargs) |
4550
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
401 |
except: |
4548
c9fcebbfc422
dispatch: move runcommand to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4525
diff
changeset
|
402 |
try: |
4551
61e33f1d44a8
dispatch: rename variables after code motion
Matt Mackall <mpm@selenic.com>
parents:
4550
diff
changeset
|
403 |
ui.warn(_('exception raised - generating ' |
4550
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
404 |
'profile anyway\n')) |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
405 |
except: |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
406 |
pass |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
407 |
raise |
4548
c9fcebbfc422
dispatch: move runcommand to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4525
diff
changeset
|
408 |
finally: |
4550
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
409 |
prof.close() |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
410 |
stats = hotshot.stats.load("hg.prof") |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
411 |
stats.strip_dirs() |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
412 |
stats.sort_stats('time', 'calls') |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
413 |
stats.print_stats(40) |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
414 |
elif options['lsprof']: |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
415 |
try: |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
416 |
from mercurial import lsprof |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
417 |
except ImportError: |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
418 |
raise util.Abort(_( |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
419 |
'lsprof not available - install from ' |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
420 |
'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/')) |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
421 |
p = lsprof.Profiler() |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
422 |
p.enable(subcalls=True) |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
423 |
try: |
4621
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
424 |
return checkargs() |
4550
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
425 |
finally: |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
426 |
p.disable() |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
427 |
stats = lsprof.Stats(p.getstats()) |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
428 |
stats.sort() |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
429 |
stats.pprint(top=10, file=sys.stderr, climit=5) |
6ed91894261e
dispatch: hoist debugging hook to runcatch
Matt Mackall <mpm@selenic.com>
parents:
4549
diff
changeset
|
430 |
else: |
4621
6fc26982f203
dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents:
4619
diff
changeset
|
431 |
return checkargs() |
4548
c9fcebbfc422
dispatch: move runcommand to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4525
diff
changeset
|
432 |
|
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
433 |
def bail_if_changed(repo): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
434 |
modified, added, removed, deleted = repo.status()[:4] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
435 |
if modified or added or removed or deleted: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
436 |
raise util.Abort(_("outstanding uncommitted changes")) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
437 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
438 |
def logmessage(opts): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
439 |
""" get the log message according to -m and -l option """ |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
440 |
message = opts['message'] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
441 |
logfile = opts['logfile'] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
442 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
443 |
if message and logfile: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
444 |
raise util.Abort(_('options --message and --logfile are mutually ' |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
445 |
'exclusive')) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
446 |
if not message and logfile: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
447 |
try: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
448 |
if logfile == '-': |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
449 |
message = sys.stdin.read() |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
450 |
else: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
451 |
message = open(logfile).read() |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
452 |
except IOError, inst: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
453 |
raise util.Abort(_("can't read commit message '%s': %s") % |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
454 |
(logfile, inst.strerror)) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
455 |
return message |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
456 |
|
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
457 |
def setremoteconfig(ui, opts): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
458 |
"copy remote options to ui tree" |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
459 |
if opts.get('ssh'): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
460 |
ui.setconfig("ui", "ssh", opts['ssh']) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
461 |
if opts.get('remotecmd'): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
462 |
ui.setconfig("ui", "remotecmd", opts['remotecmd']) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
463 |
|
4478
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4472
diff
changeset
|
464 |
def parseurl(url, revs): |
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4472
diff
changeset
|
465 |
'''parse url#branch, returning url, branch + revs''' |
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4472
diff
changeset
|
466 |
|
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4472
diff
changeset
|
467 |
if '#' not in url: |
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4472
diff
changeset
|
468 |
return url, (revs or None) |
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4472
diff
changeset
|
469 |
|
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4472
diff
changeset
|
470 |
url, rev = url.split('#', 1) |
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4472
diff
changeset
|
471 |
return url, revs + [rev] |
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4472
diff
changeset
|
472 |
|
3707
67f44b825784
Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3673
diff
changeset
|
473 |
def revpair(repo, revs): |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
474 |
'''return pair of nodes, given list of revisions. second item can |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
475 |
be None, meaning use working dir.''' |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
476 |
|
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
477 |
def revfix(repo, val, defval): |
3825
000d122071b5
fix hg diff -r ''
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3814
diff
changeset
|
478 |
if not val and val != 0 and defval is not None: |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
479 |
val = defval |
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
480 |
return repo.lookup(val) |
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
481 |
|
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
482 |
if not revs: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
483 |
return repo.dirstate.parents()[0], None |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
484 |
end = None |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
485 |
if len(revs) == 1: |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
486 |
if revrangesep in revs[0]: |
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
487 |
start, end = revs[0].split(revrangesep, 1) |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
488 |
start = revfix(repo, start, 0) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
489 |
end = revfix(repo, end, repo.changelog.count() - 1) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
490 |
else: |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
491 |
start = revfix(repo, revs[0], None) |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
492 |
elif len(revs) == 2: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
493 |
if revrangesep in revs[0] or revrangesep in revs[1]: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
494 |
raise util.Abort(_('too many revisions specified')) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
495 |
start = revfix(repo, revs[0], None) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
496 |
end = revfix(repo, revs[1], None) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
497 |
else: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
498 |
raise util.Abort(_('too many revisions specified')) |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
499 |
return start, end |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
500 |
|
3707
67f44b825784
Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3673
diff
changeset
|
501 |
def revrange(repo, revs): |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
502 |
"""Yield revision as strings from a list of revision specifications.""" |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
503 |
|
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
504 |
def revfix(repo, val, defval): |
3718
7db88b094b14
fix hg log -r ''
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3707
diff
changeset
|
505 |
if not val and val != 0 and defval is not None: |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
506 |
return defval |
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
507 |
return repo.changelog.rev(repo.lookup(val)) |
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
508 |
|
3526
68341c06bc61
Make revrange return a list of ints so that callers don't have to convert
Matt Mackall <mpm@selenic.com>
parents:
3525
diff
changeset
|
509 |
seen, l = {}, [] |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
510 |
for spec in revs: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
511 |
if revrangesep in spec: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
512 |
start, end = spec.split(revrangesep, 1) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
513 |
start = revfix(repo, start, 0) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
514 |
end = revfix(repo, end, repo.changelog.count() - 1) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
515 |
step = start > end and -1 or 1 |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
516 |
for rev in xrange(start, end+step, step): |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
517 |
if rev in seen: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
518 |
continue |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
519 |
seen[rev] = 1 |
3526
68341c06bc61
Make revrange return a list of ints so that callers don't have to convert
Matt Mackall <mpm@selenic.com>
parents:
3525
diff
changeset
|
520 |
l.append(rev) |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
521 |
else: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
522 |
rev = revfix(repo, spec, None) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
523 |
if rev in seen: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
524 |
continue |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
525 |
seen[rev] = 1 |
3526
68341c06bc61
Make revrange return a list of ints so that callers don't have to convert
Matt Mackall <mpm@selenic.com>
parents:
3525
diff
changeset
|
526 |
l.append(rev) |
68341c06bc61
Make revrange return a list of ints so that callers don't have to convert
Matt Mackall <mpm@selenic.com>
parents:
3525
diff
changeset
|
527 |
|
68341c06bc61
Make revrange return a list of ints so that callers don't have to convert
Matt Mackall <mpm@selenic.com>
parents:
3525
diff
changeset
|
528 |
return l |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
529 |
|
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
530 |
def make_filename(repo, pat, node, |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
531 |
total=None, seqno=None, revwidth=None, pathname=None): |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
532 |
node_expander = { |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
533 |
'H': lambda: hex(node), |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
534 |
'R': lambda: str(repo.changelog.rev(node)), |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
535 |
'h': lambda: short(node), |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
536 |
} |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
537 |
expander = { |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
538 |
'%': lambda: '%', |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
539 |
'b': lambda: os.path.basename(repo.root), |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
540 |
} |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
541 |
|
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
542 |
try: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
543 |
if node: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
544 |
expander.update(node_expander) |
4836
0e2d0a78f81a
archive: make the %r escape work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4825
diff
changeset
|
545 |
if node: |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
546 |
expander['r'] = (lambda: |
4836
0e2d0a78f81a
archive: make the %r escape work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4825
diff
changeset
|
547 |
str(repo.changelog.rev(node)).zfill(revwidth or 0)) |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
548 |
if total is not None: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
549 |
expander['N'] = lambda: str(total) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
550 |
if seqno is not None: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
551 |
expander['n'] = lambda: str(seqno) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
552 |
if total is not None and seqno is not None: |
3673
eb0b4a2d70a9
white space and line break cleanups
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3657
diff
changeset
|
553 |
expander['n'] = lambda: str(seqno).zfill(len(str(total))) |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
554 |
if pathname is not None: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
555 |
expander['s'] = lambda: os.path.basename(pathname) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
556 |
expander['d'] = lambda: os.path.dirname(pathname) or '.' |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
557 |
expander['p'] = lambda: pathname |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
558 |
|
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
559 |
newname = [] |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
560 |
patlen = len(pat) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
561 |
i = 0 |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
562 |
while i < patlen: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
563 |
c = pat[i] |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
564 |
if c == '%': |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
565 |
i += 1 |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
566 |
c = pat[i] |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
567 |
c = expander[c]() |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
568 |
newname.append(c) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
569 |
i += 1 |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
570 |
return ''.join(newname) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
571 |
except KeyError, inst: |
3072
bc3fe3b5b785
Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2958
diff
changeset
|
572 |
raise util.Abort(_("invalid format spec '%%%s' in output file name") % |
bc3fe3b5b785
Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2958
diff
changeset
|
573 |
inst.args[0]) |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
574 |
|
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
575 |
def make_file(repo, pat, node=None, |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
576 |
total=None, seqno=None, revwidth=None, mode='wb', pathname=None): |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
577 |
if not pat or pat == '-': |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
578 |
return 'w' in mode and sys.stdout or sys.stdin |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
579 |
if hasattr(pat, 'write') and 'w' in mode: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
580 |
return pat |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
581 |
if hasattr(pat, 'read') and 'r' in mode: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
582 |
return pat |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
583 |
return open(make_filename(repo, pat, node, total, seqno, revwidth, |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
584 |
pathname), |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
585 |
mode) |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
586 |
|
4197
492d0d5b6976
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
587 |
def matchpats(repo, pats=[], opts={}, globbed=False, default=None): |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
588 |
cwd = repo.getcwd() |
4186
08d31e43592a
Leave normalization of patterns to util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4055
diff
changeset
|
589 |
return util.cmdmatcher(repo.root, cwd, pats or [], opts.get('include'), |
4197
492d0d5b6976
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
590 |
opts.get('exclude'), globbed=globbed, |
4195
e8ee8fdeddb1
change locate to use relglobs by default
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4186
diff
changeset
|
591 |
default=default) |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
592 |
|
4197
492d0d5b6976
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
593 |
def walk(repo, pats=[], opts={}, node=None, badmatch=None, globbed=False, |
492d0d5b6976
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
594 |
default=None): |
492d0d5b6976
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
595 |
files, matchfn, anypats = matchpats(repo, pats, opts, globbed=globbed, |
492d0d5b6976
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
596 |
default=default) |
3531
730ca93ed788
convert dict(zip(x,x)) to dict.fromkeys(x)
Matt Mackall <mpm@selenic.com>
parents:
3528
diff
changeset
|
597 |
exact = dict.fromkeys(files) |
4525
78b6add1f966
Add dirstate.pathto and localrepo.pathto.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4522
diff
changeset
|
598 |
cwd = repo.getcwd() |
3528 | 599 |
for src, fn in repo.walk(node=node, files=files, match=matchfn, |
600 |
badmatch=badmatch): |
|
4525
78b6add1f966
Add dirstate.pathto and localrepo.pathto.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4522
diff
changeset
|
601 |
yield src, fn, repo.pathto(fn, cwd), fn in exact |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
602 |
|
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
603 |
def findrenames(repo, added=None, removed=None, threshold=0.5): |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
604 |
'''find renamed files -- yields (before, after, score) tuples''' |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
605 |
if added is None or removed is None: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
606 |
added, removed = repo.status()[1:3] |
3971
68a0fa81ad28
cmdutil.py: use contexts in findrenames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3891
diff
changeset
|
607 |
ctx = repo.changectx() |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
608 |
for a in added: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
609 |
aa = repo.wread(a) |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
610 |
bestname, bestscore = None, threshold |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
611 |
for r in removed: |
3971
68a0fa81ad28
cmdutil.py: use contexts in findrenames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3891
diff
changeset
|
612 |
rr = ctx.filectx(r).data() |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
613 |
|
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
614 |
# bdiff.blocks() returns blocks of matching lines |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
615 |
# count the number of bytes in each |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
616 |
equal = 0 |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
617 |
alines = mdiff.splitnewlines(aa) |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
618 |
matches = bdiff.blocks(aa, rr) |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
619 |
for x1,x2,y1,y2 in matches: |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
620 |
for line in alines[x1:x2]: |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
621 |
equal += len(line) |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
622 |
|
4472
736e49292809
addremove: comparing two empty files caused ZeroDivisionError
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4380
diff
changeset
|
623 |
lengths = len(aa) + len(rr) |
736e49292809
addremove: comparing two empty files caused ZeroDivisionError
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4380
diff
changeset
|
624 |
if lengths: |
736e49292809
addremove: comparing two empty files caused ZeroDivisionError
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4380
diff
changeset
|
625 |
myscore = equal*2.0 / lengths |
736e49292809
addremove: comparing two empty files caused ZeroDivisionError
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4380
diff
changeset
|
626 |
if myscore >= bestscore: |
736e49292809
addremove: comparing two empty files caused ZeroDivisionError
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4380
diff
changeset
|
627 |
bestname, bestscore = r, myscore |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
628 |
if bestname: |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
629 |
yield bestname, a, bestscore |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
630 |
|
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
631 |
def addremove(repo, pats=[], opts={}, wlock=None, dry_run=None, |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
632 |
similarity=None): |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
633 |
if dry_run is None: |
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
634 |
dry_run = opts.get('dry_run') |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
635 |
if similarity is None: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
636 |
similarity = float(opts.get('similarity') or 0) |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
637 |
add, remove = [], [] |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
638 |
mapping = {} |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
639 |
for src, abs, rel, exact in walk(repo, pats, opts): |
4522
591322269fed
Use absolute paths in addremove.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4478
diff
changeset
|
640 |
target = repo.wjoin(abs) |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
641 |
if src == 'f' and repo.dirstate.state(abs) == '?': |
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
642 |
add.append(abs) |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
643 |
mapping[abs] = rel, exact |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
644 |
if repo.ui.verbose or not exact: |
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
645 |
repo.ui.status(_('adding %s\n') % ((pats and rel) or abs)) |
4573
97111071d26c
addremove: use util.lexists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4563
diff
changeset
|
646 |
if repo.dirstate.state(abs) != 'r' and not util.lexists(target): |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
647 |
remove.append(abs) |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
648 |
mapping[abs] = rel, exact |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
649 |
if repo.ui.verbose or not exact: |
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
650 |
repo.ui.status(_('removing %s\n') % ((pats and rel) or abs)) |
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
651 |
if not dry_run: |
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
652 |
repo.add(add, wlock=wlock) |
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
653 |
repo.remove(remove, wlock=wlock) |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
654 |
if similarity > 0: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
655 |
for old, new, score in findrenames(repo, add, remove, similarity): |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
656 |
oldrel, oldexact = mapping[old] |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
657 |
newrel, newexact = mapping[new] |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
658 |
if repo.ui.verbose or not oldexact or not newexact: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
659 |
repo.ui.status(_('recording removal of %s as rename to %s ' |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
660 |
'(%d%% similar)\n') % |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
661 |
(oldrel, newrel, score * 100)) |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
662 |
if not dry_run: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
663 |
repo.copy(old, new, wlock=wlock) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
664 |
|
4380
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
665 |
def service(opts, parentfn=None, initfn=None, runfn=None): |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
666 |
'''Run a command as a service.''' |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
667 |
|
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
668 |
if opts['daemon'] and not opts['daemon_pipefds']: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
669 |
rfd, wfd = os.pipe() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
670 |
args = sys.argv[:] |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
671 |
args.append('--daemon-pipefds=%d,%d' % (rfd, wfd)) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
672 |
pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
673 |
args[0], args) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
674 |
os.close(wfd) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
675 |
os.read(rfd, 1) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
676 |
if parentfn: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
677 |
return parentfn(pid) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
678 |
else: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
679 |
os._exit(0) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
680 |
|
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
681 |
if initfn: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
682 |
initfn() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
683 |
|
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
684 |
if opts['pid_file']: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
685 |
fp = open(opts['pid_file'], 'w') |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
686 |
fp.write(str(os.getpid()) + '\n') |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
687 |
fp.close() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
688 |
|
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
689 |
if opts['daemon_pipefds']: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
690 |
rfd, wfd = [int(x) for x in opts['daemon_pipefds'].split(',')] |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
691 |
os.close(rfd) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
692 |
try: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
693 |
os.setsid() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
694 |
except AttributeError: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
695 |
pass |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
696 |
os.write(wfd, 'y') |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
697 |
os.close(wfd) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
698 |
sys.stdout.flush() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
699 |
sys.stderr.flush() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
700 |
fd = os.open(util.nulldev, os.O_RDWR) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
701 |
if fd != 0: os.dup2(fd, 0) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
702 |
if fd != 1: os.dup2(fd, 1) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
703 |
if fd != 2: os.dup2(fd, 2) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
704 |
if fd not in (0, 1, 2): os.close(fd) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
705 |
|
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
706 |
if runfn: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
707 |
return runfn() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
708 |
|
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
709 |
class changeset_printer(object): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
710 |
'''show changeset information when templating not requested.''' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
711 |
|
3876
1e0b94cfba0e
Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents:
3838
diff
changeset
|
712 |
def __init__(self, ui, repo, patch, buffered): |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
713 |
self.ui = ui |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
714 |
self.repo = repo |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
715 |
self.buffered = buffered |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
716 |
self.patch = patch |
3738
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
717 |
self.header = {} |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
718 |
self.hunk = {} |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
719 |
self.lastheader = None |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
720 |
|
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
721 |
def flush(self, rev): |
3738
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
722 |
if rev in self.header: |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
723 |
h = self.header[rev] |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
724 |
if h != self.lastheader: |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
725 |
self.lastheader = h |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
726 |
self.ui.write(h) |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
727 |
del self.header[rev] |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
728 |
if rev in self.hunk: |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
729 |
self.ui.write(self.hunk[rev]) |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
730 |
del self.hunk[rev] |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
731 |
return 1 |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
732 |
return 0 |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
733 |
|
4351
3380eb6d7c32
fix 'hg <not-log> -v --template foo' with revisions without copies
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4229
diff
changeset
|
734 |
def show(self, rev=0, changenode=None, copies=(), **props): |
3738
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
735 |
if self.buffered: |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
736 |
self.ui.pushbuffer() |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
737 |
self._show(rev, changenode, copies, props) |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
738 |
self.hunk[rev] = self.ui.popbuffer() |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
739 |
else: |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
740 |
self._show(rev, changenode, copies, props) |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
741 |
|
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
742 |
def _show(self, rev, changenode, copies, props): |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
743 |
'''show a single changeset or file revision''' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
744 |
log = self.repo.changelog |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
745 |
if changenode is None: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
746 |
changenode = log.node(rev) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
747 |
elif not rev: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
748 |
rev = log.rev(changenode) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
749 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
750 |
if self.ui.quiet: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
751 |
self.ui.write("%d:%s\n" % (rev, short(changenode))) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
752 |
return |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
753 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
754 |
changes = log.read(changenode) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
755 |
date = util.datestr(changes[2]) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
756 |
extra = changes[5] |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
757 |
branch = extra.get("branch") |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
758 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
759 |
hexfunc = self.ui.debugflag and hex or short |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
760 |
|
4825
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
761 |
parents = [(p, hexfunc(log.node(p))) |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
762 |
for p in self._meaningful_parentrevs(log, rev)] |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
763 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
764 |
self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode))) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
765 |
|
4176
f9bbcebcacea
"default" is the default branch name
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4055
diff
changeset
|
766 |
# don't show the default branch name |
f9bbcebcacea
"default" is the default branch name
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4055
diff
changeset
|
767 |
if branch != 'default': |
3827
3674ca805a5b
log: convert branch names to the local encoding
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3825
diff
changeset
|
768 |
branch = util.tolocal(branch) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
769 |
self.ui.write(_("branch: %s\n") % branch) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
770 |
for tag in self.repo.nodetags(changenode): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
771 |
self.ui.write(_("tag: %s\n") % tag) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
772 |
for parent in parents: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
773 |
self.ui.write(_("parent: %d:%s\n") % parent) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
774 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
775 |
if self.ui.debugflag: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
776 |
self.ui.write(_("manifest: %d:%s\n") % |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
777 |
(self.repo.manifest.rev(changes[0]), hex(changes[0]))) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
778 |
self.ui.write(_("user: %s\n") % changes[1]) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
779 |
self.ui.write(_("date: %s\n") % date) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
780 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
781 |
if self.ui.debugflag: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
782 |
files = self.repo.status(log.parents(changenode)[0], changenode)[:3] |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
783 |
for key, value in zip([_("files:"), _("files+:"), _("files-:")], |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
784 |
files): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
785 |
if value: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
786 |
self.ui.write("%-12s %s\n" % (key, " ".join(value))) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
787 |
elif changes[3] and self.ui.verbose: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
788 |
self.ui.write(_("files: %s\n") % " ".join(changes[3])) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
789 |
if copies and self.ui.verbose: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
790 |
copies = ['%s (%s)' % c for c in copies] |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
791 |
self.ui.write(_("copies: %s\n") % ' '.join(copies)) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
792 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
793 |
if extra and self.ui.debugflag: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
794 |
extraitems = extra.items() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
795 |
extraitems.sort() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
796 |
for key, value in extraitems: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
797 |
self.ui.write(_("extra: %s=%s\n") |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
798 |
% (key, value.encode('string_escape'))) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
799 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
800 |
description = changes[4].strip() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
801 |
if description: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
802 |
if self.ui.verbose: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
803 |
self.ui.write(_("description:\n")) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
804 |
self.ui.write(description) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
805 |
self.ui.write("\n\n") |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
806 |
else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
807 |
self.ui.write(_("summary: %s\n") % |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
808 |
description.splitlines()[0]) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
809 |
self.ui.write("\n") |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
810 |
|
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
811 |
self.showpatch(changenode) |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
812 |
|
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
813 |
def showpatch(self, node): |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
814 |
if self.patch: |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
815 |
prev = self.repo.changelog.parents(node)[0] |
4714
a741293793f6
Make changeset_printer respect ui diffopts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4686
diff
changeset
|
816 |
patch.diff(self.repo, prev, node, match=self.patch, fp=self.ui, |
a741293793f6
Make changeset_printer respect ui diffopts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4686
diff
changeset
|
817 |
opts=patch.diffopts(self.ui)) |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
818 |
self.ui.write("\n") |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
819 |
|
4825
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
820 |
def _meaningful_parentrevs(self, log, rev): |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
821 |
"""Return list of meaningful (or all if debug) parentrevs for rev. |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
822 |
|
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
823 |
For merges (two non-nullrev revisions) both parents are meaningful. |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
824 |
Otherwise the first parent revision is considered meaningful if it |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
825 |
is not the preceding revision. |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
826 |
""" |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
827 |
parents = log.parentrevs(rev) |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
828 |
if not self.ui.debugflag and parents[1] == nullrev: |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
829 |
if parents[0] >= rev - 1: |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
830 |
parents = [] |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
831 |
else: |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
832 |
parents = [parents[0]] |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
833 |
return parents |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
834 |
|
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
835 |
|
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
836 |
class changeset_templater(changeset_printer): |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
837 |
'''format changeset information.''' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
838 |
|
3876
1e0b94cfba0e
Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents:
3838
diff
changeset
|
839 |
def __init__(self, ui, repo, patch, mapfile, buffered): |
1e0b94cfba0e
Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents:
3838
diff
changeset
|
840 |
changeset_printer.__init__(self, ui, repo, patch, buffered) |
4352
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
841 |
filters = templater.common_filters.copy() |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
842 |
filters['formatnode'] = (ui.debugflag and (lambda x: x) |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
843 |
or (lambda x: x[:12])) |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
844 |
self.t = templater.templater(mapfile, filters, |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
845 |
cache={ |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
846 |
'parent': '{rev}:{node|formatnode} ', |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
847 |
'manifest': '{rev}:{node|formatnode}', |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
848 |
'filecopy': '{name} ({source})'}) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
849 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
850 |
def use_template(self, t): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
851 |
'''set template string to use''' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
852 |
self.t.cache['changeset'] = t |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
853 |
|
3738
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
854 |
def _show(self, rev, changenode, copies, props): |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
855 |
'''show a single changeset or file revision''' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
856 |
log = self.repo.changelog |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
857 |
if changenode is None: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
858 |
changenode = log.node(rev) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
859 |
elif not rev: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
860 |
rev = log.rev(changenode) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
861 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
862 |
changes = log.read(changenode) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
863 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
864 |
def showlist(name, values, plural=None, **args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
865 |
'''expand set of values. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
866 |
name is name of key in template map. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
867 |
values is list of strings or dicts. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
868 |
plural is plural of name, if not simply name + 's'. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
869 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
870 |
expansion works like this, given name 'foo'. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
871 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
872 |
if values is empty, expand 'no_foos'. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
873 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
874 |
if 'foo' not in template map, return values as a string, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
875 |
joined by space. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
876 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
877 |
expand 'start_foos'. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
878 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
879 |
for each value, expand 'foo'. if 'last_foo' in template |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
880 |
map, expand it instead of 'foo' for last key. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
881 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
882 |
expand 'end_foos'. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
883 |
''' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
884 |
if plural: names = plural |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
885 |
else: names = name + 's' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
886 |
if not values: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
887 |
noname = 'no_' + names |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
888 |
if noname in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
889 |
yield self.t(noname, **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
890 |
return |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
891 |
if name not in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
892 |
if isinstance(values[0], str): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
893 |
yield ' '.join(values) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
894 |
else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
895 |
for v in values: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
896 |
yield dict(v, **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
897 |
return |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
898 |
startname = 'start_' + names |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
899 |
if startname in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
900 |
yield self.t(startname, **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
901 |
vargs = args.copy() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
902 |
def one(v, tag=name): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
903 |
try: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
904 |
vargs.update(v) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
905 |
except (AttributeError, ValueError): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
906 |
try: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
907 |
for a, b in v: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
908 |
vargs[a] = b |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
909 |
except ValueError: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
910 |
vargs[name] = v |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
911 |
return self.t(tag, **vargs) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
912 |
lastname = 'last_' + name |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
913 |
if lastname in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
914 |
last = values.pop() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
915 |
else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
916 |
last = None |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
917 |
for v in values: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
918 |
yield one(v) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
919 |
if last is not None: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
920 |
yield one(last, tag=lastname) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
921 |
endname = 'end_' + names |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
922 |
if endname in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
923 |
yield self.t(endname, **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
924 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
925 |
def showbranches(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
926 |
branch = changes[5].get("branch") |
4176
f9bbcebcacea
"default" is the default branch name
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4055
diff
changeset
|
927 |
if branch != 'default': |
3827
3674ca805a5b
log: convert branch names to the local encoding
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3825
diff
changeset
|
928 |
branch = util.tolocal(branch) |
3648
2801a3efc7c3
changeset templater: convert some unnecessary yields to returns
Matt Mackall <mpm@selenic.com>
parents:
3645
diff
changeset
|
929 |
return showlist('branch', [branch], plural='branches', **args) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
930 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
931 |
def showparents(**args): |
4825
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
932 |
parents = [[('rev', p), ('node', hex(log.node(p)))] |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
933 |
for p in self._meaningful_parentrevs(log, rev)] |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
934 |
return showlist('parent', parents, **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
935 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
936 |
def showtags(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
937 |
return showlist('tag', self.repo.nodetags(changenode), **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
938 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
939 |
def showextras(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
940 |
extras = changes[5].items() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
941 |
extras.sort() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
942 |
for key, value in extras: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
943 |
args = args.copy() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
944 |
args.update(dict(key=key, value=value)) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
945 |
yield self.t('extra', **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
946 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
947 |
def showcopies(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
948 |
c = [{'name': x[0], 'source': x[1]} for x in copies] |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
949 |
return showlist('file_copy', c, plural='file_copies', **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
950 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
951 |
if self.ui.debugflag: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
952 |
files = self.repo.status(log.parents(changenode)[0], changenode)[:3] |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
953 |
def showfiles(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
954 |
return showlist('file', files[0], **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
955 |
def showadds(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
956 |
return showlist('file_add', files[1], **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
957 |
def showdels(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
958 |
return showlist('file_del', files[2], **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
959 |
def showmanifest(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
960 |
args = args.copy() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
961 |
args.update(dict(rev=self.repo.manifest.rev(changes[0]), |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
962 |
node=hex(changes[0]))) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
963 |
return self.t('manifest', **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
964 |
else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
965 |
def showfiles(**args): |
3648
2801a3efc7c3
changeset templater: convert some unnecessary yields to returns
Matt Mackall <mpm@selenic.com>
parents:
3645
diff
changeset
|
966 |
return showlist('file', changes[3], **args) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
967 |
showadds = '' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
968 |
showdels = '' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
969 |
showmanifest = '' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
970 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
971 |
defprops = { |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
972 |
'author': changes[1], |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
973 |
'branches': showbranches, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
974 |
'date': changes[2], |
4824
f3f84d5cd268
Strip whitespace from changeset description in changeset_templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4734
diff
changeset
|
975 |
'desc': changes[4].strip(), |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
976 |
'file_adds': showadds, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
977 |
'file_dels': showdels, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
978 |
'files': showfiles, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
979 |
'file_copies': showcopies, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
980 |
'manifest': showmanifest, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
981 |
'node': hex(changenode), |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
982 |
'parents': showparents, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
983 |
'rev': rev, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
984 |
'tags': showtags, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
985 |
'extras': showextras, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
986 |
} |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
987 |
props = props.copy() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
988 |
props.update(defprops) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
989 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
990 |
try: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
991 |
if self.ui.debugflag and 'header_debug' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
992 |
key = 'header_debug' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
993 |
elif self.ui.quiet and 'header_quiet' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
994 |
key = 'header_quiet' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
995 |
elif self.ui.verbose and 'header_verbose' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
996 |
key = 'header_verbose' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
997 |
elif 'header' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
998 |
key = 'header' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
999 |
else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1000 |
key = '' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1001 |
if key: |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
1002 |
h = templater.stringify(self.t(key, **props)) |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
1003 |
if self.buffered: |
3738
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
1004 |
self.header[rev] = h |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
1005 |
else: |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
1006 |
self.ui.write(h) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1007 |
if self.ui.debugflag and 'changeset_debug' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1008 |
key = 'changeset_debug' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1009 |
elif self.ui.quiet and 'changeset_quiet' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1010 |
key = 'changeset_quiet' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1011 |
elif self.ui.verbose and 'changeset_verbose' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1012 |
key = 'changeset_verbose' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1013 |
else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1014 |
key = 'changeset' |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
1015 |
self.ui.write(templater.stringify(self.t(key, **props))) |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
1016 |
self.showpatch(changenode) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1017 |
except KeyError, inst: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1018 |
raise util.Abort(_("%s: no key named '%s'") % (self.t.mapfile, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1019 |
inst.args[0])) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1020 |
except SyntaxError, inst: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1021 |
raise util.Abort(_('%s: %s') % (self.t.mapfile, inst.args[0])) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1022 |
|
3837
7df171ea50cd
Fix log regression where log -p file showed diffs for other files
Matt Mackall <mpm@selenic.com>
parents:
3827
diff
changeset
|
1023 |
def show_changeset(ui, repo, opts, buffered=False, matchfn=False): |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1024 |
"""show one changeset using template or regular display. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1025 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1026 |
Display format will be the first non-empty hit of: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1027 |
1. option 'template' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1028 |
2. option 'style' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1029 |
3. [ui] setting 'logtemplate' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1030 |
4. [ui] setting 'style' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1031 |
If all of these values are either the unset or the empty string, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1032 |
regular display via changeset_printer() is done. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1033 |
""" |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1034 |
# options |
3837
7df171ea50cd
Fix log regression where log -p file showed diffs for other files
Matt Mackall <mpm@selenic.com>
parents:
3827
diff
changeset
|
1035 |
patch = False |
7df171ea50cd
Fix log regression where log -p file showed diffs for other files
Matt Mackall <mpm@selenic.com>
parents:
3827
diff
changeset
|
1036 |
if opts.get('patch'): |
3838
dec4eba7ccad
Use util.always instead of creating a new lambda function in show_changeset
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3837
diff
changeset
|
1037 |
patch = matchfn or util.always |
3837
7df171ea50cd
Fix log regression where log -p file showed diffs for other files
Matt Mackall <mpm@selenic.com>
parents:
3827
diff
changeset
|
1038 |
|
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1039 |
tmpl = opts.get('template') |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1040 |
mapfile = None |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1041 |
if tmpl: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1042 |
tmpl = templater.parsestring(tmpl, quoted=False) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1043 |
else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1044 |
mapfile = opts.get('style') |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1045 |
# ui settings |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1046 |
if not mapfile: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1047 |
tmpl = ui.config('ui', 'logtemplate') |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1048 |
if tmpl: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1049 |
tmpl = templater.parsestring(tmpl) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1050 |
else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1051 |
mapfile = ui.config('ui', 'style') |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1052 |
|
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1053 |
if tmpl or mapfile: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1054 |
if mapfile: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1055 |
if not os.path.split(mapfile)[0]: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1056 |
mapname = (templater.templatepath('map-cmdline.' + mapfile) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1057 |
or templater.templatepath(mapfile)) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1058 |
if mapname: mapfile = mapname |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1059 |
try: |
3876
1e0b94cfba0e
Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents:
3838
diff
changeset
|
1060 |
t = changeset_templater(ui, repo, patch, mapfile, buffered) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1061 |
except SyntaxError, inst: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1062 |
raise util.Abort(inst.args[0]) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1063 |
if tmpl: t.use_template(tmpl) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1064 |
return t |
3876
1e0b94cfba0e
Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents:
3838
diff
changeset
|
1065 |
return changeset_printer(ui, repo, patch, buffered) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
1066 |
|
3814
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1067 |
def finddate(ui, repo, date): |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1068 |
"""Find the tipmost changeset that matches the given date spec""" |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1069 |
df = util.matchdate(date + " to " + date) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1070 |
get = util.cachefunc(lambda r: repo.changectx(r).changeset()) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1071 |
changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None}) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1072 |
results = {} |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1073 |
for st, rev, fns in changeiter: |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1074 |
if st == 'add': |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1075 |
d = get(rev)[2] |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1076 |
if df(d[0]): |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1077 |
results[rev] = d |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1078 |
elif st == 'iter': |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1079 |
if rev in results: |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1080 |
ui.status("Found revision %s from %s\n" % |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1081 |
(rev, util.datestr(results[rev]))) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1082 |
return str(rev) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1083 |
|
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1084 |
raise util.Abort(_("revision matching date not found")) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
1085 |
|
3650
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1086 |
def walkchangerevs(ui, repo, pats, change, opts): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1087 |
'''Iterate over files and the revs they changed in. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1088 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1089 |
Callers most commonly need to iterate backwards over the history |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1090 |
it is interested in. Doing so has awful (quadratic-looking) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1091 |
performance, so we use iterators in a "windowed" way. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1092 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1093 |
We walk a window of revisions in the desired order. Within the |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1094 |
window, we first walk forwards to gather data, then in the desired |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1095 |
order (usually backwards) to display it. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1096 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1097 |
This function returns an (iterator, matchfn) tuple. The iterator |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1098 |
yields 3-tuples. They will be of one of the following forms: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1099 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1100 |
"window", incrementing, lastrev: stepping through a window, |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1101 |
positive if walking forwards through revs, last rev in the |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1102 |
sequence iterated over - use to reset state for the current window |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1103 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1104 |
"add", rev, fns: out-of-order traversal of the given file names |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1105 |
fns, which changed during revision rev - use to gather data for |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1106 |
possible display |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1107 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1108 |
"iter", rev, None: in-order traversal of the revs earlier iterated |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1109 |
over with "add" - use to display data''' |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1110 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1111 |
def increasing_windows(start, end, windowsize=8, sizelimit=512): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1112 |
if start < end: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1113 |
while start < end: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1114 |
yield start, min(windowsize, end-start) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1115 |
start += windowsize |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1116 |
if windowsize < sizelimit: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1117 |
windowsize *= 2 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1118 |
else: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1119 |
while start > end: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1120 |
yield start, min(windowsize, start-end-1) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1121 |
start -= windowsize |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1122 |
if windowsize < sizelimit: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1123 |
windowsize *= 2 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1124 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1125 |
files, matchfn, anypats = matchpats(repo, pats, opts) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1126 |
follow = opts.get('follow') or opts.get('follow_first') |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1127 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1128 |
if repo.changelog.count() == 0: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1129 |
return [], matchfn |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1130 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1131 |
if follow: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1132 |
defrange = '%s:0' % repo.changectx().rev() |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1133 |
else: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1134 |
defrange = 'tip:0' |
3707
67f44b825784
Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3673
diff
changeset
|
1135 |
revs = revrange(repo, opts['rev'] or [defrange]) |
3650
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1136 |
wanted = {} |
3657 | 1137 |
slowpath = anypats or opts.get('removed') |
3650
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1138 |
fncache = {} |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1139 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1140 |
if not slowpath and not files: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1141 |
# No files, no patterns. Display all revs. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1142 |
wanted = dict.fromkeys(revs) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1143 |
copies = [] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1144 |
if not slowpath: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1145 |
# Only files, no patterns. Check the history of each file. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1146 |
def filerevgen(filelog, node): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1147 |
cl_count = repo.changelog.count() |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1148 |
if node is None: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1149 |
last = filelog.count() - 1 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1150 |
else: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1151 |
last = filelog.rev(node) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1152 |
for i, window in increasing_windows(last, nullrev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1153 |
revs = [] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1154 |
for j in xrange(i - window, i + 1): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1155 |
n = filelog.node(j) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1156 |
revs.append((filelog.linkrev(n), |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1157 |
follow and filelog.renamed(n))) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1158 |
revs.reverse() |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1159 |
for rev in revs: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1160 |
# only yield rev for which we have the changelog, it can |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1161 |
# happen while doing "hg log" during a pull or commit |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1162 |
if rev[0] < cl_count: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1163 |
yield rev |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1164 |
def iterfiles(): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1165 |
for filename in files: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1166 |
yield filename, None |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1167 |
for filename_node in copies: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1168 |
yield filename_node |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1169 |
minrev, maxrev = min(revs), max(revs) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1170 |
for file_, node in iterfiles(): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1171 |
filelog = repo.file(file_) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1172 |
# A zero count may be a directory or deleted file, so |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1173 |
# try to find matching entries on the slow path. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1174 |
if filelog.count() == 0: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1175 |
slowpath = True |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1176 |
break |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1177 |
for rev, copied in filerevgen(filelog, node): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1178 |
if rev <= maxrev: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1179 |
if rev < minrev: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1180 |
break |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1181 |
fncache.setdefault(rev, []) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1182 |
fncache[rev].append(file_) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1183 |
wanted[rev] = 1 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1184 |
if follow and copied: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1185 |
copies.append(copied) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1186 |
if slowpath: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1187 |
if follow: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1188 |
raise util.Abort(_('can only follow copies/renames for explicit ' |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1189 |
'file names')) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1190 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1191 |
# The slow path checks files modified in every changeset. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1192 |
def changerevgen(): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1193 |
for i, window in increasing_windows(repo.changelog.count()-1, |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1194 |
nullrev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1195 |
for j in xrange(i - window, i + 1): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1196 |
yield j, change(j)[3] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1197 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1198 |
for rev, changefiles in changerevgen(): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1199 |
matches = filter(matchfn, changefiles) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1200 |
if matches: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1201 |
fncache[rev] = matches |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1202 |
wanted[rev] = 1 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1203 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1204 |
class followfilter: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1205 |
def __init__(self, onlyfirst=False): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1206 |
self.startrev = nullrev |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1207 |
self.roots = [] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1208 |
self.onlyfirst = onlyfirst |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1209 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1210 |
def match(self, rev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1211 |
def realparents(rev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1212 |
if self.onlyfirst: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1213 |
return repo.changelog.parentrevs(rev)[0:1] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1214 |
else: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1215 |
return filter(lambda x: x != nullrev, |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1216 |
repo.changelog.parentrevs(rev)) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1217 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1218 |
if self.startrev == nullrev: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1219 |
self.startrev = rev |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1220 |
return True |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1221 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1222 |
if rev > self.startrev: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1223 |
# forward: all descendants |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1224 |
if not self.roots: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1225 |
self.roots.append(self.startrev) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1226 |
for parent in realparents(rev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1227 |
if parent in self.roots: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1228 |
self.roots.append(rev) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1229 |
return True |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1230 |
else: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1231 |
# backwards: all parents |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1232 |
if not self.roots: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1233 |
self.roots.extend(realparents(self.startrev)) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1234 |
if rev in self.roots: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1235 |
self.roots.remove(rev) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1236 |
self.roots.extend(realparents(rev)) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1237 |
return True |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1238 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1239 |
return False |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1240 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1241 |
# it might be worthwhile to do this in the iterator if the rev range |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1242 |
# is descending and the prune args are all within that range |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1243 |
for rev in opts.get('prune', ()): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1244 |
rev = repo.changelog.rev(repo.lookup(rev)) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1245 |
ff = followfilter() |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1246 |
stop = min(revs[0], revs[-1]) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1247 |
for x in xrange(rev, stop-1, -1): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1248 |
if ff.match(x) and x in wanted: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1249 |
del wanted[x] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1250 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1251 |
def iterate(): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1252 |
if follow and not files: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1253 |
ff = followfilter(onlyfirst=opts.get('follow_first')) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1254 |
def want(rev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1255 |
if ff.match(rev) and rev in wanted: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1256 |
return True |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1257 |
return False |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1258 |
else: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1259 |
def want(rev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1260 |
return rev in wanted |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1261 |
|
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1262 |
for i, window in increasing_windows(0, len(revs)): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1263 |
yield 'window', revs[0] < revs[-1], revs[-1] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1264 |
nrevs = [rev for rev in revs[i:i+window] if want(rev)] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1265 |
srevs = list(nrevs) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1266 |
srevs.sort() |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1267 |
for rev in srevs: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1268 |
fns = fncache.get(rev) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1269 |
if not fns: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1270 |
def fns_generator(): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1271 |
for f in change(rev)[3]: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1272 |
if matchfn(f): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1273 |
yield f |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1274 |
fns = fns_generator() |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1275 |
yield 'add', rev, fns |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1276 |
for rev in nrevs: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1277 |
yield 'iter', rev, None |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
1278 |
return iterate(), matchfn |