comparison mercurial/bookmarks.py @ 20027:4b06b2a445a1

bookmarks: rewrite pushing bookmarks in "localrepository.push()" by "compare()" This patch adds "updateremote()", which uses "compare()" to compare bookmarks between the local and the remote repositories, to replace pushing local bookmarks in "localrepository.push()".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 08 Nov 2013 12:45:52 +0900
parents 84905561ad41
children 2880b45636ca
comparison
equal deleted inserted replaced
20026:84905561ad41 20027:4b06b2a445a1
362 for b, node, writer, msg in sorted(changed): 362 for b, node, writer, msg in sorted(changed):
363 localmarks[b] = node 363 localmarks[b] = node
364 writer(msg) 364 writer(msg)
365 localmarks.write() 365 localmarks.write()
366 366
367 def updateremote(ui, repo, remote, revs):
368 ui.debug("checking for updated bookmarks\n")
369 revnums = map(repo.changelog.rev, revs or [])
370 ancestors = [a for a in repo.changelog.ancestors(revnums, inclusive=True)]
371 (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
372 ) = compare(repo, repo._bookmarks, remote.listkeys('bookmarks'),
373 srchex=hex)
374
375 for b, scid, dcid in advsrc:
376 if ancestors and repo[scid].rev() not in ancestors:
377 continue
378 if remote.pushkey('bookmarks', b, dcid, scid):
379 ui.status(_("updating bookmark %s\n") % b)
380 else:
381 ui.warn(_('updating bookmark %s failed!\n') % b)
382
367 def pushtoremote(ui, repo, remote, targets): 383 def pushtoremote(ui, repo, remote, targets):
368 (addsrc, adddst, advsrc, advdst, diverge, differ, invalid 384 (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
369 ) = compare(repo, repo._bookmarks, remote.listkeys('bookmarks'), 385 ) = compare(repo, repo._bookmarks, remote.listkeys('bookmarks'),
370 srchex=hex, targets=targets) 386 srchex=hex, targets=targets)
371 if invalid: 387 if invalid: