Patchwork [1,of,2] obsstore: pass a UI object reference

login
register
mail settings
Submitter Eric Sumner
Date April 14, 2015, 7:13 p.m.
Message ID <b30cb32ea6821e165aab.1429038796@waste.org>
Download mbox | patch
Permalink /patch/8666/
State Deferred
Headers show

Comments

Eric Sumner - April 14, 2015, 7:13 p.m.
# HG changeset patch
# User Eric Sumner <ericsumner@fb.com>
# Date 1429037848 14400
#      Tue Apr 14 14:57:28 2015 -0400
# Node ID b30cb32ea6821e165aab65051767aa810fdb8464
# Parent  c560d8c687916cb70a6d54c2c9ddcb5c9e457be2
obsstore: pass a UI object reference

The obsstore object currently has no channel to output messages to the user;
this diff passes one in at construction so that it's available.
Pierre-Yves David - April 15, 2015, 3:59 a.m.
On 04/14/2015 03:13 PM, Eric Sumner wrote:
> # HG changeset patch
> # User Eric Sumner <ericsumner@fb.com>
> # Date 1429037848 14400
> #      Tue Apr 14 14:57:28 2015 -0400
> # Node ID b30cb32ea6821e165aab65051767aa810fdb8464
> # Parent  c560d8c687916cb70a6d54c2c9ddcb5c9e457be2
> obsstore: pass a UI object reference
>
> The obsstore object currently has no channel to output messages to the user;
> this diff passes one in at construction so that it's available.

I'm ok with the idea, but will wait for a user of the attribute to exist 
before taking the patch.

For consistency for other functions, having the ui object as first 
argument would also be better.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -567,5 +567,5 @@ 
 
     Result is the number of markers in the repo."""
     timer, fm = gettimer(ui)
-    timer(lambda: len(obsolete.obsstore(repo.svfs)))
+    timer(lambda: len(obsolete.obsstore(repo.svfs, ui=ui)))
     fm.end()
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -425,7 +425,7 @@ 
         if defaultformat is not None:
             kwargs['defaultformat'] = defaultformat
         readonly = not obsolete.isenabled(self, obsolete.createmarkersopt)
-        store = obsolete.obsstore(self.svfs, readonly=readonly,
+        store = obsolete.obsstore(self.svfs, ui=self.ui, readonly=readonly,
                                   **kwargs)
         if store and readonly:
             self.ui.warn(
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -517,11 +517,12 @@ 
     # parents: (tuple of nodeid) or None, parents of precursors
     #          None is used when no data has been recorded
 
-    def __init__(self, sopener, defaultformat=_fm1version, readonly=False):
+    def __init__(self, sopener, ui=None, defaultformat=_fm1version, readonly=False):
         # caches for various obsolescence related cache
         self.caches = {}
         self._all = []
         self.sopener = sopener
+        self.ui = ui
         data = sopener.tryread('obsstore')
         self._version = defaultformat
         self._readonly = readonly