##// END OF EJS Templates
bookmarks: add an option to make pull mirror remote bookmarks...
Valentin Gatien-Baron -
r48847:62f325f9 default
parent child Browse files
Show More
@@ -680,8 +680,25 b' def binarydecode(repo, stream):'
680 680 return books
681 681
682 682
683 def updatefromremote(ui, repo, remotemarks, path, trfunc, explicit=()):
684 ui.debug(b"checking for updated bookmarks\n")
683 def mirroring_remote(ui, repo, remotemarks):
684 """computes the bookmark changes that set the local bookmarks to
685 remotemarks"""
686 changed = []
687 localmarks = repo._bookmarks
688 for (b, id) in pycompat.iteritems(remotemarks):
689 if id != localmarks.get(b, None) and id in repo:
690 changed.append((b, id, ui.debug, _(b"updating bookmark %s\n") % b))
691 for b in localmarks:
692 if b not in remotemarks:
693 changed.append(
694 (b, None, ui.debug, _(b"removing bookmark %s\n") % b)
695 )
696 return changed
697
698
699 def merging_from_remote(ui, repo, remotemarks, path, explicit=()):
700 """computes the bookmark changes that merge remote bookmarks into the
701 local bookmarks, based on comparebookmarks"""
685 702 localmarks = repo._bookmarks
686 703 (
687 704 addsrc,
@@ -752,6 +769,15 b' def updatefromremote(ui, repo, remotemar'
752 769 _(b"remote bookmark %s points to locally missing %s\n")
753 770 % (b, hex(scid)[:12])
754 771 )
772 return changed
773
774
775 def updatefromremote(ui, repo, remotemarks, path, trfunc, explicit=()):
776 ui.debug(b"checking for updated bookmarks\n")
777 if ui.configbool(b'bookmarks', b'mirror'):
778 changed = mirroring_remote(ui, repo, remotemarks)
779 else:
780 changed = merging_from_remote(ui, repo, remotemarks, path, explicit)
755 781
756 782 if changed:
757 783 tr = trfunc()
@@ -760,7 +786,7 b' def updatefromremote(ui, repo, remotemar'
760 786 for b, node, writer, msg in sorted(changed, key=key):
761 787 changes.append((b, node))
762 788 writer(msg)
763 localmarks.applychanges(repo, tr, changes)
789 repo._bookmarks.applychanges(repo, tr, changes)
764 790
765 791
766 792 def incoming(ui, repo, peer):
@@ -207,6 +207,11 b' coreconfigitem('
207 207 b'pushing',
208 208 default=list,
209 209 )
210 coreconfigitem(
211 b'bookmarks',
212 b'mirror',
213 default=False,
214 )
210 215 # bundle.mainreporoot: internal hack for bundlerepo
211 216 coreconfigitem(
212 217 b'bundle',
@@ -418,6 +418,16 b' Supported arguments:'
418 418 If no suitable authentication entry is found, the user is prompted
419 419 for credentials as usual if required by the remote.
420 420
421 ``bookmarks``
422 -------------
423
424 Controls some aspect of bookmarks.
425
426 ``mirror``
427 When pulling, instead of merging local bookmarks and remote bookmarks,
428 replace local bookmarks by remote bookmarks. This is useful to replicate
429 a repository, or as an optimization. (default: False)
430
421 431 ``cmdserver``
422 432 -------------
423 433
@@ -490,6 +490,30 b' divergent bookmarks'
490 490 Y 0:4e3505fd9583
491 491 Z 1:0d2164f0ce0d
492 492
493 mirroring bookmarks
494
495 $ hg book
496 @ 1:9b140be10808
497 @foo 2:0d2164f0ce0d
498 X 1:9b140be10808
499 X@foo 2:0d2164f0ce0d
500 Y 0:4e3505fd9583
501 Z 2:0d2164f0ce0d
502 foo -1:000000000000
503 * foobar 1:9b140be10808
504 $ cp .hg/bookmarks .hg/bookmarks.bak
505 $ hg book -d X
506 $ hg pull ../a --config bookmarks.mirror=true
507 pulling from ../a
508 searching for changes
509 no changes found
510 $ hg book
511 @ 2:0d2164f0ce0d
512 X 2:0d2164f0ce0d
513 Y 0:4e3505fd9583
514 Z 2:0d2164f0ce0d
515 $ mv .hg/bookmarks.bak .hg/bookmarks
516
493 517 explicit pull should overwrite the local version (issue4439)
494 518
495 519 $ hg update -r X
General Comments 0
You need to be logged in to leave comments. Login now