Patchwork [03,of,13] dumprevlog: handle being passed a mode parameter

login
register
mail settings
Submitter Boris Feld
Date Feb. 6, 2018, 1:21 p.m.
Message ID <4cd271a9bd82ddca149a.1517923284@FB>
Download mbox | patch
Permalink /patch/27354/
State New
Headers show

Comments

Boris Feld - Feb. 6, 2018, 1:21 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1517914299 -3600
#      Tue Feb 06 11:51:39 2018 +0100
# Node ID 4cd271a9bd82ddca149a0dd5a2ae819a4c1db8ef
# Parent  b9d09ad843263f81e9d561d76e65671af864cc6f
# EXP-Topic revlog-fp
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4cd271a9bd82
dumprevlog: handle being passed a mode parameter

This makes it closer to an actual file opener. Otherwise, it gets in the way
of a coming refactoring.

Patch

diff --git a/contrib/dumprevlog b/contrib/dumprevlog
--- a/contrib/dumprevlog
+++ b/contrib/dumprevlog
@@ -14,8 +14,12 @@  from mercurial import (
 for fp in (sys.stdin, sys.stdout, sys.stderr):
     util.setbinary(fp)
 
+def binopen(path, mode='rb'):
+    if 'b' not in mode:
+        mode = mode + 'b'
+    return open(path, mode)
+
 for f in sys.argv[1:]:
-    binopen = lambda fn: open(fn, 'rb')
     r = revlog.revlog(binopen, f)
     print("file:", f)
     for i in r: