Show More
@@ -282,7 +282,7 b' elif cmd == "debugindex":' | |||
|
282 | 282 | elif cmd == "merge": |
|
283 | 283 | if args: |
|
284 | 284 | other = hg.repository(ui, args[0]) |
|
285 |
print "re |
|
|
285 | print "requesting changegroup" | |
|
286 | 286 | cg = repo.getchangegroup(other) |
|
287 | 287 | repo.addchangegroup(cg) |
|
288 | 288 | else: |
@@ -613,23 +613,24 b' class localrepository:' | |||
|
613 | 613 | |
|
614 | 614 | def getchangegroup(self, remote): |
|
615 | 615 | tip = remote.branches([])[0] |
|
616 |
|
|
|
616 | m = self.changelog.nodemap | |
|
617 | 617 | unknown = [tip] |
|
618 | 618 | search = [] |
|
619 | 619 | fetch = [] |
|
620 | 620 | |
|
621 |
if tip[0] |
|
|
621 | if tip[0] in m: | |
|
622 | 622 | return None |
|
623 | 623 | |
|
624 | 624 | while unknown: |
|
625 | 625 | n = unknown.pop(0) |
|
626 | 626 | if n == nullid: break |
|
627 |
if n[1] and |
|
|
627 | if n[1] and n[1] in m: # do we know the base? | |
|
628 | 628 | search.append(n) # schedule branch range for scanning |
|
629 | 629 | else: |
|
630 | 630 | for b in remote.branches([n[2], n[3]]): |
|
631 |
if |
|
|
632 | fetch.append(n[1]) # earliest unknown | |
|
631 | if b[0] in m: | |
|
632 | if n[1] not in fetch: | |
|
633 | fetch.append(n[1]) # earliest unknown | |
|
633 | 634 | else: |
|
634 | 635 | unknown.append(b) |
|
635 | 636 | |
@@ -639,13 +640,18 b' class localrepository:' | |||
|
639 | 640 | p = n[0] |
|
640 | 641 | f = 1 |
|
641 | 642 | for i in l + [n[1]]: |
|
642 | if self.changelog.nodemap.has_key(i): | |
|
643 | if i in m: | |
|
643 | 644 | if f <= 4: |
|
644 | 645 | fetch.append(p) |
|
645 | 646 | else: |
|
646 | 647 | search.append((p, i)) |
|
648 | break | |
|
647 | 649 | p, f = i, f * 2 |
|
648 | 650 | |
|
651 | for f in fetch: | |
|
652 | if f in m: | |
|
653 | raise "already have", hex(f[:4]) | |
|
654 | ||
|
649 | 655 | return remote.changegroup(fetch) |
|
650 | 656 | |
|
651 | 657 | def changegroup(self, basenodes): |
@@ -677,55 +683,63 b' class localrepository:' | |||
|
677 | 683 | l = struct.pack(">l", len(f)) |
|
678 | 684 | yield "".join([l, f, g]) |
|
679 | 685 | |
|
680 |
def addchangegroup(self, |
|
|
681 | def getlen(data, pos): | |
|
682 | return struct.unpack(">l", data[pos:pos + 4])[0] | |
|
686 | def addchangegroup(self, generator): | |
|
687 | class genread: | |
|
688 | def __init__(self, generator): | |
|
689 | self.g = generator | |
|
690 | self.buf = "" | |
|
691 | def read(self, l): | |
|
692 | while l > len(self.buf): | |
|
693 | try: | |
|
694 | self.buf += self.g.next() | |
|
695 | except StopIteration: | |
|
696 | break | |
|
697 | d, self.buf = self.buf[:l], self.buf[l:] | |
|
698 | return d | |
|
699 | ||
|
700 | if not generator: return | |
|
701 | source = genread(generator) | |
|
683 | 702 | |
|
684 | if not data: return | |
|
685 | ||
|
703 | def getchunk(add = 0): | |
|
704 | d = source.read(4) | |
|
705 | if not d: return "" | |
|
706 | l = struct.unpack(">l", d)[0] | |
|
707 | return source.read(l - 4 + add) | |
|
708 | ||
|
686 | 709 | tr = self.transaction() |
|
687 | 710 | simple = True |
|
688 | 711 | |
|
689 | 712 | print "merging changesets" |
|
690 | 713 | # pull off the changeset group |
|
691 |
|
|
|
692 | csg = data[0:l] | |
|
693 | pos = l | |
|
714 | csg = getchunk() | |
|
694 | 715 | co = self.changelog.tip() |
|
695 | 716 | cn = self.changelog.addgroup(csg, lambda x: self.changelog.count(), tr) |
|
696 | 717 | |
|
697 | 718 | print "merging manifests" |
|
698 | 719 | # pull off the manifest group |
|
699 |
|
|
|
700 | mfg = data[pos: pos + l] | |
|
701 | pos += l | |
|
720 | mfg = getchunk() | |
|
702 | 721 | mo = self.manifest.tip() |
|
703 |
m |
|
|
722 | mm = self.manifest.addgroup(mfg, lambda x: self.changelog.rev(x), tr) | |
|
704 | 723 | |
|
705 | 724 | # do we need a resolve? |
|
706 | 725 | if self.changelog.ancestor(co, cn) != co: |
|
707 | print "NEED RESOLVE" | |
|
708 | 726 | simple = False |
|
709 | 727 | resolverev = self.changelog.count() |
|
710 | 728 | |
|
711 | 729 | # process the files |
|
712 | 730 | print "merging files" |
|
713 | 731 | new = {} |
|
714 |
while |
|
|
715 |
|
|
|
716 |
|
|
|
717 | f = data[pos:pos + l] | |
|
718 | pos += l | |
|
719 | ||
|
720 | l = getlen(data, pos) | |
|
721 | fg = data[pos: pos + l] | |
|
722 | pos += l | |
|
732 | while 1: | |
|
733 | f = getchunk(4) | |
|
734 | if not f: break | |
|
735 | fg = getchunk() | |
|
723 | 736 | |
|
724 | 737 | fl = self.file(f) |
|
725 | 738 | o = fl.tip() |
|
726 | 739 | n = fl.addgroup(fg, lambda x: self.changelog.rev(x), tr) |
|
727 | 740 | if not simple: |
|
728 |
n |
|
|
741 | nn = fl.resolvedag(o, n, tr, resolverev) | |
|
742 | if nn: new[f] = nn | |
|
729 | 743 | |
|
730 | 744 | # For simple merges, we don't need to resolve manifests or changesets |
|
731 | 745 | if simple: |
@@ -794,24 +808,30 b' class remoterepository:' | |||
|
794 | 808 | q.update(args) |
|
795 | 809 | qs = urllib.urlencode(q) |
|
796 | 810 | cu = "%s?%s" % (self.url, qs) |
|
797 |
return urllib.urlopen(cu) |
|
|
811 | return urllib.urlopen(cu) | |
|
798 | 812 | |
|
799 | 813 | def branches(self, nodes): |
|
800 | 814 | n = " ".join(map(hex, nodes)) |
|
801 | d = self.do_cmd("branches", nodes=n) | |
|
815 | d = self.do_cmd("branches", nodes=n).read() | |
|
802 | 816 | br = [ map(bin, b.split(" ")) for b in d.splitlines() ] |
|
803 | 817 | return br |
|
804 | 818 | |
|
805 | 819 | def between(self, pairs): |
|
806 | 820 | n = "\n".join(["-".join(map(hex, p)) for p in pairs]) |
|
807 | d = self.do_cmd("between", pairs=n) | |
|
821 | d = self.do_cmd("between", pairs=n).read() | |
|
808 | 822 | p = [ map(bin, l.split(" ")) for l in d.splitlines() ] |
|
809 | 823 | return p |
|
810 | 824 | |
|
811 | 825 | def changegroup(self, nodes): |
|
812 | 826 | n = " ".join(map(hex, nodes)) |
|
813 | d = self.do_cmd("changegroup", roots=n) | |
|
814 | return zlib.decompress(d) | |
|
827 | zd = zlib.decompressobj() | |
|
828 | f = self.do_cmd("changegroup", roots=n) | |
|
829 | while 1: | |
|
830 | d = f.read(4096) | |
|
831 | if not d: | |
|
832 | yield zd.flush() | |
|
833 | break | |
|
834 | yield zd.decompress(d) | |
|
815 | 835 | |
|
816 | 836 | def repository(ui, path=None, create=0): |
|
817 | 837 | if path and path[:5] == "hg://": |
@@ -345,11 +345,10 b' class revlog:' | |||
|
345 | 345 | # first delta is against its parent, which should be in our |
|
346 | 346 | # log, the rest are against the previous delta. |
|
347 | 347 | |
|
348 |
if |
|
|
348 | if not data: return self.tip() | |
|
349 | 349 | |
|
350 | 350 | # retrieve the parent revision of the delta chain |
|
351 |
chain = data[2 |
|
|
352 | text = self.revision(chain) | |
|
351 | chain = data[24:44] | |
|
353 | 352 | |
|
354 | 353 | # track the base of the current delta log |
|
355 | 354 | r = self.count() |
@@ -370,7 +369,7 b' class revlog:' | |||
|
370 | 369 | ifh = self.opener(self.indexfile, "a") |
|
371 | 370 | |
|
372 | 371 | # loop through our set of deltas |
|
373 |
pos = |
|
|
372 | pos = 0 | |
|
374 | 373 | while pos < len(data): |
|
375 | 374 | l, node, p1, p2, cs = struct.unpack(">l20s20s20s20s", |
|
376 | 375 | data[pos:pos+84]) |
@@ -391,7 +390,7 b' class revlog:' | |||
|
391 | 390 | # flush our writes here so we can read it in revision |
|
392 | 391 | dfh.flush() |
|
393 | 392 | ifh.flush() |
|
394 |
text = self.revision( |
|
|
393 | text = self.revision(chain) | |
|
395 | 394 | text = self.patch(text, delta) |
|
396 | 395 | chk = self.addrevision(text, transaction, link, p1, p2) |
|
397 | 396 | if chk != node: |
@@ -404,8 +403,7 b' class revlog:' | |||
|
404 | 403 | dfh.write(cdelta) |
|
405 | 404 | ifh.write(struct.pack(indexformat, *e)) |
|
406 | 405 | |
|
407 | t, r = r, r + 1 | |
|
408 | chain = prev | |
|
406 | t, r, chain, prev = r, r + 1, node, node | |
|
409 | 407 | start = self.start(self.base(t)) |
|
410 | 408 | end = self.end(t) |
|
411 | 409 |
General Comments 0
You need to be logged in to leave comments.
Login now