Let "hg add" do nothing

Guido Ostkamp hg at ostkamp.fastmail.fm
Wed Aug 22 18:52:32 UTC 2007


Hello,

> I really don't understand why people are typing "hg add<enter>" and 
> being surprised when it adds stuff. Do they also run reboot to get help 
> on the various ways of rebooting?
>
> And if you're the type of wreckless maniac who types "hg 
> add<tab><enter>" without even waiting to see what <tab> gave you, you 
> might want to consider cutting back on the coffee.
>
> It's going to take a significantly better use case than these to 
> convince me to break backward compatibility, folks.

well, backward compatibility is not necessarily an issue here.

It would be possible to serve all users needs by adding an optional 
parameter to ".hgrc" which allows to let 'hg add' or 'hg addremove' 
require at least one parameter to implement a 'safe mode'.

In any case, if Matt isn't willing to add it, it is always possible for 
anyone to tweak his installation of hg by applying the following patch:

--- a/mercurial/commands.py     Mon Aug 20 21:10:45 2007 -0500
+++ b/mercurial/commands.py     Wed Aug 22 20:44:29 2007 +0200
@@ -25,6 +25,8 @@ def add(ui, repo, *pats, **opts):

      If no names are given, add all files in the repository.
      """
+    if not pats:
+        raise util.Abort(_('at least one file name or pattern required'))

      names = []
      for src, abs, rel, exact in cmdutil.walk(repo, pats, opts):
@@ -52,6 +54,9 @@ def addremove(ui, repo, *pats, **opts):
      between 0 (disabled) and 100 (files must be identical) as its
      parameter.  Detecting renamed files this way can be expensive.
      """
+    if not pats:
+        raise util.Abort(_('at least one file name or pattern required'))
+
      try:
          sim = float(opts.get('similarity') or 0)
      except ValueError:


Regards,

Guido



More information about the Mercurial mailing list