hg: explicitly check that peer lookup object has instance() if call failed
If a "thing" is callable but raises TypeError for some reason, a callable
object would be returned. Thereafter, unfriendly traceback would be displayed:
Traceback (most recent call last):
...
File "mercurial/hg.pyc", line 119, in _peerorrepo
obj = _peerlookup(path).instance(ui, path, create)
AttributeError: 'function' object has no attribute 'instance'
Instead, we should show the reason why "thing(path)" didn't work:
Traceback (most recent call last):
...
File "hggit/__init__.py", line 89, in _local
p = urlcls(path).localpath()
TypeError: 'NoneType' object is not callable
If a "thing" is not callable, it must be a module or an object that implements
instance(). If that module didn't have instance(), the error message would be
"<unloaded module 'foo'> object is not callable". It doesn't make perfect sense,
but it isn't so bad as it can blame which module went wrong.
$ hg init t
$ cd t
$ echo This is file a1 > a
$ hg add a
$ hg commit -m "commit #0"
$ echo This is file b1 > b
$ hg add b
$ hg commit -m "commit #1"
$ rm b
$ hg update 0
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo This is file b2 > b
$ hg add b
$ hg commit -m "commit #2"
created new head
$ cd ..; rm -r t
$ mkdir t
$ cd t
$ hg init
$ echo This is file a1 > a
$ hg add a
$ hg commit -m "commit #0"
$ echo This is file b1 > b
$ hg add b
$ hg commit -m "commit #1"
$ rm b
$ hg update 0
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo This is file b2 > b
$ hg commit -A -m "commit #2"
adding b
created new head
$ cd ..; rm -r t
$ hg init t
$ cd t
$ echo This is file a1 > a
$ hg add a
$ hg commit -m "commit #0"
$ echo This is file b1 > b
$ hg add b
$ hg commit -m "commit #1"
$ rm b
$ hg remove b
$ hg update 0
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo This is file b2 > b
$ hg commit -A -m "commit #2"
adding b
created new head
$ cd ..