Mercurial > evolve
changeset 4347:59745d6d626d
evolve: extract "update" code into its own function
This patch moves the code to a function which handles the case when wdir
parent is obsolete and evolve will just update to its successor.
And extraction of this to a function will also help us to fix the
issue5881.
author | Sushil khanchi <sushilkhanchi97@gmail.com> |
---|---|
date | Fri, 18 Jan 2019 23:08:43 +0530 |
parents | ff483949674e |
children | 398c33b17d76 |
files | hgext3rd/evolve/evolvecmd.py |
diffstat | 1 files changed, 34 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py Tue Dec 25 16:08:05 2018 +0530 +++ b/hgext3rd/evolve/evolvecmd.py Fri Jan 18 23:08:43 2019 +0530 @@ -1479,35 +1479,8 @@ elif len(specifiedcategories) == 1: targetcat = specifiedcategories[0] elif repo['.'].obsolete(): - oldid = repo['.'].node() - displayer = compat.changesetdisplayer(ui, repo, - {'template': shorttemplate}) - # no args and parent is obsolete, update to successors - try: - ctx = repo[utility._singlesuccessor(repo, repo['.'])] - except utility.MultipleSuccessorsError as exc: - repo.ui.write_err(_('parent is obsolete with multiple' - ' successors:\n')) - for ln in exc.successorssets: - for n in ln: - displayer.show(repo[n]) - return 2 - - ui.status(_('update:')) - if not ui.quiet: - displayer.show(ctx) - - if dryrunopt: - return 0 - res = hg.update(repo, ctx.rev()) - newid = ctx.node() - - if ctx != startnode: - with repo.wlock(), repo.lock(), repo.transaction('evolve') as tr: - bmupdater = rewriteutil.bookmarksupdater(repo, oldid, tr) - bmupdater(newid) - ui.status(_('working directory is now at %s\n') % ctx) - return res + # if no args and parent is obsolete, update to successors + return solveobswdp(ui, repo, opts) ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve') troubled = set(repo.revs('troubled()')) @@ -1616,6 +1589,38 @@ progresscb() _cleanup(ui, repo, startnode, showprogress, shouldupdate) +def solveobswdp(ui, repo, opts): + oldid = repo['.'].node() + startnode = repo['.'] + dryrunopt = opts.get('dry_run', False) + displayer = compat.changesetdisplayer(ui, repo, + {'template': shorttemplate}) + try: + ctx = repo[utility._singlesuccessor(repo, repo['.'])] + except utility.MultipleSuccessorsError as exc: + repo.ui.write_err(_('parent is obsolete with multiple' + ' successors:\n')) + for ln in exc.successorssets: + for n in ln: + displayer.show(repo[n]) + return 2 + + ui.status(_('update:')) + if not ui.quiet: + displayer.show(ctx) + + if dryrunopt: + return 0 + res = hg.update(repo, ctx.rev()) + newid = ctx.node() + + if ctx != startnode: + with repo.wlock(), repo.lock(), repo.transaction('evolve') as tr: + bmupdater = rewriteutil.bookmarksupdater(repo, oldid, tr) + bmupdater(newid) + ui.status(_('working directory is now at %s\n') % ctx) + return res + def stopevolve(ui, repo, evolvestate): """logic for handling of `hg evolve --stop`""" updated = False