shelve: be quiet when unshelve pulls from the shelve bundle
authorMads Kiilerich <madski@unity3d.com>
Mon, 10 Feb 2014 00:54:12 +0100
changeset 20412 e584fc30456b
parent 20411 66359d8b8d7e
child 20413 0ac94c0a3a38
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.
hgext/shelve.py
tests/test-shelve.t
--- a/hgext/shelve.py	Mon Feb 10 00:53:27 2014 +0100
+++ b/hgext/shelve.py	Mon Feb 10 00:54:12 2014 +0100
@@ -517,6 +517,7 @@
     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 @@
 
             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 @@
         finally:
             fp.close()
 
+        ui.quiet = oldquiet
+
         shelvectx = repo['tip']
 
         # If the shelve is not immediately on top of the commit
@@ -609,6 +609,7 @@
 
         unshelvecleanup(ui, repo, basename, opts)
     finally:
+        ui.quiet = oldquiet
         if tr:
             tr.release()
         lockmod.release(lock, wlock)
--- a/tests/test-shelve.t	Mon Feb 10 00:53:27 2014 +0100
+++ b/tests/test-shelve.t	Mon Feb 10 00:54:12 2014 +0100
@@ -23,10 +23,6 @@
 
   $ 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 @@
   $ 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 @@
 
   $ 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 @@
 
   $ 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 @@
 
   $ 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 @@
   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                      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 @@
   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 @@
   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 @@
   $ 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 @@
   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 @@
   $ 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 @@
   ? 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 @@
   $ 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