Mercurial > hg
changeset 5246: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 Sat Aug 25 12:25:53 2007 -0700 +++ b/hgext/convert/git.py Sun Aug 26 16:49:26 2007 +0200 @@ -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 Sat Aug 25 12:25:53 2007 -0700 +++ b/tests/hghave Sun Aug 26 16:49:26 2007 +0200 @@ -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"),
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-convert-git Sun Aug 26 16:49:26 2007 +0200 @@ -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 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-convert-git.out Sun Aug 26 16:49:26 2007 +0200 @@ -0,0 +1,8 @@ +Initialized empty Git repository in .git/ +assuming destination git-repo-hg +initializing destination git-repo-hg repository +scanning source... +sorting... +converting... +1 t1 +0 t2