Commits

ZyX_I committed 10070c7

@%aurum/cmdutils: Moved _r.cmdutils.update to @%aurum/maputils
ftplugin/aurumlog: Moved promptuser to @%aurum/maputils

Comments (0)

Files changed (24)

autoload/aurum.vim

 scriptencoding utf-8
 execute frawor#Setup('0.1', {'@%aurum/repo': '5.0',
             \                '@aurum/cache': '2.0',
-            \            '@%aurum/cmdutils': '3.0',})
+            \            '@%aurum/cmdutils': '4.0',})
 "▶1 getcrf
 function s:F.id(val)
     return a:val

autoload/aurum/annotate.vim

 "▶1 
 scriptencoding utf-8
-execute frawor#Setup('1.0', {'@%aurum/cmdutils': '3.0',
+execute frawor#Setup('1.0', {'@%aurum/cmdutils': '4.0',
             \                 '@%aurum/bufvars': '0.0',
             \                    '@%aurum/edit': '1.0',
             \                          '@aurum': '1.0',

autoload/aurum/branch.vim

 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@aurum': '1.0',
-            \      '@%aurum/cmdutils': '3.0',})
+            \      '@%aurum/cmdutils': '4.0',})
 let s:_messages={
             \ 'bexsts': 'Error while creating branch %s for repository %s: '.
             \           'branch already exists',

autoload/aurum/cmdutils.vim

 "▶1
 scriptencoding utf-8
-execute frawor#Setup('3.1', {'@/resources': '0.0',
+execute frawor#Setup('4.0', {'@/resources': '0.0',
             \                       '@/os': '0.0',
             \               '@%aurum/repo': '5.0',
             \               '@%aurum/edit': '1.0',
             \ 'nocurf': 'Failed to deduce which file was meant',
             \'nocfile': 'Unsure what should be commited',
         \}
+let s:r={}
 "▶1 globescape :: path → glob
-function s:F.globescape(path)
+function s:r.globescape(path)
     return escape(a:path, '\*?[]{}')
 endfunction
 "▶1 getdifffile :: bvar + cursor → file
-function s:F.getdifffile(bvar)
+function s:r.getdifffile(bvar)
     if len(a:bvar.files)==1
         return a:bvar.files[0]
     endif
                 \                         a:bvar.opts)
 endfunction
 "▶1 getfile :: [path] → path
-function s:F.getfile(files)
+function s:r.getfile(files)
     let file=0
     if !empty(a:files)
         if len(a:files)==1
     let r.repo=a:bvar.repo
     let  r.rev=empty(a:bvar.rev2) ? a:bvar.rev1 : a:bvar.rev2
     " XXX Maybe it should pull in all filenames instead when act='getfiles'?
-    let r.file=s:F.getdifffile(a:bvar)
+    let r.file=s:r.getdifffile(a:bvar)
     if r.file is 0 && a:failmsg isnot 0
         return 0
     endif
     if a:act is# 'getfiles'
         let r.files=a:bvar.files
     elseif a:act isnot# 'getsilent'
-        let r.file=s:F.getfile(a:bvar.files)
+        let r.file=s:r.getfile(a:bvar.files)
         if r.file is 0 && a:failmsg isnot 0
             return 0
         endif
 "▲2
 "▶1 getrrf :: opts, failmsg, act + buf → (hasbuf, repo, rev, file)
 let s:rrffailresult=[0, 0, 0, 0]
-function s:F.getrrf(opts, failmsg, act)
+function s:r.getrrf(opts, failmsg, act)
     let hasbuf=0
     let file=0
     "▶2 a:opts.file file → (repo?)
         if index(a:opts.files, ':')!=-1
             let newopts=copy(a:opts)
             unlet newopts.files
-            let [repo, rev, file]=s:F.getrrf(newopts, 'nocurf', 'getfile')[1:]
+            let [repo, rev, file]=s:r.getrrf(newopts, 'nocurf', 'getfile')[1:]
             if repo is 0
                 unlet repo
                 let repo=s:_r.repo.get(file)
             let file=expand('%')
         else
             let repo=s:_r.repo.get(':')
-            call s:F.checkrepo(repo)
+            call s:r.checkrepo(repo)
             let file=repo.functions.reltorepo(repo, expand('%'))
         endif
         let  rev=0
         "▶2 repo
         if !exists('repo')
             let repo=s:_r.repo.get(a:opts.repo)
-            call s:F.checkrepo(repo)
+            call s:r.checkrepo(repo)
             if file isnot 0
                 let file=repo.functions.reltorepo(repo, file)
             endif
                 \   (file))]
 endfunction
 "▶1 checkrepo
-function s:F.checkrepo(repo)
+function s:r.checkrepo(repo)
     if type(a:repo)!=type({})
         call s:_f.throw('nrepo')
     endif
     return 1
 endfunction
 "▶1 checkedgetrepo
-function s:F.checkedgetrepo(repopath)
+function s:r.checkedgetrepo(repopath)
     let repo=s:_r.repo.get(a:repopath)
-    call s:F.checkrepo(repo)
+    call s:r.checkrepo(repo)
     return repo
 endfunction
 "▶1 closebuf :: bvar → + buf
-function s:F.closebuf(bvar)
+function s:r.closebuf(bvar)
     let r=''
     if has_key(a:bvar, 'prevbuf') && bufexists(a:bvar.prevbuf)
         let r.=':buffer '.a:bvar.prevbuf."\n"
     return r.':if bufexists('.buf.')|bwipeout '.buf."|endif\n"
 endfunction
 "▶1 getexsttrckdfiles
-function s:F.getexsttrckdfiles(repo, ...)
+function s:r.getexsttrckdfiles(repo, ...)
     let cs=a:repo.functions.getwork(a:repo)
     let r=copy(a:repo.functions.getcsprop(a:repo, cs, 'allfiles'))
     let status=a:repo.functions.status(a:repo)
     return r
 endfunction
 "▶1 getaddedermvdfiles
-function s:F.getaddedermvdfiles(repo)
+function s:r.getaddedermvdfiles(repo)
     let status=a:repo.functions.status(a:repo)
     return status.unknown+filter(copy(status.removed),
                 \         'filereadable(s:_r.os.path.join(a:repo.path, v:val))')
 endfunction
 "▶1 filterfiles
-function s:F.filterfiles(repo, globs, files)
+function s:r.filterfiles(repo, globs, files)
     if empty(a:globs)
         return []
     endif
     endwhile
     return r
 endfunction
-"▶1 update
-" TODO Investigate whether this function should be moved to cmdutils, or to 
-" maputils which is probably to be created
-function s:F.update(repo, rev, count)
-    let rev=a:rev
-    if a:count>1
-        let rev=a:repo.functions.getnthparent(a:repo, rev, a:count-1).hex
-    endif
-    return a:repo.functions.update(a:repo, rev, 0)
-endfunction
 "▶1 Post cmdutils resource
-call s:_f.postresource('cmdutils', {'globescape': s:F.globescape,
-            \                           'getrrf': s:F.getrrf,
-            \                      'getdifffile': s:F.getdifffile,
-            \                        'checkrepo': s:F.checkrepo,
-            \                   'checkedgetrepo': s:F.checkedgetrepo,
-            \                         'closebuf': s:F.closebuf,
-            \                'getexsttrckdfiles': s:F.getexsttrckdfiles,
-            \               'getaddedermvdfiles': s:F.getaddedermvdfiles,
-            \                      'filterfiles': s:F.filterfiles,
-            \                           'update': s:F.update,
-            \})
+call s:_f.postresource('cmdutils', s:r)
 "▶1
 call frawor#Lockvar(s:, '_pluginloaded,_r')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲

autoload/aurum/commit.vim

             \                  '@/options': '0.0',
             \                     '@aurum': '1.0',
             \             '@%aurum/status': '1.0',
-            \           '@%aurum/cmdutils': '3.0',
+            \           '@%aurum/cmdutils': '4.0',
             \            '@%aurum/bufvars': '0.0',
             \               '@%aurum/edit': '1.0',
             \               '@aurum/cache': '2.1',})

autoload/aurum/diff.vim

 "▶1 
 scriptencoding utf-8
-execute frawor#Setup('0.0', {'@%aurum/cmdutils': '3.1',
+execute frawor#Setup('0.0', {'@%aurum/cmdutils': '4.0',
+            \                '@%aurum/maputils': '0.0',
             \                 '@%aurum/bufvars': '0.0',
             \               '@%aurum/lineutils': '0.0',
             \                 '@%aurum/vimdiff': '1.0',
         let cmd.=s:_r.cmdutils.closebuf(bvar)
     elseif a:action is# 'update'
         let rev=(empty(bvar.rev1)?(bvar.rev2):(bvar.rev1))
-        call s:_r.cmdutils.update(bvar.repo, rev, v:count)
+        call s:_r.maputils.update(bvar.repo, rev, v:count)
         return ''
     elseif a:action is# 'previous' || a:action is# 'next'
         let c=((a:action is# 'previous')?(v:count1):(-v:count1))

autoload/aurum/file.vim

 "▶1 
 scriptencoding utf-8
-execute frawor#Setup('0.0', {'@%aurum/cmdutils': '3.1',
+execute frawor#Setup('0.0', {'@%aurum/cmdutils': '4.0',
+            \                '@%aurum/maputils': '0.0',
             \                 '@%aurum/bufvars': '0.0',
             \               '@%aurum/lineutils': '0.0',
             \                 '@%aurum/vimdiff': '1.0',
     if a:action is# 'exit'
         let cmd.=s:_r.cmdutils.closebuf(bvar)
     elseif a:action is# 'update'
-        call s:_r.cmdutils.update(bvar.repo, bvar.rev, v:count)
+        call s:_r.maputils.update(bvar.repo, bvar.rev, v:count)
         return ''
     elseif a:action is# 'previous' || a:action is# 'next'
         let c=((a:action is# 'previous')?(v:count1):(-v:count1))

autoload/aurum/grep.vim

 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@aurum': '1.0',
-            \      '@%aurum/cmdutils': '3.0',
+            \      '@%aurum/cmdutils': '4.0',
             \          '@%aurum/edit': '1.0',
             \             '@/options': '0.0',})
 let s:_messages={

autoload/aurum/hyperlink.vim

 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@aurum': '1.0',
-            \      '@%aurum/cmdutils': '3.0',
+            \      '@%aurum/cmdutils': '4.0',
             \             '@/options': '0.0',})
 let s:_messages={
             \'uknurl': 'Failed to process url %s of repository %s',

autoload/aurum/junk.vim

 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@aurum': '1.0',
-            \      '@%aurum/cmdutils': '3.0',})
+            \      '@%aurum/cmdutils': '4.0',})
 let s:_messages={
             \'nofiles': 'No files were specified',
         \}

autoload/aurum/log.vim

 "▶1
 scriptencoding utf-8
-execute frawor#Setup('1.1', {'@%aurum/cmdutils': '3.0',
+execute frawor#Setup('1.1', {'@%aurum/cmdutils': '4.0',
             \           '@%aurum/log/templates': '0.0',
             \               '@%aurum/lineutils': '0.0',
             \                 '@%aurum/bufvars': '0.0',

autoload/aurum/maputils.vim

+"▶1
+scriptencoding utf-8
+execute frawor#Setup('0.0', {'@/resources': '0.0',
+            \                       '@/os': '0.0',})
+let s:_messages={
+        \}
+let s:r={}
+"▶1 update
+function s:r.update(repo, rev, count)
+    let rev=a:rev
+    if a:count>1
+        let rev=a:repo.functions.getnthparent(a:repo, rev, a:count-1).hex
+    endif
+    return a:repo.functions.update(a:repo, rev, 0)
+endfunction
+"▶1 promptuser
+let s:initialized_ruby=((has('ruby'))?(0):(-1))
+function s:r.promptuser(files, cbargs)
+    if !s:initialized_ruby
+        let s:initialized_ruby=1
+        try
+            execute 'rubyfile' fnameescape(s:_r.os.path.join(s:_frawor.runtimepath, 'ruby', 'aurum-command-t-rubyinit.rb'))
+        catch
+            let s:initialized_ruby=-1
+        endtry
+        lockvar s:initialized_ruby
+    endif
+    if s:initialized_ruby==1
+        let [b:aurum_callback_fun; b:aurum_addargs]=a:cbargs
+        ruby $comman_t_old = $command_t
+        ruby $command_t = $aurum_command_t
+        ruby $command_t.show_aurum_finder
+        autocmd BufWipeOut <buffer> ruby $command_t = $command_t_old
+    else
+        let choice=inputlist(['Select file (0 to cancel):']+
+                    \        map(copy(a:files), '(v:key+1).". ".v:val'))
+        if choice
+            return call(a:cbargs[0], [a:files[choice-1]]+a:cbargs[1:], {})
+        endif
+    endif
+endfunction
+"▶1 Post maputils resource
+call s:_f.postresource('maputils', s:r)
+"▶1
+call frawor#Lockvar(s:, 'initialized_ruby')
+" vim: ft=vim ts=4 sts=4 et fmr=▶,▲

autoload/aurum/move.vim

 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@aurum': '1.0',
-            \      '@%aurum/cmdutils': '3.0',
+            \      '@%aurum/cmdutils': '4.0',
             \          '@%aurum/edit': '1.0',
             \                  '@/os': '0.0',
             \               '@/table': '0.0',})

autoload/aurum/name.vim

 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@aurum': '1.0',
-            \      '@%aurum/cmdutils': '3.0',})
+            \      '@%aurum/cmdutils': '4.0',})
 let s:_messages={
             \ 'nunsup': 'Naming is not supported for repository %s',
             \'ukntype': 'Unknown label type: %s. Supported types: %s',

autoload/aurum/other.vim

 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@aurum': '1.0',
-            \      '@%aurum/cmdutils': '3.0',
+            \      '@%aurum/cmdutils': '4.0',
             \                  '@/os': '0.0',})
 function s:cmd.function(bang, action, rev, url, repopath)
     let repo=s:_r.cmdutils.checkedgetrepo(a:repopath)

autoload/aurum/record.vim

             \                   '@aurum': '1.0',
             \             '@aurum/cache': '2.1',
             \           '@%aurum/commit': '1.0',
-            \         '@%aurum/cmdutils': '3.0',
+            \         '@%aurum/cmdutils': '4.0',
             \        '@%aurum/lineutils': '0.0',
             \             '@%aurum/edit': '1.0',
             \          '@%aurum/bufvars': '0.0',})

autoload/aurum/status.vim

 "▶1 
 scriptencoding utf-8
-execute frawor#Setup('1.1', {'@%aurum/cmdutils': '3.0',
+execute frawor#Setup('1.1', {'@%aurum/cmdutils': '4.0',
             \                    '@%aurum/edit': '1.0',
             \                          '@aurum': '1.0',
             \                       '@/options': '0.0',

autoload/aurum/track.vim

 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@aurum': '1.0',
-            \      '@%aurum/cmdutils': '3.0',})
+            \      '@%aurum/cmdutils': '4.0',})
 function s:cmd.function(...)
     let globs=filter(copy(a:000), 'v:val isnot# ":"')
     let hascur=!(a:0 && len(globs)==a:0)

autoload/aurum/update.vim

 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@aurum': '1.0',
-            \      '@%aurum/cmdutils': '3.0',})
+            \      '@%aurum/cmdutils': '4.0',})
 function s:cmd.function(bang, rev, repopath)
     let repo=s:_r.cmdutils.checkedgetrepo(a:repopath)
     if a:rev is 0

autoload/aurum/vimdiff.vim

 "▶1 
 scriptencoding utf-8
-execute frawor#Setup('1.0', {'@%aurum/cmdutils': '3.0',
+execute frawor#Setup('1.0', {'@%aurum/cmdutils': '4.0',
             \                    '@%aurum/edit': '1.3',
             \                          '@aurum': '1.0',
             \                      '@/mappings': '0.0',
          getexsttrckdfiles _r.cmdutils functions.
     3.0: Removed _r.cmdutils.nogetrepoarg.
     3.1: Added _r.cmdutils.update (moved from @aurum/repo).
+    4.0: Moved _r.cmdutils.update to @%aurum/maputils
 @%aurum:
     0.1: Added |aurum#branch()| function.
 @aurum/cache:

ftplugin/aurumannotate.vim

 execute frawor#Setup('0.0', {'@%aurum/bufvars': '0.0',
             \                '@%aurum/vimdiff': '1.0',
             \               '@%aurum/annotate': '1.0',
-            \               '@%aurum/cmdutils': '3.1',
+            \               '@%aurum/cmdutils': '4.0',
+            \               '@%aurum/maputils': '0.0',
             \                   '@%aurum/edit': '1.2',
             \                     '@/mappings': '0.0',
             \                           '@/os': '0.0',})
         endif
     "▶2 `update' action
     elseif a:action is# 'update'
-        call s:_r.cmdutils.update(bvar.repo, hex, v:count)
+        call s:_r.maputils.update(bvar.repo, hex, v:count)
     "▶2 `previous' and `next' actions
     elseif a:action is# 'previous' || a:action is# 'next'
         let c=((a:action is# 'previous')?(v:count1):(-v:count1))

ftplugin/aurumlog.vim

 endif
 setlocal noswapfile
 setlocal nomodeline
-execute frawor#Setup('0.1', {'@%aurum/cmdutils': '3.1',
+execute frawor#Setup('0.1', {'@%aurum/cmdutils': '4.0',
+            \                '@%aurum/maputils': '0.0',
             \                 '@%aurum/bufvars': '0.0',
             \                    '@%aurum/edit': '1.0',
             \                 '@%aurum/vimdiff': '1.0',
     if len(files)==1
         return call(a:cbargs[0], [files[0]]+a:cbargs[1:], {})
     else
-        return s:F.promptuser(files, a:cbargs)
-    endif
-endfunction
-"▶1 promptuser
-let s:initialized_ruby=((has('ruby'))?(0):(-1))
-function s:F.promptuser(files, cbargs)
-    if !s:initialized_ruby
-        let s:initialized_ruby=1
-        try
-            execute 'rubyfile' fnameescape(s:_r.os.path.join(s:_frawor.runtimepath, 'ruby', 'aurum-command-t-rubyinit.rb'))
-        catch
-            let s:initialized_ruby=-1
-        endtry
-        lockvar s:initialized_ruby
-    endif
-    if s:initialized_ruby==1
-        let [b:aurum_callback_fun; b:aurum_addargs]=a:cbargs
-        ruby $comman_t_old = $command_t
-        ruby $command_t = $aurum_command_t
-        ruby $command_t.show_aurum_finder
-        autocmd BufWipeOut <buffer> ruby $command_t = $command_t_old
-    else
-        let choice=inputlist(['Select file (0 to cancel):']+
-                    \        map(copy(a:files), '(v:key+1).". ".v:val'))
-        if choice
-            return call(a:cbargs[0], [a:files[choice-1]]+a:cbargs[1:], {})
-        endif
+        return s:_r.maputils.promptuser(files, a:cbargs)
     endif
 endfunction
 "▶1 gethexfile
 function s:F.update()
     let bvar=s:_r.bufvars[bufnr('%')]
     let hex=bvar.getblock(bvar)[2]
-    call s:_r.cmdutils.update(bvar.repo, hex, v:count)
+    call s:_r.maputils.update(bvar.repo, hex, v:count)
     return "\<C-\>\<C-n>:silent edit\n"
 endfunction
 "▶1 AuLog mapping group
 delfunction s:m
 delfunction s:c
 "▶1
-call frawor#Lockvar(s:, '_r,initialized_ruby')
+call frawor#Lockvar(s:, '_r')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲

ftplugin/aurumstatus.vim

 setlocal nomodeline
 execute frawor#Setup('0.0', {'@%aurum/bufvars': '0.0',
             \                '@%aurum/vimdiff': '1.0',
-            \               '@%aurum/cmdutils': '3.0',
+            \               '@%aurum/cmdutils': '4.0',
             \                   '@%aurum/edit': '1.2',
             \                 '@%aurum/commit': '1.0',
             \                     '@/mappings': '0.0',