pythonmercurialmercurial-extension

Mercurial API : repo.changectx(change) doesn't exist!


i'm trying to make a Mercurial support plugin for a Python IDE and i have a lot of troubles understanding the API. Right now i'm only making experiments for understanding the uses of the different commands of the api, but i can't find the api's doc or anything like it.

My problem is that r.changectx doesn't work because r hasn't this operation. And i see a lot of examples that use the changectx function.

My mercurial version is 1.7.3 . Thanks a lot !!

from mercurial import ui, hg


r = hg.repository(ui.ui(), "https://ninja-ide.googlecode.com/hg/")
c = r.changectx("setup.py")

# show some information about the changeset
print c # represented as the changeset hash
print c.user()
print c.description()
print

# let's take a peek at the files
files = c.files()
for f in files:
 fc = c[f]
 print " ", f, len(fc.data())

Solution

  • I think it needs a local repo for it to work like that. Also, you need a revision for changectx.

    from mercurial import ui, hg, commands
    
    myui = ui.ui()
    repourl = "https://ninja-ide.googlecode.com/hg/"
    
    commands.clone(myui, repourl, 'ninja')
    r = hg.repository(myui, './ninja')
    c = r.changectx("tip")
    
    # show some information about the changeset
    print c # represented as the changeset hash
    print c.user()
    print c.description()
    print
    
    # let's take a peek at the files
    files = c.files()
    for f in files:
     fc = c[f]
     print " ", f, len(fc.data())
    

    Edit: this FAQ entry seems to corroborate that it won't work on remote repositories.