Same reasoning as previous commits: only the workingctx should know
about the dirstate.
committablectx now seems free of dirstate references.
hg-reviewers |
Same reasoning as previous commits: only the workingctx should know
about the dirstate.
committablectx now seems free of dirstate references.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/context.py (17 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
if changes: | if changes: | ||||
self._status = changes | self._status = changes | ||||
self._extra = {} | self._extra = {} | ||||
if extra: | if extra: | ||||
self._extra = extra.copy() | self._extra = extra.copy() | ||||
if branch is not None: | if branch is not None: | ||||
self._extra['branch'] = encoding.fromlocal(branch) | self._extra['branch'] = encoding.fromlocal(branch) | ||||
elif 'branch' not in self._extra: | if not self._extra.get('branch'): | ||||
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'] == '': | |||||
self._extra['branch'] = 'default' | self._extra['branch'] = 'default' | ||||
def __bytes__(self): | def __bytes__(self): | ||||
return bytes(self._parents[0]) + "+" | return bytes(self._parents[0]) + "+" | ||||
__str__ = encoding.strmethod(__bytes__) | __str__ = encoding.strmethod(__bytes__) | ||||
def __nonzero__(self): | def __nonzero__(self): | ||||
date - any valid date string or (unixtime, offset), or None. | date - any valid date string or (unixtime, offset), or None. | ||||
user - username string, or None. | user - username string, or None. | ||||
extra - a dictionary of extra values, or None. | extra - a dictionary of extra values, or None. | ||||
changes - a list of file lists as returned by localrepo.status() | changes - a list of file lists as returned by localrepo.status() | ||||
or None to use the repository status. | or None to use the repository status. | ||||
""" | """ | ||||
def __init__(self, repo, text="", user=None, date=None, extra=None, | def __init__(self, repo, text="", user=None, date=None, extra=None, | ||||
changes=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): | def __iter__(self): | ||||
d = self._repo.dirstate | d = self._repo.dirstate | ||||
for f in d: | for f in d: | ||||
if d[f] != 'r': | if d[f] != 'r': | ||||
yield f | yield f | ||||
def __contains__(self, key): | def __contains__(self, key): |