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