Commits

ZyX_I committed 9eab8e3

@aurum/drivers/subversion: Fixed rf-setcsprop("allfiles"): now purging trailing empty line and directories
@aurum/repo: Added default rf-grep() implementation

Comments (0)

Files changed (3)

   |aurum-rf-remove|        Uses |aurum-rf-forget| to untrack file and then 
                          |delete()|s it.
   |aurum-rf-checkremote|   Returns 0.
+  |aurum-rf-grep|          Does just the same what git grep does: iterates 
+                         over given revisions and searches for given regular 
+                         expression (in this case: vim |regexp|) in each file. 
+                         If third argument is empty, then searches working 
+                         directory versions of files present in current 
+                         changeset. Uses |aurum-rf-getcsprop| (with “allfiles” 
+                         argument), |aurum-rf-revrange| and 
+                         |aurum-rf-readfile|.
+                         Slow!
   |aurum-repo.iterfuncs|   "changeset": Uses |aurum-rf-getchangesets|
                          "revrange": Uses |aurum-rf-revrange|
                          "ancestors": Iterates recursively over 

plugin/aurum/drivers/subversion.vim

     if a:prop is# 'allfiles'
         let r=s:F.svn(a:repo, 'list', ['.'], {'recursive': 1,
                     \                         'revision': a:cs.hex}, 0,
-                    \ 'listf', a:cs.hex)
+                    \ 'listf', a:cs.hex)[:-2]
+        " FIXME Investigate whether s:_r.os.pathsep should be used here instead
+        call filter(r, 'v:val[-1:] isnot# "/"')
     elseif a:prop is# 'children'
         " TODO
     elseif  a:prop is# 'changes' || a:prop is# 'files' || a:prop is# 'removes'

plugin/aurum/repo.vim

     endwhile
     return stats
 endfunction
+"▶1 grep :: repo, pattern, [file], [Either hex (hex, hex)], ic, _ → qflist
+function s:deffuncs.grep(repo, pattern, files, revs, ic, wdf)
+    if empty(a:revs)
+        let cs=a:repo.functions.getwork(a:repo)
+        let filelist=copy(a:repo.functions.getcsprop(a:repo, cs, 'allfiles'))
+        if !empty(a:files)
+            call filter(filelist, 'index(a:files, v:val)!=-1')
+        endif
+        call map(filelist, 's:_r.os.path.join(a:repo.path, v:val)')
+        call filter(filelist, 'filereadable(v:val)')
+        let expr='readfile(fspec, "b")'
+    else
+        let css=[]
+        for rspec in a:revs
+            if type(rspec)==type([])
+                let css+=a:repo.functions.revrange(a:repo, rspec[0], rspec[1])
+            else
+                let css+=[a:repo.functions.getcs(a:repo, rspec)]
+            endif
+            unlet rspec
+        endfor
+        let filelist=[]
+        let gcspexpr='a:repo.functions.getcsprop(a:repo, v:val, "allfiles")'
+        let mexpr='extend(filelist, '.
+                    \    'map('.((empty(a:files))?
+                    \               (gcspexpr):
+                    \               ('filter(copy('.gcspexpr.'), '.
+                    \                       '"index(a:files, v:val)!=-1")')).
+                    \        ', "[css[".v:key."].hex, v:val]"))'
+        call map(copy(css), mexpr)
+        let expr='a:repo.functions.readfile(a:repo, fspec[0], fspec[1])'
+    endif
+    let r=[]
+    let fexpr='v:val[1]=~'.('?#'[!a:ic]).string(a:pattern)
+    for fspec in filelist
+        let r+=map(filter(map(copy(eval(expr)), '[v:key, v:val]'), fexpr),
+                    \'{"filename": fspec,"lnum": v:val[0]+1,"text": v:val[1]}')
+    endfor
+    return r
+endfunction
 "▶1 copy
 function s:deffuncs.copy(repo, force, source, target)
     let src=s:_r.os.path.normpath(s:_r.os.path.join(a:repo.path, a:source))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.