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