Comments
Patch
@@ -963,9 +963,14 @@ class committablectx(basectx):
"""A committablectx object provides common functionality for a context that
wants the ability to commit, e.g. workingctx or memctx."""
def __init__(self, repo, text="", user=None, date=None, extra=None,
- changes=None):
+ changes=None, changeid=None):
self._repo = repo
- self._rev = None
+ # optional changeid can be used to place uncommitted revision virtually
+ # on top of changelog. node is None even if changeid is specified until
+ # we can determine the correct value for uncommitted context.
+ assert (changeid is None
+ or isinstance(changeid, int) and changeid >= len(repo))
+ self._rev = changeid
self._node = None
self._text = text
if date:
@@ -1187,8 +1192,9 @@ class workingctx(committablectx):
or None to use the repository status.
"""
def __init__(self, repo, text="", user=None, date=None, extra=None,
- changes=None):
- super(workingctx, self).__init__(repo, text, user, date, extra, changes)
+ changes=None, changeid=None):
+ super(workingctx, self).__init__(repo, text, user, date, extra, changes,
+ changeid)
def __iter__(self):
d = self._repo.dirstate
@@ -445,6 +445,8 @@ class localrepository(object):
def __getitem__(self, changeid):
if changeid is None:
return context.workingctx(self)
+ if changeid == len(self):
+ return context.workingctx(self, changeid=len(self))
return context.changectx(self, changeid)
def __contains__(self, changeid):