← Back to team overview

dulwich-users team mailing list archive

Re: Fetch a specific revision of a file

 

On Tue, Nov 17, 2009 at 17:44, Jelmer Vernooij <jelmer@xxxxxxxxx> wrote:

> Hi Emiliano,
>
> On Tue, 2009-11-17 at 17:16 +0100, Emiliano Heyns wrote:
> > Is there a way to fetch a specific revision of a file using dulwich?
> Do you mean fetching the copy of a file as it existed in a particular
> Git commit ?
>
> This is certainly possible for local repositories, you should retrieve
> the tree sha associated with the particular commit and then use
> tree_path_lookup to find the individual blob.
>
>
I've gotten this far:

from dulwich.repo import Repo
from dulwich import object_store as GitObjectStore

repo = Repo(GITREPODIR)
for commit in repo.revision_history(repo.head()):
    print commit.commit_time
    for id, name, sha in repo.tree(commit.tree).entries():
        print name, sha
        GitObjectStore.tree_lookup_path(??, commit.tree, name)

But I don't know what to use for the first parameter for tree_lookup_path.

Thanks,
Emile

Follow ups

References