dulwich-users team mailing list archive
-
dulwich-users team
-
Mailing list archive
-
Message #00118
Re: Dulwich Pull/Push command?
On Tue, 2010-06-29 at 10:59 -0700, David Borowitz wrote:
> On Mon, Jun 28, 2010 at 18:31, Seth Shelnutt <shelnutt2@xxxxxxxxx>
> wrote:
> I'm actually just looking to use the modules. I want to
> integrate git support into my python script. I would be happy
> to help and add more functionality but first I'd like to
> finish my current project and second I'm familiar enough with
> Git. I'm in the process of learning how it works. It seems
> pretty straight forward, clone, pull, push, commit, all the
> basics don't seem to bad.
>
> What I am doing is moving wine's appinstall to python and
> expanding it. Appinstall was first developed by Austin English
> for the purpose of automating testing of software packages.
> What I need git support for is when a person runs
> apptester.py, the first thing it does is do a git status (or I
> might have it simply look for .git folder), and determine if
> the git repository has already been established.
>
> The easiest way to do this in dulwich would be:
> try:
> r = repo.Repo(dirname)
> except errors.NotGitRepository:
> r = clone_repo() # You'll have to define this function yourself;
> see below.
>
> If it has, it'll do a git pull to make sure it's up to date.
> Fetching is unfortunately a bit circuitous. I'll let Augie or Jelmer
> respond as they're much more familiar with the use of GitClient.
> However, once you've seen the difficult way, feel free to offer any
> interface suggestions that would make it easier.
When you have a client object (e.g. by calling
dulwich.client.get_transport_and_path), you should be able to call
client.fetch("/path/to/remote/repo", r) where r is an instance of
dulwich.repo.BaseRepo. This will call fetch_pack under the hood for you.
[...]
>
> and then push everything back to the main repo. I'm thinking
> that this needs to be done with the TCP or SSHGitClient and
> using fetch_pack and send_pack?
> send_pack is what you want, but again I'll defer to people who know
> this piece better.
We need a wrapper for send_pack that can do The Right Thing, but for now
you should be able to call it like this:
client.send_pack("/path/to/remote/repo",
r.object_store.determine_wants_all,
r.object_store.generate_pack_contents)
(also untested).
Cheers,
Jelmer
Attachment:
signature.asc
Description: This is a digitally signed message part
Follow ups
References