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