contrib: fix binary file issues with dumprevlog on Windows
authorAdrian Buehlmann <adrian@cadifra.com>
Fri, 04 Apr 2008 16:39:44 +0200
changeset 6466 9c426da6b03b
parent 6465 9b340e725c11
child 6476 ea230fb1c0e2
contrib: fix binary file issues with dumprevlog on Windows * Fix traceback on dumprevlog: open revlog in mode 'rb' (binary) * Set stdio to binary mode so that redirected data is not modified References: http://selenic.com/pipermail/mercurial/2008-March/018330.html http://selenic.com/repo/index.cgi/hg/rev/a3fe91b4f6eb
contrib/dumprevlog
contrib/undumprevlog
--- a/contrib/dumprevlog	Thu Apr 03 17:17:39 2008 +0200
+++ b/contrib/dumprevlog	Fri Apr 04 16:39:44 2008 +0200
@@ -3,10 +3,14 @@
 # $ find .hg/store/ -name "*.i" | xargs dumprevlog > repo.dump
 
 import sys
-from mercurial import revlog, node
+from mercurial import revlog, node, util
+
+for fp in (sys.stdin, sys.stdout, sys.stderr):
+    util.set_binary(fp)
 
 for f in sys.argv[1:]:
-    r = revlog.revlog(open, f)
+    binopen = lambda fn: open(fn, 'rb')
+    r = revlog.revlog(binopen, f)
     print "file:", f
     for i in xrange(r.count()):
         n = r.node(i)
--- a/contrib/undumprevlog	Thu Apr 03 17:17:39 2008 +0200
+++ b/contrib/undumprevlog	Fri Apr 04 16:39:44 2008 +0200
@@ -6,6 +6,9 @@
 import sys
 from mercurial import revlog, node, util, transaction
 
+for fp in (sys.stdin, sys.stdout, sys.stderr):
+    util.set_binary(fp)
+
 opener = util.opener('.', False)
 tr = transaction.transaction(sys.stderr.write, opener, "undump.journal")
 while 1: