Mercurial > evolve
changeset 1325:1fe3da0b4601
evolve: add --rev option to the evolve command
This patch is part of a series of patches to refactor the evolve method and
make it more readable. We introduce a new --rev flag to specify a revset
where to solve the troubles instead of looking from the parent changeset.
All add a test checks that --rev works with several commits
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Tue, 05 May 2015 14:25:59 -0700 |
parents | 739208d1ee62 |
children | ae678c98b685 |
files | hgext/evolve.py tests/test-evolve.t |
diffstat | 2 files changed, 159 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/evolve.py Tue May 05 14:25:35 2015 -0700 +++ b/hgext/evolve.py Tue May 05 14:25:59 2015 -0700 @@ -1222,13 +1222,13 @@ if repo['.'] != startnode: ui.status(_('working directory is now at %s\n') % repo['.']) - @command('^evolve|stabilize|solve', [('n', 'dry-run', False, 'do not perform actions, just print what would be done'), ('', 'confirm', False, 'ask for confirmation before performing the action'), ('A', 'any', False, 'also consider troubled changesets unrelated to current working directory'), + ('r', 'rev', '', 'revset to find troubles in'), ('a', 'all', False, 'evolve all troubled changesets in the repo ' '(implies any)'), ('c', 'continue', False, 'continue an interrupted evolution'), @@ -1259,12 +1259,14 @@ The working directory is updated to the newly created revision. """ + # Options contopt = opts['continue'] anyopt = opts['any'] allopt = opts['all'] startnode = repo['.'] dryrunopt = opts['dry_run'] confirmopt = opts['confirm'] + revopt = opts['rev'] ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve') troubled = set(repo.revs('troubled()')) @@ -1274,7 +1276,7 @@ showprogress = allopt def progresscb(): - if allopt: + if revopt or allopt: ui.progress('evolve', seen, unit='changesets', total=count) # Continuation handling @@ -1285,9 +1287,25 @@ raise util.Abort('cannot specify both "--all" and "--continue"') graftcmd = commands.table['graft'][0] return graftcmd(ui, repo, old_obsolete=True, **{'continue': True}) - + # Rev specified on the commands line + if revopt: + revs = set(repo.revs(revopt)) + troubled = set(repo.revs('troubled()')) + _revs = revs & troubled + if not _revs: + ui.write_err("No troubled changes in the specified revset") + else: + # For the progress bar to show + count = len(_revs) + for rev in _revs: + progresscb() + _solveone(ui, repo, repo[rev], dryrunopt, confirmopt, + progresscb) + seen += 1 + progresscb() + _cleanup(ui, repo, startnode, showprogress) + return nexttrouble = _picknexttroubled(ui, repo, anyopt or allopt) - # No trouble to resolve if not nexttrouble: return handlenotrouble(ui, repo, startnode, dryrunopt)
--- a/tests/test-evolve.t Tue May 05 14:25:35 2015 -0700 +++ b/tests/test-evolve.t Tue May 05 14:25:59 2015 -0700 @@ -887,3 +887,140 @@ working directory is now at f37ed7a60f43 $ ls .hg/bookmarks* .hg/bookmarks + +Possibility to select what trouble to solve first, asking for bumped before +divergent + $ hg up 10 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg revert -r 11 --all + reverting a + $ hg log -G --template '{rev} [{branch}] {desc|firstline}\n' + o 11 [mybranch] a2 + | + @ 10 [default] a1__ + | + | o 9 [mybranch] a3 + | | + | x 8 [mybranch] a2 + | | + | x 7 [default] a1_ + |/ + o 0 [default] a0 + + $ echo "hello world" > newfile + $ hg add newfile + $ hg commit -m "add new file bumped" -o 11 + $ hg phase --public --hidden 11 + 1 new bumped changesets + $ hg glog + @ 12 : add new file bumped - test + | + | o 11 : a2 - test + |/ + o 10 testbookmark: a1__ - test + | + | o 9 : a3 - test + | | + | x 8 : a2 - test + | | + | x 7 : a1_ - test + |/ + o 0 : a0 - test + + +Now we have a bumped and an unstable changeset, we solve the bumped first +normally the unstable changeset would be solve first + + $ hg glog + @ 12 : add new file bumped - test + | + | o 11 : a2 - test + |/ + o 10 testbookmark: a1__ - test + | + | o 9 : a3 - test + | | + | x 8 : a2 - test + | | + | x 7 : a1_ - test + |/ + o 0 : a0 - test + + $ hg evolve -r 12 + recreate:[12] add new file bumped + atop:[11] a2 + computing new diff + committed as d66b1e328488 + working directory is now at d66b1e328488 + $ hg evolve --any + move:[9] a3 + atop:[13] bumped update to f37ed7a60f43: + working directory is now at 7d2ce5f38f9b +Check that we can resolve troubles in a revset with more than one commit + $ hg up 14 -C + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ mkcommit gg + $ hg up 14 + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ mkcommit gh + created new head + $ hg up 14 + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ echo "newline\nnewline" >> a + $ hg glog + o 16 : add gh - test + | + | o 15 : add gg - test + |/ + @ 14 : a3 - test + | + o 13 : bumped update to f37ed7a60f43: - test + | + o 11 : a2 - test + | + o 10 testbookmark: a1__ - test + | + o 0 : a0 - test + + $ hg amend + 2 new unstable changesets + $ hg glog + @ 18 : a3 - test + | + | o 16 : add gh - test + | | + | | o 15 : add gg - test + | |/ + | x 14 : a3 - test + |/ + o 13 : bumped update to f37ed7a60f43: - test + | + o 11 : a2 - test + | + o 10 testbookmark: a1__ - test + | + o 0 : a0 - test + + $ hg evolve --rev "14::" + move:[16] add gh + atop:[18] a3 + move:[15] add gg + atop:[18] a3 + working directory is now at 10ffdd7e3cc9 + $ hg glog + @ 20 : add gg - test + | + | o 19 : add gh - test + |/ + o 18 : a3 - test + | + o 13 : bumped update to f37ed7a60f43: - test + | + o 11 : a2 - test + | + o 10 testbookmark: a1__ - test + | + o 0 : a0 - test + + +