[PATCH] bookmarks: show also bookmarks really changed on remote side
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Thu Aug 9 15:04:46 UTC 2012
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1344523472 -32400
# Node ID 680f79fe12910de0ce987cb0fc94bf66257f5d40
# Parent b131e24e2984a610d77e124dd3f58b2b5eda6d1a
bookmarks: show also bookmarks really changed on remote side
Before this patch, "hg incoming"/"hg outgoing" show only bookmarks
newly added on remote side as "changed" bookmarks, so users can't know
whether "hg push"/"hg pull" cause divergence or overwriting of
specific bookmark or not before execution of them.
This patch compares not only sets of available bookmark names on both
repositories, but also revisions pointed by each bookmarks.
Comparison result is shown with difference type of each different
bookmarks like below:
X 9b140be10808 (changed)
Y 4efff6d98829 (changed)
Z 0d2164f0ce0d (added)
diff -r b131e24e2984 -r 680f79fe1291 mercurial/bookmarks.py
--- a/mercurial/bookmarks.py Mon Aug 06 12:07:21 2012 -0500
+++ b/mercurial/bookmarks.py Thu Aug 09 23:44:32 2012 +0900
@@ -243,10 +243,19 @@
lmarks = repo.listkeys('bookmarks')
rmarks = remote.listkeys('bookmarks')
- diff = sorted(set(rmarks) - set(lmarks))
- for k in diff:
+ lmarkset = set(lmarks)
+ rmarkset = set(rmarks)
+ diff = rmarkset - lmarkset
+ for k in rmarkset & lmarkset:
+ if lmarks[k] != rmarks[k]:
+ diff.add(k)
+ for k in sorted(diff):
mark = ui.debugflag and rmarks[k] or rmarks[k][:12]
- ui.write(" %-25s %s\n" % (k, mark))
+ if k in lmarks:
+ kind = _("(changed)")
+ else:
+ kind = _("(added)")
+ ui.write(" %-25s %s %s\n" % (k, mark, kind))
if len(diff) <= 0:
ui.status(_("no changed bookmarks found\n"))
diff -r b131e24e2984 -r 680f79fe1291 tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t Mon Aug 06 12:07:21 2012 -0500
+++ b/tests/test-bookmarks-pushpull.t Thu Aug 09 23:44:32 2012 +0900
@@ -223,8 +223,8 @@
$ hg out -B http://localhost:$HGPORT/
comparing with http://localhost:$HGPORT/
searching for changed bookmarks
- no changed bookmarks found
- [1]
+ X 0d2164f0ce0d (changed)
+ Y f6fc62dde3c0 (changed)
$ hg push -B Z http://localhost:$HGPORT/
pushing to http://localhost:$HGPORT/
searching for changes
@@ -235,9 +235,11 @@
$ hg in -B http://localhost:$HGPORT/
comparing with http://localhost:$HGPORT/
searching for changed bookmarks
- Z 0d2164f0ce0d
- foo 000000000000
- foobar 9b140be10808
+ X 9b140be10808 (changed)
+ Y 4efff6d98829 (changed)
+ Z 0d2164f0ce0d (added)
+ foo 000000000000 (added)
+ foobar 9b140be10808 (added)
$ hg pull -B Z http://localhost:$HGPORT/
pulling from http://localhost:$HGPORT/
no changes found
@@ -296,3 +298,111 @@
exporting bookmark add-foo
$ cd ..
+
+Test to show result of bookmarks comparision with kind of difference:
+this also tests to show not only added bookmarks but also changed
+bookmarks.
+
+ $ mkdir bookmarkdiff
+ $ cd bookmarkdiff
+
+ $ hg init remote
+ $ echo a > remote/a
+ $ hg -R remote commit -Am '#0'
+ adding a
+ $ echo b > remote/b
+ $ hg -R remote commit -Am '#1'
+ adding b
+ $ hg -R remote bookmark -r 0 BBB
+ $ hg -R remote bookmark -r 0 DDD
+ $ hg -R remote bookmark -r 0 FFF
+ $ hg -R remote bookmarks
+ BBB 0:bf5e395ced2c
+ DDD 0:bf5e395ced2c
+ FFF 0:bf5e395ced2c
+
+ $ hg clone remote local
+ updating to branch default
+ 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg -R local bookmarks
+ BBB 0:bf5e395ced2c
+ DDD 0:bf5e395ced2c
+ FFF 0:bf5e395ced2c
+
+ $ hg -R remote bookmark -r 1 AAA
+ $ hg -R remote bookmark -r 1 CCC
+ $ hg -R remote bookmark -r 1 EEE
+ $ hg -R remote bookmarks
+ AAA 1:669c32322c92
+ BBB 0:bf5e395ced2c
+ CCC 1:669c32322c92
+ DDD 0:bf5e395ced2c
+ * EEE 1:669c32322c92
+ FFF 0:bf5e395ced2c
+ $ hg -R local bookmarks
+ BBB 0:bf5e395ced2c
+ DDD 0:bf5e395ced2c
+ FFF 0:bf5e395ced2c
+ $ hg -R local incoming -B remote
+ comparing with remote
+ searching for changed bookmarks
+ AAA 669c32322c92 (added)
+ CCC 669c32322c92 (added)
+ EEE 669c32322c92 (added)
+ $ hg -R local outgoing -B remote
+ comparing with remote
+ searching for changed bookmarks
+ no changed bookmarks found
+ [1]
+ $ hg -R remote incoming -B local
+ comparing with local
+ searching for changed bookmarks
+ no changed bookmarks found
+ [1]
+ $ hg -R remote outgoing -B local
+ comparing with local
+ searching for changed bookmarks
+ AAA 669c32322c92 (added)
+ CCC 669c32322c92 (added)
+ EEE 669c32322c92 (added)
+
+ $ hg -R remote bookmark -r 1 -f DDD
+ $ hg -R remote bookmarks
+ AAA 1:669c32322c92
+ BBB 0:bf5e395ced2c
+ CCC 1:669c32322c92
+ * DDD 1:669c32322c92
+ EEE 1:669c32322c92
+ FFF 0:bf5e395ced2c
+ $ hg -R local bookmark -r 0 -f AAA
+ $ hg -R local bookmarks
+ AAA 0:bf5e395ced2c
+ BBB 0:bf5e395ced2c
+ DDD 0:bf5e395ced2c
+ FFF 0:bf5e395ced2c
+ $ hg -R local incoming -B remote
+ comparing with remote
+ searching for changed bookmarks
+ AAA 669c32322c92 (changed)
+ CCC 669c32322c92 (added)
+ DDD 669c32322c92 (changed)
+ EEE 669c32322c92 (added)
+ $ hg -R local outgoing -B remote
+ comparing with remote
+ searching for changed bookmarks
+ AAA bf5e395ced2c (changed)
+ DDD bf5e395ced2c (changed)
+ $ hg -R remote incoming -B local
+ comparing with local
+ searching for changed bookmarks
+ AAA bf5e395ced2c (changed)
+ DDD bf5e395ced2c (changed)
+ $ hg -R remote outgoing -B local
+ comparing with local
+ searching for changed bookmarks
+ AAA 669c32322c92 (changed)
+ CCC 669c32322c92 (added)
+ DDD 669c32322c92 (changed)
+ EEE 669c32322c92 (added)
+
+ $ cd ..
diff -r b131e24e2984 -r 680f79fe1291 tests/test-ssh.t
--- a/tests/test-ssh.t Mon Aug 06 12:07:21 2012 -0500
+++ b/tests/test-ssh.t Thu Aug 09 23:44:32 2012 +0900
@@ -171,7 +171,7 @@
$ hg out -B
comparing with ssh://user@dummy/remote
searching for changed bookmarks
- foo 1160648e36ce
+ foo 1160648e36ce (added)
$ hg push -B foo
pushing to ssh://user@dummy/remote
searching for changes
@@ -191,7 +191,7 @@
$ hg in -B
comparing with ssh://user@dummy/remote
searching for changed bookmarks
- foo a28a9d1a809c
+ foo a28a9d1a809c (added)
$ hg book -f -r 0 foo
$ hg pull -B foo
pulling from ssh://user@dummy/remote
More information about the Mercurial-devel
mailing list