changeset 580:35529f736fa2

util: add progress wrapper to maintain 1.3 support
author Augie Fackler <durin42@gmail.com>
date Wed, 03 Mar 2010 17:44:41 -0600
parents 21a389e4d8b5
children 90efea2c19df
files hgsubversion/__init__.py hgsubversion/svncommands.py hgsubversion/util.py hgsubversion/wrappers.py
diffstat 4 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/__init__.py
+++ b/hgsubversion/__init__.py
@@ -79,7 +79,6 @@ wrapcmds = { # cmd: generic, target, fix
 
 def uisetup(ui):
     """insert command wrappers for a bunch of commands"""
-
     docvals = {'extension': 'hgsubversion'}
     for cmd, (generic, target, fixdoc, ppopts, opts) in wrapcmds.iteritems():
 
--- a/hgsubversion/svncommands.py
+++ b/hgsubversion/svncommands.py
@@ -109,7 +109,7 @@ def rebuildmeta(ui, repo, args, **opts):
 
     numrevs = len(repo)
     for rev in repo:
-        ui.progress('rebuild', rev, total=numrevs)
+        util.progress(ui, 'rebuild', rev, total=numrevs)
         ctx = repo[rev]
         convinfo = ctx.extra().get('convert_revision', None)
         if not convinfo:
@@ -219,7 +219,7 @@ def rebuildmeta(ui, repo, args, **opts):
                 and droprev(cctx.extra().get('convert_revision', '@')) == droprev(convinfo)):
                 branchinfo.pop(branch, None)
                 break
-    ui.progress('rebuild', None, total=numrevs)
+    util.progress(ui, 'rebuild', None, total=numrevs)
 
     # save off branch info
     branchinfofile = open(os.path.join(svnmetadir, 'branch_info'), 'w')
--- a/hgsubversion/util.py
+++ b/hgsubversion/util.py
@@ -84,6 +84,10 @@ def normalize_url(url):
         url = '%s#%s' % (url, checkout)
     return url
 
+# TODO remove when we drop 1.3 support
+def progress(ui, *args, **kwargs):
+    if getattr(ui, 'progress', False):
+        return ui.progress(*args, **kwargs)
 
 def parseurl(url, heads=[]):
     parsed = hg.parseurl(url, heads)
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -285,7 +285,7 @@ def pull(repo, source, heads=[], force=F
                         bits = (r.revnum, r.author, msg)
                         cnt += 1
                         ui.status(('[r%d] %s: %s\n' % bits)[:w])
-                        ui.progress('pull', cnt, total=total)
+                        util.progress(ui, 'pull', cnt, total=total)
 
                         meta.save_tbdelta(tbdelta)
                         close = pullfuns[have_replay](ui, meta, svn, r, tbdelta)
@@ -313,7 +313,7 @@ def pull(repo, source, heads=[], force=F
         except KeyboardInterrupt:
             pass
     finally:
-        ui.progress('pull', None, total=total)
+        util.progress(ui, 'pull', None, total=total)
         util.swap_out_encoding(old_encoding)
 
     revisions = len(meta.revmap) - oldrevisions