# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 2016-02-08 06:18:24
# Node ID 8157c6b82f4003d870e0bcc40f8fbf3934f1e817
# Parent  6f248ba853092fa90998f4c87374b9272c8371fe

update: check command line before modifying repo

A failed command should not have any effect on the repo.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6959,24 +6959,24 @@ def update(ui, repo, node=None, rev=None
     if rev is None or rev == '':
         rev = node
 
+    if date and rev is not None:
+        raise error.Abort(_("you can't specify a revision and a date"))
+
+    if check and clean:
+        raise error.Abort(_("cannot specify both -c/--check and -C/--clean"))
+
     warndest = False
 
     with repo.wlock():
         cmdutil.clearunfinished(repo)
 
         if date:
-            if rev is not None:
-                raise error.Abort(_("you can't specify a revision and a date"))
             rev = cmdutil.finddate(ui, repo, date)
 
         # if we defined a bookmark, we have to remember the original name
         brev = rev
         rev = scmutil.revsingle(repo, rev, rev).rev()
 
-        if check and clean:
-            raise error.Abort(_("cannot specify both -c/--check and -C/--clean")
-                             )
-
         if check:
             cmdutil.bailifchanged(repo, merge=False)
         if rev is None: