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