Mercurial > hg
annotate hgext/record.py @ 24601:d80819f67d59
templater: tell hggettext to collect help of template functions
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 03 Apr 2015 21:36:39 +0900 |
parents | fefcafda10b8 |
children | 80c5b2666a96 |
rev | line source |
---|---|
5037
b2607267236d
Add record extension, giving darcs-like interactive hunk picking
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1 # record.py |
b2607267236d
Add record extension, giving darcs-like interactive hunk picking
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
2 # |
b2607267236d
Add record extension, giving darcs-like interactive hunk picking
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
3 # Copyright 2007 Bryan O'Sullivan <bos@serpentine.com> |
b2607267236d
Add record extension, giving darcs-like interactive hunk picking
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8208
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
5037
b2607267236d
Add record extension, giving darcs-like interactive hunk picking
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
7 |
8934
9dda4c73fc3b
extensions: change descriptions for extensions providing a few commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8894
diff
changeset
|
8 '''commands to interactively select changes for commit/qrefresh''' |
5037
b2607267236d
Add record extension, giving darcs-like interactive hunk picking
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
9 |
20266
061766323061
record: use "ui.extractchoices()" to get the list of available responses
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20171
diff
changeset
|
10 from mercurial.i18n import _ |
24272
26a1c617e047
record: move dorecord from record to cmdutil
Laurent Charignon <lcharignon@fb.com>
parents:
24271
diff
changeset
|
11 from mercurial import cmdutil, commands, extensions |
5037
b2607267236d
Add record extension, giving darcs-like interactive hunk picking
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
12 from mercurial import util |
b2607267236d
Add record extension, giving darcs-like interactive hunk picking
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
13 |
14408
054da1e0afbe
record: use cmdutil.command decorator
Idan Kamara <idankk86@gmail.com>
parents:
14407
diff
changeset
|
14 cmdtable = {} |
054da1e0afbe
record: use cmdutil.command decorator
Idan Kamara <idankk86@gmail.com>
parents:
14407
diff
changeset
|
15 command = cmdutil.command(cmdtable) |
16743
38caf405d010
hgext: mark all first-party extensions as such
Augie Fackler <raf@durin42.com>
parents:
16683
diff
changeset
|
16 testedwith = 'internal' |
14408
054da1e0afbe
record: use cmdutil.command decorator
Idan Kamara <idankk86@gmail.com>
parents:
14407
diff
changeset
|
17 |
5037
b2607267236d
Add record extension, giving darcs-like interactive hunk picking
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
18 |
14408
054da1e0afbe
record: use cmdutil.command decorator
Idan Kamara <idankk86@gmail.com>
parents:
14407
diff
changeset
|
19 @command("record", |
14597
3f1dccea9510
record: add white space diff options
Ingo Proetel <proetel@aicas.de>
parents:
14441
diff
changeset
|
20 # same options as commit + white space diff options |
24278
0b94b68aace9
record: add interactive option to the commit command
Laurent Charignon <lcharignon@fb.com>
parents:
24272
diff
changeset
|
21 [c for c in commands.table['^commit|ci'][1][:] |
0b94b68aace9
record: add interactive option to the commit command
Laurent Charignon <lcharignon@fb.com>
parents:
24272
diff
changeset
|
22 if c[1] != "interactive"] + commands.diffwsopts, |
14408
054da1e0afbe
record: use cmdutil.command decorator
Idan Kamara <idankk86@gmail.com>
parents:
14407
diff
changeset
|
23 _('hg record [OPTION]... [FILE]...')) |
5037
b2607267236d
Add record extension, giving darcs-like interactive hunk picking
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
24 def record(ui, repo, *pats, **opts): |
5154
67afecb8d6cc
record: improve docs, improve prompts
Bryan O'Sullivan <bos@serpentine.com>
parents:
5147
diff
changeset
|
25 '''interactively select changes to commit |
67afecb8d6cc
record: improve docs, improve prompts
Bryan O'Sullivan <bos@serpentine.com>
parents:
5147
diff
changeset
|
26 |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10890
diff
changeset
|
27 If a list of files is omitted, all changes reported by :hg:`status` |
9272
784899697571
record: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9157
diff
changeset
|
28 will be candidates for recording. |
5154
67afecb8d6cc
record: improve docs, improve prompts
Bryan O'Sullivan <bos@serpentine.com>
parents:
5147
diff
changeset
|
29 |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10890
diff
changeset
|
30 See :hg:`help dates` for a list of formats valid for -d/--date. |
6163
1f733c2f0165
Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5932
diff
changeset
|
31 |
9272
784899697571
record: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9157
diff
changeset
|
32 You will be prompted for whether to record changes to each |
784899697571
record: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9157
diff
changeset
|
33 modified file, and for files with multiple changes, for each |
784899697571
record: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9157
diff
changeset
|
34 change to use. For each query, the following responses are |
784899697571
record: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9157
diff
changeset
|
35 possible:: |
5154
67afecb8d6cc
record: improve docs, improve prompts
Bryan O'Sullivan <bos@serpentine.com>
parents:
5147
diff
changeset
|
36 |
9157
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9087
diff
changeset
|
37 y - record this change |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9087
diff
changeset
|
38 n - skip this change |
16324
46b991a1f428
record: allow splitting of hunks by manually editing patches
A. S. Budden <abudden@gmail.com>
parents:
15184
diff
changeset
|
39 e - edit this change manually |
5154
67afecb8d6cc
record: improve docs, improve prompts
Bryan O'Sullivan <bos@serpentine.com>
parents:
5147
diff
changeset
|
40 |
9157
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9087
diff
changeset
|
41 s - skip remaining changes to this file |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9087
diff
changeset
|
42 f - record remaining changes to this file |
5154
67afecb8d6cc
record: improve docs, improve prompts
Bryan O'Sullivan <bos@serpentine.com>
parents:
5147
diff
changeset
|
43 |
9157
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9087
diff
changeset
|
44 d - done, skip remaining changes and files |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9087
diff
changeset
|
45 a - record all changes to all remaining files |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9087
diff
changeset
|
46 q - quit, recording no changes |
5154
67afecb8d6cc
record: improve docs, improve prompts
Bryan O'Sullivan <bos@serpentine.com>
parents:
5147
diff
changeset
|
47 |
11237
feb2a58fc592
record: check that we are not committing a merge before patch selection
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11236
diff
changeset
|
48 ? - display help |
feb2a58fc592
record: check that we are not committing a merge before patch selection
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11236
diff
changeset
|
49 |
feb2a58fc592
record: check that we are not committing a merge before patch selection
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11236
diff
changeset
|
50 This command is not available when committing a merge.''' |
5037
b2607267236d
Add record extension, giving darcs-like interactive hunk picking
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
51 |
24307
7fcd9f4af49b
record: make record use commit -i
Laurent Charignon <lcharignon@fb.com>
parents:
24278
diff
changeset
|
52 opts["interactive"] = True |
7fcd9f4af49b
record: make record use commit -i
Laurent Charignon <lcharignon@fb.com>
parents:
24278
diff
changeset
|
53 commands.commit(ui, repo, *pats, **opts) |
5830
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
54 |
15184
351a9292e430
record: use command wrapper properly for qnew/qrefresh (issue3001)
Matt Mackall <mpm@selenic.com>
parents:
14597
diff
changeset
|
55 def qrefresh(origfn, ui, repo, *pats, **opts): |
351a9292e430
record: use command wrapper properly for qnew/qrefresh (issue3001)
Matt Mackall <mpm@selenic.com>
parents:
14597
diff
changeset
|
56 if not opts['interactive']: |
351a9292e430
record: use command wrapper properly for qnew/qrefresh (issue3001)
Matt Mackall <mpm@selenic.com>
parents:
14597
diff
changeset
|
57 return origfn(ui, repo, *pats, **opts) |
351a9292e430
record: use command wrapper properly for qnew/qrefresh (issue3001)
Matt Mackall <mpm@selenic.com>
parents:
14597
diff
changeset
|
58 |
14426
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
59 mq = extensions.find('mq') |
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
60 |
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
61 def committomq(ui, repo, *pats, **opts): |
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
62 # At this point the working copy contains only changes that |
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
63 # were accepted. All other changes were reverted. |
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
64 # We can't pass *pats here since qrefresh will undo all other |
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
65 # changed files in the patch that aren't in pats. |
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
66 mq.refresh(ui, repo, **opts) |
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
67 |
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
68 # backup all changed files |
24309
fefcafda10b8
record: change interface of dorecord to accept new filters
Laurent Charignon <lcharignon@fb.com>
parents:
24307
diff
changeset
|
69 cmdutil.dorecord(ui, repo, committomq, 'qrefresh', True, |
fefcafda10b8
record: change interface of dorecord to accept new filters
Laurent Charignon <lcharignon@fb.com>
parents:
24307
diff
changeset
|
70 cmdutil.recordfilter, *pats, **opts) |
5830
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
71 |
21251
a836fa58b512
record: declare commands using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
20334
diff
changeset
|
72 # This command registration is replaced during uisetup(). |
21787
fb5f34bb3867
record: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21251
diff
changeset
|
73 @command('qrecord', |
fb5f34bb3867
record: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21251
diff
changeset
|
74 [], |
fb5f34bb3867
record: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21251
diff
changeset
|
75 _('hg qrecord [OPTION]... PATCH [FILE]...'), |
fb5f34bb3867
record: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21251
diff
changeset
|
76 inferrepo=True) |
5932
b014ff3fdaeb
qrecord: record complements commit, so qrecord should complement qnew
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5830
diff
changeset
|
77 def qrecord(ui, repo, patch, *pats, **opts): |
b014ff3fdaeb
qrecord: record complements commit, so qrecord should complement qnew
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5830
diff
changeset
|
78 '''interactively record a new patch |
5830
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
79 |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10890
diff
changeset
|
80 See :hg:`help qnew` & :hg:`help record` for more information and |
9272
784899697571
record: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9157
diff
changeset
|
81 usage. |
5830
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
82 ''' |
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
83 |
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
84 try: |
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
85 mq = extensions.find('mq') |
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
86 except KeyError: |
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
87 raise util.Abort(_("'mq' extension not loaded")) |
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
88 |
14424
4eb88d296f63
record: check patch name is valid before prompting in qrecord
Idan Kamara <idankk86@gmail.com>
parents:
14408
diff
changeset
|
89 repo.mq.checkpatchname(patch) |
4eb88d296f63
record: check patch name is valid before prompting in qrecord
Idan Kamara <idankk86@gmail.com>
parents:
14408
diff
changeset
|
90 |
10323
0aa59f532ef9
record: function variable naming & signature cleanup.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10282
diff
changeset
|
91 def committomq(ui, repo, *pats, **opts): |
14424
4eb88d296f63
record: check patch name is valid before prompting in qrecord
Idan Kamara <idankk86@gmail.com>
parents:
14408
diff
changeset
|
92 opts['checkname'] = False |
5932
b014ff3fdaeb
qrecord: record complements commit, so qrecord should complement qnew
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5830
diff
changeset
|
93 mq.new(ui, repo, patch, *pats, **opts) |
5830
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
94 |
24309
fefcafda10b8
record: change interface of dorecord to accept new filters
Laurent Charignon <lcharignon@fb.com>
parents:
24307
diff
changeset
|
95 cmdutil.dorecord(ui, repo, committomq, 'qnew', False, |
fefcafda10b8
record: change interface of dorecord to accept new filters
Laurent Charignon <lcharignon@fb.com>
parents:
24307
diff
changeset
|
96 cmdutil.recordfilter, *pats, **opts) |
5827
0c29977bd7db
record: refactor record into generic record driver
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5826
diff
changeset
|
97 |
15184
351a9292e430
record: use command wrapper properly for qnew/qrefresh (issue3001)
Matt Mackall <mpm@selenic.com>
parents:
14597
diff
changeset
|
98 def qnew(origfn, ui, repo, patch, *args, **opts): |
351a9292e430
record: use command wrapper properly for qnew/qrefresh (issue3001)
Matt Mackall <mpm@selenic.com>
parents:
14597
diff
changeset
|
99 if opts['interactive']: |
351a9292e430
record: use command wrapper properly for qnew/qrefresh (issue3001)
Matt Mackall <mpm@selenic.com>
parents:
14597
diff
changeset
|
100 return qrecord(ui, repo, patch, *args, **opts) |
351a9292e430
record: use command wrapper properly for qnew/qrefresh (issue3001)
Matt Mackall <mpm@selenic.com>
parents:
14597
diff
changeset
|
101 return origfn(ui, repo, patch, *args, **opts) |
351a9292e430
record: use command wrapper properly for qnew/qrefresh (issue3001)
Matt Mackall <mpm@selenic.com>
parents:
14597
diff
changeset
|
102 |
5037
b2607267236d
Add record extension, giving darcs-like interactive hunk picking
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
103 |
9710
1765599f4899
record: use uisetup instead of extsetup to register qrecord
Martin Geisler <mg@lazybytes.net>
parents:
9688
diff
changeset
|
104 def uisetup(ui): |
5830
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
105 try: |
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
106 mq = extensions.find('mq') |
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
107 except KeyError: |
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
108 return |
c32d41affb68
hg qrecord -- like record, but for mq
Kirill Smelkov <kirr@mns.spb.ru>
parents:
5827
diff
changeset
|
109 |
14408
054da1e0afbe
record: use cmdutil.command decorator
Idan Kamara <idankk86@gmail.com>
parents:
14407
diff
changeset
|
110 cmdtable["qrecord"] = \ |
14427
9d4cabd189df
record: alias qrecord to qnew -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14426
diff
changeset
|
111 (qrecord, |
9d4cabd189df
record: alias qrecord to qnew -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14426
diff
changeset
|
112 # same options as qnew, but copy them so we don't get |
14597
3f1dccea9510
record: add white space diff options
Ingo Proetel <proetel@aicas.de>
parents:
14441
diff
changeset
|
113 # -i/--interactive for qrecord and add white space diff options |
20300
0076643077a3
record: use commands.diffwsopts instead of ad-hoc diffopts
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
20266
diff
changeset
|
114 mq.cmdtable['^qnew'][1][:] + commands.diffwsopts, |
14408
054da1e0afbe
record: use cmdutil.command decorator
Idan Kamara <idankk86@gmail.com>
parents:
14407
diff
changeset
|
115 _('hg qrecord [OPTION]... PATCH [FILE]...')) |
14426
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
116 |
15184
351a9292e430
record: use command wrapper properly for qnew/qrefresh (issue3001)
Matt Mackall <mpm@selenic.com>
parents:
14597
diff
changeset
|
117 _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch")) |
14426
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
118 _wrapcmd('qrefresh', mq.cmdtable, qrefresh, |
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
119 _("interactively select changes to refresh")) |
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
120 |
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
121 def _wrapcmd(cmd, table, wrapfn, msg): |
15184
351a9292e430
record: use command wrapper properly for qnew/qrefresh (issue3001)
Matt Mackall <mpm@selenic.com>
parents:
14597
diff
changeset
|
122 entry = extensions.wrapcommand(table, cmd, wrapfn) |
14426
1df64ccef23e
record: add qrefresh -i/--interactive
Idan Kamara <idankk86@gmail.com>
parents:
14425
diff
changeset
|
123 entry[1].append(('i', 'interactive', None, msg)) |