1212 # wdirrev isn't contiguous so the slice shouldn't include it |
1214 # wdirrev isn't contiguous so the slice shouldn't include it |
1213 return [self[i] |
1215 return [self[i] |
1214 for i in pycompat.xrange(*changeid.indices(len(self))) |
1216 for i in pycompat.xrange(*changeid.indices(len(self))) |
1215 if i not in self.changelog.filteredrevs] |
1217 if i not in self.changelog.filteredrevs] |
1216 try: |
1218 try: |
1217 return context.changectx(self, changeid) |
1219 if isinstance(changeid, int): |
|
1220 node = self.changelog.node(changeid) |
|
1221 rev = changeid |
|
1222 return context.changectx(self, rev, node) |
|
1223 elif changeid == 'null': |
|
1224 node = nullid |
|
1225 rev = nullrev |
|
1226 return context.changectx(self, rev, node) |
|
1227 elif changeid == 'tip': |
|
1228 node = self.changelog.tip() |
|
1229 rev = self.changelog.rev(node) |
|
1230 return context.changectx(self, rev, node) |
|
1231 elif (changeid == '.' |
|
1232 or self.local() and changeid == self.dirstate.p1()): |
|
1233 # this is a hack to delay/avoid loading obsmarkers |
|
1234 # when we know that '.' won't be hidden |
|
1235 node = self.dirstate.p1() |
|
1236 rev = self.unfiltered().changelog.rev(node) |
|
1237 return context.changectx(self, rev, node) |
|
1238 elif len(changeid) == 20: |
|
1239 try: |
|
1240 node = changeid |
|
1241 rev = self.changelog.rev(changeid) |
|
1242 return context.changectx(self, rev, node) |
|
1243 except error.FilteredLookupError: |
|
1244 changeid = hex(changeid) # for the error message |
|
1245 raise |
|
1246 except LookupError: |
|
1247 # check if it might have come from damaged dirstate |
|
1248 # |
|
1249 # XXX we could avoid the unfiltered if we had a recognizable |
|
1250 # exception for filtered changeset access |
|
1251 if (self.local() |
|
1252 and changeid in self.unfiltered().dirstate.parents()): |
|
1253 msg = _("working directory has unknown parent '%s'!") |
|
1254 raise error.Abort(msg % short(changeid)) |
|
1255 changeid = hex(changeid) # for the error message |
|
1256 |
|
1257 elif len(changeid) == 40: |
|
1258 try: |
|
1259 node = bin(changeid) |
|
1260 rev = self.changelog.rev(node) |
|
1261 return context.changectx(self, rev, node) |
|
1262 except error.FilteredLookupError: |
|
1263 raise |
|
1264 except LookupError: |
|
1265 pass |
|
1266 else: |
|
1267 raise error.ProgrammingError( |
|
1268 "unsupported changeid '%s' of type %s" % |
|
1269 (changeid, type(changeid))) |
|
1270 |
|
1271 except (error.FilteredIndexError, error.FilteredLookupError): |
|
1272 raise error.FilteredRepoLookupError(_("filtered revision '%s'") |
|
1273 % pycompat.bytestr(changeid)) |
|
1274 except IndexError: |
|
1275 pass |
1218 except error.WdirUnsupported: |
1276 except error.WdirUnsupported: |
1219 return context.workingctx(self) |
1277 return context.workingctx(self) |
|
1278 raise error.RepoLookupError( |
|
1279 _("unknown revision '%s'") % changeid) |
1220 |
1280 |
1221 def __contains__(self, changeid): |
1281 def __contains__(self, changeid): |
1222 """True if the given changeid exists |
1282 """True if the given changeid exists |
1223 |
1283 |
1224 error.AmbiguousPrefixLookupError is raised if an ambiguous node |
1284 error.AmbiguousPrefixLookupError is raised if an ambiguous node |