1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2007-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "CleanupCommand.h"
\r
22 #include "MessageBox.h"
\r
23 #include "ProgressDlg.h"
\r
25 //#include "GitGlobal.h"
\r
26 #include "GitAdminDir.h"
\r
27 #include "DirFileEnum.h"
\r
28 #include "ShellUpdater.h"
\r
30 bool CleanupCommand::Execute()
\r
34 CProgressDlg progress;
\r
35 progress.m_GitCmd.Format(_T("Git Clean -d -x"));
\r
36 if(progress.DoModal()==IDOK)
\r
40 CProgressDlg progress;
\r
41 progress.SetTitle(IDS_PROC_CLEANUP);
\r
42 progress.SetAnimation(IDR_CLEANUPANI);
\r
43 progress.SetShowProgressBar(false);
\r
44 progress.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROC_CLEANUP_INFO1)));
\r
45 progress.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROC_CLEANUP_INFO2)));
\r
46 progress.ShowModeless(hwndExplorer);
\r
48 CString strSuccessfullPaths, strFailedPaths;
\r
49 for (int i=0; i<pathList.GetCount(); ++i)
\r
52 if (!svn.CleanUp(pathList[i]))
\r
54 strFailedPaths += _T("- ") + pathList[i].GetWinPathString() + _T("\n");
\r
55 strFailedPaths += svn.GetLastErrorMessage() + _T("\n\n");
\r
59 strSuccessfullPaths += _T("- ") + pathList[i].GetWinPathString() + _T("\n");
\r
61 // after the cleanup has finished, crawl the path downwards and send a change
\r
62 // notification for every directory to the shell. This will update the
\r
63 // overlays in the left tree view of the explorer.
\r
64 CDirFileEnum crawler(pathList[i].GetWinPathString());
\r
67 CTSVNPathList updateList;
\r
68 while (crawler.NextFile(sPath, &bDir))
\r
70 if ((bDir) && (!g_SVNAdminDir.IsAdminDirPath(sPath)))
\r
72 updateList.AddPath(CTSVNPath(sPath));
\r
75 updateList.AddPath(pathList[i]);
\r
76 CShellUpdater::Instance().AddPathsForUpdate(updateList);
\r
77 CShellUpdater::Instance().Flush();
\r
78 updateList.SortByPathname(true);
\r
79 for (INT_PTR i=0; i<updateList.GetCount(); ++i)
\r
81 SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH, updateList[i].GetWinPath(), NULL);
\r
82 ATLTRACE(_T("notify change for path %s\n"), updateList[i].GetWinPath());
\r
89 if ( !strSuccessfullPaths.IsEmpty() )
\r
92 tmp.Format(IDS_PROC_CLEANUPFINISHED, (LPCTSTR)strSuccessfullPaths);
\r
96 if ( !strFailedPaths.IsEmpty() )
\r
98 if (!strMessage.IsEmpty())
\r
99 strMessage += _T("\n");
\r
101 tmp.Format(IDS_PROC_CLEANUPFINISHED_FAILED, (LPCTSTR)strFailedPaths);
\r
105 CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseSVN"), MB_OK | (strFailedPaths.IsEmpty()?MB_ICONINFORMATION:MB_ICONERROR));
\r