next-prev: always respect the --merge flag
An earlier bug fix series which started respecting commands.update.check
introduced a bug in which --merge was not respected sometimes. This patch fixes
that behavior by passing updatecheck as 'none' to hg.updatetotally() if --merge
is passed which is similar to what `hg update` does.
--- a/hgext3rd/evolve/__init__.py Fri Jun 08 18:32:48 2018 +0530
+++ b/hgext3rd/evolve/__init__.py Fri Jun 08 17:36:28 2018 +0530
@@ -966,15 +966,21 @@
def _getcurrenttopic(repo):
return getattr(repo, 'currenttopic', '')
-def _prevupdate(repo, displayer, target, bookmark, dryrun):
+def _prevupdate(repo, displayer, target, bookmark, dryrun, mergeopt):
if dryrun:
repo.ui.write(_('hg update %s;\n') % target)
if bookmark is not None:
repo.ui.write(_('hg bookmark %s -r %s;\n')
% (bookmark, target))
else:
+ updatecheck = None
+ # --merge is passed, we don't need to care about commands.update.check
+ # config option
+ if mergeopt:
+ updatecheck = 'none'
try:
- ret = hg.updatetotally(repo.ui, repo, target.node(), None)
+ ret = hg.updatetotally(repo.ui, repo, target.node(), None,
+ updatecheck=updatecheck)
except error.Abort as exc:
# replace the hint to mention about --merge option
exc.hint = _('do you want --merge?')
@@ -1047,6 +1053,7 @@
Displays the summary line of the destination for clarity."""
wlock = None
dryrunopt = opts['dry_run']
+ mergeopt = opts['merge']
if not dryrunopt:
wlock = repo.wlock()
try:
@@ -1054,7 +1061,7 @@
wparents = wkctx.parents()
if len(wparents) != 1:
raise error.Abort(_('merge in progress'))
- if not opts['merge']:
+ if not mergeopt:
# we only skip the check if noconflict is set
if ui.config('commands', 'update.check') == 'noconflict':
pass
@@ -1077,7 +1084,8 @@
if topic and _getcurrenttopic(repo) != _gettopic(target):
repo.ui.setconfig('_internal', 'keep-topic', 'yes',
source='topic-extension')
- _prevupdate(repo, displayer, target, bookmark, dryrunopt)
+ _prevupdate(repo, displayer, target, bookmark, dryrunopt,
+ mergeopt)
finally:
repo.ui.restoreconfig(backup)
return 0
@@ -1213,8 +1221,14 @@
if shouldmove:
ui.write(_('hg bookmark %s -r %s;\n') % (bm, children))
else:
+ updatecheck = None
+ # --merge is passed, we don't need to care about commands.update.check
+ # config option
+ if opts['merge']:
+ updatecheck = 'none'
try:
- ret = hg.updatetotally(ui, repo, children.node(), None)
+ ret = hg.updatetotally(ui, repo, children.node(), None,
+ updatecheck=updatecheck)
except error.Abort as exc:
# replace the hint to mention about --merge option
exc.hint = _('do you want --merge?')
--- a/tests/test-prev-next.t Fri Jun 08 18:32:48 2018 +0530
+++ b/tests/test-prev-next.t Fri Jun 08 17:36:28 2018 +0530
@@ -446,26 +446,38 @@
$ echo hi > bar
$ echo bar >> bar
$ hg next --merge
- abort: conflicting changes
- (do you want --merge?)
- [255]
+ merging bar
+ warning: conflicts while merging bar! (edit, then use 'hg resolve --mark')
+ 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+ use 'hg resolve' to retry unresolved file merges
+ [2] added bar
+
+ $ echo babar > bar
+ $ hg resolve -m
+ (no more unresolved files)
Testing --merge works with other values of commands.update.check also
XXX: things are broken!
$ hg prev --merge --config commands.update.check=abort
- abort: uncommitted changes
- (do you want --merge?)
- [255]
+ local [working copy] changed bar which other [destination] deleted
+ use (c)hanged version, (d)elete, or leave (u)nresolved?
+ 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+ use 'hg resolve' to retry unresolved file merges
+ [1] added foo
$ hg revert --all
forgetting bar
reverting wat
+ $ hg resolve -m
+ (no more unresolved files)
$ echo bar > bar
$ hg add bar
$ hg next --merge --config commands.update.check=abort
- abort: uncommitted changes
- (do you want --merge?)
- [255]
+ merging bar
+ warning: conflicts while merging bar! (edit, then use 'hg resolve --mark')
+ 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+ use 'hg resolve' to retry unresolved file merges
+ [2] added bar