Commits

ZyX_I committed 3147389

@%aurum/record: Made A mapping on edited and included file discard the edits
Made R mapping on edited and excluded file discard the edits
Fixes #79

Comments (0)

Files changed (4)

autoload/aurum/record.vim

             \'removed':  'r',
             \'deleted':  'r',
         \}
+function s:F.restorefiles(bvar, sline, eline)
+    for file in map(range(a:sline, a:eline), 'a:bvar.lines[v:val-1][2:]')
+        let fullpath=s:_r.os.path.join(a:bvar.repo.path, file)
+        let backupfile=remove(a:bvar.filesbackup, fullpath)
+        call remove(a:bvar.backupfiles, backupfile)
+        call s:F.restorebackup(fullpath, backupfile)
+    endfor
+endfunction
 function s:F.runstatmap(action, ...)
     "▶2 buf, bvar, reset
     let buf=get(a:000, 0, bufnr('%'))
             if add
                 if status<2
                     let status+=2
+                elseif status==3
+                    let status=2
+                    call s:F.restorefiles(bvar, sline, eline)
                 endif
             else
                 if status>1
                     let status-=2
+                elseif status==1
+                    let status=0
+                    call s:F.restorefiles(bvar, sline, eline)
                 endif
             endif
             if oldstatus==status

test/cmd-record.in

 :Run silent AuStatus
 :bwipeout!
 :
+:W{{{1 edit-add-edit-remove-remove
+:command -nargs=1 -bar WThree :R call WriteFile(<q-args>.': '.tr(glob('3*'), "\n", ' '))
+:R AuRecord
+:WThree Initial state
+O:w
+:wincmd p
+:WThree After edit
+:Run 0
+A:WThree After add
+:Run 0
+O:w
+:wincmd p
+:WThree After edit
+:Run 0
+R:WThree After first remove
+:Run 0
+R:WThree After second remove
+:Run 0
+:bwipeout!
+:
 :source addmessages.vim

test/cmd-record.ok

 |  Tags: tip
 |  @ Added 1 and 2
 ? 3
+{{{1 edit-add-edit-remove-remove
+Initial state: 3
+After edit: 3 3.orig
+*? 3
+After add: 3
++? 3
+After edit: 3 3.orig
+*? 3
+After first remove: 3 3.orig
+^? 3
+After second remove: 3
+-? 3
 >>> Messages:
 
 

test/wine/cmd-record.ok

+{{{1 edit-commit-vimdiff
+*1: %TMPDIR%\test\cmd-recordrepo\hglines.lst
+#2: aurum:\\file:%ETMPDIR%%+test%+cmd-recordrepo:504f74154456dbb0e9441326514e42ce66279e62:hglines.lst
+ 3: aurum:\\commit:%ETMPDIR%%+test%+cmd-recordrepo:::0:hglines.lst
 {{{1 i mapping
 @  Changeset 27
 |  Tags: tip
 @  Changeset 31
 |  Tags: tip
 |  @ Mno
+{{{1 edit-commit-discard-commit
+@  Changeset 32
+|  Tags: tip
+|  @ Added 1 and 2
+? 3
+{{{1 edit-add-edit-remove-remove
+Initial state: 3
+After edit: 3 3.orig
+*? 3
+After add: 3
++? 3
+After edit: 3 3.orig
+*? 3
+After first remove: 3 3.orig
+^? 3
+After second remove: 3
+-? 3
 >>> Messages:
 
 
+
 Frawor:autoload/aurum/record:recnof:No files were selected for commiting
 Frawor:autoload/aurum/record:recnof:No files were selected for commiting
 Frawor:autoload/aurum/record:recnof:No files were selected for commiting
 Frawor:autoload/aurum/record:recnof:No files were selected for commiting
+
 <<< Messages^