tweakdefaults: allow hg update --merge without --nocheck

Summary: The --merge flag is relatively new; we shouldn't add --check if it is specified.

Test Plan: Unit test

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4916396

Tasks: 17490374

Signature: t1:4916396:1492647440:d9955931cb9177719a58325c08a715d4d51d1226
This commit is contained in:
Arun Kulshreshtha 2017-04-19 17:20:23 -07:00
parent 6065ceef3f
commit 02e5cc57ba
2 changed files with 75 additions and 1 deletions

View File

@ -338,7 +338,7 @@ def update(orig, ui, repo, node=None, rev=None, **kwargs):
# By default, never update when there are local changes unless updating to
# the current rev. This is useful for, eg, arc feature when the only
# thing changing is the bookmark.
if not kwargs['clean'] and not kwargs['nocheck']:
if not kwargs['clean'] and not kwargs['nocheck'] and not kwargs['merge']:
target = node or rev
if target and scmutil.revsingle(repo, target, target).rev() != \
repo.revs('.').first():

View File

@ -0,0 +1,74 @@
$ extpath=`dirname $TESTDIR`
$ cp $extpath/hgext3rd/tweakdefaults.py $TESTTMP # use $TESTTMP substitution in message
$ cat >> $HGRCPATH << EOF
> [extensions]
> tweakdefaults=$TESTTMP/tweakdefaults.py
> rebase=
> EOF
Set up the repository.
$ hg init repo
$ cd repo
$ hg debugbuilddag -m '+4 *3 +1'
$ hg log --graph -r 0:: -T '{rev}'
o 5
|
o 4
|
| o 3
| |
| o 2
|/
o 1
|
o 0
$ hg up 3
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Make an uncommitted change.
$ echo foo > foo
$ hg add foo
$ hg st
A foo
Can always update to current commit.
$ hg up .
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
By default, --check should be set.
$ hg up 2
abort: uncommitted changes
[255]
$ hg up --nocheck 2
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Updates to other branches should fail without --merge.
$ hg up 4
abort: uncommitted changes
[255]
$ hg up --nocheck 4
abort: uncommitted changes
(commit or update --clean to discard changes)
[255]
$ hg up --merge 4
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Certain flags shouldn't work together.
$ hg up --check --merge 3
abort: can only specify one of -C/--clean, -c/--check, or -m/merge
[255]
$ hg up --check --clean 3
abort: can only specify one of -C/--clean, -c/--check, or -m/merge
[255]
$ hg up --clean --merge 3
abort: can only specify one of -C/--clean, -c/--check, or -m/merge
[255]
--clean should work as expected.
$ hg st
A foo
$ hg up --clean 3
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg st
? foo