D6374: context: default to using branch from dirstate only in workingctx
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Wed May 15 14:04:07 EDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG62bb49a1d05d: context: default to using branch from dirstate only in workingctx (authored by martinvonz, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D6374?vs=15084&id=15109
REVISION DETAIL
https://phab.mercurial-scm.org/D6374
AFFECTED FILES
mercurial/context.py
CHANGE DETAILS
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1119,13 +1119,7 @@
self._extra = extra.copy()
if branch is not None:
self._extra['branch'] = encoding.fromlocal(branch)
- elif 'branch' not in self._extra:
- try:
- branch = encoding.fromlocal(self._repo.dirstate.branch())
- except UnicodeDecodeError:
- raise error.Abort(_('branch name not in UTF-8!'))
- self._extra['branch'] = branch
- if self._extra['branch'] == '':
+ if not self._extra.get('branch'):
self._extra['branch'] = 'default'
def __bytes__(self):
@@ -1242,7 +1236,14 @@
"""
def __init__(self, repo, text="", user=None, date=None, extra=None,
changes=None):
- super(workingctx, self).__init__(repo, text, user, date, extra, changes)
+ branch = None
+ if not extra or 'branch' not in extra:
+ try:
+ branch = repo.dirstate.branch()
+ except UnicodeDecodeError:
+ raise error.Abort(_('branch name not in UTF-8!'))
+ super(workingctx, self).__init__(repo, text, user, date, extra, changes,
+ branch=branch)
def __iter__(self):
d = self._repo.dirstate
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list