dulwich-users team mailing list archive
-
dulwich-users team
-
Mailing list archive
-
Message #00739
Re: dulwich porcelain
>> Hi Jelmer,
>> So what is supposed to be used with send_pack? Should I modify or write
>> my own determine_wants_all for send_pack that returns the dictionary as
>> requested?
> Yes, the easiest thing to do is to write your own. This should be fairly
> simple if you're just updating a single branch or copying over the refs
> of another repository.
>
>> Is new_refs *all* of the refs in objects? or is it only the ones that are
> not
>> _old_?
> It's just the changes to the refs.
>
>> For example, I have 4 ref:shas in objects. One commit is already on the
>> remote, because it was there when I cloned it. So I assume that's
> old_ref.
>> Now is new_refs the 3 remaining refs in objects, not including the one
>> already on the remote? I really need to learn a lot more about git
> plumbing!
> It's just the changes, though including refs that are already set (to
> the same SHA1) shouldn't be harmful.
>
> Cheers,
>
> Jelmer
>
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
Follow ups
References