##// END OF EJS Templates
record: return code from underlying commit
Philippe Pepiot -
r30158:1baa0e2c default
parent child Browse files
Show More
@@ -1,152 +1,152 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 )
21 )
22
22
23 cmdtable = {}
23 cmdtable = {}
24 command = cmdutil.command(cmdtable)
24 command = cmdutil.command(cmdtable)
25 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
25 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
26 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
26 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
27 # be specifying the version(s) of Mercurial they are tested with, or
27 # be specifying the version(s) of Mercurial they are tested with, or
28 # leave the attribute unspecified.
28 # leave the attribute unspecified.
29 testedwith = 'ships-with-hg-core'
29 testedwith = 'ships-with-hg-core'
30
30
31
31
32 @command("record",
32 @command("record",
33 # same options as commit + white space diff options
33 # same options as commit + white space diff options
34 [c for c in commands.table['^commit|ci'][1][:]
34 [c for c in commands.table['^commit|ci'][1][:]
35 if c[1] != "interactive"] + commands.diffwsopts,
35 if c[1] != "interactive"] + commands.diffwsopts,
36 _('hg record [OPTION]... [FILE]...'))
36 _('hg record [OPTION]... [FILE]...'))
37 def record(ui, repo, *pats, **opts):
37 def record(ui, repo, *pats, **opts):
38 '''interactively select changes to commit
38 '''interactively select changes to commit
39
39
40 If a list of files is omitted, all changes reported by :hg:`status`
40 If a list of files is omitted, all changes reported by :hg:`status`
41 will be candidates for recording.
41 will be candidates for recording.
42
42
43 See :hg:`help dates` for a list of formats valid for -d/--date.
43 See :hg:`help dates` for a list of formats valid for -d/--date.
44
44
45 You will be prompted for whether to record changes to each
45 You will be prompted for whether to record changes to each
46 modified file, and for files with multiple changes, for each
46 modified file, and for files with multiple changes, for each
47 change to use. For each query, the following responses are
47 change to use. For each query, the following responses are
48 possible::
48 possible::
49
49
50 y - record this change
50 y - record this change
51 n - skip this change
51 n - skip this change
52 e - edit this change manually
52 e - edit this change manually
53
53
54 s - skip remaining changes to this file
54 s - skip remaining changes to this file
55 f - record remaining changes to this file
55 f - record remaining changes to this file
56
56
57 d - done, skip remaining changes and files
57 d - done, skip remaining changes and files
58 a - record all changes to all remaining files
58 a - record all changes to all remaining files
59 q - quit, recording no changes
59 q - quit, recording no changes
60
60
61 ? - display help
61 ? - display help
62
62
63 This command is not available when committing a merge.'''
63 This command is not available when committing a merge.'''
64
64
65 if not ui.interactive():
65 if not ui.interactive():
66 raise error.Abort(_('running non-interactively, use %s instead') %
66 raise error.Abort(_('running non-interactively, use %s instead') %
67 'commit')
67 'commit')
68
68
69 opts["interactive"] = True
69 opts["interactive"] = True
70 backup = ui.backupconfig('experimental', 'crecord')
70 backup = ui.backupconfig('experimental', 'crecord')
71 try:
71 try:
72 ui.setconfig('experimental', 'crecord', False, 'record')
72 ui.setconfig('experimental', 'crecord', False, 'record')
73 commands.commit(ui, repo, *pats, **opts)
73 return commands.commit(ui, repo, *pats, **opts)
74 finally:
74 finally:
75 ui.restoreconfig(backup)
75 ui.restoreconfig(backup)
76
76
77 def qrefresh(origfn, ui, repo, *pats, **opts):
77 def qrefresh(origfn, ui, repo, *pats, **opts):
78 if not opts['interactive']:
78 if not opts['interactive']:
79 return origfn(ui, repo, *pats, **opts)
79 return origfn(ui, repo, *pats, **opts)
80
80
81 mq = extensions.find('mq')
81 mq = extensions.find('mq')
82
82
83 def committomq(ui, repo, *pats, **opts):
83 def committomq(ui, repo, *pats, **opts):
84 # At this point the working copy contains only changes that
84 # At this point the working copy contains only changes that
85 # were accepted. All other changes were reverted.
85 # were accepted. All other changes were reverted.
86 # We can't pass *pats here since qrefresh will undo all other
86 # We can't pass *pats here since qrefresh will undo all other
87 # changed files in the patch that aren't in pats.
87 # changed files in the patch that aren't in pats.
88 mq.refresh(ui, repo, **opts)
88 mq.refresh(ui, repo, **opts)
89
89
90 # backup all changed files
90 # backup all changed files
91 cmdutil.dorecord(ui, repo, committomq, None, True,
91 cmdutil.dorecord(ui, repo, committomq, None, True,
92 cmdutil.recordfilter, *pats, **opts)
92 cmdutil.recordfilter, *pats, **opts)
93
93
94 # This command registration is replaced during uisetup().
94 # This command registration is replaced during uisetup().
95 @command('qrecord',
95 @command('qrecord',
96 [],
96 [],
97 _('hg qrecord [OPTION]... PATCH [FILE]...'),
97 _('hg qrecord [OPTION]... PATCH [FILE]...'),
98 inferrepo=True)
98 inferrepo=True)
99 def qrecord(ui, repo, patch, *pats, **opts):
99 def qrecord(ui, repo, patch, *pats, **opts):
100 '''interactively record a new patch
100 '''interactively record a new patch
101
101
102 See :hg:`help qnew` & :hg:`help record` for more information and
102 See :hg:`help qnew` & :hg:`help record` for more information and
103 usage.
103 usage.
104 '''
104 '''
105 return _qrecord('qnew', ui, repo, patch, *pats, **opts)
105 return _qrecord('qnew', ui, repo, patch, *pats, **opts)
106
106
107 def _qrecord(cmdsuggest, ui, repo, patch, *pats, **opts):
107 def _qrecord(cmdsuggest, ui, repo, patch, *pats, **opts):
108 try:
108 try:
109 mq = extensions.find('mq')
109 mq = extensions.find('mq')
110 except KeyError:
110 except KeyError:
111 raise error.Abort(_("'mq' extension not loaded"))
111 raise error.Abort(_("'mq' extension not loaded"))
112
112
113 repo.mq.checkpatchname(patch)
113 repo.mq.checkpatchname(patch)
114
114
115 def committomq(ui, repo, *pats, **opts):
115 def committomq(ui, repo, *pats, **opts):
116 opts['checkname'] = False
116 opts['checkname'] = False
117 mq.new(ui, repo, patch, *pats, **opts)
117 mq.new(ui, repo, patch, *pats, **opts)
118
118
119 backup = ui.backupconfig('experimental', 'crecord')
119 backup = ui.backupconfig('experimental', 'crecord')
120 try:
120 try:
121 ui.setconfig('experimental', 'crecord', False, 'record')
121 ui.setconfig('experimental', 'crecord', False, 'record')
122 cmdutil.dorecord(ui, repo, committomq, cmdsuggest, False,
122 cmdutil.dorecord(ui, repo, committomq, cmdsuggest, False,
123 cmdutil.recordfilter, *pats, **opts)
123 cmdutil.recordfilter, *pats, **opts)
124 finally:
124 finally:
125 ui.restoreconfig(backup)
125 ui.restoreconfig(backup)
126
126
127 def qnew(origfn, ui, repo, patch, *args, **opts):
127 def qnew(origfn, ui, repo, patch, *args, **opts):
128 if opts['interactive']:
128 if opts['interactive']:
129 return _qrecord(None, ui, repo, patch, *args, **opts)
129 return _qrecord(None, ui, repo, patch, *args, **opts)
130 return origfn(ui, repo, patch, *args, **opts)
130 return origfn(ui, repo, patch, *args, **opts)
131
131
132
132
133 def uisetup(ui):
133 def uisetup(ui):
134 try:
134 try:
135 mq = extensions.find('mq')
135 mq = extensions.find('mq')
136 except KeyError:
136 except KeyError:
137 return
137 return
138
138
139 cmdtable["qrecord"] = \
139 cmdtable["qrecord"] = \
140 (qrecord,
140 (qrecord,
141 # same options as qnew, but copy them so we don't get
141 # same options as qnew, but copy them so we don't get
142 # -i/--interactive for qrecord and add white space diff options
142 # -i/--interactive for qrecord and add white space diff options
143 mq.cmdtable['^qnew'][1][:] + commands.diffwsopts,
143 mq.cmdtable['^qnew'][1][:] + commands.diffwsopts,
144 _('hg qrecord [OPTION]... PATCH [FILE]...'))
144 _('hg qrecord [OPTION]... PATCH [FILE]...'))
145
145
146 _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch"))
146 _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch"))
147 _wrapcmd('qrefresh', mq.cmdtable, qrefresh,
147 _wrapcmd('qrefresh', mq.cmdtable, qrefresh,
148 _("interactively select changes to refresh"))
148 _("interactively select changes to refresh"))
149
149
150 def _wrapcmd(cmd, table, wrapfn, msg):
150 def _wrapcmd(cmd, table, wrapfn, msg):
151 entry = extensions.wrapcommand(table, cmd, wrapfn)
151 entry = extensions.wrapcommand(table, cmd, wrapfn)
152 entry[1].append(('i', 'interactive', None, msg))
152 entry[1].append(('i', 'interactive', None, msg))
@@ -1,89 +1,90 b''
1 Set up a repo
1 Set up a repo
2
2
3 $ cat <<EOF >> $HGRCPATH
3 $ cat <<EOF >> $HGRCPATH
4 > [ui]
4 > [ui]
5 > interactive = true
5 > interactive = true
6 > [extensions]
6 > [extensions]
7 > record =
7 > record =
8 > EOF
8 > EOF
9
9
10 $ hg init a
10 $ hg init a
11 $ cd a
11 $ cd a
12
12
13 Record help
13 Record help
14
14
15 $ hg record -h
15 $ hg record -h
16 hg record [OPTION]... [FILE]...
16 hg record [OPTION]... [FILE]...
17
17
18 interactively select changes to commit
18 interactively select changes to commit
19
19
20 If a list of files is omitted, all changes reported by 'hg status' will be
20 If a list of files is omitted, all changes reported by 'hg status' will be
21 candidates for recording.
21 candidates for recording.
22
22
23 See 'hg help dates' for a list of formats valid for -d/--date.
23 See 'hg help dates' for a list of formats valid for -d/--date.
24
24
25 You will be prompted for whether to record changes to each modified file,
25 You will be prompted for whether to record changes to each modified file,
26 and for files with multiple changes, for each change to use. For each
26 and for files with multiple changes, for each change to use. For each
27 query, the following responses are possible:
27 query, the following responses are possible:
28
28
29 y - record this change
29 y - record this change
30 n - skip this change
30 n - skip this change
31 e - edit this change manually
31 e - edit this change manually
32
32
33 s - skip remaining changes to this file
33 s - skip remaining changes to this file
34 f - record remaining changes to this file
34 f - record remaining changes to this file
35
35
36 d - done, skip remaining changes and files
36 d - done, skip remaining changes and files
37 a - record all changes to all remaining files
37 a - record all changes to all remaining files
38 q - quit, recording no changes
38 q - quit, recording no changes
39
39
40 ? - display help
40 ? - display help
41
41
42 This command is not available when committing a merge.
42 This command is not available when committing a merge.
43
43
44 (use 'hg help -e record' to show help for the record extension)
44 (use 'hg help -e record' to show help for the record extension)
45
45
46 options ([+] can be repeated):
46 options ([+] can be repeated):
47
47
48 -A --addremove mark new/missing files as added/removed before
48 -A --addremove mark new/missing files as added/removed before
49 committing
49 committing
50 --close-branch mark a branch head as closed
50 --close-branch mark a branch head as closed
51 --amend amend the parent of the working directory
51 --amend amend the parent of the working directory
52 -s --secret use the secret phase for committing
52 -s --secret use the secret phase for committing
53 -e --edit invoke editor on commit messages
53 -e --edit invoke editor on commit messages
54 -I --include PATTERN [+] include names matching the given patterns
54 -I --include PATTERN [+] include names matching the given patterns
55 -X --exclude PATTERN [+] exclude names matching the given patterns
55 -X --exclude PATTERN [+] exclude names matching the given patterns
56 -m --message TEXT use text as commit message
56 -m --message TEXT use text as commit message
57 -l --logfile FILE read commit message from file
57 -l --logfile FILE read commit message from file
58 -d --date DATE record the specified date as commit date
58 -d --date DATE record the specified date as commit date
59 -u --user USER record the specified user as committer
59 -u --user USER record the specified user as committer
60 -S --subrepos recurse into subrepositories
60 -S --subrepos recurse into subrepositories
61 -w --ignore-all-space ignore white space when comparing lines
61 -w --ignore-all-space ignore white space when comparing lines
62 -b --ignore-space-change ignore changes in the amount of white space
62 -b --ignore-space-change ignore changes in the amount of white space
63 -B --ignore-blank-lines ignore changes whose lines are all blank
63 -B --ignore-blank-lines ignore changes whose lines are all blank
64
64
65 (some details hidden, use --verbose to show complete help)
65 (some details hidden, use --verbose to show complete help)
66
66
67 Select no files
67 Select no files
68
68
69 $ touch empty-rw
69 $ touch empty-rw
70 $ hg add empty-rw
70 $ hg add empty-rw
71
71
72 $ hg record empty-rw<<EOF
72 $ hg record empty-rw<<EOF
73 > n
73 > n
74 > EOF
74 > EOF
75 diff --git a/empty-rw b/empty-rw
75 diff --git a/empty-rw b/empty-rw
76 new file mode 100644
76 new file mode 100644
77 examine changes to 'empty-rw'? [Ynesfdaq?] n
77 examine changes to 'empty-rw'? [Ynesfdaq?] n
78
78
79 no changes to record
79 no changes to record
80 [1]
80
81
81 $ hg tip -p
82 $ hg tip -p
82 changeset: -1:000000000000
83 changeset: -1:000000000000
83 tag: tip
84 tag: tip
84 user:
85 user:
85 date: Thu Jan 01 00:00:00 1970 +0000
86 date: Thu Jan 01 00:00:00 1970 +0000
86
87
87
88
88
89
89
90
General Comments 0
You need to be logged in to leave comments. Login now