##// END OF EJS Templates
context: move reuse of context object to repo.__getitem__ (API)...
Martin von Zweigbergk -
r37191:bb47dc2f default
parent child Browse files
Show More
@@ -62,11 +62,6 b' class basectx(object):'
62 be committed,
62 be committed,
63 memctx: a context that represents changes in-memory and can also
63 memctx: a context that represents changes in-memory and can also
64 be committed."""
64 be committed."""
65 def __new__(cls, repo, changeid='', *args, **kwargs):
66 if isinstance(changeid, basectx):
67 return changeid
68
69 return super(basectx, cls).__new__(cls)
70
65
71 def __bytes__(self):
66 def __bytes__(self):
72 return short(self.node())
67 return short(self.node())
@@ -412,11 +407,6 b' class changectx(basectx):'
412 def __init__(self, repo, changeid='.'):
407 def __init__(self, repo, changeid='.'):
413 """changeid is a revision number, node, or tag"""
408 """changeid is a revision number, node, or tag"""
414
409
415 # since basectx.__new__ already took care of copying the object, we
416 # don't need to do anything in __init__, so we just exit here
417 if isinstance(changeid, basectx):
418 return
419
420 if changeid == '':
410 if changeid == '':
421 changeid = '.'
411 changeid = '.'
422 self._repo = repo
412 self._repo = repo
@@ -2486,9 +2476,6 b' class metadataonlyctx(committablectx):'
2486 dateutil.parsedate() and defaults to current date, extra is a dictionary of
2476 dateutil.parsedate() and defaults to current date, extra is a dictionary of
2487 metadata or is left empty.
2477 metadata or is left empty.
2488 """
2478 """
2489 def __new__(cls, repo, originalctx, *args, **kwargs):
2490 return super(metadataonlyctx, cls).__new__(cls, repo)
2491
2492 def __init__(self, repo, originalctx, parents=None, text=None, user=None,
2479 def __init__(self, repo, originalctx, parents=None, text=None, user=None,
2493 date=None, extra=None, editor=False):
2480 date=None, extra=None, editor=False):
2494 if text is None:
2481 if text is None:
@@ -782,6 +782,8 b' class localrepository(object):'
782 def __getitem__(self, changeid):
782 def __getitem__(self, changeid):
783 if changeid is None:
783 if changeid is None:
784 return context.workingctx(self)
784 return context.workingctx(self)
785 if isinstance(changeid, context.basectx):
786 return changeid
785 if isinstance(changeid, slice):
787 if isinstance(changeid, slice):
786 # wdirrev isn't contiguous so the slice shouldn't include it
788 # wdirrev isn't contiguous so the slice shouldn't include it
787 return [context.changectx(self, i)
789 return [context.changectx(self, i)
General Comments 0
You need to be logged in to leave comments. Login now