From patchwork Tue Jan 17 05:41:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 4, emacs-for-augie] ui: add a parameter to set the temporary directory for edit From: Sean Farley X-Patchwork-Id: 18232 Message-Id: To: mercurial-devel@mercurial-scm.org Cc: sean@farley.io Date: Mon, 16 Jan 2017 21:41:11 -0800 # HG changeset patch # User Sean Farley # Date 1484629522 28800 # Mon Jan 16 21:05:22 2017 -0800 # Node ID cb18a2517507a169a7b3c38b369199130b1c89c0 # Parent 43c5526916752b0f7476a26069709f35590ddb04 ui: add a parameter to set the temporary directory for edit This currently does nothing but will allow hg tooling in emacs to use this to allow buffers to find the repo via the temp file's parent directory. diff --git a/mercurial/ui.py b/mercurial/ui.py index 1e82af6..7da75c3 100644 --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1010,20 +1010,26 @@ class ui(object): ''' if self.debugflag: 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', } if extra is not None: extra_defaults.update(extra) extra = extra_defaults + + tdir = None + if self.configbool('experimental', 'tmpsubhg'): + tdir = tmpdir (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) f.close()