Show More
@@ -1484,6 +1484,7 b' class queue(object):' | |||
|
1484 | 1484 | self.ui.write(_("no patches applied\n")) |
|
1485 | 1485 | return 1 |
|
1486 | 1486 | msg = opts.get('msg', '').rstrip() |
|
1487 | editor = opts.get('editor') | |
|
1487 | 1488 | newuser = opts.get('user') |
|
1488 | 1489 | newdate = opts.get('date') |
|
1489 | 1490 | if newdate: |
@@ -1652,9 +1653,20 b' class queue(object):' | |||
|
1652 | 1653 | try: |
|
1653 | 1654 | # might be nice to attempt to roll back strip after this |
|
1654 | 1655 | |
|
1655 | if not msg: | |
|
1656 | defaultmsg = "[mq]: %s" % patchfn | |
|
1657 | if editor: | |
|
1658 | origeditor = editor | |
|
1659 | def desceditor(repo, ctx, subs): | |
|
1660 | desc = origeditor(repo, ctx, subs) | |
|
1661 | if desc.rstrip(): | |
|
1662 | ph.setmessage(desc) | |
|
1663 | return desc | |
|
1664 | return defaultmsg | |
|
1665 | message = msg or "\n".join(ph.message) | |
|
1666 | editor = desceditor | |
|
1667 | elif not msg: | |
|
1656 | 1668 | if not ph.message: |
|
1657 |
message = |
|
|
1669 | message = defaultmsg | |
|
1658 | 1670 | else: |
|
1659 | 1671 | message = "\n".join(ph.message) |
|
1660 | 1672 | else: |
@@ -1664,7 +1676,7 b' class queue(object):' | |||
|
1664 | 1676 | # Ensure we create a new changeset in the same phase than |
|
1665 | 1677 | # the old one. |
|
1666 | 1678 | n = newcommit(repo, oldphase, message, user, ph.date, |
|
1667 | match=match, force=True) | |
|
1679 | match=match, force=True, editor=editor) | |
|
1668 | 1680 | # only write patch after a successful commit |
|
1669 | 1681 | c = [list(x) for x in refreshchanges] |
|
1670 | 1682 | if inclsubs: |
@@ -2478,20 +2490,16 b' def refresh(ui, repo, *pats, **opts):' | |||
|
2478 | 2490 | q = repo.mq |
|
2479 | 2491 | message = cmdutil.logmessage(ui, opts) |
|
2480 | 2492 | if opts.get('edit'): |
|
2481 | if not q.applied: | |
|
2482 | ui.write(_("no patches applied\n")) | |
|
2483 | return 1 | |
|
2484 | 2493 | if message: |
|
2485 | 2494 | raise util.Abort(_('option "-e" incompatible with "-m" or "-l"')) |
|
2486 | patch = q.applied[-1].name | |
|
2487 | ph = patchheader(q.join(patch), q.plainmode) | |
|
2488 | message = ui.edit('\n'.join(ph.message), ph.user or ui.username()) | |
|
2489 | # We don't want to lose the patch message if qrefresh fails (issue2062) | |
|
2490 | repo.savecommitmessage(message) | |
|
2495 | def editor(repo, ctx, subs): | |
|
2496 | return ui.edit(ctx.description() + "\n", ctx.user()) | |
|
2497 | else: | |
|
2498 | editor = False | |
|
2491 | 2499 | setupheaderopts(ui, opts) |
|
2492 | 2500 | wlock = repo.wlock() |
|
2493 | 2501 | try: |
|
2494 | ret = q.refresh(repo, pats, msg=message, **opts) | |
|
2502 | ret = q.refresh(repo, pats, msg=message, editor=editor, **opts) | |
|
2495 | 2503 | q.savedirty() |
|
2496 | 2504 | return ret |
|
2497 | 2505 | finally: |
@@ -2582,13 +2590,15 b' def fold(ui, repo, *files, **opts):' | |||
|
2582 | 2590 | message = '\n'.join(message) |
|
2583 | 2591 | |
|
2584 | 2592 | if opts.get('edit'): |
|
2585 | message = ui.edit(message, user or ui.username()) | |
|
2586 | repo.savecommitmessage(message) | |
|
2593 | def editor(repo, ctx, subs): | |
|
2594 | return ui.edit(ctx.description() + "\n", ctx.user()) | |
|
2595 | else: | |
|
2596 | editor = False | |
|
2587 | 2597 | |
|
2588 | 2598 | diffopts = q.patchopts(q.diffopts(), *patches) |
|
2589 | 2599 | wlock = repo.wlock() |
|
2590 | 2600 | try: |
|
2591 | q.refresh(repo, msg=message, git=diffopts.git) | |
|
2601 | q.refresh(repo, msg=message, git=diffopts.git, editor=editor) | |
|
2592 | 2602 | q.delete(repo, patches, opts) |
|
2593 | 2603 | q.savedirty() |
|
2594 | 2604 | finally: |
@@ -153,8 +153,9 b' Test saving last-message.txt:' | |||
|
153 | 153 | > repo.__class__ = commitfailure |
|
154 | 154 | > EOF |
|
155 | 155 | |
|
156 | $ cat > .hg/hgrc <<EOF | |
|
156 | $ cat >> .hg/hgrc <<EOF | |
|
157 | 157 | > [extensions] |
|
158 | > # this failure occurs before editor invocation | |
|
158 | 159 | > commitfailure = $TESTTMP/commitfailure.py |
|
159 | 160 | > EOF |
|
160 | 161 | |
@@ -165,15 +166,65 b' Test saving last-message.txt:' | |||
|
165 | 166 | > (echo; echo "test saving last-message.txt") >> \$1 |
|
166 | 167 | > EOF |
|
167 | 168 | |
|
169 | $ hg qapplied | |
|
170 | p1 | |
|
171 | git | |
|
172 | $ hg tip --template "{files}\n" | |
|
173 | aa | |
|
174 | ||
|
175 | (test that editor is not invoked before transaction starting) | |
|
176 | ||
|
168 | 177 | $ rm -f .hg/last-message.txt |
|
169 | 178 | $ HGEDITOR="sh $TESTTMP/editor.sh" hg qfold -e p3 |
|
170 | ==== before editing | |
|
171 | original message==== | |
|
172 | 179 | refresh interrupted while patch was popped! (revert --all, qpush to recover) |
|
173 | 180 | abort: emulating unexpected abort |
|
174 | 181 | [255] |
|
175 | 182 | $ cat .hg/last-message.txt |
|
183 | cat: .hg/last-message.txt: No such file or directory | |
|
184 | [1] | |
|
185 | ||
|
186 | (reset applied patches and directory status) | |
|
187 | ||
|
188 | $ cat >> .hg/hgrc <<EOF | |
|
189 | > [extensions] | |
|
190 | > # this failure occurs after editor invocation | |
|
191 | > commitfailure = ! | |
|
192 | > EOF | |
|
193 | ||
|
194 | $ hg qapplied | |
|
195 | p1 | |
|
196 | $ hg status -A aa | |
|
197 | ? aa | |
|
198 | $ rm aa | |
|
199 | $ hg status -m | |
|
200 | M a | |
|
201 | $ hg revert --no-backup -q a | |
|
202 | $ hg qpush -q git | |
|
203 | now at: git | |
|
204 | ||
|
205 | (test that editor is invoked and commit message is saved into | |
|
206 | "last-message.txt") | |
|
207 | ||
|
208 | $ cat >> .hg/hgrc <<EOF | |
|
209 | > [hooks] | |
|
210 | > # this failure occurs after editor invocation | |
|
211 | > pretxncommit.unexpectedabort = false | |
|
212 | > EOF | |
|
213 | ||
|
214 | $ rm -f .hg/last-message.txt | |
|
215 | $ HGEDITOR="sh $TESTTMP/editor.sh" hg qfold -e p3 | |
|
216 | ==== before editing | |
|
176 | 217 | original message |
|
218 | ==== | |
|
219 | transaction abort! | |
|
220 | rollback completed | |
|
221 | note: commit message saved in .hg/last-message.txt | |
|
222 | refresh interrupted while patch was popped! (revert --all, qpush to recover) | |
|
223 | abort: pretxncommit.unexpectedabort hook exited with status 1 | |
|
224 | [255] | |
|
225 | $ cat .hg/last-message.txt | |
|
226 | original message | |
|
227 | ||
|
177 | 228 | test saving last-message.txt |
|
178 | 229 | |
|
179 | 230 | $ cd .. |
@@ -59,3 +59,86 b" Should display 'Fifth commit message\\\\\\n" | |||
|
59 | 59 | $ hg log -l1 --template "{desc}\n" |
|
60 | 60 | Fifth commit message |
|
61 | 61 | This is the 5th log message |
|
62 | ||
|
63 | Test saving last-message.txt: | |
|
64 | ||
|
65 | $ cat > $TESTTMP/editor.sh << EOF | |
|
66 | > echo "==== before editing" | |
|
67 | > cat \$1 | |
|
68 | > echo "====" | |
|
69 | > (echo; echo "test saving last-message.txt") >> \$1 | |
|
70 | > EOF | |
|
71 | ||
|
72 | $ cat > $TESTTMP/commitfailure.py <<EOF | |
|
73 | > from mercurial import util | |
|
74 | > def reposetup(ui, repo): | |
|
75 | > class commitfailure(repo.__class__): | |
|
76 | > def commit(self, *args, **kwargs): | |
|
77 | > raise util.Abort('emulating unexpected abort') | |
|
78 | > repo.__class__ = commitfailure | |
|
79 | > EOF | |
|
80 | ||
|
81 | $ cat >> .hg/hgrc <<EOF | |
|
82 | > [extensions] | |
|
83 | > # this failure occurs before editor invocation | |
|
84 | > commitfailure = $TESTTMP/commitfailure.py | |
|
85 | > EOF | |
|
86 | ||
|
87 | $ hg qapplied | |
|
88 | first-patch | |
|
89 | second-patch | |
|
90 | $ hg tip --template "{files}\n" | |
|
91 | file2 | |
|
92 | ||
|
93 | (test that editor is not invoked before transaction starting) | |
|
94 | ||
|
95 | $ rm -f .hg/last-message.txt | |
|
96 | $ HGEDITOR="sh $TESTTMP/editor.sh" hg qrefresh -e | |
|
97 | refresh interrupted while patch was popped! (revert --all, qpush to recover) | |
|
98 | abort: emulating unexpected abort | |
|
99 | [255] | |
|
100 | $ cat .hg/last-message.txt | |
|
101 | cat: .hg/last-message.txt: No such file or directory | |
|
102 | [1] | |
|
103 | ||
|
104 | (reset applied patches and directory status) | |
|
105 | ||
|
106 | $ cat >> .hg/hgrc <<EOF | |
|
107 | > [extensions] | |
|
108 | > commitfailure = ! | |
|
109 | > EOF | |
|
110 | ||
|
111 | $ hg qapplied | |
|
112 | first-patch | |
|
113 | $ hg status -A file2 | |
|
114 | ? file2 | |
|
115 | $ rm file2 | |
|
116 | $ hg qpush -q second-patch | |
|
117 | now at: second-patch | |
|
118 | ||
|
119 | (test that editor is invoked and commit message is saved into | |
|
120 | "last-message.txt") | |
|
121 | ||
|
122 | $ cat >> .hg/hgrc <<EOF | |
|
123 | > [hooks] | |
|
124 | > # this failure occurs after editor invocation | |
|
125 | > pretxncommit.unexpectedabort = false | |
|
126 | > EOF | |
|
127 | ||
|
128 | $ rm -f .hg/last-message.txt | |
|
129 | $ HGEDITOR="sh $TESTTMP/editor.sh" hg qrefresh -e | |
|
130 | ==== before editing | |
|
131 | Fifth commit message | |
|
132 | This is the 5th log message | |
|
133 | ==== | |
|
134 | transaction abort! | |
|
135 | rollback completed | |
|
136 | note: commit message saved in .hg/last-message.txt | |
|
137 | refresh interrupted while patch was popped! (revert --all, qpush to recover) | |
|
138 | abort: pretxncommit.unexpectedabort hook exited with status 1 | |
|
139 | [255] | |
|
140 | $ cat .hg/last-message.txt | |
|
141 | Fifth commit message | |
|
142 | This is the 5th log message | |
|
143 | ||
|
144 | test saving last-message.txt |
General Comments 0
You need to be logged in to leave comments.
Login now