Show More
@@ -8,9 +8,12 b'' | |||
|
8 | 8 | # This software may be used and distributed according to the terms |
|
9 | 9 | # of the GNU General Public License, incorporated herein by reference. |
|
10 | 10 | |
|
11 | import zlib, struct, sha, os, tempfile | |
|
11 | import zlib, struct, sha, os, tempfile, binascii | |
|
12 | 12 | from mercurial import mdiff |
|
13 | 13 | |
|
14 | def hex(node): return binascii.hexlify(node) | |
|
15 | def bin(node): return binascii.unhexlify(node) | |
|
16 | ||
|
14 | 17 | def compress(text): |
|
15 | 18 | return zlib.compress(text) |
|
16 | 19 | |
@@ -32,7 +35,7 b' class revlog:' | |||
|
32 | 35 | self.index = [] |
|
33 | 36 | self.opener = opener |
|
34 | 37 | self.cache = None |
|
35 |
self.nodemap = { |
|
|
38 | self.nodemap = {nullid: -1} | |
|
36 | 39 | # read the whole index for now, handle on-demand later |
|
37 | 40 | try: |
|
38 | 41 | n = 0 |
@@ -60,6 +63,21 b' class revlog:' | |||
|
60 | 63 | def end(self, rev): return self.start(rev) + self.length(rev) |
|
61 | 64 | def base(self, rev): return self.index[rev][2] |
|
62 | 65 | |
|
66 | def lookup(self, id): | |
|
67 | try: | |
|
68 | rev = int(id) | |
|
69 | return self.node(rev) | |
|
70 | except ValueError: | |
|
71 | c = [] | |
|
72 | for n in self.nodemap: | |
|
73 | if id in hex(n): | |
|
74 | c.append(n) | |
|
75 | if len(c) > 1: raise KeyError("Ambiguous identifier") | |
|
76 | if len(c) < 1: raise KeyError | |
|
77 | return c[0] | |
|
78 | ||
|
79 | return None | |
|
80 | ||
|
63 | 81 | def revisions(self, list): |
|
64 | 82 | # this can be optimized to do spans, etc |
|
65 | 83 | # be stupid for now |
@@ -73,7 +91,7 b' class revlog:' | |||
|
73 | 91 | return mdiff.patch(text, patch) |
|
74 | 92 | |
|
75 | 93 | def revision(self, node): |
|
76 |
if node |
|
|
94 | if node == nullid: return "" | |
|
77 | 95 | if self.cache and self.cache[0] == node: return self.cache[2] |
|
78 | 96 | |
|
79 | 97 | text = None |
General Comments 0
You need to be logged in to leave comments.
Login now