// // Copyright 2007 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wResolveIAPane: // Interactive Non-local Resolve #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wRunPane.h" #include "p4wResolveIAPane.h" p4wResolveIAPane::p4wResolveIAPane( p4wView & ParentView, p4wRequest & Request, const char *title ) : p4wRunPane( ParentView, Request ), fSeenData(0), fForceOption(0), fMarkOption(0) { fdwbFlag.Set(""); } p4wResolveIAPane::~p4wResolveIAPane() { } // ------------------------------------- // Render functions. // void p4wResolveIAPane::Begin() { // // Begin the pane. // // Fetch and build the ACTION value. StrBuf actionURL; GetAction( actionURL ); // // Begin the pane. DoComment( "BEGIN NONLOCAL INTERACTIVE RESOLVE PANE" ); BeginForm( "Resolve Interactively:", actionURL ); } void p4wResolveIAPane::GetAction( StrBuf & actionURL ) { // // Constructs url used for the form ACTION value StrBuf newBase; fRequest.UseNewBase( newBase, NULL, "path", fActionFile.Text() ); fRequest.ConstructSafeURL( actionURL, newBase.Text(), AC_RESOLVEIAPROCESSOR, NULL ); } int p4wResolveIAPane::Resolve( ClientMerge *m, Error *e ) { if ( fSeenData ) return CMS_SKIP; FileSys *fyours = m->GetYourFile(); if (!fRequest.isLocalRequest()) { if ((fyours->Stat() & FSF_SYMLINK) && !SEC_ALLOW_CR8CHG_SYMLINKS) { fRequest << "Remote interactive resolve of symlink files is not allowed.<p>"; return CMS_SKIP; } } FileSys *f = m->GetResultFile(); StrBuf buf; StrBuf md5; f->Digest(&md5, e); if(e->Test()) return CMS_SKIP; f->Open( FOM_READ, e ); if(!e->Test()) f->ReadWhole( &buf, e ); if(!e->Test()) f->Close( e ); if( e->Test() ) return CMS_SKIP; MergeStatus ms = m->AutoResolve(CMF_FORCE); p4wHtml htm; p4wURL urlMaker; char charbuf[256]; StrBuf grayIcon; StrBuf clearIcon; StrBuf greencheckIcon; urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); urlMaker.ConstructURL( greencheckIcon, "/green_checkmarkIcon", AC_ICON, NULL ); htm.beginCol(); htm.beginTable(0, 0, "3", "0"); htm.beginTRow(); htm.beginCol("top", 0, "2", 0, 0, 0, 0, 1, "label"); htm << "Summary:"; htm.endCol(); htm.beginCol(); htm.beginTable("0", 0, "0", "0"); htm.beginTRow(); htm.beginCol(); htm << "Differences"; htm.endCol(); htm.beginCol(0, "right"); htm << "# of times"; htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(0, 0, "2"); htm.icon( clearIcon.Text(), "2", "2", "", 1 ); htm.linebreak(); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.linebreak(); htm.icon( clearIcon.Text(), "2", "2", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm << "<b>Your file</b> differs from base file:"; htm.endCol(); htm.beginCol(0, "right"); sprintf(charbuf, "%d", m->GetYourChunks()); htm << charbuf; htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "2", "2", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm << "<b>Their file</b> differs from base file:"; htm.endCol(); htm.beginCol(0, "right"); sprintf(charbuf, "%d", m->GetTheirChunks()); htm << charbuf; htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "2", "2", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm << "<b>Both</b> contain the same difference from the base file:"; htm.endCol(); htm.beginCol(0, "right"); sprintf(charbuf, "%d", m->GetBothChunks()); htm << charbuf; htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "2", "2", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm << "<b>Conflicts</b> exist between your file and their file:"; htm.endCol(); htm.beginCol(0, "right"); sprintf(charbuf, "%d", m->GetConflictChunks()); htm << charbuf; htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.endCol(); htm.beginCol(); htm.icon(greencheckIcon.Text(), "20", "20", "", 1); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,1); htm.text("Recommended Action: ", "b"); switch(ms) { case CMS_THEIRS: htm << "accept theirs"; break; case CMS_YOURS: htm << "accept yours"; break; case CMS_MERGED: htm << "accept merged"; break; default: htm << "accept merged after editing"; break; } htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(0, 0, "3"); htm.icon( clearIcon.Text(), "3", "3", "", 1 ); htm.linebreak(); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.linebreak(); htm.icon( clearIcon.Text(), "3", "3", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol("top", 0, 0, 0, 0, 0, 0, 1, "label"); htm << "Your File:"; htm.endCol(); htm.beginCol(); if (ms == CMS_YOURS) htm.icon(greencheckIcon.Text(), "20", "20", "", 1); htm.endCol(); htm.beginCol(); htm.button( "yours", "Accept Yours " ); htm << " "; StrBuf url; StrBuf newBase; fRequest.UseNewBase( newBase, NULL, "path", fRequest.GetPath().Text() ); urlMaker.ConstructURL( url, newBase.Text(), AC_FILETEXTLOCAL, NULL, fRequest.GetUnicode() ); StrBuf textIcon; urlMaker.ConstructIcon( textIcon, "/showtextsmallIcon", 18, 25, "View local file text", 1 ); htm.beginLink( url.Text(), NULL, NULL, NULL, "View local file text" ); htm << textIcon; htm << p4wStrBuf().EscapeHTML( *fyours->Path(), Unicode() ).Text(); htm.endLink(); htm.hiddenField( "Key", md5.Text() ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(0, 0, "3"); htm.icon( clearIcon.Text(), "3", "3", "", 1 ); htm.linebreak(); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.linebreak(); htm.icon( clearIcon.Text(), "3", "3", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol("top", 0, 0, 0, 0, 0, 0, 1, "label"); htm << "Their File:"; htm.endCol(); htm.beginCol(); if (ms == CMS_THEIRS) htm.icon(greencheckIcon.Text(), "20", "20", "", 1); htm.endCol(); htm.beginCol(); htm.button( "theirs", "Accept Theirs" ); htm << " "; StrBufDict tempArgs; StrBuf temp; temp << fData; char *p = strrchr(temp.Text(), '#'); if (p) { *p++ = '\0'; tempArgs.SetVar( "rev1", p ); char *q = strrchr(temp.Text(), '#'); if (q) *q = '\0'; temp.SetLength(); } if( fRequest.GetViewMode() == VM_WORKSPACE ) { 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", temp.Text() ); urlMaker.ConstructURL( url, newBase.Text(), AC_FILETEXTDEPOT, &tempArgs, fRequest.GetUnicode() ); } else { fRequest.UseNewBase( newBase, NULL, "path", temp.Text() ); urlMaker.ConstructURL( url, newBase.Text(), AC_FILETEXTDEPOT, &tempArgs, fRequest.GetUnicode() ); } temp.Clear(); temp << "View text of rev#" << (p ? p : "head"); htm.beginLink( url.Text(), NULL, NULL, NULL, temp.Text() ); urlMaker.ConstructIcon( textIcon, "/showtextsmallIcon", 18, 25, temp.Text(), 1 ); htm << textIcon; htm << p4wStrBuf().EscapeHTML( StrRef(fData), Unicode() ).Text(); htm.endLink(); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(0, 0, "3"); htm.icon( clearIcon.Text(), "3", "3", "", 1 ); htm.linebreak(); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.linebreak(); htm.icon( clearIcon.Text(), "3", "3", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol("top", 0, 0, 0, 0, 0, 0, 1, "label"); htm << "Merged Result:"; htm.endCol(); htm.beginCol(); htm.endCol(); htm.beginCol(0, 0, 0, 0, 0, "100%", 0, 1); if (fMarkOption) htm << "(changes"; else htm << "(conflicts"; htm << " enclosed between \">>>>\" and \"<<<<\" markers)<br>" << crlf; htm.beginTextbox( "Edit", 25, 90 ); fRequest << htm; p4wHtml htmnocrlf(1); htmnocrlf.text( p4wStrBuf().EscapeHTML( buf, Unicode() ).Text() ); fRequest << htmnocrlf; htm.Clear(); htm.endTextbox(); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.endCol(); htm.beginCol(); if (ms != CMS_YOURS && ms != CMS_THEIRS) htm.icon(greencheckIcon.Text(), "20", "20", "", 1); htm.endCol(); htm.beginCol(); htm.button( "merged", "Accept Merged" ); htm << " "; htm.checkbox( "conflictsOK", "y", 0 ); htm.label( "Accept even if conflict markers are still present", "conflictsOK" ); htm.hiddenField( "dwbFlag", fdwbFlag.Text() ); htm.hiddenField( "forceOption", fForceOption ? "1" : "0" ); htm.hiddenField( "markOption", fMarkOption ? "1" : "0" ); fRequest << htm; fSeenData = 1; return CMS_SKIP; } void p4wResolveIAPane::RenderInfo( char *data, char level ) { char *p = strstr(data, "merging "); if (p) fData.Set(p + sizeof("merging ")-1); } void p4wResolveIAPane::End() { // // End the pane. p4wHtml htm; if( fSeenData ) { htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.beginCol(); htm.endCol(); htm.endTRow(); htm.endTable(); } else { htm.beginTRow(); htm.beginCol(); htm.text( "File not found, file is empty or some problem with reading the merged file." ); htm.endCol(); htm.endTRow(); } fRequest << htm; // // End the pane. EndForm(); DoComment( "END NONLOCAL INTERACTIVE RESOLVE PANE" ); }
# | 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/p4wResolveIAPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |