Show More
@@ -232,7 +232,7 b' def opener(base):' | |||||
232 |
|
232 | |||
233 | return o |
|
233 | return o | |
234 |
|
234 | |||
235 | class repository: |
|
235 | class localrepository: | |
236 | def __init__(self, ui, path=None, create=0): |
|
236 | def __init__(self, ui, path=None, create=0): | |
237 | self.remote = 0 |
|
237 | self.remote = 0 | |
238 | if path and path[:7] == "http://": |
|
238 | if path and path[:7] == "http://": | |
@@ -612,15 +612,15 b' class repository:' | |||||
612 | return nl |
|
612 | return nl | |
613 |
|
613 | |||
614 | def getchangegroup(self, remote): |
|
614 | def getchangegroup(self, remote): | |
615 | tip = remote.branches([]) |
|
615 | tip = remote.branches([])[0] | |
616 | cl = self.changelog |
|
616 | cl = self.changelog | |
617 | unknown = tip |
|
617 | unknown = [tip] | |
618 | search = [] |
|
618 | search = [] | |
619 | fetch = [] |
|
619 | fetch = [] | |
620 |
|
620 | |||
621 | if tip[0] == self.changelog.tip(): |
|
621 | if tip[0] == self.changelog.tip(): | |
622 |
return |
|
622 | return None | |
623 |
|
623 | |||
624 | while unknown: |
|
624 | while unknown: | |
625 | n = unknown.pop(0) |
|
625 | n = unknown.pop(0) | |
626 | if n == nullid: break |
|
626 | if n == nullid: break | |
@@ -640,7 +640,7 b' class repository:' | |||||
640 | f = 1 |
|
640 | f = 1 | |
641 | for i in l + [n[1]]: |
|
641 | for i in l + [n[1]]: | |
642 | if self.changelog.nodemap.has_key(i): |
|
642 | if self.changelog.nodemap.has_key(i): | |
643 |
if f |
|
643 | if f <= 4: | |
644 | fetch.append(p) |
|
644 | fetch.append(p) | |
645 | else: |
|
645 | else: | |
646 | search.append((p, i)) |
|
646 | search.append((p, i)) | |
@@ -666,25 +666,22 b' class repository:' | |||||
666 | changed.sort() |
|
666 | changed.sort() | |
667 |
|
667 | |||
668 | # the changegroup is changesets + manifests + all file revs |
|
668 | # the changegroup is changesets + manifests + all file revs | |
669 | cg = [] |
|
|||
670 | revs = [ self.changelog.rev(n) for n in nodes ] |
|
669 | revs = [ self.changelog.rev(n) for n in nodes ] | |
671 |
|
670 | |||
672 |
|
|
671 | yield self.changelog.group(linkmap) | |
673 | cg.append(g) |
|
672 | yield self.manifest.group(linkmap) | |
674 | g = self.manifest.group(linkmap) |
|
|||
675 | cg.append(g) |
|
|||
676 |
|
673 | |||
677 | for f in changed: |
|
674 | for f in changed: | |
678 | g = self.file(f).group(linkmap) |
|
675 | g = self.file(f).group(linkmap) | |
679 | if not g: raise "couldn't find change to %s" % f |
|
676 | if not g: raise "couldn't find change to %s" % f | |
680 | l = struct.pack(">l", len(f)) |
|
677 | l = struct.pack(">l", len(f)) | |
681 |
|
|
678 | yield "".join([l, f, g]) | |
682 |
|
||||
683 | return "".join(cg) |
|
|||
684 |
|
679 | |||
685 | def addchangegroup(self, data): |
|
680 | def addchangegroup(self, data): | |
686 | def getlen(data, pos): |
|
681 | def getlen(data, pos): | |
687 | return struct.unpack(">l", data[pos:pos + 4])[0] |
|
682 | return struct.unpack(">l", data[pos:pos + 4])[0] | |
|
683 | ||||
|
684 | if not data: return | |||
688 |
|
685 | |||
689 | tr = self.transaction() |
|
686 | tr = self.transaction() | |
690 | simple = True |
|
687 | simple = True | |
@@ -787,6 +784,41 b' class repository:' | |||||
787 |
|
784 | |||
788 | tr.close() |
|
785 | tr.close() | |
789 |
|
786 | |||
|
787 | class remoterepository: | |||
|
788 | def __init__(self, ui, path): | |||
|
789 | self.url = path.replace("hg://", "http://", 1) | |||
|
790 | self.ui = ui | |||
|
791 | ||||
|
792 | def do_cmd(self, cmd, **args): | |||
|
793 | q = {"cmd": cmd} | |||
|
794 | q.update(args) | |||
|
795 | qs = urllib.urlencode(q) | |||
|
796 | cu = "%s?%s" % (self.url, qs) | |||
|
797 | return urllib.urlopen(cu).read() | |||
|
798 | ||||
|
799 | def branches(self, nodes): | |||
|
800 | n = " ".join(map(hex, nodes)) | |||
|
801 | d = self.do_cmd("branches", nodes=n) | |||
|
802 | br = [ map(bin, b.split(" ")) for b in d.splitlines() ] | |||
|
803 | return br | |||
|
804 | ||||
|
805 | def between(self, pairs): | |||
|
806 | n = "\n".join(["-".join(map(hex, p)) for p in pairs]) | |||
|
807 | d = self.do_cmd("between", pairs=n) | |||
|
808 | p = [ map(bin, l.split(" ")) for l in d.splitlines() ] | |||
|
809 | return p | |||
|
810 | ||||
|
811 | def changegroup(self, nodes): | |||
|
812 | n = " ".join(map(hex, nodes)) | |||
|
813 | d = self.do_cmd("changegroup", roots=n) | |||
|
814 | return zlib.decompress(d) | |||
|
815 | ||||
|
816 | def repository(ui, path=None, create=0): | |||
|
817 | if path and path[:5] == "hg://": | |||
|
818 | return remoterepository(ui, path) | |||
|
819 | else: | |||
|
820 | return localrepository(ui, path, create) | |||
|
821 | ||||
790 | class ui: |
|
822 | class ui: | |
791 | def __init__(self, verbose=False, debug=False): |
|
823 | def __init__(self, verbose=False, debug=False): | |
792 | self.verbose = verbose |
|
824 | self.verbose = verbose |
General Comments 0
You need to be logged in to leave comments.
Login now