mercurial/bookmarks.py
branchstable
changeset 19067 292cd385856d
parent 18984 efef056b1ae9
child 19110 741d94aa92e4
equal deleted inserted replaced
18875:e9662c24f946 19067:292cd385856d
   219         marks.write()
   219         marks.write()
   220         return True
   220         return True
   221     finally:
   221     finally:
   222         w.release()
   222         w.release()
   223 
   223 
   224 def updatefromremote(ui, repo, remote, path):
   224 def updatefromremote(ui, repo, remotemarks, path):
   225     ui.debug("checking for updated bookmarks\n")
   225     ui.debug("checking for updated bookmarks\n")
   226     rb = remote.listkeys('bookmarks')
       
   227     changed = False
   226     changed = False
   228     localmarks = repo._bookmarks
   227     localmarks = repo._bookmarks
   229     for k in sorted(rb):
   228     for k in sorted(remotemarks):
   230         if k in localmarks:
   229         if k in localmarks:
   231             nr, nl = rb[k], localmarks[k]
   230             nr, nl = remotemarks[k], localmarks[k]
   232             if nr in repo:
   231             if nr in repo:
   233                 cr = repo[nr]
   232                 cr = repo[nr]
   234                 cl = repo[nl]
   233                 cl = repo[nl]
   235                 if cl.rev() >= cr.rev():
   234                 if cl.rev() >= cr.rev():
   236                     continue
   235                     continue
   255                             n = '%s@%s' % (kd, p)
   254                             n = '%s@%s' % (kd, p)
   256 
   255 
   257                     localmarks[n] = cr.node()
   256                     localmarks[n] = cr.node()
   258                     changed = True
   257                     changed = True
   259                     ui.warn(_("divergent bookmark %s stored as %s\n") % (k, n))
   258                     ui.warn(_("divergent bookmark %s stored as %s\n") % (k, n))
   260         elif rb[k] in repo:
   259         elif remotemarks[k] in repo:
   261             # add remote bookmarks for changes we already have
   260             # add remote bookmarks for changes we already have
   262             localmarks[k] = repo[rb[k]].node()
   261             localmarks[k] = repo[remotemarks[k]].node()
   263             changed = True
   262             changed = True
   264             ui.status(_("adding remote bookmark %s\n") % k)
   263             ui.status(_("adding remote bookmark %s\n") % k)
   265 
   264 
   266     if changed:
   265     if changed:
   267         localmarks.write()
   266         localmarks.write()
   291     elif not old:
   290     elif not old:
   292         # old is nullrev, anything is valid.
   291         # old is nullrev, anything is valid.
   293         # (new != nullrev has been excluded by the previous check)
   292         # (new != nullrev has been excluded by the previous check)
   294         return True
   293         return True
   295     elif repo.obsstore:
   294     elif repo.obsstore:
   296         # We only need this complicated logic if there is obsolescence
   295         return new.node() in obsolete.foreground(repo, [old.node()])
   297         # XXX will probably deserve an optimised revset.
       
   298         nm = repo.changelog.nodemap
       
   299         validdests = set([old])
       
   300         plen = -1
       
   301         # compute the whole set of successors or descendants
       
   302         while len(validdests) != plen:
       
   303             plen = len(validdests)
       
   304             succs = set(c.node() for c in validdests)
       
   305             mutable = [c.node() for c in validdests if c.mutable()]
       
   306             succs.update(obsolete.allsuccessors(repo.obsstore, mutable))
       
   307             known = (n for n in succs if n in nm)
       
   308             validdests = set(repo.set('%ln::', known))
       
   309         return new in validdests
       
   310     else:
   296     else:
       
   297         # still an independant clause as it is lazyer (and therefore faster)
   311         return old.descendant(new)
   298         return old.descendant(new)