Commits

ZyX_I committed 3370696

@%aurum/drivers/common/utils: Moved nullnl here from @%aurum/drivers/git
Added _r.utils.kwargstostr

Comments (0)

Files changed (6)

 syntax: glob
-python/*.pyc
+python/**.pyc
 test/dummy.in
 test/*repo
 test/svntestreposerver

autoload/aurum/drivers/common/utils.vim

 "▶1
 scriptencoding utf-8
-execute frawor#Setup('0.2', {'@/resources': '0.0',
+execute frawor#Setup('0.3', {'@/resources': '0.0',
             \                       '@/os': '0.2'})
 let s:utils={}
+"▶1 utils.kwargstostr :: kwargs → str
+let s:prefexpr='repeat("-", 1+(len(v:val[0])>1)).v:val[0]." ="[len(v:val[0])>1]'
+function s:utils.kwargstostr(kwargs, esc)
+    return join(map(filter(items(a:kwargs), 'v:val[1] isnot 0'),
+                \   '((v:val[1] is 1)?'.
+                \     '(repeat("-", 1+(len(v:val[0])>1)).v:val[0]):'.
+                \   '((v:val[1] is 0)?'.
+                \     '(""):'.
+                \   '((type(v:val[1])=='.type([]).')?'.
+                \     '(join(map(copy(v:val[1]), '.
+                \               '"\"".'.s:prefexpr.'."\".'.
+                \                     'shellescape(v:val,    a:esc)"))):'.
+                \     '('.s:prefexpr.'.shellescape(v:val[1], a:esc)))))'
+                \  ))
+endfunction
 "▶1 utils.getcmd :: cmd, args, kwargs, esc → sh
-let s:prefexpr='repeat("-", 1+(len(v:val[0])>1)).v:val[0]." ="[len(v:val[0])>1]'
 function s:utils.getcmd(cmd, args, kwargs, esc)
     let cmd=a:cmd
     if !empty(a:kwargs)
-        let cmd.=' '.join(map(filter(items(a:kwargs), 'v:val[1] isnot 0'),
-                \             '((v:val[1] is 1)?'.
-                \               '(repeat("-", 1+(len(v:val[0])>1)).v:val[0]):'.
-                \             '((v:val[1] is 0)?'.
-                \               '(""):'.
-                \             '((type(v:val[1])=='.type([]).')?'.
-                \               '(join(map(copy(v:val[1]), '.
-                \                         '"\"".'.s:prefexpr.'."\".'.
-                \                           'shellescape(v:val,    a:esc)"))):'.
-                \               '('.s:prefexpr.'.'.
-                \                           'shellescape(v:val[1], a:esc)))))'
-                \            ))
+        let cmd.=' '.s:utils.kwargstostr(a:kwargs, a:esc)
     endif
     if !empty(a:args)
         let cmd.=' '.join(map(copy(a:args), 'shellescape(v:val, a:esc)'))
 "▶1 utils.diffopts :: opts, opts, difftrans → diffopts
 function s:utils.diffopts(opts, defaultdiffopts, difftrans)
     let opts=extend(copy(a:defaultdiffopts), a:opts)
+    if has_key(opts, 'numlines')
+        let opts.numlines.=''
+    endif
     let r={}
     call map(filter(copy(a:difftrans), 'has_key(opts, v:key)'),
             \'extend(r, {v:val : opts[v:key]})')
     endfunction
     let s:utils.using_ansi_esc_echo=0
 endif
+"▶1 nullnl :: [String] → [String]
+" Convert between lines (NL separated strings with NULLs represented as NLs) and 
+" NULL separated strings with NLs represented by NLs.
+function s:utils.nullnl(text)
+    let r=['']
+    for nlsplit in map(copy(a:text), 'split(v:val, "\n", 1)')
+        let r[-1].="\n".nlsplit[0]
+        call extend(r, nlsplit[1:])
+    endfor
+    if empty(r[0])
+        call remove(r, 0)
+    else
+        let r[0]=r[0][1:]
+    endif
+    return r
+endfunction
 "▶1 post resource
 call s:_f.postresource('utils', s:utils)
 "▶1
-call frawor#Lockvar(s:, '_pluginloaded')
+call frawor#Lockvar(s:, '')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲

autoload/aurum/drivers/git.vim

 scriptencoding utf-8
 execute frawor#Setup('0.1', {'@%aurum/drivers/common/hypsites': '0.0',
             \                                   '@%aurum/repo': '5.0',
-            \                   '@%aurum/drivers/common/utils': '0.0',
+            \                   '@%aurum/drivers/common/utils': '0.3',
             \                                           '@/os': '0.1',
             \                                      '@/options': '0.0',})
 let s:_messages={
 let s:logformat='%h-%H-%P-%at%n%an%n%ae%n%d%n%w(0,1,1)%B'
 let s:logkwargs={'format': s:logformat, 'encoding': 'utf-8', 'date-order': 1}
 function s:F.parsecs(csdata)
-    let cs={'branch': 'default'}
+    let cs={'branch': 'default', 'phase': 'unknown'}
     let [rev, hex, parents, time]=split(remove(a:csdata, 0), '-', 1)
     let cs.hex=hex
     let cs.parents=split(parents)
     let a:cs[a:prop]=r
     return r
 endfunction
-"▶1 nullnl :: [String] → [String]
-" Convert between lines (NL separated strings with NULLs represented as NLs) and 
-" NULL separated strings with NLs represented by NLs.
-function s:F.nullnl(text)
-    let r=['']
-    for nlsplit in map(copy(a:text), 'split(v:val, "\n", 1)')
-        let r[-1].="\n".nlsplit[0]
-        call extend(r, nlsplit[1:])
-    endfor
-    if empty(r[0])
-        call remove(r, 0)
-    else
-        let r[0]=r[0][1:]
-    endif
-    return r
-endfunction
 "▶1 git.status :: repo[, rev1[, rev2[, files[, clean]]]]
 let s:statchars={
             \'A': 'added',
     else
         let args=((a:0>2 && !empty(a:3))?(['--']+a:3):([]))
         let kwargs={'porcelain': 1, 'z': 1}
-        let s=s:F.nullnl(s:F.git(a:repo,'status',args,kwargs,2,'statusf'))[:-2]
+        let s=s:_r.utils.nullnl(
+                    \s:F.git(a:repo, 'status', args, kwargs, 2, 'statusf'))[:-2]
         let files={}
         while !empty(s)
             let line=remove(s, 0)
         \}
 function s:git.diff(repo, rev1, rev2, files, opts)
     let diffopts=s:_r.utils.diffopts(a:opts, a:repo.diffopts, s:difftrans)
-    if has_key(diffopts, 'unified')
-        let diffopts.unified=''.diffopts.unified
-    endif
     let kwargs=copy(diffopts)
     let args=[]
     if empty(a:rev2)

autoload/aurum/drivers/subversion.vim

             \           'time information for Subversion revisions',
             \  'r2fst': 'Second revision (%s) was found before the first (%s)',
             \     'u3': 'Subversion supports only three lines '.
-            \           'of unified context, you gave %u',
+            \           'of unified context, not requested %u',
             \ 'iediff': 'Diff parser error: expected at least one more line '.
             \           'after “====<…>====” separator line',
         \}
             \'tags': [],
             \'bookmarks': [],
             \'status': {'added': [], 'removed': [], 'modified': []},
+            \'phase': 'public',
         \}
 let s:logstatchars={
             \'M': 'modified',
                 \'initprops': ['rev', 'hex', 'parents', 'tags', 'bookmarks',
                 \              'branch', 'time', 'user', 'description',
                 \              'renames', 'copies', 'files', 'changes',
-                \              'removes'],
+                \              'removes', 'phase'],
                 \'hypsites': deepcopy(s:hypsites),
                 \'has_merges': 0, 'iterfuncs': deepcopy(s:iterfuncs),
                 \'hexreg': '\v[1-9]\d*',}
 @%aurum/drivers/common/utils:
     0.1: _r.utils.getcmd() now accepts kwargs key values 0 and [...]
     0.2: Added _r.utils.using_ansi_esc_echo
+    0.3: Added _r.utils.nullnl and _r.utils.kwargstostr
 
 vim: ft=help:tw=78

python/aurum/aumercurial.py

         cs_vim['branch']=branch
         cs_vim['tags']=cs.tags()
         cs_vim['bookmarks']=cs.bookmarks()
+        # FIXME For some reason using cs.phasestr() here results in an exception
     except AttributeError:
         pass
     return cs_vim
 
 @outermethod
 def get_phases(repo):
-    vim_extend(val={'phasemap': dict((lambda cs: (cs.hex(), cs.phasestr()))(repo[rev]) for rev in repo)})
+    vim_extend(val={'phasemap': dict((lambda cs: (cs.hex(), cs.phasestr()))(repo[rev])
+                                                 for rev in repo)})
 
 @outermethod
 def get_cs(repo, rev):
         vim.command('return '+json.dumps(r))
     finally:
         sys.path.pop(0)
+
+# vim: ft=python ts=4 sw=4 sts=4 et tw=100