Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
6707:02bad34230a2 | 6708:7566f00a3979 |
---|---|
444 | 444 |
445 class workingctx(changectx): | 445 class workingctx(changectx): |
446 """A workingctx object makes access to data related to | 446 """A workingctx object makes access to data related to |
447 the current working directory convenient. | 447 the current working directory convenient. |
448 parents - a pair of parent nodeids, or None to use the dirstate. | 448 parents - a pair of parent nodeids, or None to use the dirstate. |
449 extra - a dictionary of extra values, or None. | |
449 changes - a list of file lists as returned by localrepo.status() | 450 changes - a list of file lists as returned by localrepo.status() |
450 or None to use the repository status. | 451 or None to use the repository status. |
451 """ | 452 """ |
452 def __init__(self, repo, parents=None, changes=None): | 453 def __init__(self, repo, parents=None, extra=None, changes=None): |
453 self._repo = repo | 454 self._repo = repo |
454 self._rev = None | 455 self._rev = None |
455 self._node = None | 456 self._node = None |
456 if parents: | 457 if parents: |
457 p1, p2 = parents | 458 p1, p2 = parents |
458 self._parents = [self._repo.changectx(p) for p in (p1, p2)] | 459 self._parents = [self._repo.changectx(p) for p in (p1, p2)] |
459 if changes: | 460 if changes: |
460 self._status = list(changes) | 461 self._status = list(changes) |
462 | |
463 self._extra = {} | |
464 if extra: | |
465 self._extra = extra.copy() | |
466 if 'branch' not in self._extra: | |
467 branch = self._repo.dirstate.branch() | |
468 try: | |
469 branch = branch.decode('UTF-8').encode('UTF-8') | |
470 except UnicodeDecodeError: | |
471 raise util.Abort(_('branch name not in UTF-8!')) | |
472 self._extra['branch'] = branch | |
473 if self._extra['branch'] == '': | |
474 self._extra['branch'] = 'default' | |
461 | 475 |
462 def __str__(self): | 476 def __str__(self): |
463 return str(self._parents[0]) + "+" | 477 return str(self._parents[0]) + "+" |
464 | 478 |
465 def __nonzero__(self): | 479 def __nonzero__(self): |
516 def added(self): return self._status[1] | 530 def added(self): return self._status[1] |
517 def removed(self): return self._status[2] | 531 def removed(self): return self._status[2] |
518 def deleted(self): return self._status[3] | 532 def deleted(self): return self._status[3] |
519 def unknown(self): return self._status[4] | 533 def unknown(self): return self._status[4] |
520 def clean(self): return self._status[5] | 534 def clean(self): return self._status[5] |
521 def branch(self): return self._repo.dirstate.branch() | 535 def branch(self): return self._extra['branch'] |
536 def extra(self): return self._extra | |
522 | 537 |
523 def tags(self): | 538 def tags(self): |
524 t = [] | 539 t = [] |
525 [t.extend(p.tags()) for p in self.parents()] | 540 [t.extend(p.tags()) for p in self.parents()] |
526 return t | 541 return t |