Patchwork D7185: py3: open chistedit file in binary mode using vfs

login
register
mail settings
Submitter phabricator
Date Oct. 31, 2019, 10:23 p.m.
Message ID <differential-rev-PHID-DREV-unp4etzpv2srqdlxo3gh-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42629/
State Superseded
Headers show

Comments

phabricator - Oct. 31, 2019, 10:23 p.m.
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We write bytes to the file, so it should be open in binary
  mode. Opening it via the vfs takes care of that for us.
  
  Now you'll get yet a different traceback if you try to confirm you
  histedit plan.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS




To: martinvonz, durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1675,11 +1675,10 @@ 
         if type(rc) is list:
             ui.status(_(b"performing changes\n"))
             rules = makecommands(rc)
-            filename = repo.vfs.join(b'chistedit')
-            with open(filename, b'w+') as fp:
+            with repo.vfs(b'chistedit', b'w+') as fp:
                 for r in rules:
                     fp.write(r)
-            opts[b'commands'] = filename
+                opts[b'commands'] = fp.name
             return _texthistedit(ui, repo, *freeargs, **opts)
     except KeyboardInterrupt:
         pass