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

login
register
mail settings
Submitter David Schleimer
Date Feb. 10, 2013, 11:29 p.m.
Message ID <62d93c48151c79f5e08c.1360538998@dev010.prn1.facebook.com>
Download mbox | patch
Permalink /patch/948/
State Changes Requested
Headers show

Comments

David Schleimer - Feb. 10, 2013, 11:29 p.m.
# HG changeset patch
# User David Schleimer <dschleimer@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.
Bryan O'Sullivan - Feb. 11, 2013, 8:55 p.m.
On Sun, Feb 10, 2013 at 3:29 PM, David Schleimer <dschleimer@fb.com> wrote:

> wrokingctx


Good patch, but got a typoe.

Patch

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 = []