comparison mercurial/bundlerepo.py @ 2256:4b71f37cbdb7

fix errors spotted by pychecker (mostly scope problems)
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Thu, 11 May 2006 11:15:23 +0200
parents 9b42304d9896
children 8dafccbcede9
comparison
equal deleted inserted replaced
2255:3f38e872f39a 2256:4b71f37cbdb7
48 if node in self.nodemap: 48 if node in self.nodemap:
49 prev = node 49 prev = node
50 continue 50 continue
51 for p in (p1, p2): 51 for p in (p1, p2):
52 if not p in self.nodemap: 52 if not p in self.nodemap:
53 raise RevlogError(_("unknown parent %s") % short(p1)) 53 raise revlog.RevlogError(_("unknown parent %s") % short(p1))
54 if linkmapper is None: 54 if linkmapper is None:
55 link = n 55 link = n
56 else: 56 else:
57 link = linkmapper(cs) 57 link = linkmapper(cs)
58 58
74 """is rev from the bundle""" 74 """is rev from the bundle"""
75 if rev < 0: 75 if rev < 0:
76 return False 76 return False
77 return rev in self.basemap 77 return rev in self.basemap
78 def bundlebase(self, rev): return self.basemap[rev] 78 def bundlebase(self, rev): return self.basemap[rev]
79 def chunk(self, rev, df=None): 79 def chunk(self, rev, df=None, cachelen=4096):
80 # Warning: in case of bundle, the diff is against bundlebase, 80 # Warning: in case of bundle, the diff is against bundlebase,
81 # not against rev - 1 81 # not against rev - 1
82 # XXX: could use some caching 82 # XXX: could use some caching
83 if not self.bundle(rev): 83 if not self.bundle(rev):
84 return revlog.revlog.chunk(self, rev) 84 return revlog.revlog.chunk(self, rev, df, cachelen)
85 self.bundlefile.seek(self.start(rev)) 85 self.bundlefile.seek(self.start(rev))
86 return self.bundlefile.read(self.length(rev)) 86 return self.bundlefile.read(self.length(rev))
87 87
88 def revdiff(self, rev1, rev2): 88 def revdiff(self, rev1, rev2):
89 """return or calculate a delta between two revisions""" 89 """return or calculate a delta between two revisions"""
121 delta = self.chunk(chain.pop()) 121 delta = self.chunk(chain.pop())
122 text = self.patches(text, [delta]) 122 text = self.patches(text, [delta])
123 123
124 p1, p2 = self.parents(node) 124 p1, p2 = self.parents(node)
125 if node != revlog.hash(text, p1, p2): 125 if node != revlog.hash(text, p1, p2):
126 raise RevlogError(_("integrity check failed on %s:%d") 126 raise revlog.RevlogError(_("integrity check failed on %s:%d")
127 % (self.datafile, self.rev(node))) 127 % (self.datafile, self.rev(node)))
128 128
129 self.cache = (node, self.rev(node), text) 129 self.cache = (node, self.rev(node), text)
130 return text 130 return text
131 131
158 158
159 class bundlerepository(localrepo.localrepository): 159 class bundlerepository(localrepo.localrepository):
160 def __init__(self, ui, path, bundlename): 160 def __init__(self, ui, path, bundlename):
161 localrepo.localrepository.__init__(self, ui, path) 161 localrepo.localrepository.__init__(self, ui, path)
162 f = open(bundlename, "rb") 162 f = open(bundlename, "rb")
163 s = util.fstat(f)
164 self.bundlefile = f 163 self.bundlefile = f
165 header = self.bundlefile.read(6) 164 header = self.bundlefile.read(6)
166 if not header.startswith("HG"): 165 if not header.startswith("HG"):
167 raise util.Abort(_("%s: not a Mercurial bundle file") % bundlename) 166 raise util.Abort(_("%s: not a Mercurial bundle file") % bundlename)
168 elif not header.startswith("HG10"): 167 elif not header.startswith("HG10"):