Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 8855:f331de880cbb
update: add --check option
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 20 Jun 2009 08:29:41 -0500 |
parents | 80cc4b1a62d0 |
children | f8d00346a62d |
line wrap: on
line diff
--- 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]')),