Dan Villiom Podlaski Christiansen committed 9a4ec62

New patch.

Comments (0)

Files changed (2)


+# HG changeset patch
+# Parent 80c9089552416a24c79f01a65a96696c9e0e3909
+# User Dan Villiom Podlaski Christiansen <>
+die gracefully when accessing the repository over the network.
+diff --git a/hgit/ b/hgit/
+--- a/hgit/
++++ b/hgit/
+@@ -28,6 +28,8 @@ from mercurial import extensions
+ from mercurial import hg
+ from mercurial import util as hgutil
++from mercurial.hgweb import protocol as webprotocol
+ import gitrepo
+ # import a function from this module to force it to load
+ from bookwrap import setcurrent
+@@ -62,11 +64,22 @@ def gitinit(orig, ui, dest='.', **opts):
+         return commands.debugrebuildstate(ui, gitrepo.localgitrepo(ui, path), rev='.')
+     return orig(ui, dest=dest, **opts)
++def call(orig, repo, req, cmd):
++    if isinstance(repo, gitrepo.localgitrepo):
++        msg = ('This is not a Mercurial repository, but a Git repository '
++               'served by hgit. It cannot be accessed over the network.\n')
++        req.respond('415 this is hgit, not a Mercurial repository',
++                    type='text/plain', length=len(msg))
++        return [msg]
++    else:
++        return orig(repo, req, cmd)
+ def uisetup(ui):
+     entry = extensions.wrapcommand(commands.table, 'init', gitinit)
+     entry[1].extend([('', 'git', None, 'setup up a git repository instead of hg')])
++    extensions.wrapfunction(webprotocol, 'call', call)
+ _oldlocal = hg.schemes['file']
+ def _local(path):
+     p = hgutil.drop_scheme('file', path)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.