--- a/hgext/evolve.py Fri Feb 17 19:08:36 2012 +0100
+++ b/hgext/evolve.py Fri Feb 17 19:54:42 2012 +0100
@@ -120,29 +120,36 @@
for u in updates:
repo.addobsolete(u.node(), old.node())
repo.addobsolete(new.node(), u.node())
+ oldbookmarks = repo.nodebookmarks(old.node())
+ for book in oldbookmarks:
+ repo._bookmarks[book] = new.node()
+ if oldbookmarks:
+ bookmarks.write(repo)
finally:
wlock.release()
return newid
-def relocate(repo, rev, dest):
+def relocate(repo, orig, dest):
"""rewrite <rev> on dest"""
try:
rebase = extensions.find('rebase')
# dummy state to trick rebase node
- assert repo[rev].p2().rev() == node.nullrev, 'no support yet'
- cmdutil.duplicatecopies(repo, rev, repo[dest].node(),
- repo[rev].p2().node())
- rebase.rebasenode(repo, rev, dest, {node.nullrev: node.nullrev})
- nodenew = rebase.concludenode(repo, rev, dest, node.nullid)
- nodesrc = repo.changelog.node(rev)
+ assert orig.p2().rev() == node.nullrev, 'no support yet'
+ destbookmarks = repo.nodebookmarks(dest.node())
+ cmdutil.duplicatecopies(repo, orig.node(), dest.node())
+ rebase.rebasenode(repo, orig.node(), dest.node(), {node.nullrev: node.nullrev})
+ nodenew = rebase.concludenode(repo, orig.node(), dest.node(), node.nullid)
+ nodesrc = orig.node()
repo.addobsolete(nodenew, nodesrc)
phases.retractboundary(repo, repo[nodesrc].phase(), [nodenew])
oldbookmarks = repo.nodebookmarks(nodesrc)
for book in oldbookmarks:
repo._bookmarks[book] = nodenew
- if oldbookmarks:
+ for book in destbookmarks: # restore bookmark that rebase move
+ repo._bookmarks[book] = dest.node()
+ if oldbookmarks or destbookmarks:
bookmarks.write(repo)
except util.Abort:
# Invalidate the previous setparents
@@ -157,19 +164,21 @@
command = cmdutil.command(cmdtable)
@command('^stabilize',
- [],
+ [
+ ('n', 'dry-run', False, 'Do nothing but printing what should be done')
+ ],
'')
-def stabilize(ui, repo):
- """suggest the next evolution step"""
+def stabilize(ui, repo, **opts):
+ """move changeset out of they unstable state"""
obsolete = extensions.find('obsolete')
- unstable = repo.revs('unstable()')
+ unstable = list(repo.set('unstable()'))
if not unstable:
ui.write_err(_('no unstable changeset\n'))
return 1
- next = unstable[0]
- obs = repo[next].parents()[0]
+ node = unstable[0]
+ obs = node.parents()[0]
if not obs.obsolete():
- obs = next.parents()[1]
+ obs = node.parents()[1]
assert obs.obsolete()
newer = obsolete.newerversion(repo, obs.node())
if len(newer) > 1:
@@ -183,7 +192,22 @@
ui.write_err(_("does not handle splitted parent yet\n"))
return 2
target = targets[0]
- repo.ui.status('hg rebase -Dr %s -d %s\n' % (repo[next], repo[target]))
+ displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
+ target = repo[target]
+ repo.ui.status(_('move:'))
+ displayer.show(node)
+ repo.ui.status(_('atop:'))
+ displayer.show(target)
+ todo= 'hg rebase -Dr %s -d %s\n' % (node, target)
+ if opts['dry_run']:
+ repo.ui.status(todo)
+ else:
+ repo.ui.note(todo)
+ lock = repo.lock()
+ try:
+ relocate(repo, node, target)
+ finally:
+ lock.release()
shorttemplate = '[{rev}] {desc|firstline}\n'
--- a/tests/test-evolve.t Fri Feb 17 19:08:36 2012 +0100
+++ b/tests/test-evolve.t Fri Feb 17 19:54:42 2012 +0100
@@ -199,6 +199,7 @@
0 : base - test
$ hg up feature-A -q
+ $ hg bookmark -i feature-A
$ sed -i'' -e s/Eins/Un/ main-file-1
$ hg amend --note 'french looks better'
@@ -207,22 +208,14 @@
4 feature-B: another feature - test
1 : a nifty feature - test
0 : base - test
- $ hg stabilize
+ $ hg stabilize -n
+ move:[4] another feature
+ atop:[6] a nifty feature
hg rebase -Dr f8111a076f09 -d 23409eba69a0
- $ hg up null -q #prevent feature-A bookmark to move # XXX grml
- $ hg bookmark
- feature-A 6:23409eba69a0
- feature-B 4:f8111a076f09
- $ hg up 6
- 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
- $ hg bookmark -if feature-A
- $ hg bookmark
- feature-A 6:23409eba69a0
- feature-B 4:f8111a076f09
- $ hg graft -O 4
- grafting revision 4
+ $ hg stabilize
+ move:[4] another feature
+ atop:[6] a nifty feature
merging main-file-1
- $ hg bookmark -ifr 7 feature-B # XXX not bookmark support in rebase --keep :-/
$ hg log
7 feature-B: another feature - test
6 feature-A: a nifty feature - test