##// END OF EJS Templates
context: drop support for looking up context by ambiguous changeid (API)...
Martin von Zweigbergk -
r38108:8b86acc7 default
parent child Browse files
Show More
@@ -24,7 +24,6 b' from .node import ('
24 24 short,
25 25 wdirfilenodeids,
26 26 wdirid,
27 wdirrev,
28 27 )
29 28 from . import (
30 29 dagop,
@@ -377,31 +376,6 b' class basectx(object):'
377 376
378 377 return r
379 378
380 def changectxdeprecwarn(repo):
381 # changectx's constructor will soon lose support for these forms of
382 # changeids:
383 # * stringinfied ints
384 # * bookmarks, tags, branches, and other namespace identifiers
385 # * hex nodeid prefixes
386 #
387 # Depending on your use case, replace repo[x] by one of these:
388 # * If you want to support general revsets, use scmutil.revsingle(x)
389 # * If you know that "x" is a stringified int, use repo[int(x)]
390 # * If you know that "x" is a bookmark, use repo._bookmarks.changectx(x)
391 # * If you know that "x" is a tag, use repo[repo.tags()[x]]
392 # * If you know that "x" is a branch or in some other namespace,
393 # use the appropriate mechanism for that namespace
394 # * If you know that "x" is a hex nodeid prefix, use
395 # repo[scmutil.resolvehexnodeidprefix(repo, x)]
396 # * If "x" is a string that can be any of the above, but you don't want
397 # to allow general revsets (perhaps because "x" may come from a remote
398 # user and the revset may be too costly), use scmutil.revsymbol(repo, x)
399 # * If "x" can be a mix of the above, you'll have to figure it out
400 # yourself
401 repo.ui.deprecwarn("changectx.__init__ is getting more limited, see "
402 "context.changectxdeprecwarn() for details", "4.6",
403 stacklevel=4)
404
405 379 class changectx(basectx):
406 380 """A changecontext object makes access to data related to a particular
407 381 changeset convenient. It represents a read-only context already present in
@@ -440,24 +414,6 b' class changectx(basectx):'
440 414 except LookupError:
441 415 pass
442 416
443 try:
444 r = int(changeid)
445 if '%d' % r != changeid:
446 raise ValueError
447 l = len(repo.changelog)
448 if r < 0:
449 r += l
450 if r < 0 or r >= l and r != wdirrev:
451 raise ValueError
452 self._rev = r
453 self._node = repo.changelog.node(r)
454 changectxdeprecwarn(repo)
455 return
456 except error.FilteredIndexError:
457 raise
458 except (ValueError, OverflowError, IndexError):
459 pass
460
461 417 if len(changeid) == 40:
462 418 try:
463 419 self._node = bin(changeid)
@@ -468,21 +424,6 b' class changectx(basectx):'
468 424 except (TypeError, LookupError):
469 425 pass
470 426
471 # lookup bookmarks through the name interface
472 try:
473 self._node = repo.names.singlenode(repo, changeid)
474 self._rev = repo.changelog.rev(self._node)
475 changectxdeprecwarn(repo)
476 return
477 except KeyError:
478 pass
479
480 self._node = scmutil.resolvehexnodeidprefix(repo, changeid)
481 if self._node is not None:
482 self._rev = repo.changelog.rev(self._node)
483 changectxdeprecwarn(repo)
484 return
485
486 427 # lookup failed
487 428 # check if it might have come from damaged dirstate
488 429 #
General Comments 0
You need to be logged in to leave comments. Login now