Show More
@@ -8,9 +8,12 b'' | |||||
8 | # This software may be used and distributed according to the terms |
|
8 | # This software may be used and distributed according to the terms | |
9 | # of the GNU General Public License, incorporated herein by reference. |
|
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 | from mercurial import mdiff |
|
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 | def compress(text): |
|
17 | def compress(text): | |
15 | return zlib.compress(text) |
|
18 | return zlib.compress(text) | |
16 |
|
19 | |||
@@ -32,7 +35,7 b' class revlog:' | |||||
32 | self.index = [] |
|
35 | self.index = [] | |
33 | self.opener = opener |
|
36 | self.opener = opener | |
34 | self.cache = None |
|
37 | self.cache = None | |
35 |
self.nodemap = { |
|
38 | self.nodemap = {nullid: -1} | |
36 | # read the whole index for now, handle on-demand later |
|
39 | # read the whole index for now, handle on-demand later | |
37 | try: |
|
40 | try: | |
38 | n = 0 |
|
41 | n = 0 | |
@@ -60,6 +63,21 b' class revlog:' | |||||
60 | def end(self, rev): return self.start(rev) + self.length(rev) |
|
63 | def end(self, rev): return self.start(rev) + self.length(rev) | |
61 | def base(self, rev): return self.index[rev][2] |
|
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 | def revisions(self, list): |
|
81 | def revisions(self, list): | |
64 | # this can be optimized to do spans, etc |
|
82 | # this can be optimized to do spans, etc | |
65 | # be stupid for now |
|
83 | # be stupid for now | |
@@ -73,7 +91,7 b' class revlog:' | |||||
73 | return mdiff.patch(text, patch) |
|
91 | return mdiff.patch(text, patch) | |
74 |
|
92 | |||
75 | def revision(self, node): |
|
93 | def revision(self, node): | |
76 |
if node |
|
94 | if node == nullid: return "" | |
77 | if self.cache and self.cache[0] == node: return self.cache[2] |
|
95 | if self.cache and self.cache[0] == node: return self.cache[2] | |
78 |
|
96 | |||
79 | text = None |
|
97 | text = None |
General Comments 0
You need to be logged in to leave comments.
Login now