Possible bug in Internal Python API

Vishakh Harikumar vsh426 at gmail.com
Fri Aug 13 06:56:12 CDT 2010


On Fri, Aug 13, 2010 at 4:55 PM, Miguel Araujo <muchochini at gmail.com> wrote:
> Sorry,
> I forgot to attach the mentioned screenshot. There it goes.
> Cheers,
> Miguel Araujo
>
> 2010/8/13 Miguel Araujo <muchochini at gmail.com>
>>
>> First thank you Dirkjan Ochtman and Vishakh Harikumar for your fast
>> answers,
>> I want to clarify that of course I had read the API documentation before
>> sending this email. The fact that my code works in one machine and It
>> doesn't in other, made
>> me wonder if it was a bug. I still think there are some details that you
>> can not explain, so there still could be a flaw in the code.

have you checked the versions of your script and hg running on both machines?

>>>
>>> It looks like you don't really understand Mercurial's data model or the
>>> API...
>>
>> I'm not going to lie. This is the first time I use it, and I think the API
>> documentation at  http://mercurial.selenic.com/wiki/MercurialApi is quite
>> poor. I read it all and there are a lot of things not explained, the
>> internal methods of many modules don't even have doc strings, so it forces
>> you to read the code.
>>>
>>> This is because the repo on your server doesn't have a working
>>> directory checked out. Getting a changectx() by default gets you the
>>> revision the working directory is at (so not necessarily the last
>>> revision in the repository!).
>>
>> I didn't know this, thanks.
>>>
>>> This is silly code, context.changectx()'s first argument must be a
>>> repository, not a string (which is what you're passing here). I'm
>>> pretty sure this doesn't work on your laptop, either.
>>
>> Trust me, this works flawlessly. I'm sending a screenshot attached so you
>> can see I don't lie.

The piece of code in the screenshot and the one in your first mail differ.
(correct)repo.changectx vs context.changectx(wrong)

>>>
>>> I would advise you to read some more docs and familiarize yourself
>>> with Mercurial some more before you try to write code against it.
>>>
>>> Also check out the MercurialApi wiki page for nice API usage patterns
>>> (such as using repo['tip'] to get a changectx).
>>
>> Thanks, I have read all the docs I have found, which as I have said, are
>> not many in my humble opinion. The repo['tip'] pattern does not appear in
>> the wiki like that.
>>>
>>> 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.
>>
>> Problem is repo that returns 21 and the one that returns 43, are exactly
>> the same one. Directories don't differ a single bit.

Dirkjan's explanation stands. 'hg summary' in the directory must say
"parent: 21:XXXXXX" .On clone hg must have updated to that particular
revision. 'hg update tip' to update working directory to latest revision and
then run the same bit of code.

-- 
vsh


More information about the Mercurial-devel mailing list