Commits

ZyX_I  committed 2abb46f

@aurum/drivers/*: Added rf-getrepoprop(, "branch")
autoload/aurum: Added aurum#branch()
autoload/Powerline/**: Added powerline support

  • Participants
  • Parent commits e7319fd

Comments (0)

Files changed (9)

File autoload/Powerline/Functions/aurum.vim

+execute frawor#Setup('0.0', {'autoload/aurum': '0.1'})
+function Powerline#Functions#aurum#GetBranch(symbol)
+    let r=aurum#branch()
+    return empty(r) ? '' : a:symbol.' '.r
+endfunction

File autoload/Powerline/Segments/aurum.vim

+let g:Powerline#Segments#aurum#segments = Pl#Segment#Init(['aurum',
+            \ 1,
+            \ Pl#Segment#Create('branch', '%{Powerline#Functions#aurum#GetBranch("$BRANCH")}')
+            \])

File autoload/aurum.vim

 "▶1 
-execute frawor#Setup('0.0', {'@aurum/repo': '4.0',
+execute frawor#Setup('0.1', {'@aurum/repo': '4.0',
             \               '@aurum/cache': '0.0',})
 "▶1 aurum#repository
 function aurum#repository()
                 \          '!empty(v:val)')), 0, 0)
 endfunction
 let s:_functions+=['aurum#status']
+"▶1 aurum#branch
+function aurum#branch(...)
+    let repo=((a:0)?(a:1):(aurum#repository()))
+    if empty(repo)
+        return ''
+    endif
+    return s:_r.cache.get('branch', repo.functions.getrepoprop,
+                \         [repo, 'branch'], {})
+endfunction
+let s:_functions+=['aurum#branch']
 "▶1
 call frawor#Lockvar(s:, '_pluginloaded,_r')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲

File doc/aurum.txt

     |aurum-rf-status|) or zero. Cached (update time is controlled by 
     |g:aurum_statuscachetime|).
 
+aurum#branch :: ([{repo}]) -> branch                          *aurum#branch()*
+    Returns a current branch name (uses |aurum-rf-getrepoprop|). Should be 
+    faster then using |aurum#changeset()| and getting “branch” key from 
+    returned changeset. Cached (update time is controlled by 
+    |g:aurum_branchcachetime|).
+
 ------------------------------------------------------------------------------
 2.3. aurum:// pseudo-protocol                                       *aurum://*
 
 also global-local: you can also define an option for the current buffer using 
 buffer-local b:aurum_option (b:aurumOptions.option) variable.
 
-                                                         *g:aurum_cscachetime*
+                              *g:aurum_branchcachetime*  *g:aurum_cscachetime*
 *cachetime                   *g:aurum_statuscachetime* *g:aurum_repocachetime*
     Unsigned integer, defines time since last cache update after which cache 
     will become invalid. Time is specified in seconds.
-    Type  Default  Used by ~
-    cs       3     |aurum#changeset()|
-    status   5     |aurum#status()|
-    repo     7     |aurum#repository()|, all completion functions
+    Type    Default  Used by ~
+    branch     2     |aurum#branch()|
+    cs         3     |aurum#changeset()|
+    status     5     |aurum#status()|
+    repo       7     |aurum#repository()|, all completion functions
 
 ignorefiles                                              *g:aurum_ignorefiles*
     List containing 0 or more strings. Determines when “files” option given to 
                    can be created/revision can be named.
     url            Remote repository URL. For mercurial it is either 
                    paths.default-push or paths.default whichever is defined.
+    branch         Current branch, likely an equivalent for getting value of 
+                   “branch” key from changeset object returned by 
+                   |aurum-rf-getwork|. Used for |aurum#branch()|.
   reltorepo :: path -> path                               *aurum-rf-reltorepo*
     Turn absolute or relative to current directory path into relative to 
     repository root one.
     1.0: Renamed |:AuStatus| “rev1” and “rev2” options to “rev” and “wdrev” 
          respectively. Same for |aurum://status| “rev1” and “rev2” options.
 @aurum/commit:
-    1.0: Added fifth argument to _r.commit.commit()
+    1.0: Added fifth argument to _r.commit.commit().
 @aurum/annotate:
-    1.0: Removed one argument to _r.annotate.setannbuf()
+    1.0: Removed one argument to _r.annotate.setannbuf().
 @aurum/cmdutils:
-    1.0: Removed cmdutils.prevbuf()
+    1.0: Removed cmdutils.prevbuf().
+autoload/aurum:
+    0.1: Added |aurum#branch()| function.
 
 vim: ft=help:tw=78

File plugin/aurum/cache.vim

     finish
 endif
 let s:_options={
+            \'branchcachetime': {'default': 2, 'checker': 'range 0 inf'},
             \'cscachetime':     {'default': 3, 'checker': 'range 0 inf'},
             \'statuscachetime': {'default': 5, 'checker': 'range 0 inf'},
             \'repocachetime':   {'default': 7, 'checker': 'range 0 inf'},

File plugin/aurum/drivers/git.vim

 endfunction
 "▶1 git.getrepoprop :: repo, propname → a
 function s:git.getrepoprop(repo, prop)
-    if a:prop is# 'url'
+    if a:prop is# 'branch'
+        let branches=s:F.git(a:repo, 'branch', [], {'l': 1}, 0,
+                    \        'branchf')[:-2]
+        return get(filter(branches, 'v:val[0] is# "*"'), 0, '')[2:]
+    elseif a:prop is# 'url'
         let r=get(s:F.git(a:repo, 'config', ['remote.origin.pushurl'], {}, 0),
                     \0, 0)
         if v:shell_error || r is 0

File plugin/aurum/drivers/mercurial.vim

             \  'keyfail': 'Failed to get %s for the repository %s: %s',
             \   'csfail': 'Failed to get changeset %s '.
             \             'from the repository %s: %s',
+            \    'bfail': 'Failed to get current branch '.
+            \             '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 '.
         let d={}
         try
             " XXX get_updates also modifies a:repo
+            " execute s:_r.py.cmd 'import cProfile as profile'
+            " execute s:_r.py.cmd 'profile.run("aurum.get_updates(vim.eval(''a:repo.path''), '.a:start.')", "python.profile")'
             execute s:_r.py.cmd 'aurum.get_updates(vim.eval("a:repo.path"), '.
                         \                          a:start.')'
         endtry
 endfunction
 else "▶2
 function s:hg.getrepoprop(repo, prop)
-    if a:prop is# 'tagslist' || a:prop is# 'brancheslist' ||
+    if a:prop is# 'branch'
+        return s:F.hg(a:repo, 'branch', [], {}, 0, 'b')[0]
+    elseif 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'

File plugin/aurum/drivers/subversion.vim

 endfunction
 "▶1 svn.getrepoprop :: repo, propname → a
 function s:svn.getrepoprop(repo, prop)
-    if a:prop is# 'url'
+    if a:prop is# 'branch'
+        return substitute(a:repo.svnprefix, '/*$', '', '')
+    elseif a:prop is# 'url'
         return a:repo.svnurl
     elseif a:prop is# 'tagslist'
         return ['HEAD', 'BASE', 'COMMITTED', 'PREV']

File python/aurum.py

     bookmarks_vim={}
     if hasattr(repo, 'listkeys'):
         bookmarks_vim=repo.listkeys('bookmarks')
-    d_vim={      'css': r,
-            'startrev': startrev,
-                'tags': tags_vim,
-           'bookmarks': bookmarks_vim,}
-    vim.eval('extend(a:repo, {"csnum": '+str(len(repo)+1)+'})')
-    vim.eval('extend(d, '+utf_dumps(d_vim)+')')
+    if hasattr(vim, 'bindeval'):
+        repo_vim=vim.bindeval('a:repo')
+        repo_vim['csnum']=len(repo)+1
+        d_vim=vim.bindeval('d')
+        d['css']=r
+        d['startrev']=startrev
+        d['tags']=tags_vim
+        d['bookmarks']=bookmarks_vim
+    else:
+        d_vim={      'css': r,
+                'startrev': startrev,
+                    'tags': tags_vim,
+               'bookmarks': bookmarks_vim,}
+        vim.eval('extend(a:repo, {"csnum": '+str(len(repo)+1)+'})')
+        vim.eval('extend(d, '+utf_dumps(d_vim)+')')
 
 def get_cs_tag_dict(l):
     r={}
                                         if hasattr(repo, 'listkeys') else [],
                  'url': lambda repo: repo.ui.config('paths', 'default-push') or
                                      repo.ui.config('paths', 'default'),
+              'branch': lambda repo: repo.dirstate.branch(),
         }
 @outermethod
 def get_repo_prop(repo, prop):