dumprevlog: handle being passed a mode parameter
authorBoris Feld <boris.feld@octobus.net>
Tue, 06 Feb 2018 11:51:39 +0100
changeset 35964 a915465a731e
parent 35963 69aaad59dc02
child 35965 c839bbee1e13
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.
contrib/dumprevlog
--- a/contrib/dumprevlog	Tue Feb 06 11:08:41 2018 +0100
+++ b/contrib/dumprevlog	Tue Feb 06 11:51:39 2018 +0100
@@ -14,8 +14,12 @@
 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: