Mercurial > evolve
changeset 6101:431bf23df350
obsolete-parent: evolve the case when parent has multiple successors
Before this patch, we were used to return error that parent has multiple
successors and exit.
This patch take more care of that case and if obsolete parent's successors are:
1) split successors, then we check if they are on a single topological
branch we update to tipmost, otherwise we ask user to select.
2) divergent successors, we suggest user to `hg update` to one of the
successors and run `hg evolve --content-div` to resolve the problem.
Changes in test file shows the updated behavior.
author | Sushil khanchi <sushilkhanchi97@gmail.com> |
---|---|
date | Thu, 29 Jul 2021 00:12:10 +0530 |
parents | 46858e6f8b99 |
children | 01bc197f31d3 |
files | hgext3rd/evolve/evolvecmd.py tests/test-evolve-wdir.t |
diffstat | 2 files changed, 45 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py Tue Jul 27 18:21:34 2021 +0530 +++ b/hgext3rd/evolve/evolvecmd.py Thu Jul 29 00:12:10 2021 +0530 @@ -1816,19 +1816,32 @@ def solveobswdp(ui, repo, opts): """this function updates to the successor of obsolete wdir parent""" oldid = repo[b'.'].node() - startctx = repo[b'.'] + oldctx = repo[b'.'] dryrunopt = opts.get('dry_run', False) display = compat.format_changeset_summary_fn(ui, repo, b'evolve', shorttemplate) try: - ctx = repo[utility._singlesuccessor(repo, repo[b'.'])] + ctx = repo[utility._singlesuccessor(repo, oldctx)] except utility.MultipleSuccessorsError as exc: - repo.ui.write_err(_(b'parent is obsolete with multiple' - b' successors:\n')) - for ln in exc.successorssets: - for n in ln: - display(repo[n]) - return 2 + if exc.splitflag: + splitsucc = utility.select_split_successor(ui, repo, oldctx) + if splitsucc: + ctx = repo[splitsucc] + else: + # XXX: yet to add test coverage for this block + if util.safehasattr(error, 'CanceledError'): + err = error.CanceledError + else: + # hg <= 5.6 (ac362d5a7893) + err = error.Abort + raise err(_(b'user quit')) + elif exc.divergenceflag: + repo.ui.write_err(_(b'parent is obsolete with multiple' + b' content-divergent successors:\n')) + for sset in exc.successorssets: + for succ in sset: + display(repo[succ]) + return 2 ui.status(_(b'update:')) if not ui.quiet: @@ -1839,7 +1852,7 @@ res = hg.update(repo, ctx.rev()) newid = ctx.node() - if ctx != startctx: + if ctx != oldctx: with repo.wlock(), repo.lock(), repo.transaction(b'evolve') as tr: bmupdater = rewriteutil.bookmarksupdater(repo, oldid, tr) bmupdater(newid)
--- a/tests/test-evolve-wdir.t Tue Jul 27 18:21:34 2021 +0530 +++ b/tests/test-evolve-wdir.t Thu Jul 29 00:12:10 2021 +0530 @@ -101,18 +101,23 @@ (707ee88b2870 has diverged, use 'hg evolve --list --content-divergent' to resolve the issue) $ hg evolve - parent is obsolete with multiple successors: + parent is obsolete with multiple content-divergent successors: [3] u_B [4] c_B [2] +test that given hint works + $ hg up -r 'desc(u_B)' + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg evolve --content-div + merge:[3] u_B + with: [4] c_B + base: [1] c_B + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + working directory is now at 767c654afe84 $ hg glog - * 4:39e54eb7aa3c (draft): c_B [content-divergent] + @ 5:767c654afe84 (draft): u_B | - | * 3:90624b574289 (draft): u_B [content-divergent] - |/ - | @ 1:707ee88b2870 (draft): c_B - |/ o 0:9f0188af4c58 (draft): c_A @@ -171,9 +176,16 @@ working directory parent is obsolete! (c8b6cf6ce628) (use 'hg evolve' to update to its tipmost successor: 1eb7dbbcecbd, b99a391251cc and 1 more) + $ hg glog -l 3 + o 9:b7ec9e61ccbf (draft): c_XYZ + | + o 8:b99a391251cc (draft): c_XYZ + | + o 7:1eb7dbbcecbd (draft): c_XYZ + | + ~ +test that given hint works $ hg evolve - parent is obsolete with multiple successors: - [6] c_XYZ - [7] c_XYZ - [8] c_XYZ - [2] + update:[9] c_XYZ + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + working directory is now at b7ec9e61ccbf