[patch]util:give straightforward abort for -d '--2' to avoid typing mistake (issue2734)

yun lee yun.lee.bj at gmail.com
Sun Apr 3 21:41:14 CDT 2011


# HG changeset patch
# User Yun Lee <yunlee.bj at gmail.com>
# Date 1301883915 -28800
# Node ID 5514a034b9e6a311fcd4f4562e058e43317e4141
# Parent  0995eee8ffe4a24478379fb16fd6c38812bc3dd5
util:give straightforward abort for -d '--2' to avoid typing mistake (issue2734)

diff -r 0995eee8ffe4 -r 5514a034b9e6 mercurial/util.py
--- a/mercurial/util.py	Sat Apr 02 11:07:05 2011 +0200
+++ b/mercurial/util.py	Mon Apr 04 10:25:15 2011 +0800
@@ -1232,6 +1232,8 @@
             days = int(date[1:])
         except ValueError:
             raise Abort(_("invalid day spec: %s") % date[1:])
+        if days < 0:
+            raise Abort(_("%s is a minus number, do you mean %s?") %
(date[1:], date[2:]))
         when = makedate()[0] - days * 3600 * 24
         return lambda x: x >= when
     elif " to " in date:
diff -r 0995eee8ffe4 -r 5514a034b9e6 tests/test-log.t
--- a/tests/test-log.t	Sat Apr 02 11:07:05 2011 +0200
+++ b/tests/test-log.t	Mon Apr 04 10:25:15 2011 +0800
@@ -518,6 +518,11 @@
   abort: dates cannot consist entirely of whitespace
   [255]

+log -d "--2"
+  $ hg log -d "--2"
+  abort: -2 is a minus number, do you mean 2?
+  [255]
+
 log -d -1

   $ hg log -d -1

-- 
Yun Lee


More information about the Mercurial-devel mailing list