[PATCH evolve-ext:stable V2] evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg
olle.lundberg at gmail.com
Sat Mar 29 18:05:02 CDT 2014
# HG changeset patch
# User Olle Lundberg <geek at nerd.sh>
# Date 1395874725 -3600
# Wed Mar 26 23:58:45 2014 +0100
# Branch stable
# Node ID bb2c0450549caee1165615e893c9909612ed4300
# Parent 37c58378ad6bd3b82905f2aec3a6658a1242d3ee
evolve: active bookmark should move when using prev/next (#37)
This patch adds a new default argument to _bookmarksupdater that
controls whether we move inactive bookmarks for a current node or
not. This change does not break existing usage, but will allow us
to move active bookmarks when we traverse the history with previous
and next.
The #37 references the bitbucket issue for mutable-history, that
can be found here:
https://bitbucket.org/marmoute/mutable-history/issue/37/
diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -786,21 +786,23 @@
except util.Abort:
# Invalidate the previous setparents
repo.dirstate.invalidate()
raise
-def _bookmarksupdater(repo, oldid):
+def _bookmarksupdater(repo, oldid, moveinactive=True):
"""Return a callable update(newid) updating the current bookmark
and bookmarks bound to oldid to newid.
"""
bm = bookmarks.readcurrent(repo)
def updatebookmarks(newid):
dirty = False
if bm:
repo._bookmarks[bm] = newid
dirty = True
- oldbookmarks = repo.nodebookmarks(oldid)
+ oldbookmarks = None
+ if moveinactive:
+ oldbookmarks = repo.nodebookmarks(oldid)
if oldbookmarks:
for b in oldbookmarks:
repo._bookmarks[b] = newid
dirty = True
if dirty:
@@ -1281,11 +1283,14 @@
parents = wparents[0].parents()
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
if len(parents) == 1:
p = parents[0]
+ bmupdate = _bookmarksupdater(repo, wparents[0].node(),
+ moveinactive=False)
hg.update(repo, p.rev())
+ bmupdate(p.node())
displayer.show(p)
return 0
else:
for p in parents:
displayer.show(p)
@@ -1307,11 +1312,14 @@
if not children:
ui.warn(_('no non-obsolete children\n'))
return 1
if len(children) == 1:
c = children[0]
+ bmupdate = _bookmarksupdater(repo, wparents[0].node(),
+ moveinactive=False)
hg.update(repo, c.rev())
+ bmupdate(c.node())
displayer.show(c)
return 0
else:
for c in children:
displayer.show(c)
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookmarks.t
@@ -0,0 +1,48 @@
+ $ cat >> $HGRCPATH <<EOF
+ > [extensions]
+ > hgext.rebase=
+ > hgext.graphlog=
+ > EOF
+ $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext/evolve.py" >> $HGRCPATH
+
+hg prev should move active bookmark
+ $ hg init
+ $ touch a
+ $ hg add a
+ $ hg commit -m 'added a'
+ $ touch b
+ $ hg add b
+ $ hg commit -m 'added b'
+ $ hg bookmark mark
+ $ hg bookmarks
+ * mark 1:6e742c9127b3
+ $ hg prev
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ [0] added a
+ $ hg bookmarks
+ * mark 0:a154386e50d1
+
+hg next should move active bookmark
+ $ hg next
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ [1] added b
+ $ hg bookmarks
+ * mark 1:6e742c9127b3
+
+hg next/prev should not interfere with inactive bookmarks
+ $ touch c
+ $ hg add c
+ $ hg commit -m 'added c'
+ $ hg bookmark -r2 no-move
+ $ hg prev
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ [1] added b
+ $ hg bookmarks
+ * mark 1:6e742c9127b3
+ no-move 2:4e26ef31f919
+ $ hg next
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ [2] added c
+ $ hg bookmarks
+ * mark 2:4e26ef31f919
+ no-move 2:4e26ef31f919
More information about the Mercurial-devel
mailing list