changeset 593:a6b7ad535244

push: provide better output about changed references (issue #64) As pointed out by l33t, Hg-Git's output for push doesn't currently do a very good job of telling the user what happened. My previous changes in this area had moved some of the output from status to note, making it only show if --verbose was specified. However, I hadn't realized at the time that the reference information (though overly verbose) was providing a valueable purpose that otherwise wasn't met; telling the user that a remote reference had changed. This changeset makes it so that: * default output will include simple messages like "adding reference refs/heads/feature" and "updating reference refs/heads/master" (omitting any mention of unchanged references) * verbose output will include more detailed messages like "adding reference default::refs/heads/feature => GIT:aba43c" and "updating reference default::refs/heads/master => GIT:aba43c" (omitting any mention of unchanged references) * debug output will include the detailed output like in verbose, but addtionally will include messages like "unchanged reference default::refs/heads/other => GIT:aba43c" https://bitbucket.org/durin42/hg-git/issue/64/push-confirmation
author David M. Carr <david@carrclan.us>
date Sun, 06 Jan 2013 02:31:37 -0500
parents 163c452531cf
children ce6ad4c0cba7
files hggit/git_handler.py tests/test-git-tags.t tests/test-hg-author.t tests/test-hg-branch.t tests/test-hg-tags.t tests/test-push.t tests/test-subrepos.t
diffstat 7 files changed, 29 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -278,11 +278,21 @@
 
         if remote_name and new_refs:
             for ref, new_sha in new_refs.iteritems():
-                if new_sha != old_refs.get(ref):
-                    self.ui.note("    %s::%s => GIT:%s\n" %
+                old_sha = old_refs.get(ref)
+                if old_sha is None:
+                    if self.ui.verbose:
+                        self.ui.note("adding reference %s::%s => GIT:%s\n" %
                                    (remote_name, ref, new_sha[0:8]))
+                    else:
+                        self.ui.status("adding reference %s\n" % ref)
+                elif new_sha != old_sha:
+                    if self.ui.verbose:
+                        self.ui.note("updating reference %s::%s => GIT:%s\n" %
+                                   (remote_name, ref, new_sha[0:8]))
+                    else:
+                        self.ui.status("updating reference %s\n" % ref)
                 else:
-                    self.ui.debug("    %s::%s => GIT:%s\n" %
+                    self.ui.debug("unchanged reference %s::%s => GIT:%s\n" %
                                    (remote_name, ref, new_sha[0:8]))
 
             self.update_remote_branches(remote_name, new_refs)
--- a/tests/test-git-tags.t
+++ b/tests/test-git-tags.t
@@ -43,5 +43,6 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 1 blobs
+  updating reference refs/heads/master
 
   $ cd ..
--- a/tests/test-hg-author.t
+++ b/tests/test-hg-author.t
@@ -26,6 +26,7 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 1 blobs
+  updating reference refs/heads/master
 
   $ echo gamma >> beta
   $ fn_hg_commit -u "test <test@example.com> (comment)" -m 'modify beta'
@@ -34,6 +35,7 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 1 blobs
+  updating reference refs/heads/master
 
   $ echo gamma > gamma
   $ hg add gamma
@@ -43,6 +45,7 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 1 blobs
+  updating reference refs/heads/master
 
   $ echo delta > delta
   $ hg add delta
@@ -52,6 +55,7 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 1 blobs
+  updating reference refs/heads/master
 
   $ echo epsilon > epsilon
   $ hg add epsilon
@@ -61,6 +65,7 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 1 blobs
+  updating reference refs/heads/master
 
   $ echo zeta > zeta
   $ hg add zeta
@@ -70,6 +75,7 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 1 blobs
+  updating reference refs/heads/master
 
   $ echo eta > eta
   $ hg add eta
@@ -79,6 +85,7 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 1 blobs
+  updating reference refs/heads/master
 
   $ echo theta > theta
   $ hg add theta
@@ -88,6 +95,7 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 1 blobs
+  updating reference refs/heads/master
 
   $ hg log --graph | egrep -v ': *(not-master|master)'
   @  changeset:   8:d3c51ce68cfd
--- a/tests/test-hg-branch.t
+++ b/tests/test-hg-branch.t
@@ -25,6 +25,7 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 0 blobs
+  updating reference refs/heads/master
 
   $ hg branch gamma | grep -v 'permanent and global'
   marked working directory as branch gamma
@@ -34,6 +35,7 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 0 blobs
+  updating reference refs/heads/master
 
   $ hg log --graph | egrep -v ': *(not-master|master)'
   @  changeset:   2:05aed681ccb3
--- a/tests/test-hg-tags.t
+++ b/tests/test-hg-tags.t
@@ -24,6 +24,8 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 1 blobs
+  adding reference refs/tags/alpha
+  updating reference refs/heads/master
 
   $ hg log --graph | egrep -v ': *(not-master|master)'
   @  changeset:   1:d529e9229f6d
--- a/tests/test-push.t
+++ b/tests/test-push.t
@@ -31,6 +31,7 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 1 blobs
+  adding reference refs/heads/beta
 
   $ cd ..
 
@@ -104,6 +105,7 @@
   searching for changes
   adding objects
   added 1 commits with 1 trees and 1 blobs
+  updating reference refs/heads/master
 
 this should fail, no changes to push
 The exit code for this was broken in Mercurial (incorrectly returning 0) until
--- a/tests/test-subrepos.t
+++ b/tests/test-subrepos.t
@@ -74,6 +74,7 @@
   searching for changes
   adding objects
   added 1 commits with 2 trees and 1 blobs
+  updating reference refs/heads/master
   $ cd ..
   $ cd gitrepo1
 there shall be two gitlink entries, with values matching that in .hgsubstate