Possible bug in Internal Python API

Vishakh Harikumar vsh426 at gmail.com
Fri Aug 13 03:02:45 CDT 2010


On Fri, Aug 13, 2010 at 7:14 AM, Miguel Araujo <muchochini at gmail.com> wrote:
> Hi everyone,
> I'm writing a little Mercurial script which merely purpose is to get last
> commit's information. For this I'm using:
>
> repository = localrepo.localrepository(ui.ui(), '/path/to/repo/')
>
> current_ctx = context.changectx(repository)
>
> current_ctx.rev()
>
> This code works perfectly in my own laptop against a clone of my repository.
> I get last Change context. However, If I do the same in my server against my
> main tree I get a -1. Funny thing is I don't get any  repo.RepoError. My
> repositoriy object has a root property which points to the right path and I
> can get a changelog and move over it.
> If I try the same thing against a local clone (in the server) of that
> repository, it fails but works. It doesn't get the last Change Context which
> has rev 44, but it gets something (21). So it looks like you should be
> working on a clone and not the main tree. If I do:

The revision numbers you see probably correspond to those of the working
directory. repository supports repo[changeid] to get a changectx, so you
want repo['tip'] for the tip of the repo.

> len(repository.changelog) ---> 44
>
> Another snippet of code I have tried is:
>
> repository = localrepo.localrepository(ui.ui(), '/path/to/repo/')
>
> current_ctx = context.changectx(repository.changelog.tip())

it should be changectx(repository, repository.changelog.tip()).
repo['tip'] is better

> current_ctx.rev()
>
> This works without problems in my laptop, but I haven't found a way to make
> it work in my server. When I do it, I get:
> *** AttributeError: 'str' object has no attribute 'lookup'
> I have to say that my laptop and server run the same Mercurial version. This
> erratic behavior makes me think there could be a bug in the API. I have
> thought about moving over all the changelog till the last one, but I need a
> better performance solution, because this will be plugged into big
> repositories with lots of commits.
> Thanks for your time, best regards
> Miguel Araujo

See http://mercurial.selenic.com/wiki/MercurialApi if you havent already.
Also useful to mention hg version in these cases.

cheers
-- 
vsh


More information about the Mercurial-devel mailing list