comparison mercurial/commands.py @ 1504:0fcdd126642d

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.
author Christian Boos <cboos@neuf.fr>
date Thu, 03 Nov 2005 14:24:07 -0800
parents 3cf287a03664
children 27f08094cfe0
comparison
equal deleted inserted replaced
1503:d176c81481c8 1504:0fcdd126642d
894 errs, copied = docopy(ui, repo, pats, opts) 894 errs, copied = docopy(ui, repo, pats, opts)
895 return errs 895 return errs
896 896
897 def debugancestor(ui, index, rev1, rev2): 897 def debugancestor(ui, index, rev1, rev2):
898 """find the ancestor revision of two revisions in a given index""" 898 """find the ancestor revision of two revisions in a given index"""
899 r = revlog.revlog(file, index, "") 899 r = revlog.revlog(util.opener(os.getcwd()), index, "")
900 a = r.ancestor(r.lookup(rev1), r.lookup(rev2)) 900 a = r.ancestor(r.lookup(rev1), r.lookup(rev2))
901 ui.write("%d:%s\n" % (r.rev(a), hex(a))) 901 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
902 902
903 def debugcheckstate(ui, repo): 903 def debugcheckstate(ui, repo):
904 """validate the correctness of the current dirstate""" 904 """validate the correctness of the current dirstate"""
967 for f in repo.dirstate.copies: 967 for f in repo.dirstate.copies:
968 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copies[f], f)) 968 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copies[f], f))
969 969
970 def debugdata(ui, file_, rev): 970 def debugdata(ui, file_, rev):
971 """dump the contents of an data file revision""" 971 """dump the contents of an data file revision"""
972 r = revlog.revlog(file, file_[:-2] + ".i", file_) 972 r = revlog.revlog(util.opener(os.getcwd()), file_[:-2] + ".i", file_)
973 try: 973 try:
974 ui.write(r.revision(r.lookup(rev))) 974 ui.write(r.revision(r.lookup(rev)))
975 except KeyError: 975 except KeyError:
976 raise util.Abort(_('invalid revision identifier %s'), rev) 976 raise util.Abort(_('invalid revision identifier %s'), rev)
977 977
978 def debugindex(ui, file_): 978 def debugindex(ui, file_):
979 """dump the contents of an index file""" 979 """dump the contents of an index file"""
980 r = revlog.revlog(file, file_, "") 980 r = revlog.revlog(util.opener(os.getcwd()), file_, "")
981 ui.write(" rev offset length base linkrev" + 981 ui.write(" rev offset length base linkrev" +
982 " nodeid p1 p2\n") 982 " nodeid p1 p2\n")
983 for i in range(r.count()): 983 for i in range(r.count()):
984 e = r.index[i] 984 e = r.index[i]
985 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( 985 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
986 i, e[0], e[1], e[2], e[3], 986 i, e[0], e[1], e[2], e[3],
987 short(e[6]), short(e[4]), short(e[5]))) 987 short(e[6]), short(e[4]), short(e[5])))
988 988
989 def debugindexdot(ui, file_): 989 def debugindexdot(ui, file_):
990 """dump an index DAG as a .dot file""" 990 """dump an index DAG as a .dot file"""
991 r = revlog.revlog(file, file_, "") 991 r = revlog.revlog(util.opener(os.getcwd()), file_, "")
992 ui.write("digraph G {\n") 992 ui.write("digraph G {\n")
993 for i in range(r.count()): 993 for i in range(r.count()):
994 e = r.index[i] 994 e = r.index[i]
995 ui.write("\t%d -> %d\n" % (r.rev(e[4]), i)) 995 ui.write("\t%d -> %d\n" % (r.rev(e[4]), i))
996 if e[5] != nullid: 996 if e[5] != nullid: