tests/test-grep.t
changeset 38631 9ef10437bb88
parent 38540 1e25782a7583
child 38648 ffd08ec22955
--- a/tests/test-grep.t	Tue Jul 10 13:18:34 2018 +0200
+++ b/tests/test-grep.t	Fri Jul 06 00:39:21 2018 +0530
@@ -23,11 +23,11 @@
 
 simple
 
-  $ hg grep '.*'
+  $ hg grep -r tip:0 '.*'
   port:4:export
   port:4:vaportight
   port:4:import/export
-  $ hg grep port port
+  $ hg grep -r tip:0 port port
   port:4:export
   port:4:vaportight
   port:4:import/export
@@ -35,32 +35,32 @@
 simple with color
 
   $ hg --config extensions.color= grep --config color.mode=ansi \
-  >     --color=always port port
+  >     --color=always port port -r tip:0
   \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32m4\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc)
   \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32m4\x1b[0m\x1b[0;36m:\x1b[0mva\x1b[0;31;1mport\x1b[0might (esc)
   \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32m4\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc)
 
 simple templated
 
-  $ hg grep port \
+  $ hg grep port -r tip:0 \
   > -T '{file}:{rev}:{node|short}:{texts % "{if(matched, text|upper, text)}"}\n'
   port:4:914fa752cdea:exPORT
   port:4:914fa752cdea:vaPORTight
   port:4:914fa752cdea:imPORT/exPORT
 
-  $ hg grep port -T '{file}:{rev}:{texts}\n'
+  $ hg grep port -r tip:0 -T '{file}:{rev}:{texts}\n'
   port:4:export
   port:4:vaportight
   port:4:import/export
 
-  $ hg grep port -T '{file}:{tags}:{texts}\n'
+  $ hg grep port -r tip:0 -T '{file}:{tags}:{texts}\n'
   port:tip:export
   port:tip:vaportight
   port:tip:import/export
 
 simple JSON (no "change" field)
 
-  $ hg grep -Tjson port
+  $ hg grep -r tip:0 -Tjson port
   [
    {
     "date": [4, 0],
@@ -93,7 +93,7 @@
 
 simple JSON without matching lines
 
-  $ hg grep -Tjson -l port
+  $ hg grep -r tip:0 -Tjson -l port
   [
    {
     "date": [4, 0],
@@ -216,9 +216,9 @@
 
 other
 
-  $ hg grep -l port port
+  $ hg grep -r tip:0 -l port port
   port:4
-  $ hg grep import port
+  $ hg grep -r tip:0 import port
   port:4:import/export
 
   $ hg cp port port2
@@ -226,7 +226,7 @@
 
 follow
 
-  $ hg grep --traceback -f 'import\n\Z' port2
+  $ hg grep -r tip:0 --traceback -f 'import\n\Z' port2
   port:0:import
   
   $ echo deport >> port2
@@ -244,8 +244,8 @@
   port:0:1:+:spam:import
 
   $ hg up -q null
-  $ hg grep -f port
-  [1]
+  $ hg grep -r 'reverse(:.)' -f port
+  port:0:import
 
 Test wdir
 (at least, this shouldn't crash)
@@ -264,9 +264,9 @@
   $ cd ..
   $ hg init t2
   $ cd t2
-  $ hg grep foobar foo
+  $ hg grep -r tip:0 foobar foo
   [1]
-  $ hg grep foobar
+  $ hg grep -r tip:0 foobar
   [1]
   $ echo blue >> color
   $ echo black >> color
@@ -279,7 +279,7 @@
   $ echo orange >> color
   $ echo blue >> color
   $ hg ci -m 3
-  $ hg grep orange
+  $ hg grep -r tip:0 orange
   color:3:orange
   $ hg grep --all orange
   color:3:+:orange
@@ -293,7 +293,7 @@
 
 test substring match: '^' should only match at the beginning
 
-  $ hg grep '^.' --config extensions.color= --color debug
+  $ hg grep -r tip:0 '^.' --config extensions.color= --color debug
   [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lack
   [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|o]range
   [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lue
@@ -303,7 +303,7 @@
   $ $PYTHON -c 'fp = open("noeol", "wb"); fp.write(b"no infinite loop"); fp.close();'
   $ hg ci -Amnoeol
   adding noeol
-  $ hg grep loop
+  $ hg grep -r tip:0 loop
   noeol:4:no infinite loop
 
   $ cd ..
@@ -320,7 +320,7 @@
   adding color
   $ hg rename color colour
   $ hg ci -Am rename
-  $ hg grep octarine
+  $ hg grep -r tip:0 octarine
   colour:1:octarine
   color:0:octarine
 
@@ -424,3 +424,14 @@
   a:2147483647:abracadara
 
   $ cd ..
+
+Change Default of grep, that is, the files not in current working directory
+should not be grepp-ed on
+  $ hg init ab
+  $ cd ab
+  $ echo "some text">>file1
+  $ hg add file1
+  $ hg commit -m "adds file1"
+  $ hg mv file1 file2
+  $ hg grep "some"
+  file2:2147483647:some text