Patchwork [5,of,7,shelve-ext,v5] shelve: move ui.quiet manipulations to configoverride

login
register
mail settings
Submitter Kostia Balytskyi
Date March 29, 2017, 1:18 p.m.
Message ID <743fea249a852994c5bd.1490793528@devvm1416.lla2.facebook.com>
Download mbox | patch
Permalink /patch/19815/
State Changes Requested
Headers show

Comments

Kostia Balytskyi - March 29, 2017, 1:18 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1490790691 25200
#      Wed Mar 29 05:31:31 2017 -0700
# Node ID 743fea249a852994c5bd3e47cdfb617719f19a0a
# Parent  63f5731a2dc01b30c9cd1d2c7c60a9a16d6c79c1
shelve: move ui.quiet manipulations to configoverride
Yuya Nishihara - April 2, 2017, 8:57 a.m.
On Wed, 29 Mar 2017 06:18:48 -0700, Kostia Balytskyi wrote:
> # HG changeset patch
> # User Kostia Balytskyi <ikostia@fb.com>
> # Date 1490790691 25200
> #      Wed Mar 29 05:31:31 2017 -0700
> # Node ID 743fea249a852994c5bd3e47cdfb617719f19a0a
> # Parent  63f5731a2dc01b30c9cd1d2c7c60a9a16d6c79c1
> shelve: move ui.quiet manipulations to configoverride

I've queued only this patch which can be applied cleanly.

> @@ -911,11 +906,9 @@ def _dounshelve(ui, repo, *shelved, **op
>      if not shelvedfile(repo, basename, patchextension).exists():
>          raise error.Abort(_("shelved change '%s' not found") % basename)
>  
> -    oldquiet = ui.quiet
>      lock = tr = None
>      try:
>          lock = repo.lock()
> -
>          tr = repo.transaction('unshelve', report=lambda x: None)
>          oldtiprev = len(repo)
>  
> @@ -932,7 +925,6 @@ def _dounshelve(ui, repo, *shelved, **op
>          with ui.configoverride(overrides, 'unshelve'):
>              tmpwctx, addedbefore = _commitworkingcopychanges(ui, repo, opts,
>                                                               tmpwctx)
> -
>              repo, shelvectx = _unshelverestorecommit(ui, repo, basename,
>                                                       oldquiet)

Dropped this "oldquiet" in flight.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -630,9 +630,7 @@  def unshelveabort(ui, repo, state, opts)
 def mergefiles(ui, repo, wctx, shelvectx):
     """updates to wctx and merges the changes from shelvectx into the
     dirstate."""
-    oldquiet = ui.quiet
-    try:
-        ui.quiet = True
+    with ui.configoverride({('ui', 'quiet'): True}):
         hg.update(repo, wctx.node())
         files = []
         files.extend(shelvectx.files())
@@ -647,8 +645,6 @@  def mergefiles(ui, repo, wctx, shelvectx
                        *pathtofiles(repo, files),
                        **{'no_backup': True})
         ui.popbuffer()
-    finally:
-        ui.quiet = oldquiet
 
 def restorebranch(ui, repo, branchtorestore):
     if branchtorestore and branchtorestore != repo.dirstate.branch():
@@ -718,17 +714,16 @@  def _commitworkingcopychanges(ui, repo, 
     tempopts = {}
     tempopts['message'] = "pending changes temporary commit"
     tempopts['date'] = opts.get('date')
-    ui.quiet = True
-    node = cmdutil.commit(ui, repo, commitfunc, [], tempopts)
+    with ui.configoverride({('ui', 'quiet'): True}):
+        node = cmdutil.commit(ui, repo, commitfunc, [], tempopts)
     tmpwctx = repo[node]
     return tmpwctx, addedbefore
 
-def _unshelverestorecommit(ui, repo, basename, oldquiet):
+def _unshelverestorecommit(ui, repo, basename):
     """Recreate commit in the repository during the unshelve"""
-    ui.quiet = True
-    shelvedfile(repo, basename, 'hg').applybundle()
-    shelvectx = repo['tip']
-    ui.quiet = oldquiet
+    with ui.configoverride({('ui', 'quiet'): True}):
+        shelvedfile(repo, basename, 'hg').applybundle()
+        shelvectx = repo['tip']
     return repo, shelvectx
 
 def _rebaserestoredcommit(ui, repo, opts, tr, oldtiprev, basename, pctx,
@@ -911,11 +906,9 @@  def _dounshelve(ui, repo, *shelved, **op
     if not shelvedfile(repo, basename, patchextension).exists():
         raise error.Abort(_("shelved change '%s' not found") % basename)
 
-    oldquiet = ui.quiet
     lock = tr = None
     try:
         lock = repo.lock()
-
         tr = repo.transaction('unshelve', report=lambda x: None)
         oldtiprev = len(repo)
 
@@ -932,7 +925,6 @@  def _dounshelve(ui, repo, *shelved, **op
         with ui.configoverride(overrides, 'unshelve'):
             tmpwctx, addedbefore = _commitworkingcopychanges(ui, repo, opts,
                                                              tmpwctx)
-
             repo, shelvectx = _unshelverestorecommit(ui, repo, basename,
                                                      oldquiet)
             _checkunshelveuntrackedproblems(ui, repo, shelvectx)
@@ -952,7 +944,6 @@  def _dounshelve(ui, repo, *shelved, **op
             _finishunshelve(repo, oldtiprev, tr, activebookmark)
             unshelvecleanup(ui, repo, basename, opts)
     finally:
-        ui.quiet = oldquiet
         if tr:
             tr.release()
         lockmod.release(lock)