OSDN Git Service

add ignore
authorFrank Li <lznuaa@gmail.com>
Wed, 7 Jan 2009 13:26:51 +0000 (21:26 +0800)
committerFrank Li <lznuaa@gmail.com>
Wed, 7 Jan 2009 13:26:51 +0000 (21:26 +0800)
14 files changed:
src/TortoiseProc/AppUtils.cpp
src/TortoiseProc/AppUtils.h
src/TortoiseProc/Blame.cpp
src/TortoiseProc/Blame.h
src/TortoiseProc/BlameDlg.cpp
src/TortoiseProc/BlameDlg.h
src/TortoiseProc/Commands/BlameCommand.cpp
src/TortoiseProc/Commands/CatCommand.cpp
src/TortoiseProc/Commands/CleanupCommand.cpp
src/TortoiseProc/Commands/Command.cpp
src/TortoiseProc/Commands/DiffCommand.cpp
src/TortoiseProc/Commands/RemoveCommand.cpp
src/TortoiseProc/TortoiseProc.vcproj
src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user

index 45675c9..e4ef61f 100644 (file)
@@ -1184,4 +1184,33 @@ bool CAppUtils::Switch(CString *CommitHash)
 \r
        }\r
        return FALSE;\r
+}\r
+\r
+bool CAppUtils::IgnoreFile(CTGitPath &path,bool IsMask)\r
+{\r
+       CString ignorefile;\r
+       ignorefile=g_Git.m_CurrentDir;\r
+       ignorefile+=path.GetDirectory().GetWinPathString()+_T("\\.gitignore");\r
+\r
+       CStdioFile file;\r
+       if(!file.Open(ignorefile,CFile::modeCreate|CFile::modeWrite))\r
+       {\r
+               CMessageBox::Show(NULL,ignorefile+_T(" Open Failure"),_T("TortoiseGit"),MB_OK);\r
+               return FALSE;\r
+       }\r
+\r
+       CString ignorelist;\r
+       file.ReadString(ignorelist);\r
+\r
+       if(IsMask)\r
+       {\r
+               ignorelist+=_T("\n*.")+path.GetFileExtension();\r
+       }else\r
+       {\r
+               ignorelist+=_T("\n")+path.GetBaseFilename();\r
+       }\r
+       file.WriteString(ignorelist);\r
+\r
+       file.Close();\r
+       return TRUE;\r
 }
\ No newline at end of file
index 18cc961..d9d761b 100644 (file)
@@ -164,6 +164,8 @@ public:
        static bool CreateBranchTag(bool IsTag=TRUE,CString *CommitHash=NULL);\r
        static bool Switch(CString *CommitHash);\r
 \r
+       static bool IgnoreFile(CTGitPath &file, bool IsMask);\r
+\r
 private:\r
        static CString PickDiffTool(const CTGitPath& file1, const CTGitPath& file2);\r
        static bool GetMimeType(const CTGitPath& file, CString& mimetype);\r
index 2eaab88..86982bd 100644 (file)
@@ -20,7 +20,7 @@
 #include "TortoiseProc.h"\r
 #include "Blame.h"\r
 #include "ProgressDlg.h"\r
-#include "TSVNPath.h"\r
+#include "TGitPath.h"\r
 #include "Registry.h"\r
 #include "UnicodeUtils.h"\r
 #include "TempFile.h"\r
@@ -36,16 +36,18 @@ CBlame::CBlame()
 }\r
 CBlame::~CBlame()\r
 {\r
-       m_progressDlg.Stop();\r
+//     m_progressDlg.Stop();\r
 }\r
 \r
-BOOL CBlame::BlameCallback(LONG linenumber, svn_revnum_t revision, const CString& author, const CString& date,\r
-                                                  svn_revnum_t merged_revision, const CString& merged_author, const CString& merged_date, const CString& merged_path,\r
+BOOL CBlame::BlameCallback(LONG linenumber, git_revnum_t revision, const CString& author, const CString& date,\r
+                                                  git_revnum_t merged_revision, const CString& merged_author, const CString& merged_date, const CString& merged_path,\r
                                                   const CStringA& line)\r
 {\r
+\r
+#if 0\r
        CStringA infolineA;\r
        CStringA fulllineA;\r
-       svn_revnum_t origrev = revision;\r
+       git_revnum_t origrev = revision;\r
 \r
        if (((m_lowestrev < 0)||(m_lowestrev > revision))&&(revision >= 0))\r
                m_lowestrev = revision;\r
@@ -90,10 +92,12 @@ BOOL CBlame::BlameCallback(LONG linenumber, svn_revnum_t revision, const CString
        }\r
        else\r
                return FALSE;\r
+#endif\r
        return TRUE;\r
 }\r
 \r
-BOOL CBlame::Log(svn_revnum_t revision, const CString& /*author*/, const CString& /*date*/, const CString& message, LogChangedPathArray * /*cpaths*/, apr_time_t /*time*/, int /*filechanges*/, BOOL /*copies*/, DWORD /*actions*/, BOOL /*children*/)\r
+#if 0\r
+BOOL CBlame::Log(git_revnum_t revision, const CString& /*author*/, const CString& /*date*/, const CString& message, LogChangedPathArray * /*cpaths*/, apr_time_t /*time*/, int /*filechanges*/, BOOL /*copies*/, DWORD /*actions*/, BOOL /*children*/)\r
 {\r
        m_progressDlg.SetProgress(m_highestrev - revision, m_highestrev);\r
        if (m_saveLog.m_hFile != INVALID_HANDLE_VALUE)\r
@@ -106,18 +110,20 @@ BOOL CBlame::Log(svn_revnum_t revision, const CString& /*author*/, const CString
        }\r
        return TRUE;\r
 }\r
+#endif\r
 \r
 BOOL CBlame::Cancel()\r
 {\r
-       if (m_progressDlg.HasUserCancelled())\r
-               m_bCancelled = TRUE;\r
+//     if (m_progressDlg.HasUserCancelled())\r
+//             m_bCancelled = TRUE;\r
        return m_bCancelled;\r
 }\r
 \r
-CString CBlame::BlameToTempFile(const CTSVNPath& path, SVNRev startrev, SVNRev endrev, SVNRev pegrev, \r
+CString CBlame::BlameToTempFile(const CTGitPath& path, GitRev startrev, GitRev endrev, GitRev pegrev, \r
                                                                CString& logfile, const CString& options, BOOL includemerge, \r
                                                                BOOL showprogress, BOOL ignoremimetype)\r
 {\r
+#if 0\r
        // if the user specified to use another tool to show the blames, there's no\r
        // need to fetch the log later: only TortoiseBlame uses those logs to give \r
        // the user additional information for the blame.\r
@@ -180,7 +186,7 @@ CString CBlame::BlameToTempFile(const CTSVNPath& path, SVNRev startrev, SVNRev e
                        logfile.Empty();\r
                        return m_sSavePath;\r
                }\r
-               BOOL bRet = ReceiveLog(CTSVNPathList(path), pegrev, m_nHeadRev, m_lowestrev, 0, FALSE, m_bHasMerges, false);\r
+               BOOL bRet = ReceiveLog(CTGitPathList(path), pegrev, m_nHeadRev, m_lowestrev, 0, FALSE, m_bHasMerges, false);\r
                if (!bRet)\r
                {\r
                        m_saveLog.Close();\r
@@ -195,10 +201,11 @@ CString CBlame::BlameToTempFile(const CTSVNPath& path, SVNRev startrev, SVNRev e
        m_progressDlg.Stop();\r
        if (m_saveFile.m_hFile != INVALID_HANDLE_VALUE)\r
                m_saveFile.Close();\r
-\r
+#endif;\r
        return m_sSavePath;\r
 }\r
-BOOL CBlame::Notify(const CTSVNPath& /*path*/, svn_wc_notify_action_t /*action*/, \r
+#if 0\r
+BOOL CBlame::Notify(const CTGitPath& /*path*/, svn_wc_notify_action_t /*action*/, \r
                                        svn_node_kind_t /*kind*/, const CString& /*mime_type*/, \r
                                        svn_wc_notify_state_t /*content_state*/, \r
                                        svn_wc_notify_state_t /*prop_state*/, LONG rev,\r
@@ -209,9 +216,9 @@ BOOL CBlame::Notify(const CTSVNPath& /*path*/, svn_wc_notify_action_t /*action*/
        m_progressDlg.SetProgress(rev, m_nHeadRev);\r
        return TRUE;\r
 }\r
-\r
-bool CBlame::BlameToFile(const CTSVNPath& path, SVNRev startrev, SVNRev endrev, SVNRev peg, \r
-                                                const CTSVNPath& tofile, const CString& options, BOOL ignoremimetype, BOOL includemerge)\r
+#endif\r
+bool CBlame::BlameToFile(const CTGitPath& path, GitRev startrev, GitRev endrev, GitRev peg, \r
+                                                const CTGitPath& tofile, const CString& options, BOOL ignoremimetype, BOOL includemerge)\r
 {\r
        CString temp;\r
        if (!m_saveFile.Open(tofile.GetWinPathString(), CFile::typeText | CFile::modeReadWrite | CFile::modeCreate))\r
index ea5d03a..41a6c8e 100644 (file)
@@ -30,7 +30,7 @@ class CTGitPath;
  * \ingroup TortoiseProc\r
  * Helper class to get the blame information for a file.\r
  */\r
-class CBlame : public CGit\r
+class CBlame  \r
 {\r
 public:\r
        CBlame();\r
@@ -54,13 +54,15 @@ private:
                                                                git_revnum_t merged_revision, const CString& merged_author, const CString& merged_date, const CString& merged_path,\r
                                                                const CStringA& line);\r
        BOOL            Cancel();\r
+/*\r
        BOOL            Notify(const CTGitPath& path, git_wc_notify_action_t action, \r
                                                git_node_kind_t kind, const CString& mime_type, \r
                                                git_wc_notify_state_t content_state, \r
                                                git_wc_notify_state_t prop_state, LONG rev,\r
                                                const git_lock_t * lock, git_wc_notify_lock_state_t lock_state,\r
                                                git_error_t * err, apr_pool_t * pool);\r
-       BOOL            Log(git_revnum_t rev, const CString& author, const CString& date, const CString& message, LogChangedPathArray * cpaths, apr_time_t time, int filechanges, BOOL copies, DWORD actions, BOOL haschildren);\r
+                                               */\r
+       //BOOL          Log(git_revnum_t rev, const CString& author, const CString& date, const CString& message, LogChangedPathArray * cpaths, apr_time_t time, int filechanges, BOOL copies, DWORD actions, BOOL haschildren);\r
 private:\r
        BOOL            m_bCancelled;                   ///< TRUE if the operation should be canceled\r
        LONG            m_nCounter;                             ///< Counts the number of calls to the Cancel() callback (revisions?)\r
index f1180c3..782f884 100644 (file)
@@ -24,9 +24,9 @@
 IMPLEMENT_DYNAMIC(CBlameDlg, CStandAloneDialog)\r
 CBlameDlg::CBlameDlg(CWnd* pParent /*=NULL*/)\r
        : CStandAloneDialog(CBlameDlg::IDD, pParent)\r
-       , StartRev(1)\r
-       , EndRev(0)\r
-       , m_sStartRev(_T("1"))\r
+//     , StartRev(1)\r
+//     , EndRev(0)\r
+//     , m_sStartRev(_T("1"))\r
        , m_bTextView(FALSE)\r
        , m_bIgnoreEOL(TRUE)\r
        , m_bIncludeMerge(TRUE)\r
@@ -70,14 +70,14 @@ BOOL CBlameDlg::OnInitDialog()
 \r
        m_bTextView = m_regTextView;\r
        // set head revision as default revision\r
-       if (EndRev.IsHead())\r
+//     if (EndRev.IsHead())\r
                CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_HEAD);\r
-       else\r
-       {\r
-               m_sEndRev = EndRev.ToString();\r
-               UpdateData(FALSE);\r
-               CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_N);\r
-       }\r
+//     else\r
+//     {\r
+//             m_sEndRev = EndRev.ToString();\r
+//             UpdateData(FALSE);\r
+//             CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_N);\r
+//     }\r
 \r
        CheckRadioButton(IDC_COMPAREWHITESPACES, IDC_IGNOREALLWHITESPACES, IDC_IGNOREALLWHITESPACES);\r
 \r
@@ -92,23 +92,23 @@ void CBlameDlg::OnOK()
                return; // don't dismiss dialog (error message already shown by MFC framework)\r
 \r
        m_regTextView = m_bTextView;\r
-       StartRev = SVNRev(m_sStartRev);\r
-       EndRev = SVNRev(m_sEndRev);\r
-       if (!StartRev.IsValid())\r
-       {\r
-               ShowBalloon(IDC_REVISON_START, IDS_ERR_INVALIDREV);\r
-               return;\r
-       }\r
-       EndRev = SVNRev(m_sEndRev);\r
-       if (GetCheckedRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N) == IDC_REVISION_HEAD)\r
-       {\r
-               EndRev = SVNRev(_T("HEAD"));\r
-       }\r
-       if (!EndRev.IsValid())\r
+//     StartRev = SVNRev(m_sStartRev);\r
+//     EndRev = SVNRev(m_sEndRev);\r
+//     if (!StartRev.IsValid())\r
+//     {\r
+///            ShowBalloon(IDC_REVISON_START, IDS_ERR_INVALIDREV);\r
+//             return;\r
+//     }\r
+//     EndRev = SVNRev(m_sEndRev);\r
+//     if (GetCheckedRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N) == IDC_REVISION_HEAD)\r
        {\r
-               ShowBalloon(IDC_REVISION_END, IDS_ERR_INVALIDREV);\r
-               return;\r
+               EndRev = _T("HEAD");\r
        }\r
+//     if (!EndRev.IsValid())\r
+//     {\r
+//             ShowBalloon(IDC_REVISION_END, IDS_ERR_INVALIDREV);\r
+//             return;\r
+//     }\r
        BOOL extBlame = CRegDWORD(_T("Software\\TortoiseSVN\\TextBlame"), FALSE);\r
        if (extBlame)\r
                m_bTextView = true;\r
@@ -117,14 +117,14 @@ void CBlameDlg::OnOK()
        switch (rb)\r
        {\r
        case IDC_IGNOREWHITESPACECHANGES:\r
-               m_IgnoreSpaces = svn_diff_file_ignore_space_change;\r
+//             m_IgnoreSpaces = svn_diff_file_ignore_space_change;\r
                break;\r
        case IDC_IGNOREALLWHITESPACES:\r
-               m_IgnoreSpaces = svn_diff_file_ignore_space_all;\r
+//             m_IgnoreSpaces = svn_diff_file_ignore_space_all;\r
                break;\r
        case IDC_COMPAREWHITESPACES:\r
        default:\r
-               m_IgnoreSpaces = svn_diff_file_ignore_space_none;\r
+//             m_IgnoreSpaces = svn_diff_file_ignore_space_none;\r
                break;\r
        }\r
 \r
index 83e0dee..d7e3904 100644 (file)
@@ -17,7 +17,7 @@
 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
 //\r
 #pragma once\r
-#include "SVNRev.h"\r
+#include "GitRev.h"\r
 #include "Registry.h"\r
 #include "StandAloneDlg.h"\r
 \r
@@ -52,10 +52,10 @@ protected:
        CRegDWORD m_regTextView;\r
 \r
 public:\r
-       SVNRev  StartRev;\r
-       SVNRev  EndRev;\r
+       CString StartRev;\r
+       CString EndRev;\r
        BOOL    m_bTextView;\r
        BOOL    m_bIgnoreEOL;\r
        BOOL    m_bIncludeMerge;\r
-       svn_diff_file_ignore_space_t    m_IgnoreSpaces;\r
+       int             m_IgnoreSpaces;\r
 };\r
index a279f63..ad10847 100644 (file)
@@ -21,7 +21,7 @@
 \r
 #include "BlameDlg.h"\r
 #include "Blame.h"\r
-#include "SVN.h"\r
+#include "Git.h"\r
 #include "AppUtils.h"\r
 #include "MessageBox.h"\r
 \r
@@ -32,7 +32,9 @@ bool BlameCommand::Execute()
        bool bShowDialog = true;\r
        CBlameDlg dlg;\r
        CString options;\r
-       dlg.EndRev = SVNRev::REV_HEAD;\r
+       dlg.DoModal();\r
+//     dlg.EndRev = GitRev::REV_HEAD;\r
+#if 0\r
        if (parser.HasKey(_T("startrev")) && parser.HasKey(_T("endrev")))\r
        {\r
                bShowDialog = false;\r
@@ -102,5 +104,6 @@ bool BlameCommand::Execute()
                        CMessageBox::Show(hwndExplorer, blame.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);\r
                }\r
        }\r
+#endif\r
        return bRet;\r
 }\r
index d6ab2df..5c3be77 100644 (file)
 #include "CatCommand.h"\r
 \r
 #include "PathUtils.h"\r
-#include "SVN.h"\r
+#include "Git.h"\r
 \r
 bool CatCommand::Execute()\r
 {\r
+#if 0\r
        CString savepath = CPathUtils::GetLongPathname(parser.GetVal(_T("savepath")));\r
        CString revision = parser.GetVal(_T("revision"));\r
        CString pegrevision = parser.GetVal(_T("pegrevision"));\r
@@ -39,6 +40,7 @@ bool CatCommand::Execute()
                ::MessageBox(NULL, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);\r
                ::DeleteFile(savepath);\r
                return false;\r
-       } \r
+       }\r
+#endif\r
        return true;\r
 }\r
index b2aece9..4c3b5a5 100644 (file)
 bool CleanupCommand::Execute()\r
 {\r
        bool bRet = false;\r
+\r
+       CProgressDlg progress;\r
+       progress.m_GitCmd.Format(_T("Git Clean -d -x"));\r
+       if(progress.DoModal()==IDOK)\r
+                       return TRUE;\r
+\r
 #if 0\r
        CProgressDlg progress;\r
        progress.SetTitle(IDS_PROC_CLEANUP);\r
index a9e6f34..e958761 100644 (file)
 #include "IgnoreCommand.h"\r
 #include "FormatPatchCommand.h"\r
 #include "ImportPatchCommand.h"\r
-\r
+#include "BlameCommand.h"\r
 \r
 #if 0\r
 \r
-#include "BlameCommand.h"\r
+\r
 #include "CatCommand.h"\r
 #include "CheckoutCommand.h"\r
 #include "CleanupCommand.h"\r
@@ -290,11 +290,12 @@ Command * CommandServer::GetCommand(const CString& sCmd)
                return new FormatPatchCommand;\r
        case cmdImportPatch:\r
                return new ImportPatchCommand;\r
+       case cmdBlame:\r
+               return new BlameCommand;\r
+       \r
 \r
 #if 0\r
 \r
-       case cmdBlame:\r
-               return new BlameCommand;\r
        case cmdCat:\r
                return new CatCommand;\r
        case cmdCheckout:\r
@@ -348,8 +349,7 @@ Command * CommandServer::GetCommand(const CString& sCmd)
                return new RebuildIconCacheCommand;\r
        case cmdRelocate:\r
                return new RelocateCommand;\r
-       case cmdRemove:\r
-               return new RemoveCommand;\r
+\r
 \r
        case cmdRepoBrowser:\r
                return new RepositoryBrowserCommand;\r
index 3601eed..1ac7b52 100644 (file)
@@ -53,7 +53,7 @@ bool DiffCommand::Execute()
                        else\r
 #endif\r
                        {\r
-                               //svn_revnum_t baseRev = 0;\r
+                               //git_revnum_t baseRev = 0;\r
                                bRet = diff.Diff(&cmdLinePath,git_revnum_t(_T("HEAD")),git_revnum_t(GIT_REV_ZERO));\r
                        }\r
                }\r
index 8b1c882..8c725f7 100644 (file)
@@ -116,5 +116,28 @@ bool RemoveCommand::Execute()
        if (bRet)\r
                CShellUpdater::Instance().AddPathsForUpdate(pathList);\r
 #endif\r
+       int key=CMessageBox::Show(hwndExplorer, _T("File will removed from version control\r\n Do you want to keep local copy"), _T("TortoiseGit"), MB_ICONINFORMATION|MB_YESNOCANCEL);\r
+       if(key == IDCANCEL)\r
+               return FALSE;\r
+\r
+       CString cmd;\r
+       if(key == IDNO)\r
+               cmd=_T("git.exe rm -r -f ");\r
+\r
+       if(key == IDYES)\r
+               cmd= _T("git.exe update-index --force-remove -- ");\r
+\r
+       for(int nPath = 0; nPath < pathList.GetCount(); nPath++)\r
+       {\r
+               CString output;\r
+               if(g_Git.Run(cmd+pathList[nPath].GetGitPathString(),&output))\r
+               {\r
+                       key=CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_ICONINFORMATION|MB_OKCANCEL);\r
+                       if(key == IDCANCEL)\r
+                               return FALSE;\r
+\r
+               }\r
+       }\r
+\r
        return bRet;\r
 }\r
index 59d0b88..d18314a 100644 (file)
                        <Filter\r
                                Name="Blame"\r
                                >\r
+                               <File\r
+                                       RelativePath=".\Commands\BlameCommand.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath=".\Commands\BlameCommand.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath=".\BlameDlg.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath=".\BlameDlg.h"\r
+                                       >\r
+                               </File>\r
                        </Filter>\r
                        <Filter\r
                                Name="Log"\r
                                        >\r
                                </File>\r
                        </Filter>\r
+                       <Filter\r
+                               Name="cat"\r
+                               >\r
+                               <File\r
+                                       RelativePath=".\Commands\CatCommand.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath=".\Commands\CatCommand.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
                </Filter>\r
                <Filter\r
                        Name="Utility Dialogs"\r
index a9acb41..b3b0ce5 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\\git&quot;"\r
+                               CommandArguments="/command:blame /path:&quot;D:\\Profiles\\b20596\\git&quot;"\r
                                Attach="false"\r
                                DebuggerType="3"\r
                                Remote="1"\r