changeset 286:0661d5721ad7

git_handler: use progress API instead of reinventing the wheel
author Augie Fackler <durin42@gmail.com>
date Wed, 24 Feb 2010 21:08:38 -0600
parents 5e5aee9b32d4
children e08a22250fa9
files hggit/git_handler.py tests/test-empty-working-tree.out tests/test-encoding.out tests/test-file-removal.out tests/test-git-clone.out tests/test-git-tags.out tests/test-hg-author.out tests/test-hg-branch.out tests/test-hg-tags.out tests/test-merge.out tests/test-octopus.out tests/test-outgoing.out tests/test-pull.out tests/test-push.out tests/test-sane-without-bookmarks.out tests/test-tree-decomposition.out
diffstat 16 files changed, 6 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -173,20 +173,16 @@
         nodes = [self.repo.lookup(n) for n in self.repo]
         export = [node for node in nodes if not hex(node) in self._map_hg]
         total = len(export)
-        if total:
-          magnitude = int(math.log(total, 10)) + 1
-        else:
-          magnitude = 1
         for i, rev in enumerate(export):
-            if i%100 == 0:
-                self.ui.status(_("at: %*d/%d\n") % (magnitude, i, total))
-
+            self.ui.progress('import', i, total=total)
             ctx = self.repo.changectx(rev)
             state = ctx.extra().get('hg-git', None)
             if state == 'octopus':
                 self.ui.debug("revision %d is a part of octopus explosion\n" % ctx.rev())
                 continue
             self.export_hg_commit(rev)
+        self.ui.progress('import', None, total=total)
+
 
     # convert this commit into git objects
     # go through the manifest, convert all blobs/trees we don't have
@@ -401,15 +397,11 @@
         commits = [commit for commit in commits if not commit in self._map_git]
         # import each of the commits, oldest first
         total = len(commits)
-        if total:
-            magnitude = int(math.log(total, 10)) + 1
-        else:
-            magnitude = 1
         for i, csha in enumerate(commits):
-            if i%100 == 0:
-                self.ui.status(_("at: %*d/%d\n") % (magnitude, i, total))
+            self.ui.progress('import', i, total=total, unit='commits')
             commit = convert_list[csha]
             self.import_git_commit(commit)
+        self.ui.progress('import', None, total=total, unit='commits')
 
     def import_git_commit(self, commit):
         self.ui.debug(_("importing: %s\n") % commit.id)
@@ -844,4 +836,4 @@
                     transportpath = path
                 return transport(host, thin_packs=False), transportpath
         # if its not git or git+ssh, try a local url..
-        return SubprocessGitClient(thin_packs=False), uri
+        return client.SubprocessGitClient(thin_packs=False), uri
--- a/tests/test-empty-working-tree.out
+++ b/tests/test-empty-working-tree.out
@@ -6,13 +6,11 @@
 Counting objects: 2, done.
 Total 2 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/1
 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 files: 
 clearing out the git cache data
 pushing to git://localhost/gitrepo2
 importing Hg objects into Git
-at: 0/1
 creating and sending data
 commit 678256865a8c85ae925bf834369264193c88f8de
 Author: test <test@example.org>
--- a/tests/test-encoding.out
+++ b/tests/test-encoding.out
@@ -13,7 +13,6 @@
 Compressing objects:  14% (1/7)   
Compressing objects:  28% (2/7)   
Compressing objects:  42% (3/7)   
Compressing objects:  57% (4/7)   
Compressing objects:  71% (5/7)   
Compressing objects:  85% (6/7)   
Compressing objects: 100% (7/7)   
Compressing objects: 100% (7/7), done.
 Total 12 (delta 1), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/4
 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   3:8549ee7fe0801b2dafc06047ca6f66d36da709f5
 |  tag:         master
@@ -78,7 +77,6 @@
 clearing out the git cache data
 pushing to git://localhost/gitrepo2
 importing Hg objects into Git
-at: 0/4
 creating and sending data
 commit da0edb01d4f3d1abf08b1be298379b0b2960e680
 Author: tést èncödîng <test@example.org>
--- a/tests/test-file-removal.out
+++ b/tests/test-file-removal.out
@@ -11,7 +11,6 @@
 Compressing objects:  12% (1/8)   
Compressing objects:  25% (2/8)   
Compressing objects:  37% (3/8)   
Compressing objects:  50% (4/8)   
Compressing objects:  62% (5/8)   
Compressing objects:  75% (6/8)   
Compressing objects:  87% (7/8)   
Compressing objects: 100% (8/8)   
Compressing objects: 100% (8/8), done.
 Total 14 (delta 1), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/5
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   4:ea41a3f0ed10
 |  tag:         master
@@ -51,7 +50,6 @@
 clearing out the git cache data
 pushing to git://localhost/gitrepo2
 importing Hg objects into Git
-at: 0/5
 creating and sending data
 commit b991de8952c482a7cd51162674ffff8474862218
 Author: test <test@example.org>
--- a/tests/test-git-clone.out
+++ b/tests/test-git-clone.out
@@ -5,7 +5,6 @@
 Compressing objects:  33% (1/3)   
Compressing objects:  66% (2/3)   
Compressing objects: 100% (3/3)   
Compressing objects: 100% (3/3), done.
 Total 6 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/2
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:7bcd915dc873
 |  tag:         master
--- a/tests/test-git-tags.out
+++ b/tests/test-git-tags.out
@@ -5,7 +5,6 @@
 Compressing objects:  25% (1/4)   
Compressing objects:  50% (2/4)   
Compressing objects:  75% (3/4)   
Compressing objects: 100% (4/4)   
Compressing objects: 100% (4/4), done.
 Total 7 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/2
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:99dcc15b7b07
 |  tag:         default/master
--- a/tests/test-hg-author.out
+++ b/tests/test-hg-author.out
@@ -4,16 +4,13 @@
 Counting objects: 3, done.
 Total 3 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/1
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 pushing to git://localhost/gitrepo
 importing Hg objects into Git
-at: 0/1
 creating and sending data
     default::refs/heads/master => GIT:cffa0e8d
 pushing to git://localhost/gitrepo
 importing Hg objects into Git
-at: 0/1
 creating and sending data
     default::refs/heads/master => GIT:2b9ec6a4
 @  changeset:   2:92d33c0dd6e1
@@ -39,7 +36,6 @@
 Compressing objects:  20% (1/5)   
Compressing objects:  40% (2/5)   
Compressing objects:  60% (3/5)   
Compressing objects:  80% (4/5)   
Compressing objects: 100% (5/5)   
Compressing objects: 100% (5/5), done.
 Total 9 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/3
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   2:92d33c0dd6e1
 |  tag:         master
--- a/tests/test-hg-branch.out
+++ b/tests/test-hg-branch.out
@@ -4,17 +4,14 @@
 Counting objects: 3, done.
 Total 3 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/1
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 pushing to git://localhost/gitrepo
 importing Hg objects into Git
-at: 0/1
 creating and sending data
     default::refs/heads/master => GIT:05c2bcbe
 marked working directory as branch gamma
 pushing to git://localhost/gitrepo
 importing Hg objects into Git
-at: 0/1
 creating and sending data
     default::refs/heads/master => GIT:296802ef
 @  changeset:   2:698615204564
@@ -41,7 +38,6 @@
 Compressing objects:  33% (1/3)   
Compressing objects:  66% (2/3)   
Compressing objects: 100% (3/3)   
Compressing objects: 100% (3/3), done.
 Total 6 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/3
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 o  changeset:   2:698615204564
 |  branch:      gamma
--- a/tests/test-hg-tags.out
+++ b/tests/test-hg-tags.out
@@ -4,11 +4,9 @@
 Counting objects: 3, done.
 Total 3 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/1
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 pushing to git://localhost/gitrepo
 importing Hg objects into Git
-at: 0/1
 creating and sending data
     default::refs/tags/alpha => GIT:7eeab2ea
     default::refs/heads/master => GIT:9a2616b9
@@ -33,7 +31,6 @@
 Compressing objects:  33% (1/3)   
Compressing objects:  66% (2/3)   
Compressing objects: 100% (3/3)   
Compressing objects: 100% (3/3), done.
 Total 6 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/2
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:d529e9229f6d
 |  tag:         default/master
--- a/tests/test-merge.out
+++ b/tests/test-merge.out
@@ -13,13 +13,11 @@
 Compressing objects:  14% (1/7)   
Compressing objects:  28% (2/7)   
Compressing objects:  42% (3/7)   
Compressing objects:  57% (4/7)   
Compressing objects:  71% (5/7)   
Compressing objects:  85% (6/7)   
Compressing objects: 100% (7/7)   
Compressing objects: 100% (7/7), done.
 Total 11 (delta 3), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/4
 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % clear the cache to be sure it is regenerated correctly
 clearing out the git cache data
 pushing to git://localhost/gitrepo2
 importing Hg objects into Git
-at: 0/4
 creating and sending data
 % git log in repo pushed from hg
 commit 5806851511aaf3bfe813ae3a86c5027165fa9b96
--- a/tests/test-octopus.out
+++ b/tests/test-octopus.out
@@ -18,7 +18,6 @@
 Compressing objects:  11% (1/9)   
Compressing objects:  22% (2/9)   
Compressing objects:  33% (3/9)   
Compressing objects:  44% (4/9)   
Compressing objects:  55% (5/9)   
Compressing objects:  66% (6/9)   
Compressing objects:  77% (7/9)   
Compressing objects:  88% (8/9)   
Compressing objects: 100% (9/9)   
Compressing objects: 100% (9/9), done.
 Total 14 (delta 3), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/5
 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @    changeset:   5:6523aa9f4775
 |\   tag:         master
@@ -66,7 +65,6 @@
 clearing out the git cache data
 pushing to git://localhost/gitrepo2
 importing Hg objects into Git
-at: 0/6
 creating and sending data
 commit f0c7ec180419a130636d0c333fc34c1462cab4b5
 Merge: d8e22dd 9497a4e e5023f9
--- a/tests/test-outgoing.out
+++ b/tests/test-outgoing.out
@@ -4,11 +4,9 @@
 Counting objects: 3, done.
 Total 3 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/1
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 comparing with git://localhost/gitrepo
 importing Hg objects into Git
-at: 0/2
 changeset:   1:0564f526fb0f
 tag:         beta
 user:        test
@@ -58,7 +56,6 @@
 Compressing objects:  50% (1/2)   
Compressing objects: 100% (2/2)   
Compressing objects: 100% (2/2), done.
 Total 3 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/1
 (run 'hg update' to get a working copy)
 comparing with git://localhost/gitrepo
 importing Hg objects into Git
--- a/tests/test-pull.out
+++ b/tests/test-pull.out
@@ -6,7 +6,6 @@
 Counting objects: 3, done.
 Total 3 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/1
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   0:3442585be8a6
    tag:         alpha
@@ -23,7 +22,6 @@
 Compressing objects:  33% (1/3)   
Compressing objects:  66% (2/3)   
Compressing objects: 100% (3/3)   
Compressing objects: 100% (3/3), done.
 Total 6 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/2
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:7bcd915dc873
 |  tag:         default/beta
--- a/tests/test-push.out
+++ b/tests/test-push.out
@@ -4,11 +4,9 @@
 Counting objects: 3, done.
 Total 3 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/1
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 pushing to git://localhost/gitrepo
 importing Hg objects into Git
-at: 0/2
 creating and sending data
     default::refs/heads/beta => GIT:cffa0e8d
     default::refs/heads/master => GIT:7eeab2ea
@@ -33,7 +31,6 @@
 Compressing objects:  50% (1/2)   
Compressing objects: 100% (2/2)   
Compressing objects: 100% (2/2), done.
 Total 3 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/1
 (run 'hg update' to get a working copy)
 % master and default/master should be diferent
 tip                                3:1436150b86c2
--- a/tests/test-sane-without-bookmarks.out
+++ b/tests/test-sane-without-bookmarks.out
@@ -6,7 +6,6 @@
 Compressing objects:  33% (1/3)   
Compressing objects:  66% (2/3)   
Compressing objects: 100% (3/3)   
Compressing objects: 100% (3/3), done.
 Total 6 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/2
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:7bcd915dc873
 |  tag:         default/master
--- a/tests/test-tree-decomposition.out
+++ b/tests/test-tree-decomposition.out
@@ -7,7 +7,6 @@
 Compressing objects:  16% (1/6)   
Compressing objects:  33% (2/6)   
Compressing objects:  50% (3/6)   
Compressing objects:  66% (4/6)   
Compressing objects:  83% (5/6)   
Compressing objects: 100% (6/6)   
Compressing objects: 100% (6/6), done.
 Total 12 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/3
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 adds: d1
 dels: d1/f1
@@ -18,7 +17,6 @@
 clearing out the git cache data
 pushing to git://localhost/gitrepo2
 importing Hg objects into Git
-at: 0/3
 creating and sending data
 commit 6e0dbd8cd92ed4823c69cb48d8a2b81f904e6e69
 Author: test <test@example.org>