From patchwork Sun Feb 10 23:29:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [08,of,19] context: support updating extra in workingctx From: David Schleimer X-Patchwork-Id: 948 Message-Id: <62d93c48151c79f5e08c.1360538998@dev010.prn1.facebook.com> To: mercurial-devel@selenic.com Date: Sun, 10 Feb 2013 15:29:58 -0800 # HG changeset patch # User David Schleimer # Date 1360330570 28800 # Node ID 62d93c48151c79f5e08c3e22b79e52052283ce66 # Parent 60a9efb86ef6d91bf13d131cade4158b81fa2a58 context: support updating extra in workingctx This refactors the munging we do on the extra info in the constructor for wrokingctx into a setextra function that can be used to update the extra information after construction. This refactoring is in aid of future efficiency work relating to in-memory merging. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -829,16 +829,7 @@ self._unresolved = None self._extra = {} - if extra: - self._extra = extra.copy() - if 'branch' not in self._extra: - try: - branch = encoding.fromlocal(self._repo.dirstate.branch()) - except UnicodeDecodeError: - raise util.Abort(_('branch name not in UTF-8!')) - self._extra['branch'] = branch - if self._extra['branch'] == '': - self._extra['branch'] = 'default' + self.setextra(extra) def __str__(self): return str(self._parents[0]) + "+" @@ -1009,6 +1000,18 @@ return 'close' in self._extra def extra(self): return self._extra + def setextra(self, extra): + if extra: + self._extra = extra.copy() + if 'branch' not in self._extra: + try: + branch = encoding.fromlocal(self._repo.dirstate.branch()) + except UnicodeDecodeError: + raise util.Abort(_('branch name not in UTF-8!')) + self._extra['branch'] = branch + if self._extra['branch'] == '': + self._extra['branch'] = 'default' + def tags(self): t = []