Mercurial > hg > mercurial-crew
changeset 5232:7d3dcdd92a1a
Merge with crew-stable
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sun, 26 Aug 2007 16:49:26 +0200 |
parents | a1efa71f3ece (current diff) ceb6f242fb81 (diff) |
children | 20770c5d41e0 |
files | hgext/convert/git.py tests/test-convert-git |
diffstat | 4 files changed, 51 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/git.py +++ b/hgext/convert/git.py @@ -5,8 +5,23 @@ from common import NoRepo, commit, converter_source class convert_git(converter_source): - def gitcmd(self, s): - return os.popen('GIT_DIR=%s %s' % (self.path, s)) + # Windows does not support GIT_DIR= construct while other systems + # cannot remove environment variable. Just assume none have + # both issues. + if hasattr(os, 'unsetenv'): + def gitcmd(self, s): + prevgitdir = os.environ.get('GIT_DIR') + os.environ['GIT_DIR'] = self.path + try: + return os.popen(s) + finally: + if prevgitdir is None: + del os.environ['GIT_DIR'] + else: + os.environ['GIT_DIR'] = prevgitdir + else: + def gitcmd(self, s): + return os.popen('GIT_DIR=%s %s' % (self.path, s)) def __init__(self, ui, path, rev=None): super(convert_git, self).__init__(ui, path, rev=rev)
--- a/tests/hghave +++ b/tests/hghave @@ -51,9 +51,16 @@ except ImportError: return False +def has_git(): + fh = os.popen('git --version 2>&1') + s = fh.read() + ret = fh.close() + return ret is None and s.startswith('git version') + checks = { "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"), "execbit": (has_executablebit, "executable bit"), + "git": (has_git, "git command line client"), "fifo": (has_fifo, "named pipes"), "hotshot": (has_hotshot, "python hotshot module"), "lsprof": (has_lsprof, "python lsprof module"),
new file mode 100755 --- /dev/null +++ b/tests/test-convert-git @@ -0,0 +1,19 @@ +#!/bin/sh + +"$TESTDIR/hghave" git || exit 80 + +echo "[extensions]" >> $HGRCPATH +echo "convert=" >> $HGRCPATH + +mkdir git-repo +cd git-repo +git init +echo a > a +git add a +git commit -m t1 > /dev/null || echo "git commit error" +echo b >> a +git commit -a -m t2 > /dev/null || echo "git commit error" +cd .. + +hg convert git-repo +