Show More
@@ -0,0 +1,35 b'' | |||||
|
1 | Test temp file used with an editor has the expected suffix. | |||
|
2 | ||||
|
3 | $ hg init | |||
|
4 | ||||
|
5 | Create an editor that writes its arguments to stdout and set it to $HGEDITOR. | |||
|
6 | ||||
|
7 | $ cat > editor.sh << EOF | |||
|
8 | > #!/bin/bash | |||
|
9 | > echo "\$@" | |||
|
10 | > exit 1 | |||
|
11 | > EOF | |||
|
12 | $ chmod +x editor.sh | |||
|
13 | $ hg add editor.sh | |||
|
14 | $ HGEDITOR=$TESTTMP/editor.sh | |||
|
15 | $ export HGEDITOR | |||
|
16 | ||||
|
17 | Verify that the path for a commit editor has the expected suffix. | |||
|
18 | ||||
|
19 | $ hg commit | |||
|
20 | *.commit.hg.txt (glob) | |||
|
21 | abort: edit failed: editor.sh exited with status 1 | |||
|
22 | [255] | |||
|
23 | ||||
|
24 | Verify that the path for a histedit editor has the expected suffix. | |||
|
25 | ||||
|
26 | $ cat >> $HGRCPATH <<EOF | |||
|
27 | > [extensions] | |||
|
28 | > rebase= | |||
|
29 | > histedit= | |||
|
30 | > EOF | |||
|
31 | $ hg commit --message 'At least one commit for histedit.' | |||
|
32 | $ hg histedit | |||
|
33 | *.histedit.hg.txt (glob) | |||
|
34 | abort: edit failed: editor.sh exited with status 1 | |||
|
35 | [255] |
@@ -1370,7 +1370,7 b' def ruleeditor(repo, ui, actions, editco' | |||||
1370 | rules += '\n\n' |
|
1370 | rules += '\n\n' | |
1371 | rules += editcomment |
|
1371 | rules += editcomment | |
1372 | rules = ui.edit(rules, ui.username(), {'prefix': 'histedit'}, |
|
1372 | rules = ui.edit(rules, ui.username(), {'prefix': 'histedit'}, | |
1373 | repopath=repo.path) |
|
1373 | repopath=repo.path, action='histedit') | |
1374 |
|
1374 | |||
1375 | # Save edit rules in .hg/histedit-last-edit.txt in case |
|
1375 | # Save edit rules in .hg/histedit-last-edit.txt in case | |
1376 | # the user needs to ask for help after something |
|
1376 | # the user needs to ask for help after something |
@@ -308,7 +308,8 b' def _getdescription(repo, defaultbody, s' | |||||
308 | else: |
|
308 | else: | |
309 | ui.write(_('\nWrite the introductory message for the ' |
|
309 | ui.write(_('\nWrite the introductory message for the ' | |
310 | 'patch series.\n\n')) |
|
310 | 'patch series.\n\n')) | |
311 |
body = ui.edit(defaultbody, sender, repopath=repo.path |
|
311 | body = ui.edit(defaultbody, sender, repopath=repo.path, | |
|
312 | action='patchbombbody') | |||
312 | # Save series description in case sendmail fails |
|
313 | # Save series description in case sendmail fails | |
313 | msgfile = repo.vfs('last-email.txt', 'wb') |
|
314 | msgfile = repo.vfs('last-email.txt', 'wb') | |
314 | msgfile.write(body) |
|
315 | msgfile.write(body) |
@@ -341,7 +341,7 b' def dorecord(ui, repo, commitfunc, cmdsu' | |||||
341 | + crecordmod.patchhelptext |
|
341 | + crecordmod.patchhelptext | |
342 | + fp.read()) |
|
342 | + fp.read()) | |
343 | reviewedpatch = ui.edit(patchtext, "", |
|
343 | reviewedpatch = ui.edit(patchtext, "", | |
344 |
|
|
344 | action="diff", | |
345 | repopath=repo.path) |
|
345 | repopath=repo.path) | |
346 | fp.truncate(0) |
|
346 | fp.truncate(0) | |
347 | fp.write(reviewedpatch) |
|
347 | fp.write(reviewedpatch) | |
@@ -3217,7 +3217,7 b' def commitforceeditor(repo, ctx, subs, f' | |||||
3217 |
|
3217 | |||
3218 | editortext = repo.ui.edit(committext, ctx.user(), ctx.extra(), |
|
3218 | editortext = repo.ui.edit(committext, ctx.user(), ctx.extra(), | |
3219 | editform=editform, pending=pending, |
|
3219 | editform=editform, pending=pending, | |
3220 | repopath=repo.path) |
|
3220 | repopath=repo.path, action='commit') | |
3221 | text = editortext |
|
3221 | text = editortext | |
3222 |
|
3222 | |||
3223 | # strip away anything below this special string (used for editors that want |
|
3223 | # strip away anything below this special string (used for editors that want |
@@ -1563,8 +1563,7 b' are you sure you want to review/edit and' | |||||
1563 |
|
1563 | |||
1564 | # start the editor and wait for it to complete |
|
1564 | # start the editor and wait for it to complete | |
1565 | try: |
|
1565 | try: | |
1566 | patch = self.ui.edit(patch.getvalue(), "", |
|
1566 | patch = self.ui.edit(patch.getvalue(), "", action="diff") | |
1567 | extra={"suffix": ".diff"}) |
|
|||
1568 | except error.Abort as exc: |
|
1567 | except error.Abort as exc: | |
1569 | self.errorstr = str(exc) |
|
1568 | self.errorstr = str(exc) | |
1570 | return None |
|
1569 | return None |
@@ -1346,20 +1346,31 b' class ui(object):' | |||||
1346 | self.write(*msg, **opts) |
|
1346 | self.write(*msg, **opts) | |
1347 |
|
1347 | |||
1348 | def edit(self, text, user, extra=None, editform=None, pending=None, |
|
1348 | def edit(self, text, user, extra=None, editform=None, pending=None, | |
1349 | repopath=None): |
|
1349 | repopath=None, action=None): | |
|
1350 | if action is None: | |||
|
1351 | self.develwarn('action is None but will soon be a required ' | |||
|
1352 | 'parameter to ui.edit()') | |||
1350 | extra_defaults = { |
|
1353 | extra_defaults = { | |
1351 | 'prefix': 'editor', |
|
1354 | 'prefix': 'editor', | |
1352 | 'suffix': '.txt', |
|
1355 | 'suffix': '.txt', | |
1353 | } |
|
1356 | } | |
1354 | if extra is not None: |
|
1357 | if extra is not None: | |
|
1358 | if extra.get('suffix') is not None: | |||
|
1359 | self.develwarn('extra.suffix is not None but will soon be ' | |||
|
1360 | 'ignored by ui.edit()') | |||
1355 | extra_defaults.update(extra) |
|
1361 | extra_defaults.update(extra) | |
1356 | extra = extra_defaults |
|
1362 | extra = extra_defaults | |
1357 |
|
1363 | |||
|
1364 | if action: | |||
|
1365 | suffix = '.%s.hg.txt' % action | |||
|
1366 | else: | |||
|
1367 | suffix = extra['suffix'] | |||
|
1368 | ||||
1358 | rdir = None |
|
1369 | rdir = None | |
1359 | if self.configbool('experimental', 'editortmpinhg'): |
|
1370 | if self.configbool('experimental', 'editortmpinhg'): | |
1360 | rdir = repopath |
|
1371 | rdir = repopath | |
1361 | (fd, name) = tempfile.mkstemp(prefix='hg-' + extra['prefix'] + '-', |
|
1372 | (fd, name) = tempfile.mkstemp(prefix='hg-' + extra['prefix'] + '-', | |
1362 |
suffix= |
|
1373 | suffix=suffix, | |
1363 | dir=rdir) |
|
1374 | dir=rdir) | |
1364 | try: |
|
1375 | try: | |
1365 | f = os.fdopen(fd, r'wb') |
|
1376 | f = os.fdopen(fd, r'wb') |
General Comments 0
You need to be logged in to leave comments.
Login now