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