comparison mercurial/bookmarks.py @ 13646:31eac42d9123

bookmarks: separate bookmarks update code from localrepo's pull. We explicitly want to update bookmarks from a remote. This will avoid duplicate calls to listkeys if we clone (which calls pull) and keep bookmark related code together.
author David Soria Parra <dsp@php.net>
date Mon, 14 Mar 2011 00:10:43 +0100
parents 71a96f6c205d
children c0c599709846
comparison
equal deleted inserted replaced
13645:3786b810ea75 13646:31eac42d9123
161 write(repo) 161 write(repo)
162 return True 162 return True
163 finally: 163 finally:
164 w.release() 164 w.release()
165 165
166 def updatefromremote(ui, repo, remote):
167 ui.debug("checking for updated bookmarks\n")
168 rb = remote.listkeys('bookmarks')
169 changed = False
170 for k in rb.keys():
171 if k in repo._bookmarks:
172 nr, nl = rb[k], repo._bookmarks[k]
173 if nr in repo:
174 cr = repo[nr]
175 cl = repo[nl]
176 if cl.rev() >= cr.rev():
177 continue
178 if cr in cl.descendants():
179 repo._bookmarks[k] = cr.node()
180 changed = True
181 ui.status(_("updating bookmark %s\n") % k)
182 else:
183 ui.warn(_("not updating divergent"
184 " bookmark %s\n") % k)
185 if changed:
186 write(repo)
187
166 def diff(ui, repo, remote): 188 def diff(ui, repo, remote):
167 ui.status(_("searching for changed bookmarks\n")) 189 ui.status(_("searching for changed bookmarks\n"))
168 190
169 lmarks = repo.listkeys('bookmarks') 191 lmarks = repo.listkeys('bookmarks')
170 rmarks = remote.listkeys('bookmarks') 192 rmarks = remote.listkeys('bookmarks')