Commits

ZyX_I committed 347d432

Slightly reduced number of shell calls in some situations

Comments (0)

Files changed (1)

plugin/aurum/drivers/mercurial.vim

     endfunction
 endif
 "▶2 hg.updatechangesets
+" TODO test updating in cases of rollback and commit
 function s:hg.updatechangesets(repo)
     let d={}
     let start=len(a:repo.cslist)-2
 else "▶3
 "▶4 getrfc :: repo, cs[, _] → _ + cs
 function s:F.getrfc(repo, cs, ...)
-    let slines=s:F.hg(a:repo, 'status --change '.a:cs.rev.' -armC', 0,
-                \     'ren', a:cs.rev)[:-2]
-    let copies={}
-    let removed=[]
-    let addedmodified=[]
-    let prevfile=0
-    for line in slines
-        let s=line[0]
-        let file=line[2:]
-        if s is# ' '
-            let copies[prevfile]=file
-        elseif s is# 'R'
-            let removed+=[file]
-        else
-            let addedmodified+=[file]
-        endif
-        let prevfile=file
-    endfor
-    let a:cs.renames = filter(copy(copies), 'index(removed, v:val)!=-1')
-    let a:cs.copies  = filter(copy(copies), '!has_key(a:cs.renames, v:key)')
-    if len(a:cs.parents)>1
+    if has_key(a:cs, 'gotrenames')
+        return
+    endif
+    if a:cs.rev==0
+        let a:cs.renames={}
+        let a:cs.copies={}
+        " First changeset cannot contain removed files. All files present in 
+        " this changeset were added by it.
+        let allfiles=a:repo.functions.getcsprop(a:repo, a:cs, 'allfiles')
+        let a:cs.files=allfiles
+        let a:cs.changes=allfiles
+        let a:cs.removes=[]
+    elseif len(a:cs.parents)>1
         " TODO Ask whether merge can have a changed file list
+        let a:cs.renames={}
+        let a:cs.copies={}
         let a:cs.files=[]
         let a:cs.changes=[]
         let a:cs.removes=[]
     else
+        let slines=s:F.hg(a:repo, 'status --rev '.a:cs.parents[0].' '.
+                    \                    '--rev '.a:cs.rev.' -armC', 0,
+                    \     'ren', a:cs.rev)[:-2]
+        let copies={}
+        let removed=[]
+        let addedmodified=[]
+        let prevfile=0
+        for line in slines
+            let s=line[0]
+            let file=line[2:]
+            if s is# ' '
+                let copies[prevfile]=file
+            elseif s is# 'R'
+                let removed+=[file]
+            else
+                let addedmodified+=[file]
+            endif
+            let prevfile=file
+        endfor
+        let a:cs.renames = filter(copy(copies), 'index(removed, v:val)!=-1')
+        let a:cs.copies  = filter(copy(copies), '!has_key(a:cs.renames, v:key)')
         let a:cs.files=sort(addedmodified)
         let a:cs.changes=sort(addedmodified+removed)
         let a:cs.removes=sort(removed)
     endif
+    lockvar! a:cs.renames a:cs.copies a:cs.files a:cs.changes a:cs.removes
     let a:cs.gotrenames=1
+    lockvar a:cs.gotrenames
 endfunction
 "▲4
 function s:F.setcsprop(repo, cs, propname)