[PATCH 1 of 4 emacs-for-augie] ui: add a parameter to set the temporary directory for edit

Augie Fackler raf at durin42.com
Wed Jan 18 11:16:28 EST 2017


On Mon, Jan 16, 2017 at 09:41:11PM -0800, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean at farley.io>
> # 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

I've queued this, with the commit message substantially rewritten, and
with the config knob renamed from tmpsubhg to editortmpinhg per an IRC
conversation with smf.

I've got one more comment below that I'd like to see addressed as a
followup (which I'll gladly take during the freeze).

>
> 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):

I think part of what made this patch confusing initially was that
we're not specifying a tmpdir here, it's actually the repo path
(including the .hg). Would this keyword argument be better named
repopath? If so, just do a one-patch replacement of the variable name
as a follow-up. Thanks!

>          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()
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list