Mercurial > hg-git
diff git_handler.py @ 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 | 5185af4e649a |
children | 759ac56497e7 d28d3763eda3 |
line wrap: on
line diff
--- a/git_handler.py Wed Apr 29 15:29:02 2009 -0700 +++ b/git_handler.py Wed Apr 29 16:18:37 2009 -0700 @@ -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