mercurial/hg.py
changeset 148 c32286d0a665
parent 146 4a828422247d
child 149 8cd45e152c83
equal deleted inserted replaced
147:b6d8ed7aeba0 148:c32286d0a665
   507                       (short(tip[0]), short(tip[1])))
   507                       (short(tip[0]), short(tip[1])))
   508         m = self.changelog.nodemap
   508         m = self.changelog.nodemap
   509         unknown = [tip]
   509         unknown = [tip]
   510         search = []
   510         search = []
   511         fetch = []
   511         fetch = []
       
   512         seen = {}
       
   513         seenbranch = {}
   512 
   514 
   513         if tip[0] in m:
   515         if tip[0] in m:
   514             self.ui.note("nothing to do!\n")
   516             self.ui.note("nothing to do!\n")
   515             return None
   517             return None
   516 
   518 
   517         while unknown:
   519         while unknown:
   518             n = unknown.pop(0)
   520             n = unknown.pop(0)
       
   521             seen[n[0]] = 1
       
   522             
       
   523             self.ui.debug("examining %s:%s\n" % (short(n[0]), short(n[1])))
   519             if n == nullid: break
   524             if n == nullid: break
       
   525             if n in seenbranch:
       
   526                 self.ui.debug("branch already found\n")
       
   527                 continue
   520             if n[1] and n[1] in m: # do we know the base?
   528             if n[1] and n[1] in m: # do we know the base?
   521                 self.ui.debug("found incomplete branch %s\n" % short(n[1]))
   529                 self.ui.debug("found incomplete branch %s:%s\n"
       
   530                               % (short(n[0]), short(n[1])))
   522                 search.append(n) # schedule branch range for scanning
   531                 search.append(n) # schedule branch range for scanning
       
   532                 seenbranch[n] = 1
   523             else:
   533             else:
   524                 if n[2] in m and n[3] in m:
   534                 if n[2] in m and n[3] in m:
   525                     if n[1] not in fetch:
   535                     if n[1] not in fetch:
   526                         self.ui.debug("found new changeset %s\n" %
   536                         self.ui.debug("found new changeset %s\n" %
   527                                       short(n[1]))
   537                                       short(n[1]))
   528                         fetch.append(n[1]) # earliest unknown
   538                         fetch.append(n[1]) # earliest unknown
   529                         continue
   539                         continue
   530                 for b in remote.branches([n[2], n[3]]):
   540 
   531                     if b[0] not in m:
   541                 r = []
   532                         unknown.append(b)
   542                 for a in n[2:4]:
       
   543                     if a not in seen: r.append(a)
       
   544                     
       
   545                 if r:
       
   546                     self.ui.debug("requesting %s\n" %
       
   547                                 " ".join(map(short, r)))
       
   548                     for b in remote.branches(r):
       
   549                         self.ui.debug("received %s:%s\n" %
       
   550                                       (short(b[0]), short(b[1])))
       
   551                         if b[0] not in m and b[0] not in seen:
       
   552                             unknown.append(b)
   533   
   553   
   534         while search:
   554         while search:
   535             n = search.pop(0)
   555             n = search.pop(0)
   536             l = remote.between([(n[0], n[1])])[0]
   556             l = remote.between([(n[0], n[1])])[0]
   537             p = n[0]
   557             p = n[0]
   781         return urllib.urlopen(cu)
   801         return urllib.urlopen(cu)
   782 
   802 
   783     def branches(self, nodes):
   803     def branches(self, nodes):
   784         n = " ".join(map(hex, nodes))
   804         n = " ".join(map(hex, nodes))
   785         d = self.do_cmd("branches", nodes=n).read()
   805         d = self.do_cmd("branches", nodes=n).read()
   786         br = [ map(bin, b.split(" ")) for b in d.splitlines() ]
   806         br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ]
   787         return br
   807         return br
   788 
   808 
   789     def between(self, pairs):
   809     def between(self, pairs):
   790         n = "\n".join(["-".join(map(hex, p)) for p in pairs])
   810         n = "\n".join(["-".join(map(hex, p)) for p in pairs])
   791         d = self.do_cmd("between", pairs=n).read()
   811         d = self.do_cmd("between", pairs=n).read()