// // Copyright 2008 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wDiff2DirsPane: // Displays output of diff2 for dirs #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wPane.h" #include "p4wDiff2DirsPane.h" #define RED 0xFF0000 #define GREEN 0x007F00 #define BLUE 0x0000FF p4wDiff2DirsPane::p4wDiff2DirsPane( p4wView & ParentView, p4wRequest & Request, StrPtr *path, StrPtr *path2 ) : p4wPane( ParentView, Request ), fSeenData(0), fDiff(0), fDel(0), fAdd(0), fTypes(0), fOther(0) { } p4wDiff2DirsPane::~p4wDiff2DirsPane() { } // ------------------------------------- // Render functions. // void p4wDiff2DirsPane::Begin() { // // Begin the pane. if( !fSeenData ) { p4wHtml htm(1); htm.comment( "BEGIN DIFF 2 DIRS PANE" ); p4wURL urlMaker; StrBuf grayIcon; StrBuf clearIcon; // // Used to generate a line underneath the title, and to genrate // vertical whitespace urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); // // Title with line underneath htm.beginTRow(); htm.beginCol(); htm.beginTable(0, "100%", "0", "0"); htm.beginTRow(); htm.beginCol(); htm.beginTable(); // put the whole line in a table to prevent wrapping htm.beginTRow(); htm.beginCol(); htm.beginSpan( "title" ); htm << "Diff Two Folders:"; htm.endSpan(); htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol( "top" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, 0, 0 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); fRequest << htm; (void)OutputDirectoryHeader( p4wStrBuf().EscapeHTML( fRequest.GetPath(), Unicode() ).Text(), 0, 1, fRequest.GetViewMode() != VM_WORKSPACE ); htm.Clear(); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "15", "10", "", 1, 0, 0 ); htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); htm.endTable(); htm.beginTable(0,0,0,0,0,"f"); htm.beginTRow(); htm.beginColHead(); htm.icon( clearIcon.Text(), "1", "27", "", 1, 0, 0 ); htm.endColHead(); htm.beginColHead(0, "left"); const StrPtr *dir1 = fRequest.GetDynArg( "fil1", HE_Page ); const StrPtr *rev1 = fRequest.GetDynArg( "rev1", HE_Page ); const StrPtr *sr1 = fRequest.GetDynArg( "sr1", HE_Page ); fPath1.Set( (dir1 && dir1->Length())? dir1->Text() : "Dir 1" ); htm.text( fPath1.Text() ); if (rev1) htm << "#" << rev1->Text(); else if (sr1) htm << "@" << sr1->Text(); htm.endColHead(); htm.beginColHead(0, "left"); const StrPtr *dir2 = fRequest.GetDynArg( "fil2", HE_Page ); const StrPtr *rev2 = fRequest.GetDynArg( "rev2", HE_Page ); const StrPtr *sr2 = fRequest.GetDynArg( "sr2", HE_Page ); fPath2.Set( (dir2 && dir2->Length())? dir2->Text() : "Dir 2" ); htm.text( fPath2.Text() ); if (rev2) htm << "#" << rev2->Text(); else if (sr2) htm << "@" << sr2->Text(); htm.endColHead(); htm.endTRow(); fRequest << htm; } } void p4wDiff2DirsPane::Render( StrDict * varList ) { if( !fSeenData ) { fSeenData = 1; fDiffsFound = 1; } p4wHtml htm( 1 ); p4wURL urlMaker; StrBuf newBase; StrBuf url; StrPtr * status = varList->GetVar( "status" ); StrPtr * depotFile = varList->GetVar( "depotFile" ); StrPtr * rev = varList->GetVar( "rev" ); StrPtr * type = varList->GetVar( "type" ); StrPtr * depotFile2 = varList->GetVar( "depotFile2" ); StrPtr * rev2 = varList->GetVar( "rev2" ); StrPtr * type2 = varList->GetVar( "type2" ); int lgth = fRequest.GetPath().Length(); htm.beginTRow(); htm.beginCol(0, "right"); if (*status == "content") { fDiff++; StrBuf icon; urlMaker.ConstructIcon( icon, "/rundiff17Icon", 17, 21, "Diff 2 files", 1 ); StrBufDict args; StrBuf baseNoPath; fRequest.UseNewBase( baseNoPath, NULL, "path", "//" ); if (fRequest.GetViewMode() == VM_WORKSPACE) fRequest.UseNewBase( baseNoPath, baseNoPath.Text(), "md", "c" ); args.SetVar( "fil1", depotFile ); args.SetVar( "fil2", depotFile2 ); args.SetVar( "rev1", rev ); args.SetVar( "rev2", rev2 ); fRequest.ConstructSafeURL( url, baseNoPath.Text(), AC_DIFF22, &args ); htm.beginLink( url.Text() ); htm << icon; htm.endLink(); htm.endCol(); htm.beginCol(); char *p = depotFile->Text(); if (!strncmp(p, fRequest.GetPath().Text(), lgth)) { p += lgth; if (*p == '/') p++; fRequest.ConstructSafeURL( url, p, AC_BROWSEFILE, NULL ); htm.beginLink( url.Text() ); if (fPath1 != fPath2) { char *q = strchr(p, '/'); if (q) p = q+1; } } else { fRequest.UseNewBase( newBase, NULL, "md", "d" ); fRequest.UseNewBase( newBase, newBase.Text(), "cd", "//" ); fRequest.UseNewBase( newBase, newBase.Text(), "wr", NULL ); fRequest.UseNewBase( newBase, newBase.Text(), "path", depotFile->Text() ); urlMaker.ConstructURL( url, newBase.Text(), AC_BROWSEFILE, NULL, fRequest.GetUnicode() ); htm.beginLink( url.Text() ); } htm.text( p4wStrBuf().EscapeHTML( StrRef(p), Unicode() ).Text() ); htm.endLink(); htm.beginSpan("fSmaller"); htm << " #" << rev << " "; if (*type != *type2) htm << "<font color=\"#FF0000\">" << type << "</font>"; else htm << type; htm.endSpan(); htm.endCol(); htm.beginCol(); p = depotFile2->Text(); if (!strncmp(p, fRequest.GetPath().Text(), lgth)) { p += lgth; if (*p == '/') p++; fRequest.ConstructSafeURL( url, p, AC_BROWSEFILE, NULL ); htm.beginLink( url.Text() ); if (fPath1 != fPath2) { char *q = strchr(p, '/'); if (q) p = q+1; } } else { fRequest.UseNewBase( newBase, NULL, "md", "d" ); fRequest.UseNewBase( newBase, newBase.Text(), "cd", "//" ); fRequest.UseNewBase( newBase, newBase.Text(), "wr", NULL ); fRequest.UseNewBase( newBase, newBase.Text(), "path", depotFile2->Text() ); urlMaker.ConstructURL( url, newBase.Text(), AC_BROWSEFILE, NULL, fRequest.GetUnicode() ); htm.beginLink( url.Text() ); } htm.text( p4wStrBuf().EscapeHTML( StrRef(p), Unicode() ).Text() ); htm.endLink(); htm.beginSpan("fSmaller"); htm << " #" << rev2 << " "; if (*type != *type2) htm << "<font color=\"#FF0000\">" << type2 << "</font>"; else htm << type2; htm.endSpan(); } else if (*status == "right only") { fAdd++; StrBuf clearIcon; urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); htm.icon( clearIcon.Text(), "17", "1", "", 1, 0, 0 ); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,0,"d"); htm.endCol(); htm.beginCol(0, 0, 0, 0, 0, 0, 0, 0, "g"); char *p = depotFile2->Text(); if (!strncmp(p, fRequest.GetPath().Text(), lgth)) { p += fRequest.GetPath().Length(); if (*p == '/') p++; fRequest.ConstructSafeURL( url, p, AC_BROWSEFILE, NULL ); htm.beginLink( url.Text() ); if (fPath1 != fPath2) { char *q = strchr(p, '/'); if (q) p = q+1; } } else { fRequest.UseNewBase( newBase, NULL, "md", "d" ); fRequest.UseNewBase( newBase, newBase.Text(), "cd", "//" ); fRequest.UseNewBase( newBase, newBase.Text(), "wr", NULL ); fRequest.UseNewBase( newBase, newBase.Text(), "path", depotFile2->Text() ); urlMaker.ConstructURL( url, newBase.Text(), AC_BROWSEFILE, NULL, fRequest.GetUnicode() ); htm.beginLink( url.Text() ); } htm.text( p4wStrBuf().EscapeHTML( StrRef(p), Unicode() ).Text() ); htm.endLink(); htm.beginSpan("fSmaller"); htm << " #" << rev2 << " " << type2; htm.endSpan(); } else if (*status == "left only") { fDel++; StrBuf clearIcon; urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); htm.icon( clearIcon.Text(), "17", "1", "", 1, 0, 0 ); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,0,"r"); char *p = depotFile->Text(); if (!strncmp(p, fRequest.GetPath().Text(), lgth)) { p += fRequest.GetPath().Length(); if (*p == '/') p++; fRequest.ConstructSafeURL( url, p, AC_BROWSEFILE, NULL ); htm.beginLink( url.Text() ); if (fPath1 != fPath2) { char *q = strchr(p, '/'); if (q) p = q+1; } } else { fRequest.UseNewBase( newBase, NULL, "md", "d" ); fRequest.UseNewBase( newBase, newBase.Text(), "cd", "//" ); fRequest.UseNewBase( newBase, newBase.Text(), "wr", NULL ); fRequest.UseNewBase( newBase, newBase.Text(), "path", depotFile->Text() ); urlMaker.ConstructURL( url, newBase.Text(), AC_BROWSEFILE, NULL, fRequest.GetUnicode() ); htm.beginLink( url.Text() ); } htm.text( p4wStrBuf().EscapeHTML( StrRef(p), Unicode() ).Text() ); htm.endLink(); htm.beginSpan("fSmaller"); htm << " #" << rev << " " << type; htm.endSpan(); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,0,"d"); } else { if (*status == "types") { fTypes++; htm << "<center>=</center>"; } else { fOther++; htm.text( status->Text() ); } htm.endCol(); htm.beginCol(); if (depotFile) { char *p = depotFile->Text(); if (!strncmp(p, fRequest.GetPath().Text(), lgth)) { p += fRequest.GetPath().Length(); if (*p == '/') p++; fRequest.ConstructSafeURL( url, p, AC_BROWSEFILE, NULL ); htm.beginLink( url.Text() ); if (fPath1 != fPath2) { char *q = strchr(p, '/'); if (q) p = q+1; } } else { fRequest.UseNewBase( newBase, NULL, "md", "d" ); fRequest.UseNewBase( newBase, newBase.Text(), "cd", "//" ); fRequest.UseNewBase( newBase, newBase.Text(), "wr", NULL ); fRequest.UseNewBase( newBase, newBase.Text(), "path", depotFile->Text() ); urlMaker.ConstructURL( url, newBase.Text(), AC_BROWSEFILE, NULL, fRequest.GetUnicode() ); htm.beginLink( url.Text() ); } htm.text( p4wStrBuf().EscapeHTML( StrRef(p), Unicode() ).Text() ); htm.endLink(); } htm.beginSpan("fSmaller"); if (rev) htm << " #" << rev; if (type) { if (type2 && (*type != *type2)) htm << " <font color=\"#FF0000\">" << type << "</font>"; else htm << " " << type; } htm.endSpan(); htm.endCol(); htm.beginCol(); if (depotFile2) { char *p = depotFile2->Text(); if (!strncmp(p, fRequest.GetPath().Text(), lgth)) { p += fRequest.GetPath().Length(); if (*p == '/') p++; fRequest.ConstructSafeURL( url, p, AC_BROWSEFILE, NULL ); htm.beginLink( url.Text() ); if (fPath1 != fPath2) { char *q = strchr(p, '/'); if (q) p = q+1; } } else { fRequest.UseNewBase( newBase, NULL, "md", "d" ); fRequest.UseNewBase( newBase, newBase.Text(), "cd", "//" ); fRequest.UseNewBase( newBase, newBase.Text(), "wr", NULL ); fRequest.UseNewBase( newBase, newBase.Text(), "path", depotFile2->Text() ); urlMaker.ConstructURL( url, newBase.Text(), AC_BROWSEFILE, NULL, fRequest.GetUnicode() ); htm.beginLink( url.Text() ); } htm.text( p4wStrBuf().EscapeHTML( StrRef(p), Unicode() ).Text() ); htm.endLink(); } htm.beginSpan("fSmaller"); if (rev2) htm << " #" << rev2; if (type2) { if (type && (*type != *type2)) htm << " <font color=\"#FF0000\">" << type2 << "</font>"; else htm << " " << type2; } htm.endSpan(); } htm.endCol(); htm.endTRow(); // // If page content limit in bytes has been exceeded, don't // output this entry. However we neded to generate it in // order to get the counts. if( !PageLimitExceeded() ) fRequest << htm; } void p4wDiff2DirsPane::End() { p4wHtml htm; // // Tell user if no diffs were found. if( !fPrintedError && !fDiffsFound ) { htm.beginTRow(); htm.beginCol(0,0,"100%"); htm.text( " No differences found." ); htm.endCol(); htm.endTRow(); } // // End the table only if we started one if( fSeenData) { htm.beginTRow(); htm.beginCol(0,0,0,0,0,0,0,0,"w"); htm.endCol(); htm.beginCol(0,0,"100%",0,0,0,0,0,"w"); htm << " "; htm.linebreak(); htm << "<b>" << fDiff+fDel+fAdd+fTypes+fOther << "</b> Total Diffs: "; htm << "<span class=\"g\"> " << fAdd << " Added </span>"; htm << "<span class=\"r\"> " << fDel << " Deleted </span>"; htm << "<span class=\"l\"> " << fDiff << " Changed"; if (fTypes || fOther) htm << " ("; if (fTypes) { htm << fTypes << " filetype-only change"; if (fTypes > 1) htm << "s"; } if (fTypes && fOther) htm << ", "; if (fOther) htm << fOther << " other changes"; if (fTypes || fOther) htm << ")"; htm << " </span>"; htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.beginCol(); p4wURL urlMaker; StrBuf clearIcon; urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); htm.icon( clearIcon.Text(), "2", "9", "", 1, 0, 0 ); htm.endCol(); htm.endTRow(); htm.endTable(); } htm.comment( "END DIFF 2 DIRS PANE" ); fRequest << htm; } void p4wDiff2DirsPane::RenderText( char *data ) { // // If page content limit in bytes has been exceeded, don't // generate this entry if( PageLimitExceeded() ) return; p4wHtml htm( 1 ); if( !fSeenData ) fSeenData = 1; // // If page content limit in bytes has been exceeded, don't // generate this entry if( PageLimitExceeded() ) return; fDiffsFound = 1; htm.beginTRow(); htm.beginCol(0,0, "100%"); htm << " "; htm << p4wStrBuf().EscapeHTML( StrRef(data), Unicode() ); htm.endCol(); htm.endTRow(); fRequest << htm; } void p4wDiff2DirsPane::RenderInfo( char *data, char level ) { // // If page content limit in bytes has been exceeded, don't // generate this entry if( PageLimitExceeded() ) return; p4wHtml htm; fDiffsFound = 1; htm.beginTRow(); htm.beginCol(0,0, "100%"); htm << " "; htm.text( data ); htm.endCol(); htm.endTRow(); fRequest << htm; } void p4wDiff2DirsPane::RenderError( char *data, int escapeHTML ) { if (strstr(data, " - no file(s) to diff")) return; p4wHtml htm; htm.beginTRow(); htm.beginCol(0,0, "100%"); htm << " <font color=\"#FF0000\">"; if (escapeHTML) htm << p4wStrBuf().EscapeHTML( StrRef(data), Unicode() ); else htm << data; htm << "</font>"; htm.endCol(); htm.endTRow(); fRequest << htm; fPrintedError++; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 12234 | Matt Attaway |
Rejigger P4Web project in preparation for official sunsetting The bin directory contains the last official builds of P4Web from the Perforce download site. P4Web is soon to be completely sunsetted; these builds are here for folks who don't want to build their own. To better handle the archived builds the source code has been moved into a separate src directory. |
||
//guest/perforce_software/p4web/Panes/p4wDiff2DirsPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |