Show More
@@ -1,148 +1,148 b'' | |||||
1 | # record.py |
|
1 | # record.py | |
2 | # |
|
2 | # | |
3 | # Copyright 2007 Bryan O'Sullivan <bos@serpentine.com> |
|
3 | # Copyright 2007 Bryan O'Sullivan <bos@serpentine.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | '''commands to interactively select changes for commit/qrefresh (DEPRECATED) |
|
8 | '''commands to interactively select changes for commit/qrefresh (DEPRECATED) | |
9 |
|
9 | |||
10 | The feature provided by this extension has been moved into core Mercurial as |
|
10 | The feature provided by this extension has been moved into core Mercurial as | |
11 | :hg:`commit --interactive`.''' |
|
11 | :hg:`commit --interactive`.''' | |
12 |
|
12 | |||
13 | from __future__ import absolute_import |
|
13 | from __future__ import absolute_import | |
14 |
|
14 | |||
15 | from mercurial.i18n import _ |
|
15 | from mercurial.i18n import _ | |
16 | from mercurial import ( |
|
16 | from mercurial import ( | |
17 | cmdutil, |
|
17 | cmdutil, | |
18 | commands, |
|
18 | commands, | |
19 | error, |
|
19 | error, | |
20 | extensions, |
|
20 | extensions, | |
21 | registrar, |
|
21 | registrar, | |
22 | ) |
|
22 | ) | |
23 |
|
23 | |||
24 | cmdtable = {} |
|
24 | cmdtable = {} | |
25 | command = registrar.command(cmdtable) |
|
25 | command = registrar.command(cmdtable) | |
26 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
|
26 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | |
27 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
|
27 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | |
28 | # be specifying the version(s) of Mercurial they are tested with, or |
|
28 | # be specifying the version(s) of Mercurial they are tested with, or | |
29 | # leave the attribute unspecified. |
|
29 | # leave the attribute unspecified. | |
30 | testedwith = 'ships-with-hg-core' |
|
30 | testedwith = 'ships-with-hg-core' | |
31 |
|
31 | |||
32 |
|
32 | |||
33 | @command("record", |
|
33 | @command("record", | |
34 | # same options as commit + white space diff options |
|
34 | # same options as commit + white space diff options | |
35 | [c for c in commands.table['^commit|ci'][1][:] |
|
35 | [c for c in commands.table['^commit|ci'][1][:] | |
36 | if c[1] != "interactive"] + cmdutil.diffwsopts, |
|
36 | if c[1] != "interactive"] + cmdutil.diffwsopts, | |
37 | _('hg record [OPTION]... [FILE]...')) |
|
37 | _('hg record [OPTION]... [FILE]...')) | |
38 | def record(ui, repo, *pats, **opts): |
|
38 | def record(ui, repo, *pats, **opts): | |
39 | '''interactively select changes to commit |
|
39 | '''interactively select changes to commit | |
40 |
|
40 | |||
41 | If a list of files is omitted, all changes reported by :hg:`status` |
|
41 | If a list of files is omitted, all changes reported by :hg:`status` | |
42 | will be candidates for recording. |
|
42 | will be candidates for recording. | |
43 |
|
43 | |||
44 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
44 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
45 |
|
45 | |||
46 | If using the text interface (see :hg:`help config`), |
|
46 | If using the text interface (see :hg:`help config`), | |
47 | you will be prompted for whether to record changes to each |
|
47 | you will be prompted for whether to record changes to each | |
48 | modified file, and for files with multiple changes, for each |
|
48 | modified file, and for files with multiple changes, for each | |
49 | change to use. For each query, the following responses are |
|
49 | change to use. For each query, the following responses are | |
50 | possible:: |
|
50 | possible:: | |
51 |
|
51 | |||
52 | y - record this change |
|
52 | y - record this change | |
53 | n - skip this change |
|
53 | n - skip this change | |
54 | e - edit this change manually |
|
54 | e - edit this change manually | |
55 |
|
55 | |||
56 | s - skip remaining changes to this file |
|
56 | s - skip remaining changes to this file | |
57 | f - record remaining changes to this file |
|
57 | f - record remaining changes to this file | |
58 |
|
58 | |||
59 | d - done, skip remaining changes and files |
|
59 | d - done, skip remaining changes and files | |
60 | a - record all changes to all remaining files |
|
60 | a - record all changes to all remaining files | |
61 | q - quit, recording no changes |
|
61 | q - quit, recording no changes | |
62 |
|
62 | |||
63 | ? - display help |
|
63 | ? - display help | |
64 |
|
64 | |||
65 | This command is not available when committing a merge.''' |
|
65 | This command is not available when committing a merge.''' | |
66 |
|
66 | |||
67 | if not ui.interactive(): |
|
67 | if not ui.interactive(): | |
68 | raise error.Abort(_('running non-interactively, use %s instead') % |
|
68 | raise error.Abort(_('running non-interactively, use %s instead') % | |
69 | 'commit') |
|
69 | 'commit') | |
70 |
|
70 | |||
71 | opts["interactive"] = True |
|
71 | opts[r"interactive"] = True | |
72 | overrides = {('experimental', 'crecord'): False} |
|
72 | overrides = {('experimental', 'crecord'): False} | |
73 | with ui.configoverride(overrides, 'record'): |
|
73 | with ui.configoverride(overrides, 'record'): | |
74 | return commands.commit(ui, repo, *pats, **opts) |
|
74 | return commands.commit(ui, repo, *pats, **opts) | |
75 |
|
75 | |||
76 | def qrefresh(origfn, ui, repo, *pats, **opts): |
|
76 | def qrefresh(origfn, ui, repo, *pats, **opts): | |
77 | if not opts['interactive']: |
|
77 | if not opts[r'interactive']: | |
78 | return origfn(ui, repo, *pats, **opts) |
|
78 | return origfn(ui, repo, *pats, **opts) | |
79 |
|
79 | |||
80 | mq = extensions.find('mq') |
|
80 | mq = extensions.find('mq') | |
81 |
|
81 | |||
82 | def committomq(ui, repo, *pats, **opts): |
|
82 | def committomq(ui, repo, *pats, **opts): | |
83 | # At this point the working copy contains only changes that |
|
83 | # At this point the working copy contains only changes that | |
84 | # were accepted. All other changes were reverted. |
|
84 | # were accepted. All other changes were reverted. | |
85 | # We can't pass *pats here since qrefresh will undo all other |
|
85 | # We can't pass *pats here since qrefresh will undo all other | |
86 | # changed files in the patch that aren't in pats. |
|
86 | # changed files in the patch that aren't in pats. | |
87 | mq.refresh(ui, repo, **opts) |
|
87 | mq.refresh(ui, repo, **opts) | |
88 |
|
88 | |||
89 | # backup all changed files |
|
89 | # backup all changed files | |
90 | cmdutil.dorecord(ui, repo, committomq, None, True, |
|
90 | cmdutil.dorecord(ui, repo, committomq, None, True, | |
91 | cmdutil.recordfilter, *pats, **opts) |
|
91 | cmdutil.recordfilter, *pats, **opts) | |
92 |
|
92 | |||
93 | # This command registration is replaced during uisetup(). |
|
93 | # This command registration is replaced during uisetup(). | |
94 | @command('qrecord', |
|
94 | @command('qrecord', | |
95 | [], |
|
95 | [], | |
96 | _('hg qrecord [OPTION]... PATCH [FILE]...'), |
|
96 | _('hg qrecord [OPTION]... PATCH [FILE]...'), | |
97 | inferrepo=True) |
|
97 | inferrepo=True) | |
98 | def qrecord(ui, repo, patch, *pats, **opts): |
|
98 | def qrecord(ui, repo, patch, *pats, **opts): | |
99 | '''interactively record a new patch |
|
99 | '''interactively record a new patch | |
100 |
|
100 | |||
101 | See :hg:`help qnew` & :hg:`help record` for more information and |
|
101 | See :hg:`help qnew` & :hg:`help record` for more information and | |
102 | usage. |
|
102 | usage. | |
103 | ''' |
|
103 | ''' | |
104 | return _qrecord('qnew', ui, repo, patch, *pats, **opts) |
|
104 | return _qrecord('qnew', ui, repo, patch, *pats, **opts) | |
105 |
|
105 | |||
106 | def _qrecord(cmdsuggest, ui, repo, patch, *pats, **opts): |
|
106 | def _qrecord(cmdsuggest, ui, repo, patch, *pats, **opts): | |
107 | try: |
|
107 | try: | |
108 | mq = extensions.find('mq') |
|
108 | mq = extensions.find('mq') | |
109 | except KeyError: |
|
109 | except KeyError: | |
110 | raise error.Abort(_("'mq' extension not loaded")) |
|
110 | raise error.Abort(_("'mq' extension not loaded")) | |
111 |
|
111 | |||
112 | repo.mq.checkpatchname(patch) |
|
112 | repo.mq.checkpatchname(patch) | |
113 |
|
113 | |||
114 | def committomq(ui, repo, *pats, **opts): |
|
114 | def committomq(ui, repo, *pats, **opts): | |
115 | opts['checkname'] = False |
|
115 | opts[r'checkname'] = False | |
116 | mq.new(ui, repo, patch, *pats, **opts) |
|
116 | mq.new(ui, repo, patch, *pats, **opts) | |
117 |
|
117 | |||
118 | overrides = {('experimental', 'crecord'): False} |
|
118 | overrides = {('experimental', 'crecord'): False} | |
119 | with ui.configoverride(overrides, 'record'): |
|
119 | with ui.configoverride(overrides, 'record'): | |
120 | cmdutil.dorecord(ui, repo, committomq, cmdsuggest, False, |
|
120 | cmdutil.dorecord(ui, repo, committomq, cmdsuggest, False, | |
121 | cmdutil.recordfilter, *pats, **opts) |
|
121 | cmdutil.recordfilter, *pats, **opts) | |
122 |
|
122 | |||
123 | def qnew(origfn, ui, repo, patch, *args, **opts): |
|
123 | def qnew(origfn, ui, repo, patch, *args, **opts): | |
124 | if opts['interactive']: |
|
124 | if opts[r'interactive']: | |
125 | return _qrecord(None, ui, repo, patch, *args, **opts) |
|
125 | return _qrecord(None, ui, repo, patch, *args, **opts) | |
126 | return origfn(ui, repo, patch, *args, **opts) |
|
126 | return origfn(ui, repo, patch, *args, **opts) | |
127 |
|
127 | |||
128 |
|
128 | |||
129 | def uisetup(ui): |
|
129 | def uisetup(ui): | |
130 | try: |
|
130 | try: | |
131 | mq = extensions.find('mq') |
|
131 | mq = extensions.find('mq') | |
132 | except KeyError: |
|
132 | except KeyError: | |
133 | return |
|
133 | return | |
134 |
|
134 | |||
135 | cmdtable["qrecord"] = \ |
|
135 | cmdtable["qrecord"] = \ | |
136 | (qrecord, |
|
136 | (qrecord, | |
137 | # same options as qnew, but copy them so we don't get |
|
137 | # same options as qnew, but copy them so we don't get | |
138 | # -i/--interactive for qrecord and add white space diff options |
|
138 | # -i/--interactive for qrecord and add white space diff options | |
139 | mq.cmdtable['^qnew'][1][:] + cmdutil.diffwsopts, |
|
139 | mq.cmdtable['^qnew'][1][:] + cmdutil.diffwsopts, | |
140 | _('hg qrecord [OPTION]... PATCH [FILE]...')) |
|
140 | _('hg qrecord [OPTION]... PATCH [FILE]...')) | |
141 |
|
141 | |||
142 | _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch")) |
|
142 | _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch")) | |
143 | _wrapcmd('qrefresh', mq.cmdtable, qrefresh, |
|
143 | _wrapcmd('qrefresh', mq.cmdtable, qrefresh, | |
144 | _("interactively select changes to refresh")) |
|
144 | _("interactively select changes to refresh")) | |
145 |
|
145 | |||
146 | def _wrapcmd(cmd, table, wrapfn, msg): |
|
146 | def _wrapcmd(cmd, table, wrapfn, msg): | |
147 | entry = extensions.wrapcommand(table, cmd, wrapfn) |
|
147 | entry = extensions.wrapcommand(table, cmd, wrapfn) | |
148 | entry[1].append(('i', 'interactive', None, msg)) |
|
148 | entry[1].append(('i', 'interactive', None, msg)) |
General Comments 0
You need to be logged in to leave comments.
Login now