comparison mercurial/bookmarks.py @ 24400:03c84c966ef5

bookmarks: rewrite comparing bookmarks in commands.summary() by compare() This patch adds utility function "summary()", to replace comparing bookmarks in "commands.summary()". This replacement finishes centralizing the logic to compare bookmarks into "bookmarks.compare()". This patch also adds test to check summary output with incoming/outgoing bookmarks, because "hg summary --remote" is not tested yet on the repository with incoming/outgoing bookmarks. This test uses "(glob)" to ignore summary about incoming/outgoing changesets.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Thu, 19 Mar 2015 23:36:06 +0900
parents 3993eb47ea49
children 3d7c512b258d
comparison
equal deleted inserted replaced
24399:3993eb47ea49 24400:03c84c966ef5
496 for s in sorted(outgoings): 496 for s in sorted(outgoings):
497 ui.write(s) 497 ui.write(s)
498 498
499 return 0 499 return 0
500 500
501 def summary(repo, other):
502 '''Compare bookmarks between repo and other for "hg summary" output
503
504 This returns "(# of incoming, # of outgoing)" tuple.
505 '''
506 r = compare(repo, other.listkeys('bookmarks'), repo._bookmarks,
507 dsthex=hex)
508 addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
509 return (len(addsrc), len(adddst))
510
501 def validdest(repo, old, new): 511 def validdest(repo, old, new):
502 """Is the new bookmark destination a valid update from the old one""" 512 """Is the new bookmark destination a valid update from the old one"""
503 repo = repo.unfiltered() 513 repo = repo.unfiltered()
504 if old == new: 514 if old == new:
505 # Old == new -> nothing to update. 515 # Old == new -> nothing to update.