summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-11-23 22:37:11 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2017-11-23 22:37:11 -0500
commit1e50bb66b9d70eecf642afba1c266a39a8cb23cf (patch)
treebde7761412f6895aba6d536a4f53c93d79240dfe
parent81ce784f367dcd29de79cb12a750b28a7facfaac (diff)
more
-rw-r--r--filter.go41
1 files changed, 33 insertions, 8 deletions
diff --git a/filter.go b/filter.go
index e263988..b02924c 100644
--- a/filter.go
+++ b/filter.go
@@ -14,7 +14,7 @@ import (
)
type fullcommit struct {
- metadata libfastimport.CmdCommit
+ metadata libfastimport.CmdCommit
fileactions []libfastimport.Cmd
}
@@ -28,7 +28,7 @@ type Filter struct {
refs map[string]string
mark int
- curCommitIn libfastimport.CmdCommit
+ curCommitIn *libfastimport.CmdCommit
curCommitOut map[string]fullcommit
}
@@ -159,17 +159,37 @@ func (f *Filter) Run() error {
}
return nil
case libfastimport.CmdReset:
- // TODO
+ // This should only happen once, at the very
+ // beginning. I think I can ignore it.
case libfastimport.CmdCommit:
- // TODO
+ f.curCommitIn = &cmdt
+ f.curCommitOut = map[string]fullcommit{}
case libfastimport.CmdCommitEnd:
- // TODO
+ for _, fc := range f.curCommitOut {
+ // TODO: I think I might need to issue
+ // a 'reset' command if
+ // f.refs[fc.metadata.Ref] isn't set.
+ err = f.backend.Do(fc.metadata)
+ if err != nil {
+ return err
+ }
+ f.refs[fc.metadata.Ref] = ":" + strconv.Itoa(fc.metadata.Mark)
+ for _, fileaction := range fc.fileactions {
+ err = f.backend.Do(fileaction)
+ if err != nil {
+ return err
+ }
+ }
+ }
+ f.curCommitIn = nil
+ f.curCommitOut = nil
case libfastimport.FileModify:
branchname := filename2branchname(string(cmdt.Path))
if branchname == "" {
continue
}
- branch_ref := f.toPfx + "/" + path.Dir(string(cmdt.Path))
+
+ branch_ref := f.toPfx + "/" + branchname
from_dataref, from_dataref_ok := f.refs[branch_ref]
if from_dataref_ok {
file_mode, file_dataref, _, err := f.backend.Ls(libfastimport.CmdLs{DataRef: from_dataref, Path: cmdt.Path})
@@ -194,8 +214,13 @@ func (f *Filter) Run() error {
Merge: nil,
}}
}
- //outcommit := f.curCommitOut[branch_ref]
- // TODO
+
+ outcommit := &f.curCommitOut[branch_ref]
+ outcommit.fileactions = append(outcommit.fileactions, libfastimport.FileModify{
+ Mode: cmdt.Mode,
+ Path: strings.TrimPrefix(string(cmdt.Path), branchname+"/"),
+ DataRef: cmdt.DataRef,
+ })
case libfastimport.FileDelete:
//ref := f.toPfx + "/" + path.Dir(string(cmdt.Path))
// TODO