History

support local git repositories (fixes issue 5 bb)

Abderrahim Kitouni committed 17 years ago

Commit e7500a81 parent 3ed21623 files · +19 −12Browse files

Unified · Split

3 files
  1. __init__.py +17 −1
  2. tests/test-git-clone +1 −10
  3. tests/test-git-clone.out +1 −1
__init__.py+17−1
@@ -14,8 +14,12 @@ project that is in Git. A bridger of worlds, this plugin be. · 13 unmodified lines
1414
1515 '''
1616
17−from mercurial import commands, extensions, hg
17+from mercurial import commands, extensions, hg, util
1818 from mercurial.i18n import _
19+
20+from dulwich.repo import Repo
21+from dulwich.errors import NotGitRepository
22+
1923 import gitrepo, hgrepo
2024 from git_handler import GitHandler
2125
@@ -24,6 +28,18 @@ from git_handler import GitHandler · 2 unmodified lines
2428 hg.schemes['git'] = gitrepo
2529 hg.schemes['git+ssh'] = gitrepo
2630
31+_oldlocal = hg.schemes['file']
32+
33+def _local(path):
34+ p = util.drop_scheme('file', path)
35+ try:
36+ Repo(p)
37+ return gitrepo
38+ except NotGitRepository:
39+ return _oldlocal(path)
40+
41+hg.schemes['file'] = _local
42+
2743 def reposetup(ui, repo):
2844 klass = hgrepo.generate_repo_subclass(repo.__class__)
2945 repo.__class__ = klass
tests/test-git-clone+1−10
@@ -37,20 +37,11 @@ echo beta > beta · 36 unmodified lines
3737 git add beta
3838 commit -m 'add beta'
3939
40−# dulwich does not presently support local git repos, workaround
4140 cd ..
42−git daemon --base-path="$(pwd)"\
43− --listen=localhost\
44− --export-all\
45− --pid-file=gitdaemon.pid \
46− --detach --reuseaddr
4741
48−hg clone git://localhost/gitrepo hgrepo
42+hg clone gitrepo hgrepo
4943 cd hgrepo
5044 hg log --graph
5145
5246 echo % we should have some bookmarks
5347 hg book
54−
55−cd ..
56−kill `cat gitdaemon.pid`
tests/test-git-clone.out+1−1
@@ -1,6 +1,6 @@
11 Initialized empty Git repository in gitrepo/.git/
22
3−fetching from : git://localhost/gitrepo
3+fetching from : gitrepo
44 importing Hg objects into Git
55 Counting objects: 6, done.
66 Compressing objects: 33% (1/3) Compressing objects: 66% (2/3) Compressing objects: 100% (3/3) Compressing objects: 100% (3/3), done.