Commits

ZyX_I  committed 28a3aea

@aurum/log: Added sorting of copies and renames (thus result is more stable)
Made template function omit generating text that will be thrown away or empty in more cases

  • Participants
  • Parent commits 6827f5e

Comments (0)

Files changed (3)

File plugin/aurum/log.vim

     let rt=[]
     let special={}
     let rsl=len(a:rensep)
-    for [cur, old] in items(filter(copy(a:renames), 'type(v:val)=='.type('')))
+    for [cur, old] in sort(items(filter(copy(a:renames),
+                \                       'type(v:val)=='.type(''))))
         let cl=len(rt)
         let fl=len(cur)
         let ol=len(old)
         elseif lkw is# 'files' || lkw is# 'changes'
             let addedif=1
             let func+=['if !empty(a:cs.'.kw.')']
+        elseif lkw is# 'renames' || lkw is# 'copies'
+            let addedif=1
+            let func+=['if !empty(filter(values(a:cs.'.lkw.'), '.
+                        \               '"v:val isnot 0"))']
         endif
         "▲3
         let func+=['let text+=[""]']
         for str in lit
             let i+=1
             if !empty(str)
-                let func+=['let text[-1].='.string(str)]
+                if i==0
+                    let func[-1]='let text+=['.string(str).']'
+                else
+                    let func+=['let text[-1].='.string(str)]
+                endif
             endif
             if lmeta>i
                 "▶3 Define variables
                 "▶3 Add complex multiline statement
                 let addedif2=0
                 if ke[0]==2
+                    let func+=['let lstr=remove(text, -1)']
                     "▶4 Add missing if’s
                     if !addedif
                         if kw is# 'stat'
                         elseif kw is# 'files' || kw is# 'changes'
                             let addedif2=1
                             let func+=['if !empty(a:cs.'.kw.')']
+                        elseif kw is# 'renames' || kw is# 'copies'
+                            let addedif2=1
+                            let func+=['if !empty(filter(values(a:cs.'.kw.'), '.
+                                        \               '"v:val isnot 0"))']
                         endif
                     endif
                     "▲4
                     let expr=substitute(expr, '@<@', 'lstr', 'g')
-                    let func+=['let lstr=remove(text, -1)',
-                                \'let [ntext, sp]='.expr]+
+                    let func+=['let [ntext, sp]='.expr]+
                                 \   (has_key(arg, 'flbeg')?
                                 \       ['let ntext[0]='.string(arg.flbeg).
                                 \                                  '.ntext[0]']:
                                 \'call extend(special, sp)']
                 "▶3 Add simple multiline statement
                 elseif ke[0]
+                    let func+=['let lstr=remove(text, -1)']
                     "▶4 Add missing if’s
                     if !addedif && kw is# 'patch'
                         let addedif2=1
                     endif
                     "▲4
                     let func+=['let ntext='.expr,
-                                \'call map(ntext, '.
-                                \         'string(remove(text, -1)).".v:val")']+
+                                \'call map(ntext, string(lstr).".v:val")']+
                                 \   (has_key(arg, 'flbeg')?
                                 \       ['let ntext[0]='.string(arg.flbeg).
                                 \                                  '.ntext[0]']:

File test/cmd-move,track,junk-subdir.in

 :command -bar WTax :WTA template g:template showfiles showrenames showcopies
 :command -nargs=1 SR :R silent <args>
 :let g:subdir='directory/subdir'
-:let g:template="$rev\n*$changes\n@$description\n>$renames\n+$copies"
+:let g:template="$rev\n*$changes\n@$description\n>$renames\n+$copies\n$empty"
 :W{{{1 Track directory
 :R call mkdir(g:subdir)
 :R call writefile(['Dummy string'], g:subdir.'/subfile')

File test/cmd-move,track,junk-subdir.ok

 A directory/subdir/subfile2
 @  27
 |  *directory/subdir/subfile, directory/subdir/subfile2
+|  @Added directory/subdir/subfile{,2}
 {{{1 Move directory to unexistent directory
 A unexistentdir/file
 A unexistentdir/subdir/subfile
 |  *unexistentdir/subdir/subfile2
 |  @Moved directory/ to unexistentdir/
 |  >directory/file to unexistentdir/file
+|  >directory/subdir/subfile to unexistentdir/subdir/subfile
 |  >directory/subdir/subfile2 to unexistentdir/subdir/subfile2
 {{{1 Move directory to an existing directory
 @  29
 |  *directory/subdir/subfile
+|  @Recreated directory/subdir/subfile
 A directory/unexistentdir/file
 A directory/unexistentdir/subdir/subfile
 A directory/unexistentdir/subdir/subfile2
 |  @Moved unexistentdir
 |  >unexistentdir/file to directory/unexistentdir/file
 |  >unexistentdir/subdir/subfile to directory/unexistentdir/subdir/subfile
+|  >unexistentdir/subdir/subfile2 to directory/unexistentdir/subdir/subfile2
 {{{1 Junk directory
 R directory/subdir/subfile
 R directory/unexistentdir/file
 |  *directory/subdir/subfile, directory/unexistentdir/file
 |  *directory/unexistentdir/subdir/subfile
 |  *directory/unexistentdir/subdir/subfile2
+|  @Removed directory