equal
deleted
inserted
replaced
63 raise error.LookupError(r, b'00changelog.i', _(b'no node')) |
63 raise error.LookupError(r, b'00changelog.i', _(b'no node')) |
64 return bin(t[0]) |
64 return bin(t[0]) |
65 |
65 |
66 def hasnode(self, n): |
66 def hasnode(self, n): |
67 t = self._db.execute( |
67 t = self._db.execute( |
68 'SELECT node FROM changelog WHERE node = ?', (n,) |
68 'SELECT node FROM changelog WHERE node = ?', |
|
69 (pycompat.sysstr(n),), |
69 ).fetchone() |
70 ).fetchone() |
70 return t is not None |
71 return t is not None |
71 |
72 |
72 |
73 |
73 class baselogindex(object): |
74 class baselogindex(object): |
142 return bin(t[0]) |
143 return bin(t[0]) |
143 return sha1nodeconstants.nullid |
144 return sha1nodeconstants.nullid |
144 |
145 |
145 def revs(self, start=0, stop=None): |
146 def revs(self, start=0, stop=None): |
146 if stop is None: |
147 if stop is None: |
147 stop = self.tip() |
148 stop = self.tiprev() |
148 t = self._db.execute( |
149 t = self._db.execute( |
149 'SELECT rev FROM changelog ' |
150 'SELECT rev FROM changelog ' |
150 'WHERE rev >= ? AND rev <= ? ' |
151 'WHERE rev >= ? AND rev <= ? ' |
151 'ORDER BY REV ASC', |
152 'ORDER BY REV ASC', |
152 (start, stop), |
153 (start, stop), |
154 return (int(r[0]) for r in t) |
155 return (int(r[0]) for r in t) |
155 |
156 |
156 def tiprev(self): |
157 def tiprev(self): |
157 t = self._db.execute( |
158 t = self._db.execute( |
158 'SELECT rev FROM changelog ' 'ORDER BY REV DESC ' 'LIMIT 1' |
159 'SELECT rev FROM changelog ' 'ORDER BY REV DESC ' 'LIMIT 1' |
159 ) |
160 ).fetchone() |
160 return next(t) |
161 |
|
162 if t is not None: |
|
163 return t[0] |
|
164 return -1 |
161 |
165 |
162 def _partialmatch(self, id): |
166 def _partialmatch(self, id): |
163 if sha1nodeconstants.wdirhex.startswith(id): |
167 if sha1nodeconstants.wdirhex.startswith(id): |
164 raise error.WdirUnsupported |
168 raise error.WdirUnsupported |
165 candidates = [ |
169 candidates = [ |
166 bin(x[0]) |
170 bin(x[0]) |
167 for x in self._db.execute( |
171 for x in self._db.execute( |
168 'SELECT node FROM changelog WHERE node LIKE ?', (id + b'%',) |
172 'SELECT node FROM changelog WHERE node LIKE ?', |
|
173 (pycompat.sysstr(id + b'%'),), |
169 ) |
174 ) |
170 ] |
175 ] |
171 if sha1nodeconstants.nullhex.startswith(id): |
176 if sha1nodeconstants.nullhex.startswith(id): |
172 candidates.append(sha1nodeconstants.nullid) |
177 candidates.append(sha1nodeconstants.nullid) |
173 if len(candidates) > 1: |
178 if len(candidates) > 1: |
211 # Ensure we have a node id |
216 # Ensure we have a node id |
212 if isinstance(nodeorrev, int): |
217 if isinstance(nodeorrev, int): |
213 n = self.node(nodeorrev) |
218 n = self.node(nodeorrev) |
214 else: |
219 else: |
215 n = nodeorrev |
220 n = nodeorrev |
|
221 extra = {b'branch': b'default'} |
216 # handle looking up nullid |
222 # handle looking up nullid |
217 if n == sha1nodeconstants.nullid: |
223 if n == sha1nodeconstants.nullid: |
218 return hgchangelog._changelogrevision( |
224 return hgchangelog._changelogrevision( |
219 extra={}, manifest=sha1nodeconstants.nullid |
225 extra=extra, manifest=sha1nodeconstants.nullid |
220 ) |
226 ) |
221 hn = gitutil.togitnode(n) |
227 hn = gitutil.togitnode(n) |
222 # We've got a real commit! |
228 # We've got a real commit! |
223 files = [ |
229 files = [ |
224 r[0] |
230 r[0] |
231 filesremoved = [ |
237 filesremoved = [ |
232 r[0] |
238 r[0] |
233 for r in self._db.execute( |
239 for r in self._db.execute( |
234 'SELECT filename FROM changedfiles ' |
240 'SELECT filename FROM changedfiles ' |
235 'WHERE node = ? and filenode = ?', |
241 'WHERE node = ? and filenode = ?', |
236 (hn, sha1nodeconstants.nullhex), |
242 (hn, gitutil.nullgit), |
237 ) |
243 ) |
238 ] |
244 ] |
239 c = self.gitrepo[hn] |
245 c = self.gitrepo[hn] |
240 return hgchangelog._changelogrevision( |
246 return hgchangelog._changelogrevision( |
241 manifest=n, # pretend manifest the same as the commit node |
247 manifest=n, # pretend manifest the same as the commit node |
245 files=files, |
251 files=files, |
246 # TODO filesadded in the index |
252 # TODO filesadded in the index |
247 filesremoved=filesremoved, |
253 filesremoved=filesremoved, |
248 description=c.message.encode('utf8'), |
254 description=c.message.encode('utf8'), |
249 # TODO do we want to handle extra? how? |
255 # TODO do we want to handle extra? how? |
250 extra={b'branch': b'default'}, |
256 extra=extra, |
251 ) |
257 ) |
252 |
258 |
253 def ancestors(self, revs, stoprev=0, inclusive=False): |
259 def ancestors(self, revs, stoprev=0, inclusive=False): |
254 revs = list(revs) |
260 revs = list(revs) |
255 tip = self.rev(self.tip()) |
261 tip = self.rev(self.tip()) |