[PATCH 08 of 19] context: support updating extra in workingctx

David Schleimer dschleimer at fb.com
Sun Feb 10 17:29:58 CST 2013


# HG changeset patch
# User David Schleimer <dschleimer at fb.com>
# 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 = []


More information about the Mercurial-devel mailing list