Mercurial > hg-stable
changeset 42323:df2f22befdc8
context: let caller pass in branch to committablectx.__init__()
committablectx.__init__() currently looks up the branch from the
dirstate unless it's passed in the extras. memctx.__init__() has a
branch argument, but since committablectx.__init__() doesn't accept
it, it lets that constructor look up the branch from the dirstate
before it overwrites it, which seems awkward.
Differential Revision: https://phab.mercurial-scm.org/D6366
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 10 May 2019 22:51:33 -0700 |
parents | fdd4d668ceb5 |
children | 62bb49a1d05d |
files | mercurial/context.py |
diffstat | 1 files changed, 6 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Fri May 10 21:55:59 2019 -0700 +++ b/mercurial/context.py Fri May 10 22:51:33 2019 -0700 @@ -1102,7 +1102,7 @@ """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, branch=None): super(committablectx, self).__init__(repo) self._rev = None self._node = None @@ -1117,7 +1117,9 @@ self._extra = {} if extra: self._extra = extra.copy() - if 'branch' not in self._extra: + 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: @@ -2308,7 +2310,8 @@ def __init__(self, repo, parents, text, files, filectxfn, user=None, date=None, extra=None, branch=None, editor=False): - super(memctx, self).__init__(repo, text, user, date, extra) + super(memctx, self).__init__(repo, text, user, date, extra, + branch=branch) self._rev = None self._node = None parents = [(p or nullid) for p in parents] @@ -2316,8 +2319,6 @@ self._parents = [self._repo[p] for p in (p1, p2)] files = sorted(set(files)) self._files = files - if branch is not None: - self._extra['branch'] = encoding.fromlocal(branch) self.substate = {} if isinstance(filectxfn, patch.filestore):