fix file opening for some commands on Windows
Using file as opener in debug commands won't work on Windows, as the
index and data files needs to be opened in binary mode.
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -896,7 +896,7 @@ def copy(ui, repo, *pats, **opts):
def debugancestor(ui, index, rev1, rev2):
"""find the ancestor revision of two revisions in a given index"""
- r = revlog.revlog(file, index, "")
+ r = revlog.revlog(util.opener(os.getcwd()), index, "")
a = r.ancestor(r.lookup(rev1), r.lookup(rev2))
ui.write("%d:%s\n" % (r.rev(a), hex(a)))
@@ -969,7 +969,7 @@ def debugstate(ui, repo):
def debugdata(ui, file_, rev):
"""dump the contents of an data file revision"""
- r = revlog.revlog(file, file_[:-2] + ".i", file_)
+ r = revlog.revlog(util.opener(os.getcwd()), file_[:-2] + ".i", file_)
try:
ui.write(r.revision(r.lookup(rev)))
except KeyError:
@@ -977,7 +977,7 @@ def debugdata(ui, file_, rev):
def debugindex(ui, file_):
"""dump the contents of an index file"""
- r = revlog.revlog(file, file_, "")
+ r = revlog.revlog(util.opener(os.getcwd()), file_, "")
ui.write(" rev offset length base linkrev" +
" nodeid p1 p2\n")
for i in range(r.count()):
@@ -988,7 +988,7 @@ def debugindex(ui, file_):
def debugindexdot(ui, file_):
"""dump an index DAG as a .dot file"""
- r = revlog.revlog(file, file_, "")
+ r = revlog.revlog(util.opener(os.getcwd()), file_, "")
ui.write("digraph G {\n")
for i in range(r.count()):
e = r.index[i]