--- 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]')),
--- 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
--- 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
--- 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