Submitter | Sean Farley |
---|---|
Date | Jan. 17, 2017, 5:41 a.m. |
Message ID | <cb18a2517507a169a7b3.1484631671@1.0.0.127.in-addr.arpa> |
Download | mbox | patch |
Permalink | /patch/18232/ |
State | Accepted |
Headers | show |
Comments
Sean Farley <sean@farley.io> writes: > # HG changeset patch > # User Sean Farley <sean@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 > > 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'): Suggestions for a better config name are welcomed.
On Mon, Jan 16, 2017 at 09:41:11PM -0800, Sean Farley wrote: > # HG changeset patch > # User Sean Farley <sean@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 > > 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 I'm not following what this config knob is for - it looks like it's new in this change, but it's not documented here. Can you elaborate? In general, series seems okay though. > (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@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Augie Fackler <raf@durin42.com> writes: > On Mon, Jan 16, 2017 at 09:41:11PM -0800, Sean Farley wrote: >> # HG changeset patch >> # User Sean Farley <sean@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 >> >> 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 > > I'm not following what this config knob is for - it looks like it's > new in this change, but it's not documented here. Can you elaborate? Sure. Currently, when hg creates a tmp file, it's in /tmp or something similar. This knob will put those tmp files under .hg so that when emacs loads the buffer, it will immediately know which repo the tmp file belongs to. It's not easy to do this in emacs since you can run 'hg histedit' which (in my case) fires up emacs. In my magit clone work, hitting 'enter' will display the diff of the highlighted commit and without this knob, I have no way to tell which repo to query. Does that help? (If so, feel free to use some of that explanation in the commit message or comment)
On Mon, Jan 16, 2017 at 09:41:11PM -0800, Sean Farley wrote: > # HG changeset patch > # User Sean Farley <sean@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@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Augie Fackler <raf@durin42.com> writes: > On Mon, Jan 16, 2017 at 09:41:11PM -0800, Sean Farley wrote: >> # HG changeset patch >> # User Sean Farley <sean@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! Thanks! Will do.
Patch
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()