Skip to content
Snippets Groups Projects
Commit bcad61a1 authored by Sean Farley's avatar Sean Farley
Browse files

ui: add a parameter to set the temporary directory for edit

Until callsites are updated, this will have no effect. Once callsites
are updated, specifying experimental.editortmpinhg will create editor
temporary files in a subdirectory of .hg, which will make it easier
for tool integrations to determine what repository is in play when
they're asked to edit an hg-related file.
parent 64a9160b
No related branches found
No related tags found
No related merge requests found
......@@ -1021,7 +1021,8 @@
opts['label'] = opts.get('label', '') + ' ui.debug'
self.write(*msg, **opts)
def edit(self, text, user, extra=None, editform=None, pending=None):
def edit(self, text, user, extra=None, editform=None, pending=None,
tmpdir=None):
extra_defaults = {
'prefix': 'editor',
'suffix': '.txt',
......@@ -1029,4 +1030,8 @@
if extra is not None:
extra_defaults.update(extra)
extra = extra_defaults
tdir = None
if self.configbool('experimental', 'editortmpinhg'):
tdir = tmpdir
(fd, name) = tempfile.mkstemp(prefix='hg-' + extra['prefix'] + '-',
......@@ -1032,5 +1037,6 @@
(fd, name) = tempfile.mkstemp(prefix='hg-' + extra['prefix'] + '-',
suffix=extra['suffix'], text=True)
suffix=extra['suffix'], text=True,
dir=tdir)
try:
f = os.fdopen(fd, "w")
f.write(text)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment