Commits

ZyX_I committed bd2c86a

Added `workdirfiles' and `:AuGrep wdfiles' options
Added $tags positional parameter test

Comments (0)

Files changed (8)

     files          Glob. Determines which files should be searched. May be 
                    specified more then once.
     repo           Path. Repository that should be searched.
+    [no]wdfiles    Flag. Determines whether :AuGrep should output files in 
+                   working directory if they have not changed since found 
+                   revision. Overrides |g:aurum_workdirfiles|.
 
                                                                 *:AuHyperlink*
 AuHyperlink [rev {rev}] [file {file}] [line {line}] [cmd {cmd}] [repo {repo}]
     size (vertical if 'diffopt' contains `vertical', horizontal otherwise).
     Default: 0.
 
+workdirfiles                                            *g:aurum_workdirfiles*
+    Bool. Determines whether |:AuGrep| should output files in working 
+    directory if they have not changed since revision found.
+    Default: 1.
+
 ==============================================================================
 5. Globs                                                         *aurum-globs*
 
     it happen to contain any wildcards.
   ignoreglob :: glob -> _                                *aurum-rf-ignoreglob*
     Add given glob to .hgignore or similar.
-  grep :: pattern -> qflist                                    *aurum-rf-grep*
+                                                               *aurum-rf-grep*
+  grep :: pattern, [ file ], [ Either hex (hex, hex) ], ic, wdf -> qflist
     Search repository for given pattern and return results in a list that can 
-    be passed to |setqflist()| function.
+    be passed to |setqflist()| function. Second argument here controls what 
+    files should be searched for. Third controls revisions that are to be 
+    searched (tuple variant: range of revisions). {ic} determines whether case 
+    should be ignored and {wdf} determines whether grep should output files in 
+    working directory if they have not changed since found revision.
                                                              *aurum-rf-status*
   status :: [hex[, hex[, [ file ]]]] -> {status : [ files ]}
     Returns dictionary where values are lists of files and keys are 
                 \               '@/functions': '0.0',
                 \                   '@/table': '0.0',
                 \                '@/mappings': '0.0',
+                \                 '@/options': '0.0',
                 \                      '@/os': '0.1',
                 \            '@/autocommands': '0.0',
                 \           '@aurum/cmdutils': '0.0',
             \   'nogf': 'No files found',
             \'_mvheader': ['Source', 'Destination'],
         \}
+let s:_options={
+            \'workdirfiles': {'default': 1,
+            \                  'filter': 'bool',},
+        \}
 "▶1 getexsttrckdfiles
 function s:F.getexsttrckdfiles(repo)
     let cs=a:repo.functions.getcs(a:repo, '.')
             \substitute(s:tracfunc['@FWC'][0],
             \'\V+ type ""', '+ (path)', ''))
 "▶1 hypfunc
+" TODO bundleurl ?
 function s:hypfunc.function(opts)
     let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf(a:opts, 'nocurf', 0)
     call s:_r.cmdutils.checkrepo(repo)
             return
         endif
     endif
+    let wdfiles=((has_key(a:opts, 'wdfiles'))?(a:opts.wdfiles):
+                \                             (s:_f.getoption('workdirfiles')))
     let qf=repo.functions.grep(repo, a:pattern, files, revisions,
-                \              get(a:opts, 'ignorecase', 0))
+                \              get(a:opts, 'ignorecase', 0), wdfiles)
     call setqflist(qf)
 endfunction
 let s:grepfunc['@FWC']=['-onlystrings '.
             \           ' ?*+2 revrange   type ""  type ""'.
             \           ' ?*   revision   type ""'.
             \           ' ?*   files      type ""'.
+            \           ' ?   !wdfiles'.
             \           ' ?   !ignorecase '.
             \           '}', 'filter']
 call add(s:grepcomp,

plugin/aurum/drivers/mercurial.vim

     let hgignore=s:_r.os.path.join(a:repo.path, '.hgignore')
     return s:F.addtosection(a:repo, hgignore, 'glob', a:glob)
 endfunction
-"▶1 hg.grep :: repo, pattern, files, revisions, ignore_case → qflist
+"▶1 hg.grep :: repo, pattern, files, revisions, ignore_case, wdfiles → qflist
 " revisions :: [Either rev (rev, rev)]
-" TODO noworkfiles ?
 if s:usepythondriver "▶2
-function s:hg.grep(repo, pattern, files, revisions, ignore_case)
+function s:hg.grep(repo, pattern, files, revisions, ignore_case, wdfiles)
     let r=[]
     execute s:_r.py.cmd 'aurum.grep(vim.eval("a:repo.path"), '.
                 \                  'vim.eval("a:pattern"), '.
                 \                  'vim.eval("a:files"), '.
                 \                  'vim.eval("a:revisions"), '.
-                \                  'bool(int(vim.eval("a:ignore_case"))))'
+                \                  'bool(int(vim.eval("a:ignore_case"))), '.
+                \                  'bool(int(vim.eval("a:wdfiles"))))'
     return r
 endfunction
 else "▶2
     return r
 endfunction
 "▲3
-function s:hg.grep(repo, pattern, files, revisions, ignore_case)
+function s:hg.grep(repo, pattern, files, revisions, ignore_case, wdfiles)
     let cmd='grep '.join(map(copy(a:revisions),
             \                '((type(v:val)=='.type([]).')?'.
             \                   '("-r".shellescape(join(v:val, ".."), 1)):'.
             call s:_f.throw('grepfail', a:repo.path, line)
         endif
         let [file, rev, lnum, text]=match[1:4]
-        if s:F.checknotmodifiedsince(a:repo, rev, file, cnmscache)
+        if a:wdfiles && s:F.checknotmodifiedsince(a:repo, rev, file, cnmscache)
             let file=s:_r.os.path.normpath(s:_r.os.path.join(a:repo.path, file))
         else
             let file='aurum://file:'.epath.':'.rev.':'.file
         pass
 
 grepre=re.compile('^(.*?):(0|[1-9]\d*):([1-9]\d*):(.*)$')
-def grep(path, pattern, files, revisions=None, ignore_case=False):
+def grep(path, pattern, files, revisions=None, ignore_case=False, wdfiles=True):
     try:
         repo=g_repo(path)
         ui=CaptureUI()
             if not m:
                 continue
             (file, rev, lnum, text)=m.groups()
-            if check_not_modified_since(rev, file):
+            if wdfiles and check_not_modified_since(rev, file):
                 file=os.path.join(repo.root, file)
             else:
                 file='aurum://file:'+epath+':'+rev+':'+file
 :RG A\b files ../testrepo/nohglinesrev.lst
 :RG A\b revision 4 files ../testrepo/*.lst
 :RG A\b revision 2 files ../testrepo/*.lst
+:RG /bin/zsh nowdfiles
+:let g:aurum_workdirfiles=0
+:RG /bin/zsh
+:RG /bin/zsh wdfiles
+:let g:aurum_workdirfiles=1
+:RG /bin/zsh
+:RG /bin/zsh nowdfiles
 :source addmessages.vim
 %TMPDIR%/test/testrepo/hglines.lst|39| hg commit -A -m 'Added ignored10.lst' \
 %TMPDIR%/test/testrepo/hglines.lst|40| hg commit -A -m 'Added .hgignore' \
 {{{1 A\b revision 2 files ../testrepo/*.lst
+{{{1 /bin/zsh nowdfiles
+aurum://file:%TMPDIR%/test/greprepo:19:nohglines.lst|1| #!/bin/zsh
+aurum://file:%TMPDIR%/test/greprepo:10:blines.lst|1| #!/bin/zsh
+aurum://file:%TMPDIR%/test/greprepo:3:chgrepo.zsh|1| #!/bin/zsh
+{{{1 /bin/zsh
+aurum://file:%TMPDIR%/test/greprepo:19:nohglines.lst|1| #!/bin/zsh
+aurum://file:%TMPDIR%/test/greprepo:10:blines.lst|1| #!/bin/zsh
+aurum://file:%TMPDIR%/test/greprepo:3:chgrepo.zsh|1| #!/bin/zsh
+{{{1 /bin/zsh wdfiles
+nohglines.lst|1| #!/bin/zsh
+blines.lst|1| #!/bin/zsh
+chgrepo.zsh|1| #!/bin/zsh
+{{{1 /bin/zsh
+nohglines.lst|1| #!/bin/zsh
+blines.lst|1| #!/bin/zsh
+chgrepo.zsh|1| #!/bin/zsh
+{{{1 /bin/zsh nowdfiles
+aurum://file:%TMPDIR%/test/greprepo:19:nohglines.lst|1| #!/bin/zsh
+aurum://file:%TMPDIR%/test/greprepo:10:blines.lst|1| #!/bin/zsh
+aurum://file:%TMPDIR%/test/greprepo:3:chgrepo.zsh|1| #!/bin/zsh
 >>> Messages:
 Frawor:plugin/aurum:nogf:No files found
 <<< Messages^

test/log-templates.in

 :ST $parents
 :ST $children
 :ST $tags;$bookmarks
+:ST $tags#;#;$bookmarks#;#
 :ST $rev$tags#\,,pref:[,suf:]#
 :ST $summary
 :ST $rev: $description-

test/log-templates.ok

 |  
 o  ;
 |  
+{{{1 $tags#;#;$bookmarks#;#
+@  tip;
+|  
+o    ;
+|\   
+o |  ;
+| |  
+| o  ;
+|/   
+o  ;
+|  
+o  ;
+|  
+o  ;
+|  
+o  ;
+|  
+o  ;
+|  
+o    ;
+|\   
+o |    ;
+|\ \   
+| | o    ;
+| | |\   
+| | o |    ;
+| | |\ \   
+| | | | | o  ;
+| | | | |/   
+| +-----o  clines;oldtag;
+| | | |    
+| +-----o  ;
+| | | |    
+| o | |  blines;
+| | | |  
+o | | |    ;
+|\ \ \ \   
+| | o | |  ;
+| |/ / /   
+| o---+  ablines;
+|  / /   
+| | o  ;
+| |/   
+| o  ;
+|/   
+o  ;
+|  
+o  ;
+|  
+o  ;
+|  
+o  ;
+|  
+o  ;
+|  
 {{{1 $rev$tags#\,,pref:[,suf:]#
 @  26[tip]
 |