Patchwork [07,of,15,V4] bookmarks: add "outgoing()" to replace "diff()" for outgoing bookmarks

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 15, 2013, 3:25 p.m.
Message ID <64738e34e68eb49277da.1381850729@juju>
Download mbox | patch
Permalink /patch/2777/
State Superseded
Headers show

Comments

Katsunori FUJIWARA - Oct. 15, 2013, 3:25 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1381849966 -32400
#      Wed Oct 16 00:12:46 2013 +0900
# Node ID 64738e34e68eb49277da5c38254e162423e6a7b0
# Parent  fed21b736c42c16a712660df949917779798d061
bookmarks: add "outgoing()" to replace "diff()" for outgoing bookmarks

This patch adds "outgoing()", which uses "compare()" to compare
bookmarks between the local and the remote repositories, to replace
"diff()" for outgoing bookmarks newly from the local repository.

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -432,6 +432,29 @@ 
 
     return 0
 
+def outgoing(ui, repo, other):
+    ui.status(_("searching for changed bookmarks\n"))
+
+    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
+     ) = compare(repo, repo._bookmarks, other.listkeys('bookmarks'),
+                 srchex=hex)
+
+    outgoings = []
+    def add(b, id):
+        outgoings.append("   %-25s %s\n" %
+                         (b, ui.debugflag and id or id[:12]))
+    for b, scid, dcid in addsrc:
+        add(b, scid)
+
+    if not outgoings:
+        ui.status(_("no changed bookmarks found\n"))
+        return 1
+
+    for s in sorted(outgoings):
+        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
@@ -4338,7 +4338,7 @@ 
             ui.warn(_("remote doesn't support bookmarks\n"))
             return 0
         ui.status(_('comparing with %s\n') % util.hidepassword(dest))
-        return bookmarks.diff(ui, other, repo)
+        return bookmarks.outgoing(ui, repo, other)
 
     repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
     try: