Show More
@@ -187,7 +187,7 b' elif cmd == "export":' | |||||
187 | diff(None, prev, node) |
|
187 | diff(None, prev, node) | |
188 |
|
188 | |||
189 | elif cmd == "debugchangegroup": |
|
189 | elif cmd == "debugchangegroup": | |
190 |
newer = repo.newer(repo.changelog.lookup |
|
190 | newer = repo.newer(map(repo.changelog.lookup, args)) | |
191 | cg = repo.changegroup(newer) |
|
191 | cg = repo.changegroup(newer) | |
192 | sys.stdout.write(cg) |
|
192 | sys.stdout.write(cg) | |
193 |
|
193 | |||
@@ -195,6 +195,16 b' elif cmd == "debugaddchangegroup":' | |||||
195 | data = sys.stdin.read() |
|
195 | data = sys.stdin.read() | |
196 | repo.addchangegroup(data) |
|
196 | repo.addchangegroup(data) | |
197 |
|
197 | |||
|
198 | elif cmd == "debuggetchangegroup": | |||
|
199 | if args: | |||
|
200 | other = hg.repository(ui, args[0]) | |||
|
201 | print "building changegroup" | |||
|
202 | cg = repo.getchangegroup(other) | |||
|
203 | print "applying changegroup" | |||
|
204 | repo.addchangegroup(cg) | |||
|
205 | else: | |||
|
206 | print "missing source repository" | |||
|
207 | ||||
198 | elif cmd == "addremove": |
|
208 | elif cmd == "addremove": | |
199 | (c, a, d) = repo.diffdir(repo.root, repo.current) |
|
209 | (c, a, d) = repo.diffdir(repo.root, repo.current) | |
200 | repo.add(a) |
|
210 | repo.add(a) |
@@ -560,14 +560,97 b' class repository:' | |||||
560 | for f in list: |
|
560 | for f in list: | |
561 | dl.write(f + "\n") |
|
561 | dl.write(f + "\n") | |
562 |
|
562 | |||
563 |
def |
|
563 | def branches(self, nodes): | |
564 | nodes = [] |
|
564 | if not nodes: nodes = [self.changelog.tip()] | |
565 | for i in xrange(self.changelog.rev(node) + 1, self.changelog.count()): |
|
565 | b = [] | |
566 | nodes.append(self.changelog.node(i)) |
|
566 | for n in nodes: | |
|
567 | t = n | |||
|
568 | while n: | |||
|
569 | p = self.changelog.parents(n) | |||
|
570 | if p[1] != nullid or p[0] == nullid: | |||
|
571 | b.append((t, n, p[0], p[1])) | |||
|
572 | break | |||
|
573 | n = p[0] | |||
|
574 | return b | |||
|
575 | ||||
|
576 | def between(self, pairs): | |||
|
577 | r = [] | |||
|
578 | ||||
|
579 | for top, bottom in pairs: | |||
|
580 | n, l, i = top, [], 0 | |||
|
581 | f = 1 | |||
|
582 | ||||
|
583 | while n != bottom: | |||
|
584 | p = self.changelog.parents(n)[0] | |||
|
585 | if i == f: | |||
|
586 | l.append(n) | |||
|
587 | f = f * 2 | |||
|
588 | n = p | |||
|
589 | i += 1 | |||
|
590 | ||||
|
591 | r.append(l) | |||
|
592 | ||||
|
593 | return r | |||
|
594 | ||||
|
595 | def newer(self, nodes): | |||
|
596 | m = {} | |||
|
597 | nl = [] | |||
|
598 | cl = self.changelog | |||
|
599 | t = l = cl.count() | |||
|
600 | for n in nodes: | |||
|
601 | l = min(l, cl.rev(n)) | |||
|
602 | for p in cl.parents(n): | |||
|
603 | m[p] = 1 | |||
567 |
|
604 | |||
568 | return nodes |
|
605 | for i in xrange(l, t): | |
|
606 | n = cl.node(i) | |||
|
607 | for p in cl.parents(n): | |||
|
608 | if p in m and n not in m: | |||
|
609 | m[n] = 1 | |||
|
610 | nl.append(n) | |||
|
611 | ||||
|
612 | return nl | |||
|
613 | ||||
|
614 | def getchangegroup(self, remote): | |||
|
615 | tip = remote.branches([]) | |||
|
616 | cl = self.changelog | |||
|
617 | unknown = tip | |||
|
618 | search = [] | |||
|
619 | fetch = [] | |||
569 |
|
620 | |||
570 | def changegroup(self, nodes): |
|
621 | if tip[0] == self.changelog.tip(): | |
|
622 | return "" | |||
|
623 | ||||
|
624 | while unknown: | |||
|
625 | n = unknown.pop(0) | |||
|
626 | if n == nullid: break | |||
|
627 | if n[1] and cl.nodemap.has_key(n[1]): # do we know the base? | |||
|
628 | search.append(n) # schedule branch range for scanning | |||
|
629 | else: | |||
|
630 | for b in remote.branches([n[2], n[3]]): | |||
|
631 | if cl.nodemap.has_key(b[0]): | |||
|
632 | fetch.append(n[1]) # earliest unknown | |||
|
633 | else: | |||
|
634 | unknown.append(b) | |||
|
635 | ||||
|
636 | while search: | |||
|
637 | n = search.pop(0) | |||
|
638 | l = remote.between([(n[0], n[1])])[0] | |||
|
639 | p = n[0] | |||
|
640 | f = 1 | |||
|
641 | for i in l + [n[1]]: | |||
|
642 | if self.changelog.nodemap.has_key(i): | |||
|
643 | if f == 1: | |||
|
644 | fetch.append(p) | |||
|
645 | else: | |||
|
646 | search.append((p, i)) | |||
|
647 | p, f = i, f * 2 | |||
|
648 | ||||
|
649 | return remote.changegroup(fetch) | |||
|
650 | ||||
|
651 | def changegroup(self, basenodes): | |||
|
652 | nodes = self.newer(basenodes) | |||
|
653 | ||||
571 | # construct the link map |
|
654 | # construct the link map | |
572 | linkmap = {} |
|
655 | linkmap = {} | |
573 | for n in nodes: |
|
656 | for n in nodes: | |
@@ -597,10 +680,9 b' class repository:' | |||||
597 | l = struct.pack(">l", len(f)) |
|
680 | l = struct.pack(">l", len(f)) | |
598 | cg += [l, f, g] |
|
681 | cg += [l, f, g] | |
599 |
|
682 | |||
600 |
return |
|
683 | return "".join(cg) | |
601 |
|
684 | |||
602 | def addchangegroup(self, data): |
|
685 | def addchangegroup(self, data): | |
603 | data = decompress(data) |
|
|||
604 | def getlen(data, pos): |
|
686 | def getlen(data, pos): | |
605 | return struct.unpack(">l", data[pos:pos + 4])[0] |
|
687 | return struct.unpack(">l", data[pos:pos + 4])[0] | |
606 |
|
688 |
General Comments 0
You need to be logged in to leave comments.
Login now