[PATCH 7 of 9] shelve: be quiet when unshelve pulls from the shelve bundle

Mads Kiilerich mads at kiilerich.com
Sun Feb 9 18:01:16 CST 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1391990052 -3600
#      Mon Feb 10 00:54:12 2014 +0100
# Node ID 04610a5b38ce9ca5d2274710cd47749f291ddfa0
# Parent  1551c9dd865de3a336f36991ed35a76a975eaf3d
shelve: be quiet when unshelve pulls from the shelve bundle

unshelve was quite verbose and it was hard for a user to follow what really was
going on. It ended up saying 'added 1 changesets' ... but the user just
expected and got pending changes and never saw any changeset.

The use of bundles is an implementation detail that we don't have to leak here.

Pulling is quite verbose, optimized for pulling many changesets from remote
repos - that is not the case here.

Instead, set the quiet flag when pulling the bundle - not only when temporarily
committing pending changes.

The 'finally' restore of ui.quiet is moved to the outer try/finally used for
locking.

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -517,6 +517,7 @@ def unshelve(ui, repo, *shelved, **opts)
     if not shelvedfile(repo, basename, 'files').exists():
         raise util.Abort(_("shelved change '%s' not found") % basename)
 
+    oldquiet = ui.quiet
     wlock = lock = tr = None
     try:
         lock = repo.lock()
@@ -550,15 +551,12 @@ def unshelve(ui, repo, *shelved, **opts)
 
             tempopts = {}
             tempopts['message'] = "pending changes temporary commit"
-            oldquiet = ui.quiet
-            try:
-                ui.quiet = True
-                node = cmdutil.commit(ui, repo, commitfunc, [], tempopts)
-            finally:
-                ui.quiet = oldquiet
+            ui.quiet = True
+            node = cmdutil.commit(ui, repo, commitfunc, [], tempopts)
             tmpwctx = repo[node]
 
         try:
+            ui.quiet = True
             fp = shelvedfile(repo, basename, 'hg').opener()
             gen = changegroup.readbundle(fp, fp.name)
             repo.addchangegroup(gen, 'unshelve', 'bundle:' + fp.name)
@@ -567,6 +565,8 @@ def unshelve(ui, repo, *shelved, **opts)
         finally:
             fp.close()
 
+        ui.quiet = oldquiet
+
         shelvectx = repo['tip']
 
         # If the shelve is not immediately on top of the commit
@@ -609,6 +609,7 @@ def unshelve(ui, repo, *shelved, **opts)
 
         unshelvecleanup(ui, repo, basename, opts)
     finally:
+        ui.quiet = oldquiet
         if tr:
             tr.release()
         lockmod.release(lock, wlock)
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -23,10 +23,6 @@ shelving in an empty repo should be poss
 
   $ hg unshelve
   unshelving change 'default'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 5 changes to 5 files
 
   $ hg commit -q -m 'initial commit'
 
@@ -104,10 +100,6 @@ local edits should not prevent a shelved
   $ printf "z\na\n" > a/a
   $ hg unshelve --keep
   unshelving change 'default-01'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 3 changes to 8 files (+1 heads)
   merging a/a
 
   $ hg revert --all -q
@@ -117,10 +109,6 @@ apply it and make sure our state is as e
 
   $ hg unshelve
   unshelving change 'default-01'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 3 changes to 8 files
   $ hg status -C
   M a/a
   A b.rename/b
@@ -192,10 +180,6 @@ force a conflicted merge to occur
 
   $ hg unshelve
   unshelving change 'default'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 3 changes to 8 files (+1 heads)
   merging a/a
   warning: conflicts during merge.
   merging a/a incomplete! (edit conflicts, then use 'hg resolve --mark')
@@ -379,10 +363,6 @@ if we resolve a conflict while unshelvin
 
   $ HGMERGE=true hg unshelve
   unshelving change 'default'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 6 files (+1 heads)
   merging a/a
   $ hg parents -q
   4:33f7f61e6c5e
@@ -403,10 +383,6 @@ test keep and cleanup
   default         (*)    changes to 'create conflict' (glob)
   $ hg unshelve --keep
   unshelving change 'default'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 7 files
   $ hg shelve --list
   default         (*)    changes to 'create conflict' (glob)
   $ hg shelve --cleanup
@@ -424,10 +400,6 @@ test bookmarks
    * test                      4:33f7f61e6c5e
   $ hg unshelve
   unshelving change 'test'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 7 files
   $ hg bookmark
    * test                      4:33f7f61e6c5e
 
@@ -440,10 +412,6 @@ shelve should still work even if mq is d
   test            (*)    changes to 'create conflict' (glob)
   $ hg --config extensions.mq=! unshelve
   unshelving change 'test'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 7 files
 
 shelve should leave dirstate clean (issue 4055)
 
@@ -468,10 +436,6 @@ shelve should leave dirstate clean (issu
   saved backup bundle to $TESTTMP/shelverebase/.hg/strip-backup/323bfa07f744-backup.hg (glob)
   $ hg unshelve
   unshelving change 'default'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 2 changesets with 2 changes to 2 files (+1 heads)
   $ hg status
   M z
 
@@ -497,10 +461,6 @@ shelve should only unshelve pending chan
   $ hg up -q 1
   $ hg unshelve
   unshelving change 'default'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 3 files
   $ hg status
   A d
 
@@ -513,10 +473,6 @@ unshelve should work on an ancestor of t
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg unshelve
   unshelving change 'default'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 3 files
   $ hg status
   A d
 
@@ -534,10 +490,6 @@ test bug 4073 we need to enable obsolete
   $ hg debugobsolete `hg --debug id -i -r 1`
   $ hg unshelve
   unshelving change 'default'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 2 files (+1 heads)
 
 unshelve should leave unknown files alone (issue4113)
 
@@ -549,10 +501,6 @@ unshelve should leave unknown files alon
   ? e
   $ hg unshelve
   unshelving change 'default'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 2 files (+1 heads)
   $ hg status
   A d
   ? e
@@ -568,10 +516,6 @@ unshelve should keep a copy of unknown f
   $ echo z > e
   $ hg unshelve
   unshelving change 'default'
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 2 changes to 3 files (+1 heads)
   $ cat e
   e
   $ cat e.orig


More information about the Mercurial-devel mailing list