[PATCH] dispatch: abort when specifying repository on norepo commands

Laurens Holst laurens.nospam at grauw.nl
Tue Dec 20 14:03:17 CST 2011


# HG changeset patch
# User Laurens Holst <laurens.hg at grauw.nl>
# Date 1324409721 -3600
# Node ID c153131ce1fc1de11b8725785a51345b8dfa1930
# Parent  21eb048edc19a9b78ae262d222c0de1f3ad6c4d2
dispatch: abort when specifying repository on norepo commands

For (norepo) commands where this option does not apply the option is 
currently
ignored, which results in an unintended state that the user has to clean 
up. For
example “hg init -R test” will not create a repo in directory “test” but 
in “.”.

When a repository is specified with the --repository option, the user 
clearly
intends the operation to be performed in the given location. Therefore, this
patch changes the behaviour from a warning to an abort.

diff -r 21eb048edc19 -r c153131ce1fc mercurial/dispatch.py
--- a/mercurial/dispatch.py    Mon Dec 19 11:37:44 2011 +0100
+++ b/mercurial/dispatch.py    Tue Dec 20 20:35:21 2011 +0100
@@ -673,7 +673,7 @@
              ui = repo.ui
          args.insert(0, repo)
      elif rpath:
-        ui.warn(_("warning: --repository ignored\n"))
+        raise util.Abort(_("repository option does not apply to %s 
command" % cmd))

      msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
      ui.log("command", msg + "\n")



More information about the Mercurial-devel mailing list