OSDN Git Service

Compare previous version ok
authorFrank Li <lznuaa@gmail.com>
Mon, 29 Dec 2008 02:21:41 +0000 (10:21 +0800)
committerFrank Li <lznuaa@gmail.com>
Mon, 29 Dec 2008 02:21:41 +0000 (10:21 +0800)
src/Git/GitRev.cpp
src/Git/GitRev.h
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/FileDiffDlg.cpp
src/TortoiseProc/FileDiffDlg.h
src/TortoiseProc/GitLogList.cpp
src/TortoiseProc/LogDataVector.cpp
src/TortoiseProc/LogDlgHelper.h
src/TortoiseProc/TortoiseProc.vcproj
src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user
src/TortoiseShell/resourceshell.rc

index f1e4f37..dc08239 100644 (file)
@@ -20,6 +20,19 @@ GitRev& GitRev::operator=(GitRev &rev)
        return *this;\r
 }\r
 #endif\r
+void GitRev::Clear()\r
+{\r
+       this->m_Action=0;\r
+       this->m_Files.Clear();\r
+       this->m_Action=0;\r
+       this->m_ParentHash.clear();\r
+       m_CommitterName.Empty();\r
+       m_CommitterEmail.Empty();\r
+       m_Body.Empty();\r
+       m_Subject.Empty();\r
+       m_CommitHash.Empty();\r
+\r
+}\r
 int GitRev::ParserFromLog(CString &log)\r
 {\r
        int pos=0;\r
@@ -41,6 +54,9 @@ int GitRev::ParserFromLog(CString &log)
                        mode = one[2];\r
                        switch(mode)\r
                        {\r
+                       case LOG_REV_ITEM_BEGIN:\r
+                               this->Clear();\r
+\r
                        case LOG_REV_AUTHOR_NAME:\r
                                this->m_AuthorName = text;\r
                                break;\r
index 64dda9a..bc9b0fb 100644 (file)
@@ -47,6 +47,7 @@ public:
        git_revnum_t m_CommitHash;\r
        GIT_REV_LIST m_ParentHash;\r
        CTGitPathList m_Files;\r
+       void Clear();\r
        int     m_Action;\r
        int ParserFromLog(CString &log);\r
        CTime ConverFromString(CString input);\r
index fab9ac5..9eeaf38 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index 3dc296f..9455b40 100644 (file)
@@ -96,6 +96,31 @@ void CFileDiffDlg::SetDiff(CTGitPath * path, GitRev rev1, GitRev rev2)
        m_rev2 = rev2;\r
        \r
 }\r
+void CFileDiffDlg::SetDiff(CTGitPath * path, CString &hash1, CString &hash2)\r
+{\r
+       if(path!=NULL)\r
+       {\r
+               m_path1 = *path;\r
+               m_path2 = *path;\r
+       }\r
+       m_rev1.m_CommitHash = hash1;\r
+       m_rev2.m_CommitHash = hash2;\r
+}\r
+void CFileDiffDlg::SetDiff(CTGitPath * path, GitRev rev1)\r
+{\r
+       if(path!=NULL)\r
+       {\r
+               m_path1 = *path;\r
+               m_path2 = *path;\r
+       }\r
+       m_rev1 = rev1;\r
+       m_rev2.m_CommitHash = _T("");\r
+       m_rev2.m_Subject = _T("Previou Version");\r
+\r
+       //this->GetDlgItem()->EnableWindow(FALSE);\r
+       \r
+       \r
+}\r
 \r
 BOOL CFileDiffDlg::OnInitDialog()\r
 {\r
@@ -170,6 +195,9 @@ BOOL CFileDiffDlg::OnInitDialog()
 \r
        // Start with focus on file list\r
        GetDlgItem(IDC_FILELIST)->SetFocus();\r
+\r
+       if(m_rev2.m_CommitHash.IsEmpty())\r
+               m_SwitchButton.EnableWindow(FALSE);\r
        return FALSE;\r
 }\r
 \r
@@ -228,6 +256,7 @@ UINT CFileDiffDlg::DiffThread()
        {\r
                cmd.Format(_T("git.exe diff-tree -r --raw -C -M --numstat %s %s"),rev1,m_rev2.m_CommitHash);\r
        }\r
+\r
        CString out;\r
        g_Git.Run(cmd,&out);\r
        this->m_arFileList.ParserFromLog(out);\r
index 7630d7d..e94a8b5 100644 (file)
@@ -59,6 +59,8 @@ public:
 //     void SetDiff(const CTGitPath& path, GitRev peg, GitRev rev1, GitRev rev2, svn_depth_t depth, bool ignoreancestry);\r
 \r
        void SetDiff(CTGitPath * path, GitRev rev1,GitRev rev2);\r
+       void SetDiff(CTGitPath * path, GitRev rev1);\r
+       void SetDiff(CTGitPath * path, CString &hash1, CString &hash2);\r
 \r
        void    DoBlame(bool blame = true) {m_bBlame = blame;}\r
 \r
index cfefc00..37bbe94 100644 (file)
@@ -1086,6 +1086,8 @@ void CGitLogList::OnContextMenu(CWnd* pWnd, CPoint point)
                                
                        }
                        break;
+               
+
                case ID_COMPARE:
                        {
                                GitRev * r1 = &m_wcRev;
@@ -1106,6 +1108,32 @@ void CGitLogList::OnContextMenu(CWnd* pWnd, CPoint point)
                                //      CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_WC, m_path, revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
                        }
                        break;
+
+               case ID_COMPAREWITHPREVIOUS:
+                       {
+
+                               CFileDiffDlg dlg;
+                               
+                               if(pSelLogEntry->m_ParentHash.size()>0)
+                               //if(m_logEntries.m_HashMap[pSelLogEntry->m_ParentHash[0]]>=0)
+                               {
+                                       dlg.SetDiff(NULL,pSelLogEntry->m_CommitHash,pSelLogEntry->m_ParentHash[0]);
+                                       dlg.DoModal();
+                               }else
+                               {
+                                       CMessageBox::Show(NULL,_T("No previous version"),_T("TortoiseGit"),MB_OK);      
+                               }
+                               //if (PromptShown())
+                               //{
+                               //      GitDiff diff(this, m_hWnd, true);
+                               //      diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
+                               //      diff.SetHEADPeg(m_LogRevision);
+                               //      diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected);
+                               //}
+                               //else
+                               //      CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
+                       }
+                       break;
                case ID_COPYCLIPBOARD:
                        {
                                CopySelectionToClipBoard();
@@ -1134,37 +1162,12 @@ void CGitLogList::OnContextMenu(CWnd* pWnd, CPoint point)
                case ID_SWITCHTOREV:
                        CAppUtils::Switch(&pSelLogEntry->m_CommitHash);
                        break;
-               
 
                default:
-                       CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK);
+                       //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK);
                        break;
 #if 0
-               case ID_GNUDIFF1:
-                       {
-                               if (PromptShown())
-                               {
-                                       GitDiff diff(this, this->m_hWnd, true);
-                                       diff.SetHEADPeg(m_LogRevision);
-                                       diff.ShowUnifiedDiff(m_path, revPrevious, m_path, revSelected);
-                               }
-                               else
-                                       CAppUtils::StartShowUnifiedDiff(m_hWnd, m_path, revPrevious, m_path, revSelected, GitRev(), m_LogRevision);
-                       }
-                       break;
-
-               case ID_GNUDIFF2:
-                       {
-                               if (PromptShown())
-                               {
-                                       GitDiff diff(this, this->m_hWnd, true);
-                                       diff.SetHEADPeg(m_LogRevision);
-                                       diff.ShowUnifiedDiff(m_path, revSelected2, m_path, revSelected);
-                               }
-                               else
-                                       CAppUtils::StartShowUnifiedDiff(m_hWnd, m_path, revSelected2, m_path, revSelected, GitRev(), m_LogRevision);
-                       }
-                       break;
+       
                case ID_REVERTREV:
                        {
                                // we need an URL to complete this command, so error out if we can't get an URL
@@ -1259,68 +1262,9 @@ void CGitLogList::OnContextMenu(CWnd* pWnd, CPoint point)
                                }
                        }
                        break;
-               case ID_COPY:
-                       {
-                               // we need an URL to complete this command, so error out if we can't get an URL
-                               if (pathURL.IsEmpty())
-                               {
-                                       CString strMessage;
-                                       strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
-                                       CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
-                                       TRACE(_T("could not retrieve the URL of the folder!\n"));
-                                       break;          //exit
-                               }
-
-                               CCopyDlg dlg;
-                               dlg.m_URL = pathURL;
-                               dlg.m_path = m_path;
-                               dlg.m_CopyRev = revSelected;
-                               if (dlg.DoModal() == IDOK)
-                               {
-                                       // should we show a progress dialog here? Copies are done really fast
-                                       // and without much network traffic.
-                                       if (!Copy(CTGitPathList(CTGitPath(pathURL)), CTGitPath(dlg.m_URL), dlg.m_CopyRev, dlg.m_CopyRev, dlg.m_sLogMessage))
-                                               CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
-                                       else
-                                               CMessageBox::Show(this->m_hWnd, IDS_LOG_COPY_SUCCESS, IDS_APPNAME, MB_ICONINFORMATION);
-                               }
-                       } 
-                       break;
+       
 
-               case ID_COMPARETWO:
-                       {
-                               GitRev r1 = revSelected;
-                               GitRev r2 = revSelected2;
-                               if (GetSelectedCount() > 2)
-                               {
-                                       r1 = revHighest;
-                                       r2 = revLowest;
-                               }
-                               //user clicked on the menu item "compare revisions"
-                               if (PromptShown())
-                               {
-                                       GitDiff diff(this, m_hWnd, true);
-                                       diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
-                                       diff.SetHEADPeg(m_LogRevision);
-                                       diff.ShowCompare(CTGitPath(pathURL), r2, CTGitPath(pathURL), r1);
-                               }
-                               else
-                                       CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), r2, CTGitPath(pathURL), r1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
-                       }
-                       break;
-               case ID_COMPAREWITHPREVIOUS:
-                       {
-                               if (PromptShown())
-                               {
-                                       GitDiff diff(this, m_hWnd, true);
-                                       diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
-                                       diff.SetHEADPeg(m_LogRevision);
-                                       diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected);
-                               }
-                               else
-                                       CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
-                       }
-                       break;
+       
                case ID_BLAMECOMPARE:
                        {
                                //user clicked on the menu item "compare with working copy"
@@ -1361,48 +1305,7 @@ void CGitLogList::OnContextMenu(CWnd* pWnd, CPoint point)
                                        CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
                        }
                        break;
-               case ID_SAVEAS:
-                       {
-                               //now first get the revision which is selected
-                               CString revFilename;
-                               if (m_hasWC)
-                               {
-                                       CString strWinPath = m_path.GetWinPathString();
-                                       int rfind = strWinPath.ReverseFind('.');
-                                       if (rfind > 0)
-                                               revFilename.Format(_T("%s-%ld%s"), (LPCTSTR)strWinPath.Left(rfind), (LONG)revSelected, (LPCTSTR)strWinPath.Mid(rfind));
-                                       else
-                                               revFilename.Format(_T("%s-%ld"), (LPCTSTR)strWinPath, revSelected);
-                               }
-                               if (CAppUtils::FileOpenSave(revFilename, NULL, IDS_LOG_POPUP_SAVE, IDS_COMMONFILEFILTER, false, m_hWnd))
-                               {
-                                       CTGitPath tempfile;
-                                       tempfile.SetFromWin(revFilename);
-                                       CProgressDlg progDlg;
-                                       progDlg.SetTitle(IDS_APPNAME);
-                                       progDlg.SetAnimation(IDR_DOWNLOAD);
-                                       CString sInfoLine;
-                                       sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, m_path.GetWinPath(), (LPCTSTR)revSelected.ToString());
-                                       progDlg.SetLine(1, sInfoLine, true);
-                                       SetAndClearProgressInfo(&progDlg);
-                                       progDlg.ShowModeless(m_hWnd);
-                                       if (!Cat(m_path, GitRev(GitRev::REV_HEAD), revSelected, tempfile))
-                                       {
-                                               // try again with another peg revision
-                                               if (!Cat(m_path, revSelected, revSelected, tempfile))
-                                               {
-                                                       progDlg.Stop();
-                                                       SetAndClearProgressInfo((HWND)NULL);
-                                                       CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
-                                                       EnableOKButton();
-                                                       break;
-                                               }
-                                       }
-                                       progDlg.Stop();
-                                       SetAndClearProgressInfo((HWND)NULL);
-                               }
-                       }
-                       break;
+               
                case ID_OPENWITH:
                        bOpenWith = true;
                case ID_OPEN:
index 1f9b340..a748856 100644 (file)
@@ -91,7 +91,7 @@ int CLogDataVector::ParserFromLog()
                onelog=log.Mid(start -4,length);
                rev.ParserFromLog(onelog);
                this->push_back(rev);
-               m_HashMap[rev.m_CommitHash]=&rev;
+               m_HashMap[rev.m_CommitHash]=size()-1;
                start = next +4;
        }
 
index 53c4d9d..ce4a360 100644 (file)
@@ -30,7 +30,7 @@ class CLogDlg;
  * Instances of CStoreSelection save the selection of the CLogDlg. When the instance\r
  * is deleted the destructor restores the selection.\r
  */\r
-typedef std::map<CString, GitRev*> MAP_HASH_REV;\r
+typedef std::map<CString, int> MAP_HASH_REV;\r
 \r
 class CStoreSelection\r
 {\r
index 4aa809c..d2b88c3 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\explorer.ico"\r
+                               RelativePath="..\Resources\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\explorer.ico"\r
+                               RelativePath=".\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\newfolder.ico"\r
+                               RelativePath="..\Resources\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\newfolder.ico"\r
+                               RelativePath=".\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\open.ico"\r
+                               RelativePath="..\Resources\open.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\open.ico"\r
+                               RelativePath=".\open.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\save.ico"\r
+                               RelativePath="..\Resources\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\save.ico"\r
+                               RelativePath=".\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\saveas.ico"\r
+                               RelativePath="..\Resources\saveas.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\saveas.ico"\r
+                               RelativePath=".\saveas.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\up.ico"\r
+                               RelativePath="..\Resources\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\up.ico"\r
+                               RelativePath=".\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
                        </File>\r
                </Filter>\r
                <File\r
-                       RelativePath="..\..\..\..\tortoisegit\src\TortoiseProc\CloneDlg.htm"\r
-                       DeploymentContent="true"\r
-                       >\r
-               </File>\r
-               <File\r
                        RelativePath="Resource.h"\r
                        >\r
                </File>\r
index 8990368..a9acb41 100644 (file)
@@ -11,7 +11,7 @@
                        <DebugSettings\r
                                Command="$(TargetPath)"\r
                                WorkingDirectory="D:\Profiles\b20596\tortoisegit"\r
-                               CommandArguments="/command:log /path:&quot;D:\\Profiles\\b20596\\buildtest\\tortoisegit&quot;"\r
+                               CommandArguments="/command:log /path:&quot;D:\\Profiles\\b20596\\git&quot;"\r
                                Attach="false"\r
                                DebuggerType="3"\r
                                Remote="1"\r
index 9e2db9c..ce41b0b 100644 (file)
@@ -205,10 +205,6 @@ BEGIN
     IDS_MENUREVERT          "Re&vert..."\r
     IDS_MENUCLEANUP         "&Clean up"\r
     IDS_MENURESOLVE         "Res&olved..."\r
-       IDS_MENUSWITCH_HERE             "Switch/Checkout to here"\r
-       IDS_MENUSWITCH                  "Switch/Checkout"\r
-       IDS_MENUCHERRYPICK_HERE "Cherry Pick This Version"                      \r
-       IDS_MENUCHERRYPICK              "Cherry Pick"\r
 END\r
 \r
 STRINGTABLE \r
@@ -216,12 +212,8 @@ BEGIN
     IDS_MENUSWITCH          "S&witch..."\r
     IDS_MENUMERGE           "&Merge..."\r
     IDS_MENUBRANCH          "Create Branch"\r
-       IDS_MENUBRANCH_HERE             "Create Branch at here"\r
-       IDS_MENUTAG                             "Create Tag"\r
-       IDS_MENUTAG_HERE                "Create Tag at here"\r
     IDS_MENUIMPORT          "&Import..."\r
     IDS_MENUEXPORT          "E&xport..."\r
-       IDS_MENUEXPORT_HERE             "Export at here"\r
     IDS_MENUSETTINGS        "&Settings"\r
     IDS_MENUABOUT           "A&bout"\r
     IDS_MENUSUBMENU         "&TortoiseGit"\r