← Back to team overview

dulwich-users team mailing list archive

Re: dulwich porcelain

 

> 

> This is the new push code:
> 
> from dulwich.repo import Repo
> from dulwich.client import get_transport_and_path
> from getopt import getopt
> import sys
> 
> 
> def push(args):
>     opts, args = getopt(args, "", [])
>     opts = dict(opts)
>     client, path = get_transport_and_path(args.pop(0))
>     r = Repo(".")
>     objsto = r.object_store
>     refs = r.get_refs()
>     def determine_wants_new(old):
>         same = list(set(refs).intersection(old))
>         new = dict([(k,refs[k]) for k in same if refs[k] != old[k]])
>         dfky = list(set(refs) - set(new))
>         dfrnt = dict([(k,refs[k]) for k in dfky if k != 'HEAD'])
>         return dict(new.items() + dfrnt.items())
>     refs = client.send_pack(path,
>                             determine_wants_new,
>                             objsto.generate_pack_contents,
>                             sys.stdout.write)
> 
> It works, but I don't think my objects are packed, so it just pushes a bunch 
> of nothing. When I look at the remote, it has all the right shas for each commit 
> but it says all of the files have been deleted. Do I need to pack the objects 
> after commiting them but before sending them? How do I do that?
> 
> BTW I had to remove 'HEAD' as a ref, because server said "error: 
> refusing inconsistent update between symref 'HEAD' and its target
> '/refs/heads/master'
> 
> Dulwich is really amazing. Thanks for your help.
> 
> Thanks,
> Mark
> 


OK, I'm an idiot. I had _never_ staged anything, so all of my commits were meaningless. Everything is working fine now!


References