Commits

ZyX_I committed 97fcff2

Made completion and :AuHyperref work with non-python driver (untested)
Added :AuGrep files in place of `next' arguments
Some grep() fixes in non-python driver (it is still failing to pass tests though)

Comments (0)

Files changed (5)

     to open aurum://file buffer (default: `silent edit') (may be overriden by 
     `replace' option).
 
-AuGrep {pattern} {opts} [glob1 [...]]                                *:AuGrep*
+AuGrep {pattern} {opts}                                              *:AuGrep*
     Populates |quickfix| list with the results of searching repository for 
     given {pattern} ({pattern} syntax is determined by used VCS). If any globs 
     are given, then only files matching these globs are searched.
                    for. May be specified more then once.
     revision       Accepts one revision. Adds it to the list of revisions that 
                    should be searched for. May be specified more then once.
+    files          Glob. Determines which files should be searched. May be 
+                   specified more then once.
     repo           Path. Repository that should be searched.
 
-    Note that neither revrange nor revision options accept revision names that 
-         contain question marks, stars or dots. This is to resolve possible 
-         ambiguity with glob: `revision 1 abc' will take `abc' as its 
-         argument, but `revision 1 ./abc' won't.
-
                                                                 *:AuHyperlink*
 AuHyperlink [rev {rev}] [file {file}] [line {line}] [cmd {cmd}] [repo {repo}]
     Construct a URL that refers to revision {rev} of a file {file} (default: 
             \'\Vcmd\s\+type ""',  'cmd '.s:_r.comp.cmd,  ''),
             \'\Vrev\s\+type ""',  'rev '.s:_r.comp.rev,  ''))
 "▶1 grepfunc
-function s:grepfunc.function(pattern, opts, ...)
-    if a:opts.repo is# ':' && a:0
-        let repo=s:_r.repo.get(a:1)
+function s:grepfunc.function(pattern, opts)
+    if has_key(a:opts, 'files') && a:opts.repo is# ':'
+        let repo=s:_r.repo.get(a:opts.files[0])
     else
         let repo=s:_r.repo.get(a:opts.repo)
     endif
         let revisions+=[[cs1.hex, cs2.hex]]
     endwhile
     let files=[]
-    if a:0
+    if has_key(a:opts, 'files')
         if empty(revisions)
             call repo.functions.getchangesets(repo)
             let cslist=repo.cslist
         call map(copy(allfiless),
                     \'extend(allfiles, filter(v:val, '.
                     \                        '"index(allfiles, v:val)==-1"))')
-        for pattern in map(copy(a:000), 's:_r.cmdutils.globtopat('.
-                    \                   'repo.functions.reltorepo(repo, v:val))')
+        for pattern in map(copy(a:opts.files),
+                    \'s:_r.cmdutils.globtopat('.
+                    \                  'repo.functions.reltorepo(repo, v:val))')
             let files+=filter(copy(allfiles),
                         \     'v:val=~#pattern && index(files, v:val)==-1')
         endfor
                 \              get(a:opts, 'ignorecase', 0))
     call setqflist(qf)
 endfunction
-let s:grevarg='match @\v^[^.*?]+$@'
 let s:grepfunc['@FWC']=['-onlystrings '.
             \           'type "" '.
-            \           '{?   !ignorecase '.
-            \           ' ?*+2 revrange   '.s:grevarg.' '.s:grevarg.
-            \           ' ?*   revision   '.s:grevarg.
-            \           '      repo '.s:_r.cmdutils.nogetrepoarg.
-            \           '} + type ""', 'filter']
+            \           '{     repo     '.s:_r.cmdutils.nogetrepoarg.
+            \           ' ?*+2 revrange   type ""  type ""'.
+            \           ' ?*   revision   type ""'.
+            \           ' ?*   files      type ""'.
+            \           ' ?   !ignorecase '.
+            \           '}', 'filter']
 call add(s:grepcomp,
             \substitute(substitute(s:grepfunc['@FWC'][0],
-            \'\V+ type ""', '+ (path)', ''),
-            \'\V'.escape(s:grevarg, '\'), '(?'.s:_r.comp.rev.' \1)', 'g'))
+            \'\Vfiles \+type ""', 'files (path)', ''),
+            \'\v(rev%(ision|range))\ +\Vtype ""', '\1 '.s:_r.comp.rev, 'g'))
 "▶1
 call frawor#Lockvar(s:, '_pluginloaded,_r')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲

plugin/aurum/drivers/mercurial.vim

 if !s:usepythondriver
     call extend(s:_messages, {
                 \'parsefail': 'Failed to parse changeset information',
-                \ 'filefail': 'Failed to get file %s from repository %s: %s',
+                \ 'filefail': 'Failed to get file %s '.
+                \             'from the repository %s: %s',
                 \ 'difffail': 'Failed to get diff between %s and %s '.
                 \             'for files %s from the repository %s: %s',
                 \ 'statfail': 'Failed to obtain status information '.
                 \             'in the repository %s: %s',
                 \  'cspfail': 'Failed to get property %s for changeset %s '.
                 \             'in the repository %s: %s',
-                \  'logfail': 'Failed to get log for repository %s: %s',
-                \  'keyfail': 'Failed to get %s for repository %s: %s',
+                \  'logfail': 'Failed to get log for the repository %s: %s',
+                \  'keyfail': 'Failed to get %s for the repository %s: %s',
                 \   'csfail': 'Failed to get changeset %s '.
                 \             'from the repository %s: %s',
                 \  'renfail': 'Failed to get renames list for revision %s '.
                 \             'in the repository %s: %s',
                 \  'cmdfail': 'Failure while running command %s '.
                 \             'for the repository %s: %s',
-                \ 'grepfail': 'Failed to search through repository %s: %s',
+                \ 'grepfail': 'Failed to search through the repository %s: %s',
+                \   'scfail': 'Failed to show [paths] section '.
+                \             'for the repository %s: %s',
                 \ 'stat1mis': 'You must specify first revision as well',
             \})
 endif
         let r=split(system(cmd), "\n", 1)
     endif
     if v:shell_error
-        call call(s:_f.throw, [a:msgid.'fail']+a:000+[a:repo.path,
-                    \                                 join(r[:-1-(a:hasnulls)],
-                    \                                      "\n")], {})
+        if a:msgid isnot 0
+            call call(s:_f.throw, [a:msgid.'fail']+a:000+[a:repo.path,
+                        \                                 join(r[:-1-(a:hasnulls)],
+                        \                                      "\n")], {})
+        endif
     endif
     return r
 endfunction
     let css+=[cs0]
     return css
 endfunction
+"▶2 getkeylist :: repo, key → [(name, rev)]
+function s:F.getkeylist(repo, key)
+    let lines=s:F.hg(a:repo, a:key, 0, 'key', a:key)[:-2]
+    if len(lines)==1 && lines[0]!~#'\v\ [1-9]\d*\:\x{12}$'
+        return []
+    endif
+    return map(copy(lines), 'matchlist(v:val, '.
+                \                    '''\v^(.{-})\ +(\d+)\:\x{12}$'')[1:2]')
+endfunction
 "▲2
 endif
 "▶1 hg.updatechangesets :: repo → + repo
     endfunction
 "▶2 no python
 else
-    "▶3 getkeylist :: repo, key → [(name, rev)]
-    function s:F.getkeylist(repo, key)
-        let lines=s:F.hg(a:repo, a:key, 0, 'key', a:key)[:-2]
-        if len(lines)==1 && lines[0]!~#'\v\ [1-9]\d*\:\x{12}$'
-            return []
-        endif
-        return map(copy(lines), 'matchlist(v:val, '.
-                    \                    '''\v^(.{-})\ +(\d+)\:\x{12}$'')[1:2]')
-    endfunction
-    "▲3
     function s:F.getupdates(repo, start)
         let r={}
         let r.css=s:F.getcslist(a:repo, a:start, -1)
     return stats
 endfunction
 "▶1 hg.getrepoprop :: repo, prop → a
+if s:usepythondriver "▶2
 function s:hg.getrepoprop(repo, prop)
     let d={}
     try
     endtry
     return a:repo[a:prop]
 endfunction
+else "▶2
+function s:hg.getrepoprop(repo, prop)
+    if a:prop is# 'tagslist' || a:prop is# 'brancheslist' || a:prop is# 'bookmarkslist'
+        return map(copy(s:F.getkeylist(a:repo, a:prop[:-5])), 'v:val[0]')
+    elseif a:prop is# 'url'
+        let lines=s:F.hg(a:repo, 'showconfig paths', 0, 'sc')[:-2]
+        let confs={}
+        call map(lines, 'matchlist(v:val, ''\v^paths\.([^=]+)\=(.*)$'')[1:2]')
+        call map(copy(lines), 'extend(confs, {v:val[0]: v:val[1]})')
+        if has_key(confs, 'default-push')
+            return confs['default-push']
+        elseif has_key(confs, 'default')
+            return confs.default
+        endif
+    endif
+    call s:_f.throw('nocfg', a:prop, a:repo.path)
+endfunction
+endif
 "▶1 runcmd :: repo, attr, args, kwargs → + ?
 if s:usepythondriver "▶2
 function s:F.runcmd(repo, attr, args, kwargs)
             return a:cache[key]
         endif
     endif
-    let status=a:repo.functions.status(a:rev, 0, [a:file])
+    let status=a:repo.functions.status(a:repo, a:rev, 0, [a:file])
     let r=(index(status.clean, a:file)!=-1)
     if a:cache isnot 0
         let a:cache[key]=r
 function s:hg.grep(repo, pattern, files, revisions, ignore_case)
     let cmd='grep '.join(map(copy(a:revisions),
             \                '((type(v:val)=='.type([]).')?'.
-            \                   '("-r".shellescape(join(v:val, "..")), 1):'.
+            \                   '("-r".shellescape(join(v:val, ".."), 1)):'.
             \                   '("-r".shellescape(v:val, 1)))')).' '
     if a:ignore_case
         let cmd.='--ignore-case '
     let cmd.='--line-number '
     let cmd.='-- '.shellescape(a:pattern, 1).
                 \join(map(copy(a:files), 'shellescape(v:val, 1)'))
-    let lines=s:F.hg(a:repo, cmd, 1, 'grep')
-    let epath=escape(bvar.repo.path, ':\')
+    let lines=s:F.hg(a:repo, cmd, 1, 0)
+    if v:shell_error
+        if lines ==# ['']
+            return []
+        else
+            call s:_f.throw('grepfail', a:repo.path, join(lines, "\n"))
+        endif
+    endif
+    let epath=escape(a:repo.path, ':\')
     let r=[]
     let cnmscache={}
     for line in lines
         let match=matchlist(line, '\v^(.{-})\:(0|[1-9]\d*)\:([1-9]\d*)\:(.*)$')
         if empty(match)
-            call s:_f.throw('grepfail', line)
+            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)
 :RG A\b revision 4
 :RG A\b revrange 2 10
 :RG A\b repo ../testrepo
-:RG A\b ../testrepo/nohglinesrev.lst
-:RG A\b revision 4 ../testrepo/*.lst
-:RG A\b revision 2 ../testrepo/*.lst
+:RG A\b files ../testrepo/nohglinesrev.lst
+:RG A\b revision 4 files ../testrepo/*.lst
+:RG A\b revision 2 files ../testrepo/*.lst
 :source addmessages.vim
 %TMPDIR%/test/testrepo/chgrepo.zsh|83| --date '2002-02-11 03:15' --user $A
 %TMPDIR%/test/testrepo/chgrepo.zsh|85| hg commit -A -m 'Added .hgignore' \
 %TMPDIR%/test/testrepo/chgrepo.zsh|86| --date '2002-02-11 05:43' --user $A
-{{{1 A\b ../testrepo/nohglinesrev.lst
+{{{1 A\b files ../testrepo/nohglinesrev.lst
 aurum://file:%TMPDIR%/test/testrepo:2c2d8b2b8164681fcc1ea55bf8e086f034ddc70e:nohglinesrev.lst|4| '>moc.elpmaxe@a< A'=A lacol
 aurum://file:%TMPDIR%/test/testrepo:2c2d8b2b8164681fcc1ea55bf8e086f034ddc70e:nohglinesrev.lst|12| A$ resu-- '02:5 20-10-9991' etad--        
 aurum://file:%TMPDIR%/test/testrepo:2c2d8b2b8164681fcc1ea55bf8e086f034ddc70e:nohglinesrev.lst|13| A$ resu-- '03:7 50-10-0002' etad--        
 aurum://file:%TMPDIR%/test/testrepo:2c2d8b2b8164681fcc1ea55bf8e086f034ddc70e:nohglinesrev.lst|44| A$ resu-- '51:30 11-20-2002' etad--        
 aurum://file:%TMPDIR%/test/testrepo:2c2d8b2b8164681fcc1ea55bf8e086f034ddc70e:nohglinesrev.lst|46| A$ resu-- '34:50 11-20-2002' etad--        
 aurum://file:%TMPDIR%/test/testrepo:2c2d8b2b8164681fcc1ea55bf8e086f034ddc70e:nohglinesrev.lst|51| cbaderongi > 'cbA' ohce    
-{{{1 A\b revision 4 ../testrepo/*.lst
+{{{1 A\b revision 4 files ../testrepo/*.lst
 %TMPDIR%/test/testrepo/datelines.lst|2| hg commit -A -m 'Added «createrepo.zsh»' \
 %TMPDIR%/test/testrepo/datelines.lst|4| hg commit -A -m 'Renamed «createrepo.zsh» to «crepo.zsh»' \
 %TMPDIR%/test/testrepo/datelines.lst|7| hg commit -A -m 'Renamed «crepo.zsh» to «chgrepo.zsh»' \
 %TMPDIR%/test/testrepo/hglines.lst|38| hg commit -A -m 'Added nohglinesrev.lst' \
 %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 ../testrepo/*.lst
+{{{1 A\b revision 2 files ../testrepo/*.lst
 >>> Messages:
 Frawor:plugin/aurum:nogf:No files found
 <<< Messages^