ultimatepp/uppsrc/usvn/Diff.cpp
cxl 6023477e37 Core: LocalProcess now has (No)ConvertCharset option, fixes issue with usvn file history
git-svn-id: svn://ultimatepp.org/upp/trunk@3962 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2011-10-07 08:42:16 +00:00

84 lines
1.6 KiB
C++

#include "usvn.h"
#define IMAGECLASS UsvnImg
#define IMAGEFILE <usvn/usvn.iml>
#include <Draw/iml.h>
struct SvnDiff : DiffDlg {
FrameTop<DropList> r;
void Load();
void Execute(const String& f);
typedef SvnDiff CLASSNAME;
SvnDiff();
};
void SvnDiff::Execute(const String& f)
{
{
WaitCursor wait;
editfile = f;
String log = Sys("svn log " + f);
if(log.IsVoid()) {
Exclamation("Error executing 'svn log'");
return;
}
StringStream ss(log);
while(!ss.IsEof()) {
String l = ss.GetLine();
if(l[0] == 'r') {
Vector<String> h = Split(l, '|');
if(h.GetCount() > 3) {
String rev = TrimBoth(h[0]);
String s = rev;
Vector<String> t = Split(h[2], ' ');
if(t.GetCount() > 1)
s << ' ' << t[0];
s << ' ' << TrimBoth(h[1]);
while(!ss.IsEof()) {
l = ss.GetLine();
if(l.GetCount()) {
if(l[0] != '-')
s << ": " << l;
break;
}
}
r.Add(rev, s);
}
}
}
if(r.GetCount() == 0) {
Exclamation("No parsable history for the file");
return;
}
r.SetIndex(0);
Load();
}
DiffDlg::Execute(f);
}
void SvnDiff::Load()
{
diff.Set(LoadFile(editfile), extfile = Sys("svn cat " + editfile + '@' + AsString(~r), false));
}
SvnDiff::SvnDiff()
{
r.Height(EditField::GetStdHeight());
r.SetDropLines(32);
Icon(UsvnImg::SvnDiff());
diff.InsertFrameRight(r);
r <<= THISBACK(Load);
}
void RunSvnDiff(String editfile)
{
if(!CheckSvn())
return;
if(IsNull(editfile))
return;
SvnDiff dlg;
dlg.Execute(editfile);
}