Source

aurum / autoload / aurum / maputils.vim

Diff from to

autoload/aurum/maputils.vim

 "▶1
 scriptencoding utf-8
-execute frawor#Setup('0.1', {'@/resources': '0.0',
+execute frawor#Setup('0.2', {'@/resources': '0.0',
             \                       '@/os': '0.0',})
 let s:_messages={
             \'plinst': 'If you install Command-T, Ctrlp, FuzzyFinder, unite, '.
 function s:r.readfilewrapper(file, repo, rev)
     return a:repo.functions.readfile(a:repo, a:rev, a:file)
 endfunction
-"▶1 getnthparentfile :: repo, rev, file, n → (hex, file)
-function s:r.getnthparentfile(repo, rev, file, n)
+"▶1 getnthparentfile :: repo, rev, file, n[, changedonly] → (hex, file)
+function s:r.getnthparentfile(repo, rev, file, n, ...)
     let n=a:n
     let shift=(n>0 ? 1 : -1)
     let file=a:file
+    let prevhex=0
     let hex=a:repo.functions.getrevhex(a:repo, a:rev)
-    while n
+    while n && hex isnot# prevhex
+        let prevhex=hex
         let cs=a:repo.functions.getnthparent(a:repo, hex, shift)
         let rhex=(shift>0 ? hex : cs.hex)
         if cs.hex is# hex
             call map(copy(renames), 'extend(rrenames, {v:val : v:key})')
             let renames=rrenames
         endif
+        let haschanges=get(a:000, 0, 1)
         if get(renames, file, 0) isnot 0
             let file=renames[file]
+            let haschanges=1
+        elseif !haschanges
+            let status=a:repo.functions.status(a:repo, prevhex, hex, [a:file])
+            let haschanges=!empty(filter(copy(status),
+                        \              'v:key isnot# "clean" && !empty(v:val)'))
         endif
-        let n-=shift
+        if haschanges
+            let n-=shift
+        endif
     endwhile
     return [hex, file]
 endfunction