# HG changeset patch # User Matt Mackall # Date 1245504581 18000 # Node ID f331de880cbbfbd601e710a2735718ccf882c462 # Parent 980f5b7c5fb61fc2f67935513849c37c2fe94405 update: add --check option diff -r 980f5b7c5fb6 -r f331de880cbb mercurial/commands.py --- a/mercurial/commands.py Thu Jun 18 23:08:33 2009 -0500 +++ b/mercurial/commands.py Sat Jun 20 08:29:41 2009 -0500 @@ -2975,7 +2975,7 @@ return postincoming(ui, repo, modheads, opts.get('update'), None) -def update(ui, repo, node=None, rev=None, clean=False, date=None): +def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False): """update working directory Update the repository's working directory to the specified @@ -2991,7 +2991,8 @@ When there are uncommitted changes, use option -C/--clean to discard them, forcibly replacing the state of the working - directory with the requested revision. + directory with the requested revision. Alternately, use -c/--check + to abort. When there are uncommitted changes and option -C/--clean is not used, and the parent revision and requested revision are on the @@ -3011,6 +3012,12 @@ if not rev: rev = node + if not clean and check: + # we could use dirty() but we can ignore merge and branch trivia + c = repo[None] + if c.modified() or c.added() or c.removed(): + raise util.Abort(_("uncommitted local changes")) + if date: if rev: raise util.Abort(_("you can't specify a revision and a date")) @@ -3502,6 +3509,7 @@ "^update|up|checkout|co": (update, [('C', 'clean', None, _('overwrite locally modified files (no backup)')), + ('c', 'check', None, _('check for uncommitted changes')), ('d', 'date', '', _('tipmost revision matching date')), ('r', 'rev', '', _('revision'))], _('[-C] [-d DATE] [[-r] REV]')), diff -r 980f5b7c5fb6 -r f331de880cbb tests/test-debugcomplete.out --- a/tests/test-debugcomplete.out Thu Jun 18 23:08:33 2009 -0500 +++ b/tests/test-debugcomplete.out Sat Jun 20 08:29:41 2009 -0500 @@ -176,7 +176,7 @@ remove: after, force, include, exclude serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, webdir-conf, pid-file, stdio, templates, style, ipv6, certificate status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, include, exclude -update: clean, date, rev +update: clean, check, date, rev addremove: similarity, include, exclude, dry-run archive: no-decode, prefix, rev, type, include, exclude backout: merge, parent, rev, include, exclude, message, logfile, date, user diff -r 980f5b7c5fb6 -r f331de880cbb tests/test-up-issue1456 --- a/tests/test-up-issue1456 Thu Jun 18 23:08:33 2009 -0500 +++ b/tests/test-up-issue1456 Sat Jun 20 08:29:41 2009 -0500 @@ -10,7 +10,7 @@ hg ci -m1 hg co -q 0 echo dirty > foo -sleep 1 +hg up -c hg up -q cat foo hg st -A diff -r 980f5b7c5fb6 -r f331de880cbb tests/test-up-issue1456.out --- a/tests/test-up-issue1456.out Thu Jun 18 23:08:33 2009 -0500 +++ b/tests/test-up-issue1456.out Sat Jun 20 08:29:41 2009 -0500 @@ -1,3 +1,4 @@ +abort: uncommitted local changes dirty M foo % validate update of standalone execute bit change