[hg-import bug] operation not supported over http

John Arbash Meinel john at arbash-meinel.com
Sun Jun 18 02:38:45 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aaron Bentley wrote:
> John Arbash Meinel wrote:
>>> Aaron Bentley wrote:
>>>>> I'm getting an error from the hg-import plugin on non-hg branches.
>>>>>
>>>>> $ bzr pull --remember http://michael.ellerman.id.au/bzr/plugins/shelf
>>>>> bzr: ERROR: mercurial.util.Abort: operation not supported over http
>>>>>   at /usr/local/lib/python2.4/site-packages/mercurial/httprepo.py line 71
>>>>>   in lock
>>>>>
>>>>> It appears that the plugin breaks find-repo, which means that branches
>>>>> in shared repositories don't work (unless they're in the repo root).
>>>>>
>>>>> Aaron
>>>
>>> It seems like the plugin needs to trap the Abort exception. It seems
>>> like we may be locking too strongly for 'lock_read()'. Probably
>>> lock_read() should not call 'lock()' at all.
> 
> That's probably so, if we want to support Hg over http properly.  But I
> think we should not have gotten here.  I think HgDirFormat should throw
> NotBranchError in probe_transport, if there's no .hg directory.
> 
> So here's a patch that fixes it for now.
> 
> Aaron


...

=== modified file __init__.py
- --- __init__.py
+++ __init__.py
@@ -469,6 +469,8 @@
         # try a manual probe first, its a little faster perhaps ?
         if transport.has('.hg'):
             return format
+        else:
+            raise errors.NotBranchError(path=transport.base)


This is risky code. Transports aren't guaranteed to work perfectly with
directories instead of files. I would be much happier if we looked for
something like '.hg/dirstate'. Though I don't know hg's rules on what
makes an hg directory. (It very easily could be the presence of a
directory). They don't seem to have much of a way to indicate the
version for the directory. Other than maybe reading something like
dirstate and seeing the format header.

'Transport.has()' is also not a very heavily used codepath. I thought it
would be good, but really 'get()' is more important. We generally use:
try:
  f = get('foo')
except NoSuchFile:


rather than 'has()'.

The reason being if the file exists, we now have a copy of it, and don't
need another round trip.

If we are using 'transport.has()', though, I prefer your code which
raises 'NotBranchError' when it cannot bind to the branch at that location.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFElK6lJdeBCYSNAAMRAgGcAJ0RoHrUZigNR4+Fv5qRtce+5wDziACglr0L
BjMYBQ8cYvXU8RxQwfFGucI=
=a1Rt
-----END PGP SIGNATURE-----




More information about the bazaar mailing list