# HG changeset patch # User David Douard # Date 1265459455 -3600 # Node ID d229511201894e3af6b42d0064cb45afeed3cb86 # Parent 83f2e11a22be0f87ffd916cafa19299c0017fe84 Changes to become Python 2.5 compatible diff -r 83f2e11a22be -r d22951120189 README --- a/README Sat Feb 06 06:51:10 2010 -0500 +++ b/README Sat Feb 06 13:30:55 2010 +0100 @@ -7,7 +7,7 @@ Installing ========== -`hg-review` requires Mercurial (probably 1.3.1+) and **Python 2.6+**. Seriously, you need the latest version of Python. I'm not going to rewrite `os.relpath()` to support older versions, sorry. +`hg-review` requires Mercurial (probably 1.3.1+). Get it: diff -r 83f2e11a22be -r d22951120189 review/api.py --- a/review/api.py Sat Feb 06 06:51:10 2010 -0500 +++ b/review/api.py Sat Feb 06 13:30:55 2010 +0100 @@ -9,6 +9,28 @@ from mercurial import ui as _ui +try: + from os.path import relpath +except ImportError: # python < 2.6 + from os.path import curdir, abspath, sep, commonprefix, pardir, join + def relpath(path, start=curdir): + """Return a relative version of a path""" + + if not path: + raise ValueError("no path specified") + + start_list = abspath(start).split(sep) + path_list = abspath(path).split(sep) + + # Work out how much of the filepath is shared by start and path. + i = len(commonprefix([start_list, path_list])) + + rel_list = [pardir] * (len(start_list)-i) + path_list[i:] + if not rel_list: + return curdir + return join(*rel_list) + + DEFAULT_DATASTORE_DIRNAME = 'code-review' class PreexistingDatastore(Exception): @@ -157,7 +179,7 @@ """ if repo: - p = os.path.relpath(os.path.realpath(p), start=repo.root) + p = relpath(os.path.realpath(p), start=repo.root) return '/'.join(_split_path_dammit(p)) diff -r 83f2e11a22be -r d22951120189 review/tests/test_init.py --- a/review/tests/test_init.py Sat Feb 06 06:51:10 2010 -0500 +++ b/review/tests/test_init.py Sat Feb 06 13:30:55 2010 +0100 @@ -1,3 +1,4 @@ +from __future__ import with_statement from nose import * from util import * from .. import messages diff -r 83f2e11a22be -r d22951120189 review/tests/util.py --- a/review/tests/util.py Sat Feb 06 06:51:10 2010 -0500 +++ b/review/tests/util.py Sat Feb 06 13:30:55 2010 +0100 @@ -1,5 +1,5 @@ """Utilities for writing unit tests for hg-review.""" - +from __future__ import with_statement import os, shutil import sample_data from mercurial import cmdutil, commands, hg, ui @@ -10,14 +10,15 @@ def review(init=False, comment=False, signoff=False, yes=False, no=False, force=False, message='', rev='.', local_path='', remote_path='', lines='', files=None, unified='5', web=False): - - files = files if files else [] + + if not files: + files = [] _ui.pushbuffer() extension_ui.review(_ui, get_sandbox_repo(), *files, - init=init, comment=comment, signoff=signoff, yes=yes, no=no, + **dict(init=init, comment=comment, signoff=signoff, yes=yes, no=no, force=force, message=message, rev=rev, local_path=local_path, - remote_path=remote_path, lines=lines, unified=unified, web=web) + remote_path=remote_path, lines=lines, unified=unified, web=web)) output = _ui.popbuffer() print output diff -r 83f2e11a22be -r d22951120189 review/web_ui.py --- a/review/web_ui.py Sat Feb 06 06:51:10 2010 -0500 +++ b/review/web_ui.py Sat Feb 06 13:30:55 2010 +0100 @@ -1,4 +1,5 @@ """The review extension's web UI.""" +from __future__ import with_statement import sys, os import api