Mercurial > public > mercurial-scm > hg-stable
diff mercurial/context.py @ 6708:7566f00a3979
localrepo: let commit() get extra data from workingctx
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Wed, 18 Jun 2008 22:52:26 +0200 |
parents | 02bad34230a2 |
children | f84f507c53d3 |
line wrap: on
line diff
--- a/mercurial/context.py Wed Jun 18 22:52:25 2008 +0200 +++ b/mercurial/context.py Wed Jun 18 22:52:26 2008 +0200 @@ -446,10 +446,11 @@ """A workingctx object makes access to data related to the current working directory convenient. parents - a pair of parent nodeids, or None to use the dirstate. + extra - a dictionary of extra values, or None. changes - a list of file lists as returned by localrepo.status() or None to use the repository status. """ - def __init__(self, repo, parents=None, changes=None): + def __init__(self, repo, parents=None, extra=None, changes=None): self._repo = repo self._rev = None self._node = None @@ -459,6 +460,19 @@ if changes: self._status = list(changes) + self._extra = {} + if extra: + self._extra = extra.copy() + if 'branch' not in self._extra: + branch = self._repo.dirstate.branch() + try: + branch = branch.decode('UTF-8').encode('UTF-8') + except UnicodeDecodeError: + raise util.Abort(_('branch name not in UTF-8!')) + self._extra['branch'] = branch + if self._extra['branch'] == '': + self._extra['branch'] = 'default' + def __str__(self): return str(self._parents[0]) + "+" @@ -518,7 +532,8 @@ def deleted(self): return self._status[3] def unknown(self): return self._status[4] def clean(self): return self._status[5] - def branch(self): return self._repo.dirstate.branch() + def branch(self): return self._extra['branch'] + def extra(self): return self._extra def tags(self): t = []