Mercurial > hg-stable
changeset 31177:696e321b304d
update: add experimental config for default way of handling dirty wdir
This allows the user to set e.g. experimental.updatecheck=abort to
abort update if the working directory is dirty, but still be able to
override the behavior with e.g. --merge when needed.
I considered adding a --mergelinear option to get back the old
behavior even when experimental.updatecheck=abort is set, but I
couldn't see why anyone would prefer that over --merge.
The default is read in hg.updatetotally(), which means it also applies
to "hg pull -u" and "hg unbundle -u".
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 13 Feb 2017 16:03:05 -0800 |
parents | fad5e299cfc7 |
children | 41a9edc5d00f |
files | mercurial/hg.py tests/test-pull-update.t tests/test-update-branches.t |
diffstat | 3 files changed, 94 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hg.py Mon Feb 13 12:58:37 2017 -0800 +++ b/mercurial/hg.py Mon Feb 13 16:03:05 2017 -0800 @@ -747,7 +747,10 @@ This returns whether conflict is detected at updating or not. """ if updatecheck is None: - updatecheck = 'linear' + updatecheck = ui.config('experimental', 'updatecheck') + if updatecheck not in ('abort', 'none', 'linear'): + # If not configured, or invalid value configured + updatecheck = 'linear' with repo.wlock(): movemarkfrom = None warndest = False
--- a/tests/test-pull-update.t Mon Feb 13 12:58:37 2017 -0800 +++ b/tests/test-pull-update.t Mon Feb 13 16:03:05 2017 -0800 @@ -16,6 +16,21 @@ $ echo 1.2 > foo $ hg ci -Am m +Should respect config to disable dirty update + $ hg co -qC 0 + $ echo 2 > foo + $ hg --config experimental.updatecheck=abort pull -u ../tt + pulling from ../tt + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files (+1 heads) + abort: uncommitted changes + [255] + $ hg --config extensions.strip= strip --no-backup tip + $ hg co -qC tip + Should not update to the other topological branch: $ hg pull -u ../tt
--- a/tests/test-update-branches.t Mon Feb 13 12:58:37 2017 -0800 +++ b/tests/test-update-branches.t Mon Feb 13 16:03:05 2017 -0800 @@ -195,6 +195,81 @@ parent=1 M foo + $ echo '[experimental]' >> .hg/hgrc + $ echo 'updatecheck = abort' >> .hg/hgrc + + $ revtest 'none dirty linear' dirty 1 2 + abort: uncommitted changes + parent=1 + M foo + + $ revtest 'none dirty linear' dirty 1 2 -c + abort: uncommitted changes + parent=1 + M foo + + $ revtest 'none dirty linear' dirty 1 2 -C + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + parent=2 + + $ echo 'updatecheck = none' >> .hg/hgrc + + $ revtest 'none dirty cross' dirty 3 4 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + parent=4 + M foo + + $ revtest 'none dirty linear' dirty 1 2 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + parent=2 + M foo + + $ revtest 'none dirty linear' dirty 1 2 -c + abort: uncommitted changes + parent=1 + M foo + + $ revtest 'none dirty linear' dirty 1 2 -C + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + parent=2 + + $ hg co -qC 3 + $ echo dirty >> a + $ hg co --tool :merge3 4 + merging a + warning: conflicts while merging a! (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 + [1] + $ hg st + M a + ? a.orig + $ cat a + <<<<<<< working copy: 6efa171f091b - test: 3 + three + dirty + ||||||| base + three + ======= + four + >>>>>>> destination: d047485b3896 b1 - test: 4 + $ rm a.orig + +Uses default value of "linear" when value is misspelled + $ echo 'updatecheck = linyar' >> .hg/hgrc + + $ revtest 'dirty cross' dirty 3 4 + abort: uncommitted changes + (commit or update --clean to discard changes) + parent=3 + M foo + +Setup for later tests + $ revtest 'none dirty linear' dirty 1 2 -c + abort: uncommitted changes + parent=1 + M foo + $ cd .. Test updating to null revision