comparison mercurial/hg.py @ 37:a8811676c85a

Move hex/bin bits to revlog Handle lookup of rev -1 of changelog
author mpm@selenic.com
date Sat, 07 May 2005 16:12:31 -0800
parents 98633e60067c
children 5f87633e1ea2
comparison
equal deleted inserted replaced
36:da28286bf6b7 37:a8811676c85a
3 # Copyright 2005 Matt Mackall <mpm@selenic.com> 3 # Copyright 2005 Matt Mackall <mpm@selenic.com>
4 # 4 #
5 # This software may be used and distributed according to the terms 5 # This software may be used and distributed according to the terms
6 # of the GNU General Public License, incorporated herein by reference. 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 import sys, struct, sha, socket, os, time, base64, re, urllib2, binascii 8 import sys, struct, sha, socket, os, time, base64, re, urllib2
9 import urllib 9 import urllib
10 from mercurial import byterange 10 from mercurial import byterange
11 from mercurial.transaction import * 11 from mercurial.transaction import *
12 from mercurial.revlog import * 12 from mercurial.revlog import *
13
14 def hex(node): return binascii.hexlify(node)
15 def bin(node): return binascii.unhexlify(node)
16 13
17 class filelog(revlog): 14 class filelog(revlog):
18 def __init__(self, opener, path): 15 def __init__(self, opener, path):
19 s = self.encodepath(path) 16 s = self.encodepath(path)
20 revlog.__init__(self, opener, os.path.join("data", s + "i"), 17 revlog.__init__(self, opener, os.path.join("data", s + "i"),
110 class changelog(revlog): 107 class changelog(revlog):
111 def __init__(self, opener): 108 def __init__(self, opener):
112 revlog.__init__(self, opener, "00changelog.i", "00changelog.d") 109 revlog.__init__(self, opener, "00changelog.i", "00changelog.d")
113 110
114 def extract(self, text): 111 def extract(self, text):
112 if not text:
113 return (nullid, "", 0, [], "")
115 last = text.index("\n\n") 114 last = text.index("\n\n")
116 desc = text[last + 2:] 115 desc = text[last + 2:]
117 l = text[:last].splitlines() 116 l = text[:last].splitlines()
118 manifest = bin(l[0]) 117 manifest = bin(l[0])
119 user = l[1] 118 user = l[1]