D468: util: use ~ as a suffix for a temp file in the same directory as a source file

smf (Sean Farley) phabricator at mercurial-scm.org
Wed Aug 23 16:45:12 EDT 2017


smf added a comment.


  In https://phab.mercurial-scm.org/D468#7909, @durin42 wrote:
  
  > In https://phab.mercurial-scm.org/D468#7908, @smf wrote:
  >
  > > In https://phab.mercurial-scm.org/D468#7836, @quark wrote:
  > >
  > > > In https://phab.mercurial-scm.org/D468#7833, @smf wrote:
  > > >
  > > > > Basically, I'd like a more unified approach for all types of temp files (commit message, histedit, conflicts, etc).
  > > >
  > > >
  > > > I think this patch is about low-level `util` function that shouldn't be coupled with `ui` or config. It has value on its own and I don't think such "unified approach" should block this patch - we can always add configs and make callers of `util.mktempcopy` pass `suffix` down here AFTER this patch.
  > >
  > >
  > > Um, what? That's the whole point of review. Yes, I know you think you can do this AFTER (why are we yelling?). I don't like this patch as-is and am frankly tired of trying to jam stuff through review and promise to clean up later. I am against this patch.
  >
  >
  > As a bystander here, I'm not even sure what the proposals are. Can one of you summarize what the competing ideas are?
  >
  > (In general I agree with smf that a more unified error-resistant API should be a goal, and I'm -0 on adding complexity to hg in the name of buck performance if there's a better proposal on the table (but if there is I've missed it.))
  
  
  From the mailing list (just posting this here for now so I can reply to it in the next message):
  
  Jun Wu <quark at fb.com> writes:
  
  > I think this patch is about changing the suffix. I guess some less powerful
  >  editors may only support matching file types by suffixes.
  
  Yeah, it seems that way.
  
  > Please correct me if I'm wrong, but I failed to see how the
  >  "experimental.editortmpinhg" setting could be used as-is to change the
  >  suffix. Therefore I think the patch is still needed.
  > 
  > Maybe we can change it to a config option? Like, instead of saying:
  > 
  >   extra_defaults = {
  >       'prefix': 'editor',
  >       'suffix': '.txt',
  >   }
  > 
  > Changing ".txt" there to be a config option (maybe
  >  experimental.editorsuffix).
  
  That seems a bit over complicated to me. Why not just just use the
  random tmp as a directory instead of a file while renaming the file at
  the same time:
  
  /tmp/XYZ123/hg-editor (or HG_EDITOR or whatever)
  
  This would allow 'editortmpinhg'[1] to just be .hg/hg-editor (or
  HG_EDITOR etc). The '~' seems a bit like a quick hack and I think I'd
  prefer to do this cleanly. My logic here is:
  
  1. if we can append a character to the suffix, then we should be able to
  
  change the directory
  
  2. we might want different 'file types' for different tmp files and '~' seems that it might not get us far enough. For instance: a) editor, b) conflicts c) histedit etc
  
  For (a) and (c), I hacked something together for my fork of magit
  (called mahgic) so that I can have different modes for commit (to show
  the diff) and for histedit (so that 'tab' and 'enter' will show the
  commit at the point).
  
  [1] I planned on making editortmpinhg a more thorough thing so that
  everything would be in the .hg directory so that programs (like emacs)
  would be able to find the correct repo given only the tmp file.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D468

To: mbolin, #hg-reviewers, quark, durin42
Cc: smf, mercurial-devel


More information about the Mercurial-devel mailing list