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
14 14
15'''15'''
16 16
17from mercurial import commands, extensions, hg17from mercurial import commands, extensions, hg, util
18from mercurial.i18n import _18from mercurial.i18n import _
19
20from dulwich.repo import Repo
21from dulwich.errors import NotGitRepository
22
19import gitrepo, hgrepo23import gitrepo, hgrepo
20from git_handler import GitHandler24from git_handler import GitHandler
21 25
@@ -24,6 +28,18 @@ from git_handler import GitHandler · 2 unmodified lines
24hg.schemes['git'] = gitrepo28hg.schemes['git'] = gitrepo
25hg.schemes['git+ssh'] = gitrepo29hg.schemes['git+ssh'] = gitrepo
26 30
31_oldlocal = hg.schemes['file']
32
33def _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
41hg.schemes['file'] = _local
42
27def reposetup(ui, repo):43def reposetup(ui, repo):
28 klass = hgrepo.generate_repo_subclass(repo.__class__)44 klass = hgrepo.generate_repo_subclass(repo.__class__)
29 repo.__class__ = klass45 repo.__class__ = klass
tests/test-git-clone+1−10
@@ -37,20 +37,11 @@ echo beta > beta · 36 unmodified lines
37git add beta37git add beta
38commit -m 'add beta'38commit -m 'add beta'
39 39
40# dulwich does not presently support local git repos, workaround
41cd ..40cd ..
42git daemon --base-path="$(pwd)"\
43 --listen=localhost\
44 --export-all\
45 --pid-file=gitdaemon.pid \
46 --detach --reuseaddr
47 41
48hg clone git://localhost/gitrepo hgrepo42hg clone gitrepo hgrepo
49cd hgrepo43cd hgrepo
50hg log --graph44hg log --graph
51 45
52echo % we should have some bookmarks46echo % we should have some bookmarks
53hg book47hg book
54
55cd ..
56kill `cat gitdaemon.pid`
tests/test-git-clone.out+1−1
@@ -1,6 +1,6 @@
1Initialized empty Git repository in gitrepo/.git/1Initialized empty Git repository in gitrepo/.git/
2 2
3fetching from : git://localhost/gitrepo3fetching from : gitrepo
4importing Hg objects into Git4importing Hg objects into Git
5Counting objects: 6, done.5Counting objects: 6, done.
6Compressing objects: 33% (1/3) Compressing objects: 66% (2/3) Compressing objects: 100% (3/3) Compressing objects: 100% (3/3), done.6Compressing objects: 33% (1/3) Compressing objects: 66% (2/3) Compressing objects: 100% (3/3) Compressing objects: 100% (3/3), done.