Mercurial > hg
comparison mercurial/bookmarks.py @ 22659:798185707833
pull: merge bookmark updates and imports
We do all the things in one go now, updating existing bookmark, adding new ones,
and overwriting the ones explicitly specified for --bookmark. This impacts the
tests by removing some duplicated or unnecessary output.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sun, 28 Sep 2014 14:07:56 -0700 |
parents | a8f0d8e4c80a |
children | 6bd685d2a2de |
comparison
equal
deleted
inserted
replaced
22658:a8f0d8e4c80a | 22659:798185707833 |
---|---|
356 status = ui.status | 356 status = ui.status |
357 warn = ui.warn | 357 warn = ui.warn |
358 if ui.configbool('ui', 'quietbookmarkmove', False): | 358 if ui.configbool('ui', 'quietbookmarkmove', False): |
359 status = warn = ui.debug | 359 status = warn = ui.debug |
360 | 360 |
361 explicit = set(explicit) | |
361 changed = [] | 362 changed = [] |
362 for b, scid, dcid in addsrc: | 363 for b, scid, dcid in addsrc: |
363 if scid in repo: # add remote bookmarks for changes we already have | 364 if scid in repo: # add remote bookmarks for changes we already have |
364 changed.append((b, bin(scid), status, | 365 changed.append((b, bin(scid), status, |
365 _("adding remote bookmark %s\n") % (b))) | 366 _("adding remote bookmark %s\n") % (b))) |
366 for b, scid, dcid in advsrc: | 367 for b, scid, dcid in advsrc: |
367 changed.append((b, bin(scid), status, | 368 changed.append((b, bin(scid), status, |
368 _("updating bookmark %s\n") % (b))) | 369 _("updating bookmark %s\n") % (b))) |
370 # remove normal movement from explicit set | |
371 explicit.difference_update(d[0] for d in changed) | |
372 | |
369 for b, scid, dcid in diverge: | 373 for b, scid, dcid in diverge: |
370 db = _diverge(ui, b, path, localmarks) | 374 if b in explicit: |
371 changed.append((db, bin(scid), warn, | 375 explicit.discard(b) |
372 _("divergent bookmark %s stored as %s\n") % (b, db))) | 376 changed.append((b, bin(scid), status, |
377 _("importing bookmark %s\n") % (b, b))) | |
378 else: | |
379 db = _diverge(ui, b, path, localmarks) | |
380 changed.append((db, bin(scid), warn, | |
381 _("divergent bookmark %s stored as %s\n") | |
382 % (b, db))) | |
383 for b, scid, dcid in adddst + advdst: | |
384 if b in explicit: | |
385 explicit.discard(b) | |
386 changed.append((b, bin(scid), status, | |
387 _("importing bookmark %s\n") % (b, b))) | |
388 | |
373 if changed: | 389 if changed: |
374 for b, node, writer, msg in sorted(changed): | 390 for b, node, writer, msg in sorted(changed): |
375 localmarks[b] = node | 391 localmarks[b] = node |
376 writer(msg) | 392 writer(msg) |
377 localmarks.write() | 393 localmarks.write() |
378 # update specified bookmarks | |
379 if explicit: | |
380 marks = repo._bookmarks | |
381 for b in explicit: | |
382 # explicit pull overrides local bookmark if any | |
383 repo.ui.status(_("importing bookmark %s\n") % b) | |
384 marks[b] = repo[remotemarks[b]].node() | |
385 marks.write() | |
386 | 394 |
387 def diff(ui, dst, src): | 395 def diff(ui, dst, src): |
388 ui.status(_("searching for changed bookmarks\n")) | 396 ui.status(_("searching for changed bookmarks\n")) |
389 | 397 |
390 smarks = src.listkeys('bookmarks') | 398 smarks = src.listkeys('bookmarks') |