DiffEditorDialogFromRevs opens a dialog for displaying diff between file at two different revisions from given repository if empty, defaults to: A = current HEAD, B = current WC file. -1, -2 etc also work as universal ways of specifying prior revisions.
(ctx core.Widget, repo vcs.Repo, file string, fbuf *Buffer, rev_a, rev_b string)
| 53 | // if empty, defaults to: A = current HEAD, B = current WC file. |
| 54 | // -1, -2 etc also work as universal ways of specifying prior revisions. |
| 55 | func DiffEditorDialogFromRevs(ctx core.Widget, repo vcs.Repo, file string, fbuf *Buffer, rev_a, rev_b string) (*DiffEditor, error) { |
| 56 | var astr, bstr []string |
| 57 | if rev_b == "" { // default to current file |
| 58 | if fbuf != nil { |
| 59 | bstr = fbuf.Strings(false) |
| 60 | } else { |
| 61 | fb, err := text.FileBytes(file) |
| 62 | if err != nil { |
| 63 | core.ErrorDialog(ctx, err) |
| 64 | return nil, err |
| 65 | } |
| 66 | bstr = text.BytesToLineStrings(fb, false) // don't add new lines |
| 67 | } |
| 68 | } else { |
| 69 | fb, err := repo.FileContents(file, rev_b) |
| 70 | if err != nil { |
| 71 | core.ErrorDialog(ctx, err) |
| 72 | return nil, err |
| 73 | } |
| 74 | bstr = text.BytesToLineStrings(fb, false) // don't add new lines |
| 75 | } |
| 76 | fb, err := repo.FileContents(file, rev_a) |
| 77 | if err != nil { |
| 78 | core.ErrorDialog(ctx, err) |
| 79 | return nil, err |
| 80 | } |
| 81 | astr = text.BytesToLineStrings(fb, false) // don't add new lines |
| 82 | if rev_a == "" { |
| 83 | rev_a = "HEAD" |
| 84 | } |
| 85 | return DiffEditorDialog(ctx, "DiffVcs: "+fsx.DirAndFile(file), astr, bstr, file, file, rev_a, rev_b), nil |
| 86 | } |
| 87 | |
| 88 | // DiffEditorDialog opens a dialog for displaying diff between two files as line-strings |
| 89 | func DiffEditorDialog(ctx core.Widget, title string, astr, bstr []string, afile, bfile, arev, brev string) *DiffEditor { |
no test coverage detected