# HG changeset patch # User FUJIWARA Katsunori # Date 2015-03-19 14:36:05 # Node ID d0ea2028e8e668a459bbfdf0a49d68e3f6a20d8e # Parent 9e03602cd2d8b98e63344c0d9149d828caa93382 bookmarks: add incoming() to replace diff() for incoming bookmarks This replacement makes enhancement of "show incoming bookmarks" easy, because "compare()" can detect more detailed difference of bookmarks between two repositories. diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -442,6 +442,34 @@ def updatefromremote(ui, repo, remotemar writer(msg) localmarks.recordchange(tr) +def incoming(ui, repo, other): + '''Show bookmarks incoming from other to repo + ''' + ui.status(_("searching for changed bookmarks\n")) + + r = compare(repo, other.listkeys('bookmarks'), repo._bookmarks, + dsthex=hex) + addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r + + incomings = [] + if ui.debugflag: + getid = lambda id: id + else: + getid = lambda id: id[:12] + def add(b, id): + incomings.append(" %-25s %s\n" % (b, getid(id))) + for b, scid, dcid in addsrc: + add(b, scid) + + if not incomings: + ui.status(_("no changed bookmarks found\n")) + return 1 + + for s in sorted(incomings): + ui.write(s) + + return 0 + def diff(ui, dst, src): ui.status(_("searching for changed bookmarks\n")) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4302,7 +4302,7 @@ def incoming(ui, repo, source="default", ui.warn(_("remote doesn't support bookmarks\n")) return 0 ui.status(_('comparing with %s\n') % util.hidepassword(source)) - return bookmarks.diff(ui, repo, other) + return bookmarks.incoming(ui, repo, other) repo._subtoppath = ui.expandpath(source) try: