Mercurial > hg > hg-git
changeset 300:eec31dee258e
Various hg 1.4 compat fixes.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sat, 27 Mar 2010 21:37:58 -0500 |
parents | 6bde2f727de9 |
children | 7ddb740ac7cc |
files | hggit/__init__.py hggit/git_handler.py tests/test-pull-after-strip tests/test-pull-after-strip.out |
diffstat | 4 files changed, 26 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -61,7 +61,8 @@ if getattr(lrepo, 'changelog', False) and co not in lrepo.changelog: co = None return revs, co -extensions.wrapfunction(hg, 'addbranchrevs', safebranchrevs) +if getattr(hg, 'addbranchrevs', False): + extensions.wrapfunction(hg, 'addbranchrevs', safebranchrevs) def reposetup(ui, repo): if not isinstance(repo, gitrepo.gitrepo):
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -11,6 +11,7 @@ from mercurial.i18n import _ from mercurial.node import hex, bin, nullid from mercurial import context, util as hgutil +from mercurial import error class GitHandler(object): @@ -509,8 +510,16 @@ if octopus: extra['hg-git'] ='octopus-done' - if p1 not in self.repo or p2 not in self.repo: - raise hgutil.Abort(_('you appear to have run strip - please run hg git-cleanup')) + # TODO use 'n in self.repo' when we require hg 1.5 + def repo_contains(n): + try: + return bool(self.repo.lookup(n)) + except error.RepoLookupError: + return False + + if not (repo_contains(p1) and repo_contains(p2)): + raise hgutil.Abort(_('you appear to have run strip - ' + 'please run hg git-cleanup')) ctx = context.memctx(self.repo, (p1, p2), text, list(files), getfilectx, author, date, extra)
--- a/tests/test-pull-after-strip +++ b/tests/test-pull-after-strip @@ -3,6 +3,17 @@ # Fails for some reason, need to investigate # "$TESTDIR/hghave" git || exit 80 +# this test is busted on hg < 1.5. I'm not sure how to fix it. +cat > tmp.py <<EOF +import sys +v = sys.stdin.read().strip()[:-1] +if v[1] == '.' and int(v[2]) > 4: + sys.exit(0) +sys.exit(1) +EOF + +hg version | grep version | sed 's/.*(version //' | python tmp.py || exit 80 + # bail if the user does not have dulwich python -c 'import dulwich, dulwich.repo' || exit 80 @@ -78,6 +89,7 @@ hg strip tip 2>&1 | grep -v saving hg pull -r beta hg git-cleanup +echo % pull works after `hg git-cleanup` hg pull -r beta hg log --graph
--- a/tests/test-pull-after-strip.out +++ b/tests/test-pull-after-strip.out @@ -48,6 +48,7 @@ importing Git objects into Hg abort: you appear to have run strip - please run hg git-cleanup git commit map cleaned +% pull works after git commit map cleaned pulling from git://localhost/gitrepo importing Hg objects into Git Counting objects: 6, done.