# HG changeset patch # User Augie Fackler <durin42@gmail.com> # Date 1272641713 18000 # Node ID 6eded2e4c616c62a3cd9868cd43a8144dfc46be5 # Parent 3ab3765db5bc8bf6be62c0de93a10b765e4fd0bb Un-break hg 1.3 by adding a compat layer for progress. diff --git a/hggit/__init__.py b/hggit/__init__.py --- 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 diff --git a/hggit/git_handler.py b/hggit/git_handler.py --- 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) diff --git a/hggit/util.py b/hggit/util.py 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)