Show More
@@ -1,143 +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''' |
|
9 | from __future__ import absolute_import | |
|
9 | 10 | |
|
11 | from mercurial import ( | |
|
12 | cmdutil, | |
|
13 | commands, | |
|
14 | error, | |
|
15 | extensions, | |
|
16 | ) | |
|
10 | 17 | from mercurial.i18n import _ |
|
11 | from mercurial import cmdutil, commands, extensions | |
|
12 | from mercurial import error | |
|
13 | 18 | |
|
14 | 19 | cmdtable = {} |
|
15 | 20 | command = cmdutil.command(cmdtable) |
|
16 | 21 | # Note for extension authors: ONLY specify testedwith = 'internal' for |
|
17 | 22 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
|
18 | 23 | # be specifying the version(s) of Mercurial they are tested with, or |
|
19 | 24 | # leave the attribute unspecified. |
|
20 | 25 | testedwith = 'internal' |
|
21 | 26 | |
|
22 | 27 | |
|
23 | 28 | @command("record", |
|
24 | 29 | # same options as commit + white space diff options |
|
25 | 30 | [c for c in commands.table['^commit|ci'][1][:] |
|
26 | 31 | if c[1] != "interactive"] + commands.diffwsopts, |
|
27 | 32 | _('hg record [OPTION]... [FILE]...')) |
|
28 | 33 | def record(ui, repo, *pats, **opts): |
|
29 | 34 | '''interactively select changes to commit |
|
30 | 35 | |
|
31 | 36 | If a list of files is omitted, all changes reported by :hg:`status` |
|
32 | 37 | will be candidates for recording. |
|
33 | 38 | |
|
34 | 39 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
35 | 40 | |
|
36 | 41 | You will be prompted for whether to record changes to each |
|
37 | 42 | modified file, and for files with multiple changes, for each |
|
38 | 43 | change to use. For each query, the following responses are |
|
39 | 44 | possible:: |
|
40 | 45 | |
|
41 | 46 | y - record this change |
|
42 | 47 | n - skip this change |
|
43 | 48 | e - edit this change manually |
|
44 | 49 | |
|
45 | 50 | s - skip remaining changes to this file |
|
46 | 51 | f - record remaining changes to this file |
|
47 | 52 | |
|
48 | 53 | d - done, skip remaining changes and files |
|
49 | 54 | a - record all changes to all remaining files |
|
50 | 55 | q - quit, recording no changes |
|
51 | 56 | |
|
52 | 57 | ? - display help |
|
53 | 58 | |
|
54 | 59 | This command is not available when committing a merge.''' |
|
55 | 60 | |
|
56 | 61 | if not ui.interactive(): |
|
57 | 62 | raise error.Abort(_('running non-interactively, use %s instead') % |
|
58 | 63 | 'commit') |
|
59 | 64 | |
|
60 | 65 | opts["interactive"] = True |
|
61 | 66 | backup = ui.backupconfig('experimental', 'crecord') |
|
62 | 67 | try: |
|
63 | 68 | ui.setconfig('experimental', 'crecord', False, 'record') |
|
64 | 69 | commands.commit(ui, repo, *pats, **opts) |
|
65 | 70 | finally: |
|
66 | 71 | ui.restoreconfig(backup) |
|
67 | 72 | |
|
68 | 73 | def qrefresh(origfn, ui, repo, *pats, **opts): |
|
69 | 74 | if not opts['interactive']: |
|
70 | 75 | return origfn(ui, repo, *pats, **opts) |
|
71 | 76 | |
|
72 | 77 | mq = extensions.find('mq') |
|
73 | 78 | |
|
74 | 79 | def committomq(ui, repo, *pats, **opts): |
|
75 | 80 | # At this point the working copy contains only changes that |
|
76 | 81 | # were accepted. All other changes were reverted. |
|
77 | 82 | # We can't pass *pats here since qrefresh will undo all other |
|
78 | 83 | # changed files in the patch that aren't in pats. |
|
79 | 84 | mq.refresh(ui, repo, **opts) |
|
80 | 85 | |
|
81 | 86 | # backup all changed files |
|
82 | 87 | cmdutil.dorecord(ui, repo, committomq, None, True, |
|
83 | 88 | cmdutil.recordfilter, *pats, **opts) |
|
84 | 89 | |
|
85 | 90 | # This command registration is replaced during uisetup(). |
|
86 | 91 | @command('qrecord', |
|
87 | 92 | [], |
|
88 | 93 | _('hg qrecord [OPTION]... PATCH [FILE]...'), |
|
89 | 94 | inferrepo=True) |
|
90 | 95 | def qrecord(ui, repo, patch, *pats, **opts): |
|
91 | 96 | '''interactively record a new patch |
|
92 | 97 | |
|
93 | 98 | See :hg:`help qnew` & :hg:`help record` for more information and |
|
94 | 99 | usage. |
|
95 | 100 | ''' |
|
96 | 101 | return _qrecord('qnew', ui, repo, patch, *pats, **opts) |
|
97 | 102 | |
|
98 | 103 | def _qrecord(cmdsuggest, ui, repo, patch, *pats, **opts): |
|
99 | 104 | try: |
|
100 | 105 | mq = extensions.find('mq') |
|
101 | 106 | except KeyError: |
|
102 | 107 | raise error.Abort(_("'mq' extension not loaded")) |
|
103 | 108 | |
|
104 | 109 | repo.mq.checkpatchname(patch) |
|
105 | 110 | |
|
106 | 111 | def committomq(ui, repo, *pats, **opts): |
|
107 | 112 | opts['checkname'] = False |
|
108 | 113 | mq.new(ui, repo, patch, *pats, **opts) |
|
109 | 114 | |
|
110 | 115 | backup = ui.backupconfig('experimental', 'crecord') |
|
111 | 116 | try: |
|
112 | 117 | ui.setconfig('experimental', 'crecord', False, 'record') |
|
113 | 118 | cmdutil.dorecord(ui, repo, committomq, cmdsuggest, False, |
|
114 | 119 | cmdutil.recordfilter, *pats, **opts) |
|
115 | 120 | finally: |
|
116 | 121 | ui.restoreconfig(backup) |
|
117 | 122 | |
|
118 | 123 | def qnew(origfn, ui, repo, patch, *args, **opts): |
|
119 | 124 | if opts['interactive']: |
|
120 | 125 | return _qrecord(None, ui, repo, patch, *args, **opts) |
|
121 | 126 | return origfn(ui, repo, patch, *args, **opts) |
|
122 | 127 | |
|
123 | 128 | |
|
124 | 129 | def uisetup(ui): |
|
125 | 130 | try: |
|
126 | 131 | mq = extensions.find('mq') |
|
127 | 132 | except KeyError: |
|
128 | 133 | return |
|
129 | 134 | |
|
130 | 135 | cmdtable["qrecord"] = \ |
|
131 | 136 | (qrecord, |
|
132 | 137 | # same options as qnew, but copy them so we don't get |
|
133 | 138 | # -i/--interactive for qrecord and add white space diff options |
|
134 | 139 | mq.cmdtable['^qnew'][1][:] + commands.diffwsopts, |
|
135 | 140 | _('hg qrecord [OPTION]... PATCH [FILE]...')) |
|
136 | 141 | |
|
137 | 142 | _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch")) |
|
138 | 143 | _wrapcmd('qrefresh', mq.cmdtable, qrefresh, |
|
139 | 144 | _("interactively select changes to refresh")) |
|
140 | 145 | |
|
141 | 146 | def _wrapcmd(cmd, table, wrapfn, msg): |
|
142 | 147 | entry = extensions.wrapcommand(table, cmd, wrapfn) |
|
143 | 148 | entry[1].append(('i', 'interactive', None, msg)) |
@@ -1,146 +1,145 b'' | |||
|
1 | 1 | #require test-repo |
|
2 | 2 | |
|
3 | 3 | $ cd "$TESTDIR"/.. |
|
4 | 4 | |
|
5 | 5 | $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py |
|
6 | 6 | contrib/check-code.py not using absolute_import |
|
7 | 7 | contrib/check-code.py requires print_function |
|
8 | 8 | contrib/debugshell.py not using absolute_import |
|
9 | 9 | contrib/hgfixes/fix_bytes.py not using absolute_import |
|
10 | 10 | contrib/hgfixes/fix_bytesmod.py not using absolute_import |
|
11 | 11 | contrib/hgfixes/fix_leftover_imports.py not using absolute_import |
|
12 | 12 | contrib/import-checker.py not using absolute_import |
|
13 | 13 | contrib/import-checker.py requires print_function |
|
14 | 14 | contrib/memory.py not using absolute_import |
|
15 | 15 | contrib/perf.py not using absolute_import |
|
16 | 16 | contrib/python-hook-examples.py not using absolute_import |
|
17 | 17 | contrib/revsetbenchmarks.py not using absolute_import |
|
18 | 18 | contrib/revsetbenchmarks.py requires print_function |
|
19 | 19 | contrib/showstack.py not using absolute_import |
|
20 | 20 | contrib/synthrepo.py not using absolute_import |
|
21 | 21 | contrib/win32/hgwebdir_wsgi.py not using absolute_import |
|
22 | 22 | doc/check-seclevel.py not using absolute_import |
|
23 | 23 | doc/gendoc.py not using absolute_import |
|
24 | 24 | doc/hgmanpage.py not using absolute_import |
|
25 | 25 | hgext/__init__.py not using absolute_import |
|
26 | 26 | hgext/color.py not using absolute_import |
|
27 | 27 | hgext/convert/__init__.py not using absolute_import |
|
28 | 28 | hgext/convert/bzr.py not using absolute_import |
|
29 | 29 | hgext/convert/common.py not using absolute_import |
|
30 | 30 | hgext/convert/convcmd.py not using absolute_import |
|
31 | 31 | hgext/convert/cvs.py not using absolute_import |
|
32 | 32 | hgext/convert/subversion.py not using absolute_import |
|
33 | 33 | hgext/convert/transport.py not using absolute_import |
|
34 | 34 | hgext/eol.py not using absolute_import |
|
35 | 35 | hgext/extdiff.py not using absolute_import |
|
36 | 36 | hgext/factotum.py not using absolute_import |
|
37 | 37 | hgext/fetch.py not using absolute_import |
|
38 | 38 | hgext/gpg.py not using absolute_import |
|
39 | 39 | hgext/graphlog.py not using absolute_import |
|
40 | 40 | hgext/hgcia.py not using absolute_import |
|
41 | 41 | hgext/hgk.py not using absolute_import |
|
42 | 42 | hgext/highlight/__init__.py not using absolute_import |
|
43 | 43 | hgext/highlight/highlight.py not using absolute_import |
|
44 | 44 | hgext/histedit.py not using absolute_import |
|
45 | 45 | hgext/largefiles/__init__.py not using absolute_import |
|
46 | 46 | hgext/largefiles/basestore.py not using absolute_import |
|
47 | 47 | hgext/largefiles/lfcommands.py not using absolute_import |
|
48 | 48 | hgext/largefiles/lfutil.py not using absolute_import |
|
49 | 49 | hgext/largefiles/localstore.py not using absolute_import |
|
50 | 50 | hgext/largefiles/overrides.py not using absolute_import |
|
51 | 51 | hgext/largefiles/proto.py not using absolute_import |
|
52 | 52 | hgext/largefiles/remotestore.py not using absolute_import |
|
53 | 53 | hgext/largefiles/reposetup.py not using absolute_import |
|
54 | 54 | hgext/largefiles/uisetup.py not using absolute_import |
|
55 | 55 | hgext/largefiles/wirestore.py not using absolute_import |
|
56 | 56 | hgext/mq.py not using absolute_import |
|
57 | 57 | hgext/notify.py not using absolute_import |
|
58 | 58 | hgext/patchbomb.py not using absolute_import |
|
59 | 59 | hgext/purge.py not using absolute_import |
|
60 | 60 | hgext/rebase.py not using absolute_import |
|
61 | hgext/record.py not using absolute_import | |
|
62 | 61 | hgext/share.py not using absolute_import |
|
63 | 62 | hgext/transplant.py not using absolute_import |
|
64 | 63 | hgext/win32mbcs.py not using absolute_import |
|
65 | 64 | hgext/win32text.py not using absolute_import |
|
66 | 65 | i18n/check-translation.py not using absolute_import |
|
67 | 66 | i18n/polib.py not using absolute_import |
|
68 | 67 | setup.py not using absolute_import |
|
69 | 68 | tests/filterpyflakes.py requires print_function |
|
70 | 69 | tests/generate-working-copy-states.py requires print_function |
|
71 | 70 | tests/get-with-headers.py requires print_function |
|
72 | 71 | tests/heredoctest.py requires print_function |
|
73 | 72 | tests/hypothesishelpers.py not using absolute_import |
|
74 | 73 | tests/hypothesishelpers.py requires print_function |
|
75 | 74 | tests/killdaemons.py not using absolute_import |
|
76 | 75 | tests/md5sum.py not using absolute_import |
|
77 | 76 | tests/mockblackbox.py not using absolute_import |
|
78 | 77 | tests/printenv.py not using absolute_import |
|
79 | 78 | tests/readlink.py not using absolute_import |
|
80 | 79 | tests/readlink.py requires print_function |
|
81 | 80 | tests/revlog-formatv0.py not using absolute_import |
|
82 | 81 | tests/run-tests.py not using absolute_import |
|
83 | 82 | tests/seq.py not using absolute_import |
|
84 | 83 | tests/seq.py requires print_function |
|
85 | 84 | tests/silenttestrunner.py not using absolute_import |
|
86 | 85 | tests/silenttestrunner.py requires print_function |
|
87 | 86 | tests/sitecustomize.py not using absolute_import |
|
88 | 87 | tests/svn-safe-append.py not using absolute_import |
|
89 | 88 | tests/svnxml.py not using absolute_import |
|
90 | 89 | tests/test-ancestor.py requires print_function |
|
91 | 90 | tests/test-atomictempfile.py not using absolute_import |
|
92 | 91 | tests/test-batching.py not using absolute_import |
|
93 | 92 | tests/test-batching.py requires print_function |
|
94 | 93 | tests/test-bdiff.py not using absolute_import |
|
95 | 94 | tests/test-bdiff.py requires print_function |
|
96 | 95 | tests/test-context.py not using absolute_import |
|
97 | 96 | tests/test-context.py requires print_function |
|
98 | 97 | tests/test-demandimport.py not using absolute_import |
|
99 | 98 | tests/test-demandimport.py requires print_function |
|
100 | 99 | tests/test-dispatch.py not using absolute_import |
|
101 | 100 | tests/test-dispatch.py requires print_function |
|
102 | 101 | tests/test-doctest.py not using absolute_import |
|
103 | 102 | tests/test-duplicateoptions.py not using absolute_import |
|
104 | 103 | tests/test-duplicateoptions.py requires print_function |
|
105 | 104 | tests/test-filecache.py not using absolute_import |
|
106 | 105 | tests/test-filecache.py requires print_function |
|
107 | 106 | tests/test-filelog.py not using absolute_import |
|
108 | 107 | tests/test-filelog.py requires print_function |
|
109 | 108 | tests/test-hg-parseurl.py not using absolute_import |
|
110 | 109 | tests/test-hg-parseurl.py requires print_function |
|
111 | 110 | tests/test-hgweb-auth.py not using absolute_import |
|
112 | 111 | tests/test-hgweb-auth.py requires print_function |
|
113 | 112 | tests/test-hgwebdir-paths.py not using absolute_import |
|
114 | 113 | tests/test-hybridencode.py not using absolute_import |
|
115 | 114 | tests/test-hybridencode.py requires print_function |
|
116 | 115 | tests/test-lrucachedict.py not using absolute_import |
|
117 | 116 | tests/test-lrucachedict.py requires print_function |
|
118 | 117 | tests/test-manifest.py not using absolute_import |
|
119 | 118 | tests/test-minirst.py not using absolute_import |
|
120 | 119 | tests/test-minirst.py requires print_function |
|
121 | 120 | tests/test-parseindex2.py not using absolute_import |
|
122 | 121 | tests/test-parseindex2.py requires print_function |
|
123 | 122 | tests/test-pathencode.py not using absolute_import |
|
124 | 123 | tests/test-pathencode.py requires print_function |
|
125 | 124 | tests/test-propertycache.py not using absolute_import |
|
126 | 125 | tests/test-propertycache.py requires print_function |
|
127 | 126 | tests/test-revlog-ancestry.py not using absolute_import |
|
128 | 127 | tests/test-revlog-ancestry.py requires print_function |
|
129 | 128 | tests/test-run-tests.py not using absolute_import |
|
130 | 129 | tests/test-simplemerge.py not using absolute_import |
|
131 | 130 | tests/test-status-inprocess.py not using absolute_import |
|
132 | 131 | tests/test-status-inprocess.py requires print_function |
|
133 | 132 | tests/test-symlink-os-yes-fs-no.py not using absolute_import |
|
134 | 133 | tests/test-trusted.py not using absolute_import |
|
135 | 134 | tests/test-trusted.py requires print_function |
|
136 | 135 | tests/test-ui-color.py not using absolute_import |
|
137 | 136 | tests/test-ui-color.py requires print_function |
|
138 | 137 | tests/test-ui-config.py not using absolute_import |
|
139 | 138 | tests/test-ui-config.py requires print_function |
|
140 | 139 | tests/test-ui-verbosity.py not using absolute_import |
|
141 | 140 | tests/test-ui-verbosity.py requires print_function |
|
142 | 141 | tests/test-url.py not using absolute_import |
|
143 | 142 | tests/test-url.py requires print_function |
|
144 | 143 | tests/test-walkrepo.py requires print_function |
|
145 | 144 | tests/test-wireproto.py requires print_function |
|
146 | 145 | tests/tinyproxy.py requires print_function |
General Comments 0
You need to be logged in to leave comments.
Login now