diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -791,7 +791,7 @@ repo._bookmarks.applychanges(repo, tr, changes) -def incoming(ui, repo, peer): +def incoming(ui, repo, peer, mode=None): """Show bookmarks incoming from other to repo""" ui.status(_(b"searching for changed bookmarks\n")) @@ -805,9 +805,6 @@ ).result() ) - r = comparebookmarks(repo, remotemarks, repo._bookmarks) - addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r - incomings = [] if ui.debugflag: getid = lambda id: id @@ -823,18 +820,36 @@ def add(b, id, st): incomings.append(b" %-25s %s\n" % (b, getid(id))) - for b, scid, dcid in addsrc: - # i18n: "added" refers to a bookmark - add(b, hex(scid), _(b'added')) - for b, scid, dcid in advsrc: - # i18n: "advanced" refers to a bookmark - add(b, hex(scid), _(b'advanced')) - for b, scid, dcid in diverge: - # i18n: "diverged" refers to a bookmark - add(b, hex(scid), _(b'diverged')) - for b, scid, dcid in differ: - # i18n: "changed" refers to a bookmark - add(b, hex(scid), _(b'changed')) + if mode == b'mirror': + localmarks = repo._bookmarks + allmarks = set(remotemarks.keys()) | set(localmarks.keys()) + for b in sorted(allmarks): + loc = localmarks.get(b) + rem = remotemarks.get(b) + if loc == rem: + continue + elif loc is None: + add(b, hex(rem), _(b'added')) + elif rem is None: + add(b, hex(repo.nullid), _(b'removed')) + else: + add(b, hex(rem), _(b'changed')) + else: + r = comparebookmarks(repo, remotemarks, repo._bookmarks) + addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r + + for b, scid, dcid in addsrc: + # i18n: "added" refers to a bookmark + add(b, hex(scid), _(b'added')) + for b, scid, dcid in advsrc: + # i18n: "advanced" refers to a bookmark + add(b, hex(scid), _(b'advanced')) + for b, scid, dcid in diverge: + # i18n: "diverged" refers to a bookmark + add(b, hex(scid), _(b'diverged')) + for b, scid, dcid in differ: + # i18n: "changed" refers to a bookmark + add(b, hex(scid), _(b'changed')) if not incomings: ui.status(_(b"no changed bookmarks found\n")) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4360,7 +4360,9 @@ ui.status( _(b'comparing with %s\n') % urlutil.hidepassword(source) ) - return bookmarks.incoming(ui, repo, other) + return bookmarks.incoming( + ui, repo, other, mode=path.bookmarks_mode + ) finally: other.close() diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t --- a/tests/test-bookmarks-pushpull.t +++ b/tests/test-bookmarks-pushpull.t @@ -503,6 +503,26 @@ * foobar 1:9b140be10808 $ cp .hg/bookmarks .hg/bookmarks.bak $ hg book -d X + $ hg incoming --bookmark -v ../a + comparing with ../a + searching for changed bookmarks + @ 0d2164f0ce0d diverged + X 0d2164f0ce0d added + $ hg incoming --bookmark -v ../a --config 'paths.*:bookmarks.mode=babar' + (paths.*:bookmarks.mode has unknown value: "babar") + comparing with ../a + searching for changed bookmarks + @ 0d2164f0ce0d diverged + X 0d2164f0ce0d added + $ hg incoming --bookmark -v ../a --config 'paths.*:bookmarks.mode=mirror' + comparing with ../a + searching for changed bookmarks + @ 0d2164f0ce0d changed + @foo 000000000000 removed + X 0d2164f0ce0d added + X@foo 000000000000 removed + foo 000000000000 removed + foobar 000000000000 removed $ hg pull ../a --config 'paths.*:bookmarks.mode=mirror' pulling from ../a searching for changes