changeset 65:5ed8316d3cfa

Start using reasonable ui.{status,debug,warn} calls instead of print.
author Augie Fackler <durin42@gmail.com>
date Wed, 29 Apr 2009 16:18:37 -0700
parents f8973754189e
children a061dce264b7
files git_handler.py tests/test-file-removal.out tests/test-git-clone.out tests/test-sane-without-bookmarks.out
diffstat 4 files changed, 18 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/git_handler.py
+++ b/git_handler.py
@@ -139,15 +139,15 @@
         key = 'remote.' + remote_name + '.url'
         if key in self._config:
             name = self._config[key]
-            print "URL for " + remote_name + " : " + name
+            self.ui.status("URL for %s : %s\n" % (remote_name, name, ))
         else:
-            print "No remote named : " + remote_name
+            self.ui.status("No remote named : %s\n" % remote_name)
         return
 
     def remote_list(self):
         for key, value in self._config.iteritems():
             if key[0:6] == 'remote':
-                print key + "\t" + value
+                self.ui.status('%s\t%s\n' % (key, value, ))
 
     def remote_name_to_url(self, remote_name):
         return self._config['remote.' + remote_name + '.url']
@@ -158,7 +158,7 @@
         self.git.set_ref('refs/heads/master', c)
 
     def export_git_objects(self):
-        print "exporting git objects"
+        self.ui.status("exporting git objects\n")
         for rev in self.repo.changelog:
             self.export_hg_commit(rev)
 
@@ -197,16 +197,16 @@
         commit['author'] = ctx.user() + ' ' + str(int(time)) + ' ' + seconds_to_offset(timezone)
         message = ctx.description()
         commit['message'] = ctx.description()
-        
+
         # HG EXTRA INFORMATION
         add_extras = False
         if not ctx.branch() == 'default':
             add_extras = True
-            
+
         if add_extras:
             commit['message'] += "\n\n--HG--\n"
             commit['message'] += "branch : " + ctx.branch() + "\n"
-            
+
         commit['parents'] = []
         for parent in parents:
             hgsha = hex(parent.node())
@@ -246,14 +246,14 @@
                         nparpath = part + '/'
                     else:
                         nparpath += part + '/'
-                    
+
                     treeentry = ['tree', part + '/', nparpath]
-                    
+
                     if parpath not in trees:
                         trees[parpath] = []
                     if treeentry not in trees[parpath]:
                         trees[parpath].append( treeentry )
-                        
+
                     parpath = nparpath
 
                 # set file entry
@@ -267,7 +267,7 @@
                 if '/' not in trees:
                     trees['/'] = []
                 trees['/'].append(fileentry)
-        
+
         # sort by tree depth, so we write the deepest trees first
         dirs = trees.keys()
         dirs.sort(lambda a, b: len(b.split('/'))-len(a.split('/')))
@@ -420,7 +420,7 @@
                 convert_list[sha] = commit
                 todo.extend([p for p in commit.parents if p not in done])
             except:
-                print "Cannot import tags yet" # TODO
+                self.ui.warn("Cannot import tags yet\n") # TODO
 
         # sort the commits
         commits = TopoSort(convert_list).items()
@@ -442,9 +442,9 @@
                     bms[remote_name + '/' + head] = hgsha
             bookmarks.write(self.repo, bms)
         except AttributeError:
-            self.repo.ui.warn('creating bookmarks failed, do you have'
-                              ' bookmarks enabled?\n')
-                              
+            self.ui.warn('creating bookmarks failed, do you have'
+                         ' bookmarks enabled?\n')
+
     def convert_git_int_mode(self, mode):
         convert = {
          33188: '',
@@ -453,9 +453,9 @@
         if mode in convert:
             return convert[mode]
         return ''
-        
+
     def import_git_commit(self, commit):
-        print "importing: " + commit.id
+        self.ui.debug("importing: %s\n" % commit.id)
         # TODO : look for HG metadata in the message and use it
         # TODO : add extra Git data (committer info) as extras to changeset
 
@@ -483,7 +483,6 @@
             pass
 
         files = self.git.get_files_changed(commit)
-        #print files
 
         # get a list of the changed, added, removed files
         extra = {}
@@ -501,7 +500,7 @@
 
     def check_bookmarks(self):
         if self.ui.config('extensions', 'hgext.bookmarks') is not None:
-            print "YOU NEED TO SETUP BOOKMARKS"
+            self.ui.warn("YOU NEED TO SETUP BOOKMARKS\n")
 
     def get_transport_and_path(self, uri):
         from dulwich.client import TCPGitClient, SSHGitClient, SubprocessGitClient
--- a/tests/test-file-removal.out
+++ b/tests/test-file-removal.out
@@ -10,11 +10,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
-importing: 7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03
-importing: 9497a4ee62e16ee641860d7677cdb2589ea15554
-importing: f2d0d5bfa905e12dee728b509b96cf265bb6ee43
-importing: b0edaf0adac19392cf2867498b983bc5192b41dd
-importing: b991de8952c482a7cd51162674ffff8474862218
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   4:ea41a3f0ed10
 |  tag:         origin/master
--- a/tests/test-git-clone.out
+++ b/tests/test-git-clone.out
@@ -6,8 +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
-importing: 7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03
-importing: 9497a4ee62e16ee641860d7677cdb2589ea15554
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:7bcd915dc873
 |  tag:         origin/master
--- a/tests/test-sane-without-bookmarks.out
+++ b/tests/test-sane-without-bookmarks.out
@@ -6,8 +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
-importing: 7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03
-importing: 9497a4ee62e16ee641860d7677cdb2589ea15554
 creating bookmarks failed, do you have bookmarks enabled?
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:7bcd915dc873