Mercurial > hg > hg-git
changeset 320:6eded2e4c616
Un-break hg 1.3 by adding a compat layer for progress.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Fri, 30 Apr 2010 10:35:13 -0500 |
parents | 3ab3765db5bc |
children | 4383d915fad3 f0c1c35d95ba 62315903f88b 628829fb92f1 |
files | hggit/__init__.py hggit/git_handler.py hggit/util.py |
diffstat | 3 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -17,7 +17,7 @@ import os -from mercurial import commands, extensions, hg, util +from mercurial import commands, extensions, hg, util as hgutil from mercurial.i18n import _ import gitrepo, hgrepo @@ -32,7 +32,7 @@ _oldlocal = hg.schemes['file'] def _local(path): - p = util.drop_scheme('file', path) + p = hgutil.drop_scheme('file', path) if (os.path.exists(os.path.join(p, '.git')) and not os.path.exists(os.path.join(p, '.hg'))): return gitrepo
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -13,6 +13,7 @@ from mercurial import context, util as hgutil from mercurial import error +import util class GitHandler(object): mapfile = 'git-mapfile' @@ -176,7 +177,7 @@ export = [node for node in nodes if not hex(node) in self._map_hg] total = len(export) for i, rev in enumerate(export): - self.ui.progress('import', i, total=total) + util.progress(self.ui, 'import', i, total=total) ctx = self.repo.changectx(rev) state = ctx.extra().get('hg-git', None) if state == 'octopus': @@ -184,7 +185,7 @@ "of octopus explosion\n" % ctx.rev()) continue self.export_hg_commit(rev) - self.ui.progress('import', None, total=total) + util.progress(self.ui, 'import', None, total=total) # convert this commit into git objects @@ -401,10 +402,10 @@ # import each of the commits, oldest first total = len(commits) for i, csha in enumerate(commits): - self.ui.progress('import', i, total=total, unit='commits') + util.progress(self.ui, 'import', i, total=total, unit='commits') commit = convert_list[csha] self.import_git_commit(commit) - self.ui.progress('import', None, total=total, unit='commits') + util.progress(self.ui, 'import', None, total=total, unit='commits') def import_git_commit(self, commit): self.ui.debug(_("importing: %s\n") % commit.id)
new file mode 100644 --- /dev/null +++ b/hggit/util.py @@ -0,0 +1,5 @@ +"""Compatability functions for old Mercurial versions.""" + +def progress(ui, *args, **kwargs): + """Shim for progress on hg < 1.4. Remove when 1.3 is dropped.""" + getattr(ui, 'progress', lambda *x, **kw: None)(*args, **kwargs)