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:49:50 EDT 2017


smf added a comment.


  In https://phab.mercurial-scm.org/D468#7910, @smf wrote:
  
  > 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.
  
  
  Basically, I was pondering aloud if '~' would be enough to future-proof us and if we shouldn't just rename all temp files to something unique (HG_EDITOR for commits, HG_HISTEDIT for histedit, etc). What I was hoping for was a discussion on that.

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