Commits

ZyX_I committed 9770073

@aurum/repo, @aurum/drivers/mercurial: Added rf-revrange()
@aurum/log: Made it use rf-revrange() instead of cslist

Comments (0)

Files changed (6)

     dictionary. If this function is not called, then |aurum-repo.changesets| 
     dictionary contains only changesets that were used at least ones. Returns 
     list of changesets as contained in |aurum-repo.cslist|.
+  revrange :: hex, hex -> [ cs ]                           *aurum-rf-revrange*
+    Get revision range (inclusive). Numbers are to be treated specially, like 
+    it is done by |list-index|, but it is up to driver what it thinks is “last 
+    revision” (-1) or “first revision” (0).
   getcs :: hex -> cs                                          *aurum-rf-getcs*
     Returns |aurum-changeset| object which has given hash. See also 
     |aurum-cs.hex|.
                          changeset object. If yes returns its value, otherwise 
                          calls |aurum-rf-setcsprop|.
   |aurum-rf-reltorepo|     Uses |aurum-repo.path| to get requested path.
+  |aurum-rf-revrange|      Gets sublist of cslist (uses |aurum-repo.cslist| or 
+                         |aurum-rf-getchangesets| if repo.cslist is empty), 
+                         using values of |aurum-cs.rev| as indexes.
   |aurum-rf-difftobuffer|  Wrapper around |aurum-rf-diff|.
   |aurum-rf-diffname|      Uses value of first capturing group of given 
                          regular expression.
 |aurum-cs.branch| always contains string "default".
 |aurum-cs.tags|:
     Contains list of all references pointing to given commit, not just tags.
+|aurum-cs.rev| contains truncated hash (for use in |aurum://annotate|).
 |aurum-rf-status|:
     If two first optional arguments are given and are non-zero, then unknown 
     and deleted files won’t be shown (if any).
 |aurum-rf-checkdir| does not support bare repositories.
 |aurum-rf-setcsprop|:
     Is not able to get real renames, copies, changes, files and removes for 
-    merge changesets.
+    merge changesets (“real” here means “generated by merge conflicts”: if 
+    file A was modified in both parents, then it is to be listed in 
+    merge_cs.changes only if git was unable to merge changes and had to ask 
+    user to do this).
 
 ==============================================================================
 11. Changelog                                                *aurum-changelog*
     1.1: Added repo.branch and repo.label
     1.2: Added setlines function, default implementations of |aurum-rf-copy|, 
          |aurum-rf-getstats|, |aurum-rf-getcsprop| and |aurum-rf-diffname|.
+    1.3: Added default implementation of |aurum-rf-revrange|.
 @aurum:
     0.1: Added :AuBranch and :AuName
 @aurum/edit:
         let [rev1, rev2; revrange]=revrange
         let cs1=repo.functions.getcs(repo, rev1)
         let cs2=repo.functions.getcs(repo, rev2)
-        if cs1.rev>cs2.rev
+        if type(cs1.rev)==type(0) && cs1.rev>cs2.rev
             let [cs1, cs2]=[cs2, cs1]
         elseif cs1 is cs2
             let revisions+=[cs1.hex]

plugin/aurum/drivers/git.vim

     let cs.user=aname.' <'.aemail.'>'
     let cs.tags=split(a:csdata[line][2:-2], ', ')       | let line+=1
     let cs.bookmarks=[]
+    let cs.rev=cs.hex[:6]
     "▶2 get description
     let description=[]
     while a:csdata[line][0] is# ' '

plugin/aurum/drivers/mercurial.vim

     call a:repo.functions.updatechangesets(a:repo)
     return a:repo.cslist
 endfunction
+"▶1 hg.revrange :: repo, rev, rev → [cs]
+function s:F.getrev(repo, rev, cslist)
+    if type(a:rev)==type(0)
+        if a:rev<0
+            return len(a:cslist)+a:rev-1
+        else
+            return a:rev
+        endif
+    else
+        return a:repo.functions.getcs(a:repo, a:rev).rev
+    endif
+endfunction
+function s:hg.revrange(repo, rev1, rev2)
+    if empty(a:repo.cslist)
+        let cslist=a:repo.functions.getchangesets(a:repo)
+    else
+        let cslist=a:repo.cslist
+    endif
+    let rev1=s:F.getrev(a:repo, a:rev1, cslist)
+    let rev2=s:F.getrev(a:repo, a:rev2, cslist)
+    if rev1>rev2
+        let [rev1, rev2]=[rev2, rev1]
+    endif
+    return cslist[(rev1):(rev2)]
+endfunction
 "▶1 hg.getrevhex :: repo, rev → rev(hex)
 if s:usepythondriver "▶2
 function s:hg.getrevhex(repo, rev)
                 \         '@aurum/bufvars': '0.0',
                 \            '@aurum/edit': '1.0',
                 \                  '@/fwc': '0.3',
-                \            '@aurum/repo': '1.2',
+                \            '@aurum/repo': '1.3',
                 \             '@/commands': '0.0',
                 \            '@/functions': '0.0',
                 \              '@/options': '0.0',}, 0)
 function s:F.setup(read, repo, opts)
     let opts=a:opts
     let bvar={}
-    let cslist=a:repo.functions.getchangesets(a:repo)
+    call a:repo.functions.getchangesets(a:repo)
     "▶2 Add `ignorefiles'
     let ignorefiles=(has_key(opts, 'ignfiles')?
                 \               (opts.ignfiles):
     if has_key(opts, 'revrange')
         let opts.revs=map(copy(opts.revrange),
                     \'a:repo.changesets['.
-                    \   'a:repo.functions.getrevhex(a:repo, v:val)].rev')
+                    \   'a:repo.functions.getrevhex(a:repo, v:val)].hex')
     elseif get(opts, 'limit', 0)>0
-        let opts.revs=[a:repo.csnum-opts.limit-1,
-                    \       a:repo.csnum-2]
+        let opts.revs=[-opts.limit, -1]
     else
-        let opts.revs=[0, a:repo.csnum-2]
+        let opts.revs=[0, -1]
     endif
     "▶2 Process `revision' option
     if has_key(opts, 'revision')
         let hex=a:repo.functions.getrevhex(a:repo, opts.revision)
         let cs=a:repo.changesets[hex]
-        if cs.rev<opts.revs[1]
+        if type(cs.rev)==type(0) && cs.rev<opts.revs[1]
             let opts.revs[1]=cs.rev
         endif
         let opts.revisions={}
         endwhile
     endif
     "▲2
-    let css=cslist[opts.revs[0]:opts.revs[1]]
+    let css=a:repo.functions.revrange(a:repo, opts.revs[0], opts.revs[1])
     "▶2 Generate cs.{kw} for various options (`show{kw}'+`files')
     for key in ['renames', 'copies']
         if get(opts, 'show'.key, 0) || has_key(opts, 'files')
     let opts.templatefunc=s:F.temp.compile(bvar.templatelist,
                 \                               opts)
     "▲2
-    let css=cslist[opts.revs[0]:opts.revs[1]]
+    let css=a:repo.functions.revrange(a:repo, opts.revs[0], opts.revs[1])
     let text=s:F.glog.graphlog(a:repo, opts, css)
     let bvar.specials=text.specials
     let bvar.rectangles=text.rectangles

plugin/aurum/repo.vim

 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('1.2', {'@/resources': '0.0',
+    execute frawor#Setup('1.3', {'@/resources': '0.0',
                 \                       '@/os': '0.0',
                 \                  '@/options': '0.0',
                 \             '@aurum/bufvars': '0.0',}, 0)
     " with given name is added to changeset dictionary
     return cs[a:propname]
 endfunction
+"▶1 revrange :: repo, rev, rev → [cs]
+function s:F.getrev(repo, rev, cslist)
+    if type(a:rev)==type(0)
+        if a:rev<0
+            return len(a:cslist)+a:rev
+        else
+            return a:rev
+        endif
+    else
+        return a:repo.functions.getcs(a:repo, a:rev).rev
+    endif
+endfunction
+function s:deffuncs.revrange(repo, rev1, rev2)
+    if empty(a:repo.cslist)
+        let cslist=a:repo.functions.getchangesets(a:repo)
+    else
+        let cslist=a:repo.cslist
+    endif
+    let rev1=s:F.getrev(a:repo, a:rev1, cslist)
+    let rev2=s:F.getrev(a:repo, a:rev2, cslist)
+    if rev1>rev2
+        let [rev1, rev2]=[rev2, rev1]
+    endif
+    return cslist[(rev1):(rev2)]
+endfunction
 "▶1 difftobuffer
 function s:deffuncs.difftobuffer(repo, buf, ...)
     let diff=call(a:repo.functions.diff, [a:repo]+a:000, {})