diff --git a/uppsrc/TextDiffCtrl/Diff.iml b/uppsrc/TextDiffCtrl/Diff.iml index d88066ed0..d2b318186 100644 --- a/uppsrc/TextDiffCtrl/Diff.iml +++ b/uppsrc/TextDiffCtrl/Diff.iml @@ -14,36 +14,36 @@ IMAGE_ID(CopyLeft) IMAGE_ID(CopyRight) IMAGE_BEGIN_DATA -IMAGE_DATA(120,156,237,89,191,107,219,64,20,86,140,109,44,145,154,44,165,80,92,2,221,226,45,67,193,83,108,10,165,193,187,198) -IMAGE_DATA(146,193,91,55,67,11,221,172,127,192,80,8,153,189,123,240,228,14,93,34,79,129,102,204,218,161,193,80,232,218,64,231) -IMAGE_DATA(171,62,89,103,159,79,247,83,231,80,67,245,133,135,229,187,239,123,239,221,187,167,67,114,206,3,47,240,4,232,38,22) -IMAGE_DATA(39,70,50,155,36,118,204,113,46,48,215,233,120,100,60,94,25,174,51,254,69,198,129,134,132,161,71,8,217,54,140,101) -IMAGE_DATA(92,196,154,136,56,28,55,205,7,113,100,60,204,209,156,13,121,177,65,220,73,150,163,110,29,199,22,117,161,56,206,252) -IMAGE_DATA(175,243,201,98,165,56,151,108,142,17,90,45,175,149,4,31,35,201,229,210,91,226,26,99,60,7,115,252,162,48,198,114) -IMAGE_DATA(169,31,73,49,199,148,39,242,197,26,229,169,56,240,97,27,215,116,29,108,93,40,95,84,23,35,212,146,63,6,207,18) -IMAGE_DATA(251,158,117,195,93,246,253,46,9,66,19,33,116,94,208,61,223,57,222,90,79,231,211,239,92,64,33,166,83,111,10,71) -IMAGE_DATA(248,20,85,91,197,227,177,56,242,142,108,10,82,66,143,208,219,220,235,38,22,10,125,180,146,57,116,138,232,15,227,45) -IMAGE_DATA(169,86,237,195,76,43,246,97,167,221,246,113,83,72,187,241,33,175,149,41,236,111,255,255,12,229,97,96,14,151,102,114) -IMAGE_DATA(105,102,151,155,201,229,102,118,57,76,92,14,179,93,28,166,37,10,96,127,14,131,166,195,205,214,78,155,175,83,88,251) -IMAGE_DATA(118,243,0,106,173,29,38,173,93,36,119,104,163,164,153,219,5,154,153,106,67,238,145,175,153,86,97,168,204,135,106,97) -IMAGE_DATA(34,30,157,23,213,132,213,34,142,12,208,130,131,218,80,30,171,29,36,71,155,14,208,82,62,123,29,165,7,137,126,175) -IMAGE_DATA(193,97,53,212,108,246,26,185,179,218,225,230,133,198,24,88,171,77,222,60,176,71,136,203,239,181,13,80,123,131,30,21) -IMAGE_DATA(30,6,71,65,240,235,240,240,144,152,24,184,188,190,209,104,76,223,53,26,201,43,138,167,52,112,192,229,245,181,90,109) -IMAGE_DATA(8,223,58,61,56,224,242,250,131,131,131,22,230,102,213,170,84,139,57,112,192,21,21,198,247,253,27,213,26,48,7,142) -IMAGE_DATA(172,176,245,122,125,252,34,8,254,200,244,152,3,71,166,175,84,42,29,228,247,173,82,201,105,49,134,57,112,100,122,224) -IMAGE_DATA(73,16,252,252,84,175,231,244,24,195,156,74,11,96,111,94,249,254,3,175,199,152,104,223,120,84,171,213,144,238,3,107) -IMAGE_DATA(24,195,156,78,79,215,192,247,156,73,238,187,2,250,227,165,239,255,160,177,113,45,235,25,17,158,7,193,195,107,223,95) -IMAGE_DATA(175,29,215,24,51,213,35,38,187,135,184,198,152,169,158,238,1,107,210,218,239,205,147,193,10,154,71,194,72,99,30,185) -IMAGE_DATA(191,191,23,26,213,143,63,199,66,123,12,61,251,157,213,227,90,167,23,249,98,227,243,62,88,189,190,142,27,123,140,248) -IMAGE_DATA(187,88,127,62,182,188,254,155,222,200,235,49,182,88,44,164,122,140,127,249,250,91,154,63,180,50,61,213,178,122,199,254) -IMAGE_DATA(253,183,216,229,97,208,110,183,195,249,124,78,226,56,38,151,151,151,203,32,8,158,218,232,187,221,238,40,142,71,228,250) -IMAGE_DATA(250,58,245,65,109,62,255,72,224,91,167,239,245,122,35,66,62,228,126,135,190,189,245,8,230,60,205,187,251,74,63,202) -IMAGE_DATA(233,227,120,173,103,55,55,231,99,165,127,175,210,179,241,115,62,176,198,201,164,79,162,168,183,101,163,209,27,209,250,119) -IMAGE_DATA(241,163,26,245,193,67,214,152,186,134,103,121,162,188,52,135,109,46,47,222,71,202,61,61,61,37,131,193,128,204,102,51) -IMAGE_DATA(153,158,247,177,254,4,183,223,239,147,171,171,171,212,20,122,214,199,218,104,124,86,27,69,145,76,159,203,131,198,103,181) -IMAGE_DATA(138,248,202,250,81,173,141,94,105,229,97,192,235,203,195,64,50,38,131,76,159,203,235,228,228,100,171,63,146,215,44,89) -IMAGE_DATA(127,8,215,118,118,118,38,237,15,248,86,248,72,63,209,95,178,254,192,156,34,143,212,86,122,113,127,72,244,91,121,172) -IMAGE_DATA(244,226,254,80,232,183,234,39,235,15,193,250,237,177,103,175,9,123,132,102,242,94,56,180,255,193,104,75,91,228,209,143) -IMAGE_DATA(213,22,209,15,110,244,143,163,170,199,83,215,248,188,143,162,112,169,127,137,66,40,15,131,162,64,163,54,29,254,221,136) -IMAGE_DATA(27,197,197,7,189,89,69,62,108,15,131,129,254,215,125,171,248,166,122,151,245,187,214,191,4,143,191,233,51,205,147,0) +IMAGE_DATA(120,156,237,153,49,107,219,64,20,199,21,99,27,75,164,38,75,41,20,151,64,183,120,203,80,240,20,155,66,105,240,238) +IMAGE_DATA(177,100,240,214,205,208,66,55,235,11,24,10,33,179,119,15,158,220,161,75,228,41,208,140,89,59,52,24,10,93,27,232) +IMAGE_DATA(124,213,95,214,41,79,167,187,211,157,228,180,134,248,133,135,228,187,247,123,239,221,187,167,67,118,78,61,199,115,36,210) +IMAGE_DATA(13,53,8,149,197,58,13,245,80,176,57,195,92,167,227,176,201,100,173,184,143,237,207,98,27,48,108,48,112,24,99,105) +IMAGE_DATA(197,88,108,139,88,83,153,141,96,27,229,131,56,42,59,204,241,156,13,237,2,131,184,211,56,199,188,117,28,90,212,133) +IMAGE_DATA(203,97,236,63,201,39,142,21,201,169,98,115,140,164,213,114,90,97,240,9,146,92,173,156,21,238,49,38,218,96,78,92) +IMAGE_DATA(20,198,168,45,247,163,40,230,132,219,201,124,81,229,118,58,27,248,176,141,107,186,14,90,23,110,47,171,139,145,212,194) +IMAGE_DATA(63,34,207,66,253,30,119,195,77,252,249,38,12,194,19,97,124,94,210,61,223,5,187,132,231,243,209,103,33,160,84,102) +IMAGE_DATA(51,103,6,71,184,202,170,173,179,19,101,121,224,28,216,20,228,177,10,35,90,136,143,55,230,95,242,52,103,202,219,172) +IMAGE_DATA(69,245,136,91,229,81,130,77,249,40,200,38,62,74,176,143,66,118,135,129,185,148,106,196,178,15,194,38,30,68,75,31) +IMAGE_DATA(155,56,76,82,121,88,50,27,229,29,251,156,31,157,108,207,97,208,44,240,226,198,165,237,12,66,186,83,152,125,123,255) +IMAGE_DATA(2,106,205,142,194,151,220,34,185,131,245,195,230,196,181,40,59,16,94,249,154,81,21,70,218,124,56,11,149,217,241,121) +IMAGE_DATA(89,77,40,139,56,42,1,11,27,212,134,219,81,118,232,92,229,174,17,44,183,167,247,80,147,189,134,13,101,184,218,236) +IMAGE_DATA(53,114,167,236,232,254,11,141,177,96,173,54,121,139,130,61,66,92,113,175,109,4,181,55,232,81,233,97,112,224,121,191) +IMAGE_DATA(246,247,247,153,137,194,86,228,27,141,198,236,93,163,17,30,230,142,86,97,3,91,145,175,213,106,35,248,206,227,97,3) +IMAGE_DATA(91,145,223,219,219,107,97,110,94,173,42,89,204,193,6,182,178,194,184,174,123,165,91,3,230,96,163,42,108,189,94,159) +IMAGE_DATA(188,240,188,63,42,30,115,176,81,241,149,74,165,131,252,190,85,42,25,22,99,152,131,141,138,135,60,241,188,159,159,234) +IMAGE_DATA(245,12,143,49,204,233,88,8,246,230,149,235,222,137,60,198,100,251,38,74,181,90,29,240,125,160,138,49,204,229,241,124) +IMAGE_DATA(13,98,207,153,228,190,41,65,127,188,116,221,31,60,54,238,85,61,35,147,231,158,119,247,218,117,147,181,227,30,99,166) +IMAGE_DATA(60,98,210,61,196,61,198,76,121,190,7,84,149,181,223,154,55,131,181,200,94,69,137,250,57,234,176,219,219,91,169,114) +IMAGE_DATA(126,242,57,144,234,67,240,244,51,229,113,159,199,203,124,209,248,162,15,202,231,215,145,252,238,250,0,241,55,177,254,108) +IMAGE_DATA(108,117,253,239,123,35,203,99,108,185,92,42,121,140,127,249,250,91,153,63,88,21,207,89,202,151,236,223,255,43,155,60) +IMAGE_DATA(12,218,237,246,96,177,88,176,32,8,216,249,249,249,202,243,188,167,54,124,183,219,29,7,193,152,93,94,94,70,62,184) +IMAGE_DATA(46,22,31,25,124,231,241,189,94,111,204,216,135,204,119,228,235,107,135,97,46,52,129,15,22,95,21,252,56,195,7,65) +IMAGE_DATA(194,211,205,205,248,88,243,239,117,60,141,159,241,129,53,78,167,125,230,251,189,148,142,199,111,100,235,215,174,197,80,184) +IMAGE_DATA(15,81,84,141,153,215,240,212,78,150,87,206,97,155,201,75,244,17,217,30,31,31,179,225,112,200,230,243,185,138,23,125) +IMAGE_DATA(36,87,216,246,251,125,118,113,113,17,169,134,167,62,18,229,241,41,235,251,190,138,207,228,193,227,83,86,19,95,91,63) +IMAGE_DATA(206,218,240,90,221,29,6,34,191,59,12,20,99,42,81,241,153,188,142,142,142,82,253,17,126,205,82,245,135,116,109,39) +IMAGE_DATA(39,39,202,254,128,111,141,143,232,138,254,82,245,7,230,52,121,68,186,230,229,253,161,224,83,121,172,121,121,127,104,248) +IMAGE_DATA(84,253,84,253,33,89,191,189,108,217,215,132,45,146,102,248,189,112,100,255,131,81,138,45,242,234,71,217,34,252,240,42) +IMAGE_DATA(255,117,84,247,122,90,54,190,232,163,168,148,169,255,78,10,201,238,48,40,42,104,212,102,241,255,128,68,15,74,25,31) +IMAGE_DATA(252,97,149,249,176,61,12,134,249,191,238,91,197,55,229,203,172,191,108,253,119,34,202,95,224,168,209,101,0,0,0,0) IMAGE_END_DATA(1024, 13) diff --git a/uppsrc/ide/Diff.cpp b/uppsrc/ide/Diff.cpp index facf57489..c501b2416 100644 --- a/uppsrc/ide/Diff.cpp +++ b/uppsrc/ide/Diff.cpp @@ -5,10 +5,12 @@ #include struct RepoDiff : DiffDlg { - FrameTop r; + FrameTop pane; + DropList r, branch; int kind; + void LoadGit(); void Load(); void Execute(const String& f); @@ -22,6 +24,7 @@ void RepoDiff::Execute(const String& f) kind = GetRepoKind(f); editfile = f; if(kind == SVN_DIR) { + pane << r.SizePos(); WaitCursor wait; String log = HostSys("svn log " + f); if(log.IsVoid()) { @@ -52,59 +55,91 @@ void RepoDiff::Execute(const String& f) } } } - } - - if(kind == GIT_DIR) { - String log = GitCmd(GetFileFolder(f), "log --format=medium --date=short " + GetFileName(f)); - StringStream ss(log); - String author, date, commit; - while(!ss.IsEof()) { - String l = TrimBoth(ss.GetLine()); - if(l.GetCount() == 0) { - while(!ss.IsEof()) { - l = ss.GetLine(); - if(l.GetCount()) - break; - } - String msg = l; - while(!ss.IsEof()) { - l = ss.GetLine(); - if(l.GetCount() == 0) - break; - msg << l; - } - if(commit.GetCount()) - r.Add(commit, "\1[g [@b \1" + date + "\1] [@r \1" + author + "\1]: [* \1" + Join(Split(msg, CharFilterWhitespace), " ")); - date = commit = author = Null; - } - else - if(l.TrimStart("Author:")) { - int q = l.Find('<'); - author = TrimBoth(q >= 0 ? l.Mid(0, q) : l); - } - else - if(l.TrimStart("Date:")) - date = TrimBoth(l); - else - if(l.TrimStart("commit")) - commit = TrimBoth(l); + if(r.GetCount() == 0) { + Exclamation("No parsable history for the file"); + return; } + + if(r.GetCount()) + r.SetIndex(0); Load(); } - if(r.GetCount() == 0) { - Exclamation("No parsable history for the file"); - return; + if(kind == GIT_DIR) { + pane << branch.LeftPos(0, Zx(100)).VSizePos() + << r.HSizePos(Zx(100) + DPI(2), 0).VSizePos(); + + String branches = GitCmd(GetFileFolder(f), "branch"); + StringStream ss(branches); + String author, date, commit; + int ci = -1; + while(!ss.IsEof()) { + String l = ss.GetLine(); + if(l.StartsWith("* ")) { + ci = branch.GetCount(); + branch.Add(l.Mid(2)); + } + if(l.StartsWith(" ")) + branch.Add(l.Mid(2)); + } + + if(ci >= 0) + branch.SetIndex(ci); + + LoadGit(); } - r.SetIndex(0); - Load(); - DiffDlg::Execute(f); } +void RepoDiff::LoadGit() +{ + String log = GitCmd(GetFileFolder(editfile), "log --format=medium --date=short " + + ~~branch + " -- " + GetFileName(editfile)); + StringStream ss(log); + String author, date, commit; + r.ClearList(); + while(!ss.IsEof()) { + String l = TrimBoth(ss.GetLine()); + if(l.GetCount() == 0) { + while(!ss.IsEof()) { + l = ss.GetLine(); + if(l.GetCount()) + break; + } + String msg = l; + while(!ss.IsEof()) { + l = ss.GetLine(); + if(l.GetCount() == 0) + break; + msg << l; + } + if(commit.GetCount()) + r.Add(commit, "\1[g [@b \1" + date + "\1] [@r \1" + author + "\1]: [* \1" + Join(Split(msg, CharFilterWhitespace), " ")); + date = commit = author = Null; + } + else + if(l.TrimStart("Author:")) { + int q = l.Find('<'); + author = TrimBoth(q >= 0 ? l.Mid(0, q) : l); + } + else + if(l.TrimStart("Date:")) + date = TrimBoth(l); + else + if(l.TrimStart("commit")) + commit = TrimBoth(l); + } + + if(r.GetCount()) + r.SetIndex(0); + Load(); +} + void RepoDiff::Load() { + if(IsNull(r)) + return; if(kind == SVN_DIR) extfile = HostSys("svn cat " + editfile + '@' + AsString(~r)); if(kind == GIT_DIR) @@ -114,11 +149,17 @@ void RepoDiff::Load() RepoDiff::RepoDiff() { - r.Height(EditField::GetStdHeight()); + pane.Height(EditField::GetStdHeight()); r.SetDropLines(32); + branch.SetDropLines(32); Icon(UrepoImg::RepoDiff()); - diff.InsertFrameRight(r); - r <<= THISBACK(Load); + diff.InsertFrameRight(pane); + r << [=] { Load(); }; + branch << [=] { LoadGit(); }; + Sizeable().Zoomable(); + Rect r = TheIde()->GetWorkArea(); + r.Deflate(DPI(30), DPI(30)); + SetRect(r); } void RunRepoDiff(const String& filepath)