OSDN Git Service

Send email to multi person success and add CC and TO list
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / SVNProgressDlg.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \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
9 \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
14 \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
18 //\r
19 #include "stdafx.h"\r
20 #include "TortoiseProc.h"\r
21 #include "messagebox.h"\r
22 #include "SVNProgressDlg.h"\r
23 #include "LogDlg.h"\r
24 #include "TGitPath.h"\r
25 #include "Registry.h"\r
26 #include "GitStatus.h"\r
27 #include "AppUtils.h"\r
28 #include "PathUtils.h"\r
29 #include "StringUtils.h"\r
30 #include "TempFile.h"\r
31 #include "UnicodeUtils.h"\r
32 #include "SoundUtils.h"\r
33 #include "GitDiff.h"\r
34 #include "Hooks.h"\r
35 #include "DropFiles.h"\r
36 //#include "GitLogHelper.h"\r
37 #include "RegHistory.h"\r
38 //#include "ConflictResolveDlg.h"\r
39 #include "LogFile.h"\r
40 #include "ShellUpdater.h"\r
41 #include "IconMenu.h"\r
42 #include "BugTraqAssociations.h"\r
43 #include "patch.h"\r
44 \r
45 static UINT WM_GITPROGRESS = RegisterWindowMessage(_T("TORTOISEGIT_GITPROGRESS_MSG"));\r
46 \r
47 BOOL    CGitProgressDlg::m_bAscending = FALSE;\r
48 int             CGitProgressDlg::m_nSortedColumn = -1;\r
49 \r
50 #define TRANSFERTIMER   100\r
51 #define VISIBLETIMER    101\r
52 \r
53 enum SVNProgressDlgContextMenuCommands\r
54 {\r
55         // needs to start with 1, since 0 is the return value if *nothing* is clicked on in the context menu\r
56         ID_COMPARE = 1,\r
57         ID_EDITCONFLICT,\r
58         ID_CONFLICTRESOLVE,\r
59         ID_CONFLICTUSETHEIRS,\r
60         ID_CONFLICTUSEMINE,\r
61         ID_LOG,\r
62         ID_OPEN,\r
63         ID_OPENWITH,\r
64         ID_EXPLORE,\r
65         ID_COPY\r
66 };\r
67 \r
68 IMPLEMENT_DYNAMIC(CGitProgressDlg, CResizableStandAloneDialog)\r
69 CGitProgressDlg::CGitProgressDlg(CWnd* pParent /*=NULL*/)\r
70         : CResizableStandAloneDialog(CGitProgressDlg::IDD, pParent)\r
71 #if 0\r
72         , m_Revision(_T("HEAD"))\r
73         //, m_RevisionEnd(0)\r
74         , m_bLockWarning(false)\r
75         , m_bLockExists(false)\r
76         , m_bCancelled(FALSE)\r
77         , m_bThreadRunning(FALSE)\r
78         , m_nConflicts(0)\r
79         , m_bErrorsOccurred(FALSE)\r
80         , m_bMergesAddsDeletesOccurred(FALSE)\r
81         , m_pThread(NULL)\r
82         , m_options(ProgOptNone)\r
83         , m_dwCloseOnEnd((DWORD)-1)\r
84         , m_bFinishedItemAdded(false)\r
85         , m_bLastVisible(false)\r
86 //      , m_depth(svn_depth_unknown)\r
87         , m_itemCount(-1)\r
88         , m_itemCountTotal(-1)\r
89         , m_AlwaysConflicted(false)\r
90         , m_BugTraqProvider(NULL)\r
91         , sIgnoredIncluded(MAKEINTRESOURCE(IDS_PROGRS_IGNOREDINCLUDED))\r
92         , sExtExcluded(MAKEINTRESOURCE(IDS_PROGRS_EXTERNALSEXCLUDED))\r
93         , sExtIncluded(MAKEINTRESOURCE(IDS_PROGRS_EXTERNALSINCLUDED))\r
94         , sIgnoreAncestry(MAKEINTRESOURCE(IDS_PROGRS_IGNOREANCESTRY))\r
95         , sRespectAncestry(MAKEINTRESOURCE(IDS_PROGRS_RESPECTANCESTRY))\r
96         , sDryRun(MAKEINTRESOURCE(IDS_PROGRS_DRYRUN))\r
97         , sRecordOnly(MAKEINTRESOURCE(IDS_MERGE_RECORDONLY))\r
98 #endif\r
99 {\r
100 }\r
101 \r
102 CGitProgressDlg::~CGitProgressDlg()\r
103 {\r
104         for (size_t i=0; i<m_arData.size(); i++)\r
105         {\r
106                 delete m_arData[i];\r
107         } \r
108         if(m_pThread != NULL)\r
109         {\r
110                 delete m_pThread;\r
111         }\r
112 }\r
113 \r
114 void CGitProgressDlg::DoDataExchange(CDataExchange* pDX)\r
115 {\r
116         CResizableStandAloneDialog::DoDataExchange(pDX);\r
117         DDX_Control(pDX, IDC_SVNPROGRESS, m_ProgList);\r
118 }\r
119 \r
120 BEGIN_MESSAGE_MAP(CGitProgressDlg, CResizableStandAloneDialog)\r
121         ON_BN_CLICKED(IDC_LOGBUTTON, OnBnClickedLogbutton)\r
122         ON_NOTIFY(NM_CUSTOMDRAW, IDC_SVNPROGRESS, OnNMCustomdrawSvnprogress)\r
123         ON_WM_CLOSE()\r
124         ON_NOTIFY(NM_DBLCLK, IDC_SVNPROGRESS, OnNMDblclkSvnprogress)\r
125         ON_NOTIFY(HDN_ITEMCLICK, 0, OnHdnItemclickSvnprogress)\r
126         ON_WM_SETCURSOR()\r
127         ON_WM_CONTEXTMENU()\r
128         ON_REGISTERED_MESSAGE(WM_GITPROGRESS, OnGitProgress)\r
129         ON_WM_TIMER()\r
130         ON_EN_SETFOCUS(IDC_INFOTEXT, &CGitProgressDlg::OnEnSetfocusInfotext)\r
131         ON_NOTIFY(LVN_BEGINDRAG, IDC_SVNPROGRESS, &CGitProgressDlg::OnLvnBegindragSvnprogress)\r
132         ON_WM_SIZE()\r
133         ON_NOTIFY(LVN_GETDISPINFO, IDC_SVNPROGRESS, &CGitProgressDlg::OnLvnGetdispinfoSvnprogress)\r
134         ON_BN_CLICKED(IDC_NONINTERACTIVE, &CGitProgressDlg::OnBnClickedNoninteractive)\r
135         ON_MESSAGE(WM_SHOWCONFLICTRESOLVER, OnShowConflictResolver)\r
136 END_MESSAGE_MAP()\r
137 \r
138 BOOL CGitProgressDlg::Cancel()\r
139 {\r
140         return m_bCancelled;\r
141 }\r
142 \r
143 LRESULT CGitProgressDlg::OnShowConflictResolver(WPARAM /*wParam*/, LPARAM lParam)\r
144 {\r
145 #if 0\r
146         CConflictResolveDlg dlg(this);\r
147         const svn_wc_conflict_description_t *description = (svn_wc_conflict_description_t *)lParam;\r
148         if (description)\r
149         {\r
150                 dlg.SetConflictDescription(description);\r
151                 if (dlg.DoModal() == IDOK)\r
152                 {\r
153                         if (dlg.GetResult() == svn_wc_conflict_choose_postpone)\r
154                         {\r
155                                 // if the result is conflicted and the dialog returned IDOK,\r
156                                 // that means we should not ask again in case of a conflict\r
157                                 m_AlwaysConflicted = true;\r
158                                 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_SETCHECK, BST_CHECKED, 0);\r
159                         }\r
160                 }\r
161                 m_mergedfile = dlg.GetMergedFile();\r
162                 m_bCancelled = dlg.IsCancelled();\r
163                 return dlg.GetResult();\r
164         }\r
165 \r
166         return svn_wc_conflict_choose_postpone;\r
167 #endif\r
168         return 0;\r
169 }\r
170 #if 0\r
171 svn_wc_conflict_choice_t CGitProgressDlg::ConflictResolveCallback(const svn_wc_conflict_description_t *description, CString& mergedfile)\r
172 {\r
173         // we only bother the user when merging\r
174         if (((m_Command == GitProgress_Merge)||(m_Command == GitProgress_MergeAll)||(m_Command == GitProgress_MergeReintegrate))&&(!m_AlwaysConflicted)&&(description))\r
175         {\r
176                 // we're in a worker thread here. That means we must not show a dialog from the thread\r
177                 // but let the UI thread do it.\r
178                 // To do that, we send a message to the UI thread and let it show the conflict resolver dialog.\r
179                 LRESULT dlgResult = ::SendMessage(GetSafeHwnd(), WM_SHOWCONFLICTRESOLVER, 0, (LPARAM)description);\r
180                 mergedfile = m_mergedfile;\r
181                 return (svn_wc_conflict_choice_t)dlgResult;\r
182         }\r
183 \r
184         return svn_wc_conflict_choose_postpone;\r
185 }\r
186 #endif\r
187 void CGitProgressDlg::AddItemToList()\r
188 {\r
189         int totalcount = m_ProgList.GetItemCount();\r
190 \r
191         m_ProgList.SetItemCountEx(totalcount+1, LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL);\r
192         // make columns width fit\r
193         if (iFirstResized < 30)\r
194         {\r
195                 // only resize the columns for the first 30 or so entries.\r
196                 // after that, don't resize them anymore because that's an\r
197                 // expensive function call and the columns will be sized\r
198                 // close enough already.\r
199                 ResizeColumns();\r
200                 iFirstResized++;\r
201         }\r
202 \r
203         // Make sure the item is *entirely* visible even if the horizontal\r
204         // scroll bar is visible.\r
205         int count = m_ProgList.GetCountPerPage();\r
206         if (totalcount <= (m_ProgList.GetTopIndex() + count + nEnsureVisibleCount + 2))\r
207         {\r
208                 nEnsureVisibleCount++;\r
209                 m_bLastVisible = true;\r
210         }\r
211         else\r
212         {\r
213                 nEnsureVisibleCount = 0;\r
214                 if (IsIconic() == 0)\r
215                         m_bLastVisible = false;\r
216         }\r
217 }\r
218 \r
219 \r
220 BOOL CGitProgressDlg::Notify(const CTGitPath& path, git_wc_notify_action_t action,\r
221                                                          int status ,\r
222                                                          CString *strErr \r
223                                                          /*\r
224                                                          svn_node_kind_t kind, const CString& mime_type, \r
225                                                          svn_wc_notify_state_t content_state, \r
226                                                          svn_wc_notify_state_t prop_state, LONG rev,\r
227                                                          const svn_lock_t * lock, svn_wc_notify_lock_state_t lock_state,\r
228                                                          const CString& changelistname,\r
229                                                          svn_merge_range_t * range,\r
230                                                          svn_error_t * err, apr_pool_t * pool\r
231                                                          */)\r
232 {\r
233         bool bNoNotify = false;\r
234         bool bDoAddData = true;\r
235         NotificationData * data = new NotificationData();\r
236         data->path = path;\r
237         data->action = action;\r
238         data->sPathColumnText=path.GetGitPathString();\r
239         data->bAuxItem = false;\r
240 #if 0\r
241         data->kind = kind;\r
242         data->mime_type = mime_type;\r
243         data->content_state = content_state;\r
244         data->prop_state = prop_state;\r
245         data->rev = rev;\r
246         data->lock_state = lock_state;\r
247         data->changelistname = changelistname;\r
248         if ((lock)&&(lock->owner))\r
249                 data->owner = CUnicodeUtils::GetUnicode(lock->owner);\r
250         data->sPathColumnText = path.GetUIPathString();\r
251         if (!m_basePath.IsEmpty())\r
252                 data->basepath = m_basePath;\r
253         if (range)\r
254                 data->merge_range = *range;\r
255 #endif\r
256         switch (data->action)\r
257         {\r
258         case git_wc_notify_add:\r
259         //case svn_wc_notify_update_add:\r
260         //      if ((data->content_state == svn_wc_notify_state_conflicted) || (data->prop_state == svn_wc_notify_state_conflicted))\r
261         //      {\r
262         //              data->color = m_Colors.GetColor(CColors::Conflict);\r
263         //              data->bConflictedActionItem = true;\r
264         //              data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);\r
265         //              m_nConflicts++;\r
266         //      }\r
267         //      else\r
268         //      {\r
269         //              m_bMergesAddsDeletesOccurred = true;\r
270                         data->sActionColumnText.LoadString(IDS_SVNACTION_ADD);\r
271                         data->color = m_Colors.GetColor(CColors::Added);\r
272         //      }\r
273                 break;\r
274         case git_wc_notify_sendmail_start:\r
275                 data->bAuxItem = true;\r
276                 data->sActionColumnText.LoadString(IDS_SVNACTION_SENDMAIL_START);\r
277                 data->color = m_Colors.GetColor(CColors::Modified);\r
278                 break;\r
279         \r
280         case git_wc_notify_sendmail_error:\r
281                 data->bAuxItem = true;\r
282                 data->sActionColumnText.LoadString(IDS_SVNACTION_SENDMAIL_ERROR);\r
283                 if(strErr)\r
284                         data->sPathColumnText = *strErr;\r
285                 else\r
286                         data->sPathColumnText.Empty();\r
287                 data->color = m_Colors.GetColor(CColors::Modified);\r
288                 break;\r
289 \r
290         case git_wc_notify_sendmail_done:\r
291                 \r
292                 data->sActionColumnText.LoadString(IDS_SVNACTION_SENDMAIL_DONE);\r
293                 data->sPathColumnText.Empty();\r
294                 data->color = m_Colors.GetColor(CColors::Modified);\r
295                 break;\r
296 \r
297 \r
298         case git_wc_notify_resolved:\r
299                 data->sActionColumnText.LoadString(IDS_SVNACTION_RESOLVE);\r
300                 break;\r
301 \r
302 #if 0\r
303         case svn_wc_notify_commit_added:\r
304                 data->sActionColumnText.LoadString(IDS_SVNACTION_ADDING);\r
305                 data->color = m_Colors.GetColor(CColors::Added);\r
306                 break;\r
307         case svn_wc_notify_copy:\r
308                 data->sActionColumnText.LoadString(IDS_SVNACTION_COPY);\r
309                 break;\r
310         case svn_wc_notify_commit_modified:\r
311                 data->sActionColumnText.LoadString(IDS_SVNACTION_MODIFIED);\r
312                 data->color = m_Colors.GetColor(CColors::Modified);\r
313                 break;\r
314         case svn_wc_notify_delete:\r
315         case svn_wc_notify_update_delete:\r
316                 data->sActionColumnText.LoadString(IDS_SVNACTION_DELETE);\r
317                 m_bMergesAddsDeletesOccurred = true;\r
318                 data->color = m_Colors.GetColor(CColors::Deleted);\r
319                 break;\r
320         case svn_wc_notify_commit_deleted:\r
321                 data->sActionColumnText.LoadString(IDS_SVNACTION_DELETING);\r
322                 data->color = m_Colors.GetColor(CColors::Deleted);\r
323                 break;\r
324         case svn_wc_notify_restore:\r
325                 data->sActionColumnText.LoadString(IDS_SVNACTION_RESTORE);\r
326                 break;\r
327         case svn_wc_notify_revert:\r
328                 data->sActionColumnText.LoadString(IDS_SVNACTION_REVERT);\r
329                 break;\r
330         case svn_wc_notify_update_replace:\r
331         case svn_wc_notify_commit_replaced:\r
332                 data->sActionColumnText.LoadString(IDS_SVNACTION_REPLACED);\r
333                 data->color = m_Colors.GetColor(CColors::Deleted);\r
334                 break;\r
335         case svn_wc_notify_exists:\r
336                 if ((data->content_state == svn_wc_notify_state_conflicted) || (data->prop_state == svn_wc_notify_state_conflicted))\r
337                 {\r
338                         data->color = m_Colors.GetColor(CColors::Conflict);\r
339                         data->bConflictedActionItem = true;\r
340                         m_nConflicts++;\r
341                         data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);\r
342                 }\r
343                 else if ((data->content_state == svn_wc_notify_state_merged) || (data->prop_state == svn_wc_notify_state_merged))\r
344                 {\r
345                         data->color = m_Colors.GetColor(CColors::Merged);\r
346                         m_bMergesAddsDeletesOccurred = true;\r
347                         data->sActionColumnText.LoadString(IDS_SVNACTION_MERGED);\r
348                 }\r
349                 else\r
350                         data->sActionColumnText.LoadString(IDS_SVNACTION_EXISTS);\r
351                 break;\r
352         case svn_wc_notify_update_update:\r
353                 // if this is an inoperative dir change, don't show the notification.\r
354                 // an inoperative dir change is when a directory gets updated without\r
355                 // any real change in either text or properties.\r
356                 if ((kind == svn_node_dir)\r
357                         && ((prop_state == svn_wc_notify_state_inapplicable)\r
358                         || (prop_state == svn_wc_notify_state_unknown)\r
359                         || (prop_state == svn_wc_notify_state_unchanged)))\r
360                 {\r
361                         bNoNotify = true;\r
362                         break;\r
363                 }\r
364                 if ((data->content_state == svn_wc_notify_state_conflicted) || (data->prop_state == svn_wc_notify_state_conflicted))\r
365                 {\r
366                         data->color = m_Colors.GetColor(CColors::Conflict);\r
367                         data->bConflictedActionItem = true;\r
368                         m_nConflicts++;\r
369                         data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);\r
370                 }\r
371                 else if ((data->content_state == svn_wc_notify_state_merged) || (data->prop_state == svn_wc_notify_state_merged))\r
372                 {\r
373                         data->color = m_Colors.GetColor(CColors::Merged);\r
374                         m_bMergesAddsDeletesOccurred = true;\r
375                         data->sActionColumnText.LoadString(IDS_SVNACTION_MERGED);\r
376                 }\r
377                 else if (((data->content_state != svn_wc_notify_state_unchanged)&&(data->content_state != svn_wc_notify_state_unknown)) || \r
378                         ((data->prop_state != svn_wc_notify_state_unchanged)&&(data->prop_state != svn_wc_notify_state_unknown)))\r
379                 {\r
380                         data->sActionColumnText.LoadString(IDS_SVNACTION_UPDATE);\r
381                 }\r
382                 else\r
383                 {\r
384                         bNoNotify = true;\r
385                         break;\r
386                 }\r
387                 if (lock_state == svn_wc_notify_lock_state_unlocked)\r
388                 {\r
389                         CString temp(MAKEINTRESOURCE(IDS_SVNACTION_UNLOCKED));\r
390                         data->sActionColumnText += _T(", ") + temp;\r
391                 }\r
392                 break;\r
393 \r
394         case svn_wc_notify_update_external:\r
395                 // For some reason we build a list of externals...\r
396                 m_ExtStack.AddHead(path.GetUIPathString());\r
397                 data->sActionColumnText.LoadString(IDS_SVNACTION_EXTERNAL);\r
398                 data->bAuxItem = true;\r
399                 break;\r
400 \r
401         case svn_wc_notify_update_completed:\r
402                 {\r
403                         data->sActionColumnText.LoadString(IDS_SVNACTION_COMPLETED);\r
404                         data->bAuxItem = true;\r
405                         bool bEmpty = !!m_ExtStack.IsEmpty();\r
406                         if (!bEmpty)\r
407                                 data->sPathColumnText.Format(IDS_PROGRS_PATHATREV, (LPCTSTR)m_ExtStack.RemoveHead(), rev);\r
408                         else\r
409                                 data->sPathColumnText.Format(IDS_PROGRS_ATREV, rev);\r
410 \r
411                         if ((m_nConflicts>0)&&(bEmpty))\r
412                         {\r
413                                 // We're going to add another aux item - let's shove this current onto the list first\r
414                                 // I don't really like this, but it will do for the moment.\r
415                                 m_arData.push_back(data);\r
416                                 AddItemToList();\r
417 \r
418                                 data = new NotificationData();\r
419                                 data->bAuxItem = true;\r
420                                 data->sActionColumnText.LoadString(IDS_PROGRS_CONFLICTSOCCURED_WARNING);\r
421                                 data->sPathColumnText.LoadString(IDS_PROGRS_CONFLICTSOCCURED);\r
422                                 data->color = m_Colors.GetColor(CColors::Conflict);\r
423                                 CSoundUtils::PlayTSVNWarning();\r
424                                 // This item will now be added after the switch statement\r
425                         }\r
426                         if (!m_basePath.IsEmpty())\r
427                                 m_FinishedRevMap[m_basePath.GetSVNApiPath(pool)] = rev;\r
428                         m_RevisionEnd = rev;\r
429                         m_bFinishedItemAdded = true;\r
430                 }\r
431                 break;\r
432         case svn_wc_notify_commit_postfix_txdelta:\r
433                 data->sActionColumnText.LoadString(IDS_SVNACTION_POSTFIX);\r
434                 break;\r
435         case svn_wc_notify_failed_revert:\r
436                 data->sActionColumnText.LoadString(IDS_SVNACTION_FAILEDREVERT);\r
437                 break;\r
438         case svn_wc_notify_status_completed:\r
439         case svn_wc_notify_status_external:\r
440                 data->sActionColumnText.LoadString(IDS_SVNACTION_STATUS);\r
441                 break;\r
442         case svn_wc_notify_skip:\r
443                 if ((content_state == svn_wc_notify_state_missing)||(content_state == svn_wc_notify_state_obstructed)||(content_state == svn_wc_notify_state_conflicted))\r
444                 {\r
445                         data->sActionColumnText.LoadString(IDS_SVNACTION_SKIPMISSING);\r
446 \r
447                         // The color settings dialog describes the red color with\r
448                         // "possible or real conflict / obstructed" which also applies to\r
449                         // skipped targets during a merge. So we just use the same color.\r
450                         data->color = m_Colors.GetColor(CColors::Conflict);\r
451                 }\r
452                 else\r
453                         data->sActionColumnText.LoadString(IDS_SVNACTION_SKIP);\r
454                 break;\r
455         case svn_wc_notify_locked:\r
456                 if ((lock)&&(lock->owner))\r
457                         data->sActionColumnText.Format(IDS_SVNACTION_LOCKEDBY, (LPCTSTR)CUnicodeUtils::GetUnicode(lock->owner));\r
458                 break;\r
459         case svn_wc_notify_unlocked:\r
460                 data->sActionColumnText.LoadString(IDS_SVNACTION_UNLOCKED);\r
461                 break;\r
462         case svn_wc_notify_failed_lock:\r
463                 data->sActionColumnText.LoadString(IDS_SVNACTION_FAILEDLOCK);\r
464                 m_arData.push_back(data);\r
465                 AddItemToList();\r
466                 ReportError(SVN::GetErrorString(err));\r
467                 bDoAddData = false;\r
468                 if (err->apr_err == SVN_ERR_FS_OUT_OF_DATE)\r
469                         m_bLockWarning = true;\r
470                 if (err->apr_err == SVN_ERR_FS_PATH_ALREADY_LOCKED)\r
471                         m_bLockExists = true;\r
472                 break;\r
473         case svn_wc_notify_failed_unlock:\r
474                 data->sActionColumnText.LoadString(IDS_SVNACTION_FAILEDUNLOCK);\r
475                 m_arData.push_back(data);\r
476                 AddItemToList();\r
477                 ReportError(SVN::GetErrorString(err));\r
478                 bDoAddData = false;\r
479                 if (err->apr_err == SVN_ERR_FS_OUT_OF_DATE)\r
480                         m_bLockWarning = true;\r
481                 break;\r
482         case svn_wc_notify_changelist_set:\r
483                 data->sActionColumnText.Format(IDS_SVNACTION_CHANGELISTSET, (LPCTSTR)data->changelistname);\r
484                 break;\r
485         case svn_wc_notify_changelist_clear:\r
486                 data->sActionColumnText.LoadString(IDS_SVNACTION_CHANGELISTCLEAR);\r
487                 break;\r
488         case svn_wc_notify_changelist_moved:\r
489                 data->sActionColumnText.Format(IDS_SVNACTION_CHANGELISTMOVED, (LPCTSTR)data->changelistname);\r
490                 break;\r
491         case svn_wc_notify_foreign_merge_begin:\r
492         case svn_wc_notify_merge_begin:\r
493                 if (range == NULL)\r
494                         data->sActionColumnText.LoadString(IDS_SVNACTION_MERGEBEGINNONE);\r
495                 else if ((data->merge_range.start == data->merge_range.end) || (data->merge_range.start == data->merge_range.end - 1))\r
496                         data->sActionColumnText.Format(IDS_SVNACTION_MERGEBEGINSINGLE, data->merge_range.end);\r
497                 else if (data->merge_range.start - 1 == data->merge_range.end)\r
498                         data->sActionColumnText.Format(IDS_SVNACTION_MERGEBEGINSINGLEREVERSE, data->merge_range.start);\r
499                 else if (data->merge_range.start < data->merge_range.end)\r
500                         data->sActionColumnText.Format(IDS_SVNACTION_MERGEBEGINMULTIPLE, data->merge_range.start + 1, data->merge_range.end);\r
501                 else\r
502                         data->sActionColumnText.Format(IDS_SVNACTION_MERGEBEGINMULTIPLEREVERSE, data->merge_range.start, data->merge_range.end + 1);\r
503                 data->bAuxItem = true;\r
504                 break;\r
505 #endif\r
506         default:\r
507                 break;\r
508         } // switch (data->action)\r
509 \r
510         if (bNoNotify)\r
511                 delete data;\r
512         else\r
513         {\r
514                 if (bDoAddData)\r
515                 {\r
516                         m_arData.push_back(data);\r
517                         AddItemToList();\r
518                         if ((!data->bAuxItem) && (m_itemCount > 0))\r
519                         {\r
520                                 m_itemCount--;\r
521 \r
522                                 CProgressCtrl * progControl = (CProgressCtrl *)GetDlgItem(IDC_PROGRESSBAR);\r
523                                 progControl->ShowWindow(SW_SHOW);\r
524                                 progControl->SetPos(m_itemCountTotal - m_itemCount);\r
525                                 progControl->SetRange32(0, m_itemCountTotal);\r
526                         }\r
527                 }\r
528                 //if ((action == svn_wc_notify_commit_postfix_txdelta)&&(bSecondResized == FALSE))\r
529                 //{\r
530                 //      ResizeColumns();\r
531                 //      bSecondResized = TRUE;\r
532                 //}\r
533         }\r
534 \r
535         return TRUE;\r
536 }\r
537 \r
538 \r
539 CString CGitProgressDlg::BuildInfoString()\r
540 {\r
541         CString infotext;\r
542 #if 0\r
543         \r
544         CString temp;\r
545         int added = 0;\r
546         int copied = 0;\r
547         int deleted = 0;\r
548         int restored = 0;\r
549         int reverted = 0;\r
550         int resolved = 0;\r
551         int conflicted = 0;\r
552         int updated = 0;\r
553         int merged = 0;\r
554         int modified = 0;\r
555         int skipped = 0;\r
556         int replaced = 0;\r
557 \r
558         for (size_t i=0; i<m_arData.size(); ++i)\r
559         {\r
560                 const NotificationData * dat = m_arData[i];\r
561                 switch (dat->action)\r
562                 {\r
563                 case svn_wc_notify_add:\r
564                 case svn_wc_notify_update_add:\r
565                 case svn_wc_notify_commit_added:\r
566                         if (dat->bConflictedActionItem)\r
567                                 conflicted++;\r
568                         else\r
569                                 added++;\r
570                         break;\r
571                 case svn_wc_notify_copy:\r
572                         copied++;\r
573                         break;\r
574                 case svn_wc_notify_delete:\r
575                 case svn_wc_notify_update_delete:\r
576                 case svn_wc_notify_commit_deleted:\r
577                         deleted++;\r
578                         break;\r
579                 case svn_wc_notify_restore:\r
580                         restored++;\r
581                         break;\r
582                 case svn_wc_notify_revert:\r
583                         reverted++;\r
584                         break;\r
585                 case svn_wc_notify_resolved:\r
586                         resolved++;\r
587                         break;\r
588                 case svn_wc_notify_update_update:\r
589                         if (dat->bConflictedActionItem)\r
590                                 conflicted++;\r
591                         else if ((dat->content_state == svn_wc_notify_state_merged) || (dat->prop_state == svn_wc_notify_state_merged))\r
592                                 merged++;\r
593                         else\r
594                                 updated++;\r
595                         break;\r
596                 case svn_wc_notify_commit_modified:\r
597                         modified++;\r
598                         break;\r
599                 case svn_wc_notify_skip:\r
600                         skipped++;\r
601                         break;\r
602                 case svn_wc_notify_commit_replaced:\r
603                         replaced++;\r
604                         break;\r
605                 }\r
606         }\r
607         if (conflicted)\r
608         {\r
609                 temp.LoadString(IDS_SVNACTION_CONFLICTED);\r
610                 infotext += temp;\r
611                 temp.Format(_T(":%d "), conflicted);\r
612                 infotext += temp;\r
613         }\r
614         if (skipped)\r
615         {\r
616                 temp.LoadString(IDS_SVNACTION_SKIP);\r
617                 infotext += temp;\r
618                 infotext.AppendFormat(_T(":%d "), skipped);\r
619         }\r
620         if (merged)\r
621         {\r
622                 temp.LoadString(IDS_SVNACTION_MERGED);\r
623                 infotext += temp;\r
624                 infotext.AppendFormat(_T(":%d "), merged);\r
625         }\r
626         if (added)\r
627         {\r
628                 temp.LoadString(IDS_SVNACTION_ADD);\r
629                 infotext += temp;\r
630                 infotext.AppendFormat(_T(":%d "), added);\r
631         }\r
632         if (deleted)\r
633         {\r
634                 temp.LoadString(IDS_SVNACTION_DELETE);\r
635                 infotext += temp;\r
636                 infotext.AppendFormat(_T(":%d "), deleted);\r
637         }\r
638         if (modified)\r
639         {\r
640                 temp.LoadString(IDS_SVNACTION_MODIFIED);\r
641                 infotext += temp;\r
642                 infotext.AppendFormat(_T(":%d "), modified);\r
643         }\r
644         if (copied)\r
645         {\r
646                 temp.LoadString(IDS_SVNACTION_COPY);\r
647                 infotext += temp;\r
648                 infotext.AppendFormat(_T(":%d "), copied);\r
649         }\r
650         if (replaced)\r
651         {\r
652                 temp.LoadString(IDS_SVNACTION_REPLACED);\r
653                 infotext += temp;\r
654                 infotext.AppendFormat(_T(":%d "), replaced);\r
655         }\r
656         if (updated)\r
657         {\r
658                 temp.LoadString(IDS_SVNACTION_UPDATE);\r
659                 infotext += temp;\r
660                 infotext.AppendFormat(_T(":%d "), updated);\r
661         }\r
662         if (restored)\r
663         {\r
664                 temp.LoadString(IDS_SVNACTION_RESTORE);\r
665                 infotext += temp;\r
666                 infotext.AppendFormat(_T(":%d "), restored);\r
667         }\r
668         if (reverted)\r
669         {\r
670                 temp.LoadString(IDS_SVNACTION_REVERT);\r
671                 infotext += temp;\r
672                 infotext.AppendFormat(_T(":%d "), reverted);\r
673         }\r
674         if (resolved)\r
675         {\r
676                 temp.LoadString(IDS_SVNACTION_RESOLVE);\r
677                 infotext += temp;\r
678                 infotext.AppendFormat(_T(":%d "), resolved);\r
679         }\r
680 #endif\r
681         return infotext;\r
682 }\r
683 \r
684 void CGitProgressDlg::SetSelectedList(const CTGitPathList& selPaths)\r
685 {\r
686         m_selectedPaths = selPaths;\r
687 }\r
688 \r
689 void CGitProgressDlg::ResizeColumns()\r
690 {\r
691         m_ProgList.SetRedraw(FALSE);\r
692 \r
693         TCHAR textbuf[MAX_PATH];\r
694 \r
695         int maxcol = ((CHeaderCtrl*)(m_ProgList.GetDlgItem(0)))->GetItemCount()-1;\r
696         for (int col = 0; col <= maxcol; col++)\r
697         {\r
698                 // find the longest width of all items\r
699                 int count = m_ProgList.GetItemCount();\r
700                 HDITEM hdi = {0};\r
701                 hdi.mask = HDI_TEXT;\r
702                 hdi.pszText = textbuf;\r
703                 hdi.cchTextMax = sizeof(textbuf);\r
704                 ((CHeaderCtrl*)(m_ProgList.GetDlgItem(0)))->GetItem(col, &hdi);\r
705                 int cx = m_ProgList.GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin\r
706 \r
707                 for (int index = 0; index<count; ++index)\r
708                 {\r
709                         // get the width of the string and add 12 pixels for the column separator and margins\r
710                         int linewidth = cx;\r
711                         switch (col)\r
712                         {\r
713                         case 0:\r
714                                 linewidth = m_ProgList.GetStringWidth(m_arData[index]->sActionColumnText) + 12;\r
715                                 break;\r
716                         case 1:\r
717                                 linewidth = m_ProgList.GetStringWidth(m_arData[index]->sPathColumnText) + 12;\r
718                                 break;\r
719                         case 2:\r
720                                 linewidth = m_ProgList.GetStringWidth(m_arData[index]->mime_type) + 12;\r
721                                 break;\r
722                         }\r
723                         if (cx < linewidth)\r
724                                 cx = linewidth;\r
725                 }\r
726                 m_ProgList.SetColumnWidth(col, cx);\r
727         }\r
728 \r
729         m_ProgList.SetRedraw(TRUE);     \r
730 }\r
731 \r
732 BOOL CGitProgressDlg::OnInitDialog()\r
733 {\r
734         __super::OnInitDialog();\r
735 \r
736         m_ProgList.SetExtendedStyle (LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);\r
737 \r
738         m_ProgList.DeleteAllItems();\r
739         int c = ((CHeaderCtrl*)(m_ProgList.GetDlgItem(0)))->GetItemCount()-1;\r
740         while (c>=0)\r
741                 m_ProgList.DeleteColumn(c--);\r
742         CString temp;\r
743         temp.LoadString(IDS_PROGRS_ACTION);\r
744         m_ProgList.InsertColumn(0, temp);\r
745         temp.LoadString(IDS_PROGRS_PATH);\r
746         m_ProgList.InsertColumn(1, temp);\r
747         temp.LoadString(IDS_PROGRS_MIMETYPE);\r
748         m_ProgList.InsertColumn(2, temp);\r
749 \r
750         m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);\r
751         if (m_pThread==NULL)\r
752         {\r
753                 ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));\r
754         }\r
755         else\r
756         {\r
757                 m_pThread->m_bAutoDelete = FALSE;\r
758                 m_pThread->ResumeThread();\r
759         }\r
760 \r
761         UpdateData(FALSE);\r
762 \r
763         // Call this early so that the column headings aren't hidden before any\r
764         // text gets added.\r
765         ResizeColumns();\r
766 \r
767         SetTimer(VISIBLETIMER, 300, NULL);\r
768 \r
769         AddAnchor(IDC_SVNPROGRESS, TOP_LEFT, BOTTOM_RIGHT);\r
770         AddAnchor(IDC_PROGRESSLABEL, BOTTOM_LEFT, BOTTOM_CENTER);\r
771         AddAnchor(IDC_PROGRESSBAR, BOTTOM_CENTER, BOTTOM_RIGHT);\r
772         AddAnchor(IDC_INFOTEXT, BOTTOM_LEFT, BOTTOM_RIGHT);\r
773         AddAnchor(IDC_NONINTERACTIVE, BOTTOM_LEFT, BOTTOM_RIGHT);\r
774         AddAnchor(IDCANCEL, BOTTOM_RIGHT);\r
775         AddAnchor(IDOK, BOTTOM_RIGHT);\r
776         AddAnchor(IDC_LOGBUTTON, BOTTOM_RIGHT);\r
777         //SetPromptParentWindow(this->m_hWnd);\r
778         if (hWndExplorer)\r
779                 CenterWindow(CWnd::FromHandle(hWndExplorer));\r
780         EnableSaveRestore(_T("SVNProgressDlg"));\r
781         return TRUE;\r
782 }\r
783 \r
784 bool CGitProgressDlg::SetBackgroundImage(UINT nID)\r
785 {\r
786         return CAppUtils::SetListCtrlBackgroundImage(m_ProgList.GetSafeHwnd(), nID);\r
787 }\r
788 \r
789 #if 0\r
790 void CGitProgressDlg::ReportSVNError()\r
791 {\r
792         ReportError(GetLastErrorMessage());\r
793 }\r
794 #endif\r
795 \r
796 void CGitProgressDlg::ReportError(const CString& sError)\r
797 {\r
798         CSoundUtils::PlayTGitError();\r
799         ReportString(sError, CString(MAKEINTRESOURCE(IDS_ERR_ERROR)), m_Colors.GetColor(CColors::Conflict));\r
800         m_bErrorsOccurred = true;\r
801 }\r
802 \r
803 void CGitProgressDlg::ReportWarning(const CString& sWarning)\r
804 {\r
805         CSoundUtils::PlayTGitWarning();\r
806         ReportString(sWarning, CString(MAKEINTRESOURCE(IDS_WARN_WARNING)), m_Colors.GetColor(CColors::Conflict));\r
807 }\r
808 \r
809 void CGitProgressDlg::ReportNotification(const CString& sNotification)\r
810 {\r
811         CSoundUtils::PlayTGitNotification();\r
812         ReportString(sNotification, CString(MAKEINTRESOURCE(IDS_WARN_NOTE)));\r
813 }\r
814 \r
815 void CGitProgressDlg::ReportCmd(const CString& sCmd)\r
816 {\r
817         ReportString(sCmd, CString(MAKEINTRESOURCE(IDS_PROGRS_CMDINFO)), m_Colors.GetColor(CColors::Cmd));\r
818 }\r
819 \r
820 void CGitProgressDlg::ReportString(CString sMessage, const CString& sMsgKind, COLORREF color)\r
821 {\r
822         // instead of showing a dialog box with the error message or notification,\r
823         // just insert the error text into the list control.\r
824         // that way the user isn't 'interrupted' by a dialog box popping up!\r
825 \r
826         // the message may be split up into different lines\r
827         // so add a new entry for each line of the message\r
828         while (!sMessage.IsEmpty())\r
829         {\r
830                 NotificationData * data = new NotificationData();\r
831                 data->bAuxItem = true;\r
832                 data->sActionColumnText = sMsgKind;\r
833                 if (sMessage.Find('\n')>=0)\r
834                         data->sPathColumnText = sMessage.Left(sMessage.Find('\n'));\r
835                 else\r
836                         data->sPathColumnText = sMessage;               \r
837                 data->sPathColumnText.Trim(_T("\n\r"));\r
838                 data->color = color;\r
839                 if (sMessage.Find('\n')>=0)\r
840                 {\r
841                         sMessage = sMessage.Mid(sMessage.Find('\n'));\r
842                         sMessage.Trim(_T("\n\r"));\r
843                 }\r
844                 else\r
845                         sMessage.Empty();\r
846                 m_arData.push_back(data);\r
847                 AddItemToList();\r
848         }\r
849 }\r
850 \r
851 UINT CGitProgressDlg::ProgressThreadEntry(LPVOID pVoid)\r
852 {\r
853         return ((CGitProgressDlg*)pVoid)->ProgressThread();\r
854 }\r
855 \r
856 UINT CGitProgressDlg::ProgressThread()\r
857 {\r
858         // The SetParams function should have loaded something for us\r
859 \r
860         CString temp;\r
861         CString sWindowTitle;\r
862         bool localoperation = false;\r
863         bool bSuccess = false;\r
864         m_AlwaysConflicted = false;\r
865 \r
866         DialogEnableWindow(IDOK, FALSE);\r
867         DialogEnableWindow(IDCANCEL, TRUE);\r
868 //      SetAndClearProgressInfo(m_hWnd);\r
869         m_itemCount = m_itemCountTotal;\r
870 \r
871         InterlockedExchange(&m_bThreadRunning, TRUE);\r
872         iFirstResized = 0;\r
873         bSecondResized = FALSE;\r
874         m_bFinishedItemAdded = false;\r
875         CTime startTime = CTime::GetCurrentTime();\r
876         switch (m_Command)\r
877         {\r
878         case GitProgress_Add:\r
879                 bSuccess = CmdAdd(sWindowTitle, localoperation);\r
880                 break;\r
881         case GitProgress_Checkout:\r
882                 bSuccess = CmdCheckout(sWindowTitle, localoperation);\r
883                 break;\r
884         case GitProgress_Commit:\r
885                 bSuccess = CmdCommit(sWindowTitle, localoperation);\r
886                 break;\r
887         case GitProgress_Copy:\r
888                 bSuccess = CmdCopy(sWindowTitle, localoperation);\r
889                 break;\r
890         case GitProgress_Export:\r
891                 bSuccess = CmdExport(sWindowTitle, localoperation);\r
892                 break;\r
893         case GitProgress_Import:\r
894                 bSuccess = CmdImport(sWindowTitle, localoperation);\r
895                 break;\r
896         case GitProgress_Lock:\r
897                 bSuccess = CmdLock(sWindowTitle, localoperation);\r
898                 break;\r
899         case GitProgress_Merge:\r
900                 bSuccess = CmdMerge(sWindowTitle, localoperation);\r
901                 break;\r
902         case GitProgress_MergeAll:\r
903                 bSuccess = CmdMergeAll(sWindowTitle, localoperation);\r
904                 break;\r
905         case GitProgress_MergeReintegrate:\r
906                 bSuccess = CmdMergeReintegrate(sWindowTitle, localoperation);\r
907                 break;\r
908         case GitProgress_Rename:\r
909                 bSuccess = CmdRename(sWindowTitle, localoperation);\r
910                 break;\r
911         case GitProgress_Resolve:\r
912                 bSuccess = CmdResolve(sWindowTitle, localoperation);\r
913                 break;\r
914         case GitProgress_Revert:\r
915                 bSuccess = CmdRevert(sWindowTitle, localoperation);\r
916                 break;\r
917         case GitProgress_Switch:\r
918                 bSuccess = CmdSwitch(sWindowTitle, localoperation);\r
919                 break;\r
920         case GitProgress_Unlock:\r
921                 bSuccess = CmdUnlock(sWindowTitle, localoperation);\r
922                 break;\r
923         case GitProgress_Update:\r
924                 bSuccess = CmdUpdate(sWindowTitle, localoperation);\r
925                 break;\r
926         case GitProgress_SendMail:\r
927                 bSuccess = CmdSendMail(sWindowTitle, localoperation);\r
928                 break;\r
929         }\r
930         if (!bSuccess)\r
931                 temp.LoadString(IDS_PROGRS_TITLEFAILED);\r
932         else\r
933                 temp.LoadString(IDS_PROGRS_TITLEFIN);\r
934         sWindowTitle = sWindowTitle + _T(" ") + temp;\r
935         SetWindowText(sWindowTitle);\r
936 \r
937         KillTimer(TRANSFERTIMER);\r
938         KillTimer(VISIBLETIMER);\r
939 \r
940         DialogEnableWindow(IDCANCEL, FALSE);\r
941         DialogEnableWindow(IDOK, TRUE);\r
942 \r
943         CString info = BuildInfoString();\r
944         if (!bSuccess)\r
945                 info.LoadString(IDS_PROGRS_INFOFAILED);\r
946         SetDlgItemText(IDC_INFOTEXT, info);\r
947         ResizeColumns();\r
948         SendMessage(DM_SETDEFID, IDOK);\r
949         GetDlgItem(IDOK)->SetFocus();   \r
950 \r
951         CString sFinalInfo;\r
952         if (!m_sTotalBytesTransferred.IsEmpty())\r
953         {\r
954                 CTimeSpan time = CTime::GetCurrentTime() - startTime;\r
955                 temp.Format(IDS_PROGRS_TIME, (LONG)time.GetTotalMinutes(), (LONG)time.GetSeconds());\r
956                 sFinalInfo.Format(IDS_PROGRS_FINALINFO, m_sTotalBytesTransferred, (LPCTSTR)temp);\r
957                 SetDlgItemText(IDC_PROGRESSLABEL, sFinalInfo);\r
958         }\r
959         else\r
960                 GetDlgItem(IDC_PROGRESSLABEL)->ShowWindow(SW_HIDE);\r
961 \r
962         GetDlgItem(IDC_PROGRESSBAR)->ShowWindow(SW_HIDE);\r
963 \r
964         if (!m_bFinishedItemAdded)\r
965         {\r
966                 // there's no "finished: xxx" line at the end. We add one here to make\r
967                 // sure the user sees that the command is actually finished.\r
968                 NotificationData * data = new NotificationData();\r
969                 data->bAuxItem = true;\r
970                 data->sActionColumnText.LoadString(IDS_PROGRS_FINISHED);\r
971                 m_arData.push_back(data);\r
972                 AddItemToList();\r
973         }\r
974 \r
975         int count = m_ProgList.GetItemCount();\r
976         if ((count > 0)&&(m_bLastVisible))\r
977                 m_ProgList.EnsureVisible(count-1, FALSE);\r
978 \r
979         CLogFile logfile;\r
980         if (logfile.Open())\r
981         {\r
982                 logfile.AddTimeLine();\r
983                 for (size_t i=0; i<m_arData.size(); i++)\r
984                 {\r
985                         NotificationData * data = m_arData[i];\r
986                         temp.Format(_T("%-20s : %s"), (LPCTSTR)data->sActionColumnText, (LPCTSTR)data->sPathColumnText);\r
987                         logfile.AddLine(temp);\r
988                 }\r
989                 if (!sFinalInfo.IsEmpty())\r
990                         logfile.AddLine(sFinalInfo);\r
991                 logfile.Close();\r
992         }\r
993 \r
994         m_bCancelled = TRUE;\r
995         InterlockedExchange(&m_bThreadRunning, FALSE);\r
996         RefreshCursor();\r
997 \r
998         DWORD dwAutoClose = CRegStdWORD(_T("Software\\TortoiseGit\\AutoClose"));\r
999         if (m_options & ProgOptDryRun)\r
1000                 dwAutoClose = 0;                // dry run means progress dialog doesn't auto close at all\r
1001         if (!m_bLastVisible)\r
1002                 dwAutoClose = 0;\r
1003         if (m_dwCloseOnEnd != (DWORD)-1)\r
1004                 dwAutoClose = m_dwCloseOnEnd;           // command line value has priority over setting value\r
1005         if ((dwAutoClose == CLOSE_NOERRORS)&&(!m_bErrorsOccurred))\r
1006                 PostMessage(WM_COMMAND, 1, (LPARAM)GetDlgItem(IDOK)->m_hWnd);\r
1007         if ((dwAutoClose == CLOSE_NOCONFLICTS)&&(!m_bErrorsOccurred)&&(m_nConflicts==0))\r
1008                 PostMessage(WM_COMMAND, 1, (LPARAM)GetDlgItem(IDOK)->m_hWnd);\r
1009         if ((dwAutoClose == CLOSE_NOMERGES)&&(!m_bErrorsOccurred)&&(m_nConflicts==0)&&(!m_bMergesAddsDeletesOccurred))\r
1010                 PostMessage(WM_COMMAND, 1, (LPARAM)GetDlgItem(IDOK)->m_hWnd);\r
1011         if ((dwAutoClose == CLOSE_LOCAL)&&(!m_bErrorsOccurred)&&(m_nConflicts==0)&&(localoperation))\r
1012                 PostMessage(WM_COMMAND, 1, (LPARAM)GetDlgItem(IDOK)->m_hWnd);\r
1013 \r
1014         //Don't do anything here which might cause messages to be sent to the window\r
1015         //The window thread is probably now blocked in OnOK if we've done an auto close\r
1016         return 0;\r
1017 }\r
1018 \r
1019 void CGitProgressDlg::OnBnClickedLogbutton()\r
1020 {\r
1021 #if 0\r
1022         if (m_targetPathList.GetCount() != 1)\r
1023                 return;\r
1024         StringRevMap::iterator it = m_UpdateStartRevMap.begin();\r
1025         svn_revnum_t rev = -1;\r
1026         if (it != m_UpdateStartRevMap.end())\r
1027         {\r
1028                 rev = it->second;\r
1029         }\r
1030         CLogDlg dlg;\r
1031         dlg.SetParams(m_targetPathList[0], m_RevisionEnd, m_RevisionEnd, rev, 0, TRUE);\r
1032         dlg.DoModal();\r
1033 #endif\r
1034 }\r
1035 \r
1036 \r
1037 void CGitProgressDlg::OnClose()\r
1038 {\r
1039         if (m_bCancelled)\r
1040         {\r
1041                 TerminateThread(m_pThread->m_hThread, (DWORD)-1);\r
1042                 InterlockedExchange(&m_bThreadRunning, FALSE);\r
1043         }\r
1044         else\r
1045         {\r
1046                 m_bCancelled = TRUE;\r
1047                 return;\r
1048         }\r
1049         DialogEnableWindow(IDCANCEL, TRUE);\r
1050         __super::OnClose();\r
1051 }\r
1052 \r
1053 void CGitProgressDlg::OnOK()\r
1054 {\r
1055         if ((m_bCancelled)&&(!m_bThreadRunning))\r
1056         {\r
1057                 // I have made this wait a sensible amount of time (10 seconds) for the thread to finish\r
1058                 // You must be careful in the thread that after posting the WM_COMMAND/IDOK message, you \r
1059                 // don't do any more operations on the window which might require message passing\r
1060                 // If you try to send windows messages once we're waiting here, then the thread can't finished\r
1061                 // because the Window's message loop is blocked at this wait\r
1062                 WaitForSingleObject(m_pThread->m_hThread, 10000);\r
1063                 __super::OnOK();\r
1064         }\r
1065         m_bCancelled = TRUE;\r
1066 }\r
1067 \r
1068 void CGitProgressDlg::OnCancel()\r
1069 {\r
1070         if ((m_bCancelled)&&(!m_bThreadRunning))\r
1071                 __super::OnCancel();\r
1072         m_bCancelled = TRUE;\r
1073 }\r
1074 \r
1075 void CGitProgressDlg::OnLvnGetdispinfoSvnprogress(NMHDR *pNMHDR, LRESULT *pResult)\r
1076 {\r
1077         NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);\r
1078 \r
1079         if (pDispInfo)\r
1080         {\r
1081                 if (pDispInfo->item.mask & LVIF_TEXT)\r
1082                 {\r
1083                         if (pDispInfo->item.iItem < (int)m_arData.size())\r
1084                         {\r
1085                                 const NotificationData * data = m_arData[pDispInfo->item.iItem];\r
1086                                 switch (pDispInfo->item.iSubItem)\r
1087                                 {\r
1088                                 case 0:\r
1089                                         lstrcpyn(m_columnbuf, data->sActionColumnText, MAX_PATH);\r
1090                                         break;\r
1091                                 case 1:\r
1092                                         lstrcpyn(m_columnbuf, data->sPathColumnText, pDispInfo->item.cchTextMax);\r
1093                                         if (!data->bAuxItem)\r
1094                                         {\r
1095                                                 int cWidth = m_ProgList.GetColumnWidth(1);\r
1096                                                 cWidth = max(12, cWidth-12);\r
1097                                                 CDC * pDC = m_ProgList.GetDC();\r
1098                         if (pDC != NULL)\r
1099                         {\r
1100                                                     CFont * pFont = pDC->SelectObject(m_ProgList.GetFont());\r
1101                                                     PathCompactPath(pDC->GetSafeHdc(), m_columnbuf, cWidth);\r
1102                                                     pDC->SelectObject(pFont);\r
1103                                                         ReleaseDC(pDC);\r
1104                         }\r
1105                                         }\r
1106                                         break;\r
1107                                 case 2:\r
1108                                         lstrcpyn(m_columnbuf, data->mime_type, MAX_PATH);\r
1109                                         break;\r
1110                                 default:\r
1111                                         m_columnbuf[0] = 0;\r
1112                                 }\r
1113                                 pDispInfo->item.pszText = m_columnbuf;\r
1114                         }\r
1115                 }\r
1116         }\r
1117         *pResult = 0;\r
1118 }\r
1119 \r
1120 void CGitProgressDlg::OnNMCustomdrawSvnprogress(NMHDR *pNMHDR, LRESULT *pResult)\r
1121 {\r
1122         NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );\r
1123 \r
1124         // Take the default processing unless we set this to something else below.\r
1125         *pResult = CDRF_DODEFAULT;\r
1126 \r
1127         // First thing - check the draw stage. If it's the control's prepaint\r
1128         // stage, then tell Windows we want messages for every item.\r
1129 \r
1130         if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )\r
1131         {\r
1132                 *pResult = CDRF_NOTIFYITEMDRAW;\r
1133         }\r
1134         else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )\r
1135         {\r
1136                 // This is the prepaint stage for an item. Here's where we set the\r
1137                 // item's text color. Our return value will tell Windows to draw the\r
1138                 // item itself, but it will use the new color we set here.\r
1139 \r
1140                 // Tell Windows to paint the control itself.\r
1141                 *pResult = CDRF_DODEFAULT;\r
1142 \r
1143                 ASSERT(pLVCD->nmcd.dwItemSpec <  m_arData.size());\r
1144                 if(pLVCD->nmcd.dwItemSpec >= m_arData.size())\r
1145                 {\r
1146                         return;\r
1147                 }\r
1148                 const NotificationData * data = m_arData[pLVCD->nmcd.dwItemSpec];\r
1149                 ASSERT(data != NULL);\r
1150                 if (data == NULL)\r
1151                         return;\r
1152 \r
1153                 // Store the color back in the NMLVCUSTOMDRAW struct.\r
1154                 pLVCD->clrText = data->color;\r
1155         }\r
1156 }\r
1157 \r
1158 void CGitProgressDlg::OnNMDblclkSvnprogress(NMHDR *pNMHDR, LRESULT *pResult)\r
1159 {\r
1160 #if 0\r
1161         LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
1162         *pResult = 0;\r
1163         if (pNMLV->iItem < 0)\r
1164                 return;\r
1165         if (m_options & ProgOptDryRun)\r
1166                 return; //don't do anything in a dry-run.\r
1167 \r
1168         const NotificationData * data = m_arData[pNMLV->iItem];\r
1169         if (data == NULL)\r
1170                 return;\r
1171 \r
1172         if (data->bConflictedActionItem)\r
1173         {\r
1174                 // We've double-clicked on a conflicted item - do a three-way merge on it\r
1175                 SVNDiff::StartConflictEditor(data->path);\r
1176         }\r
1177         else if ((data->action == svn_wc_notify_update_update) && ((data->content_state == svn_wc_notify_state_merged)||(GitProgress_Merge == m_Command)) || (data->action == svn_wc_notify_resolved))\r
1178         {\r
1179                 // This is a modified file which has been merged on update. Diff it against base\r
1180                 CTGitPath temporaryFile;\r
1181                 SVNDiff diff(this, this->m_hWnd, true);\r
1182                 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));\r
1183                 svn_revnum_t baseRev = 0;\r
1184                 diff.DiffFileAgainstBase(data->path, baseRev);\r
1185         }\r
1186         else if ((!data->bAuxItem)&&(data->path.Exists())&&(!data->path.IsDirectory()))\r
1187         {\r
1188                 bool bOpenWith = false;\r
1189                 int ret = (int)ShellExecute(m_hWnd, NULL, data->path.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);\r
1190                 if (ret <= HINSTANCE_ERROR)\r
1191                         bOpenWith = true;\r
1192                 if (bOpenWith)\r
1193                 {\r
1194                         CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");\r
1195                         cmd += data->path.GetWinPathString() + _T(" ");\r
1196                         CAppUtils::LaunchApplication(cmd, NULL, false);\r
1197                 }\r
1198         }\r
1199 #endif\r
1200 }\r
1201 \r
1202 void CGitProgressDlg::OnHdnItemclickSvnprogress(NMHDR *pNMHDR, LRESULT *pResult)\r
1203 {\r
1204         LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);\r
1205         if (m_bThreadRunning)\r
1206                 return;\r
1207         if (m_nSortedColumn == phdr->iItem)\r
1208                 m_bAscending = !m_bAscending;\r
1209         else\r
1210                 m_bAscending = TRUE;\r
1211         m_nSortedColumn = phdr->iItem;\r
1212         Sort();\r
1213 \r
1214         CString temp;\r
1215         m_ProgList.SetRedraw(FALSE);\r
1216         m_ProgList.DeleteAllItems();\r
1217         m_ProgList.SetItemCountEx (static_cast<int>(m_arData.size()));\r
1218 \r
1219         m_ProgList.SetRedraw(TRUE);\r
1220 \r
1221         *pResult = 0;\r
1222 }\r
1223 \r
1224 bool CGitProgressDlg::NotificationDataIsAux(const NotificationData* pData)\r
1225 {\r
1226         return pData->bAuxItem;\r
1227 }\r
1228 \r
1229 LRESULT CGitProgressDlg::OnGitProgress(WPARAM /*wParam*/, LPARAM lParam)\r
1230 {\r
1231 #if 0\r
1232         SVNProgress * pProgressData = (SVNProgress *)lParam;\r
1233         CProgressCtrl * progControl = (CProgressCtrl *)GetDlgItem(IDC_PROGRESSBAR);\r
1234         if ((pProgressData->total > 1000)&&(!progControl->IsWindowVisible()))\r
1235         {\r
1236                 progControl->ShowWindow(SW_SHOW);\r
1237         }\r
1238         if (((pProgressData->total < 0)&&(pProgressData->progress > 1000)&&(progControl->IsWindowVisible()))&&(m_itemCountTotal<0))\r
1239         {\r
1240                 progControl->ShowWindow(SW_HIDE);\r
1241         }\r
1242         if (!GetDlgItem(IDC_PROGRESSLABEL)->IsWindowVisible())\r
1243                 GetDlgItem(IDC_PROGRESSLABEL)->ShowWindow(SW_SHOW);\r
1244         SetTimer(TRANSFERTIMER, 2000, NULL);\r
1245         if ((pProgressData->total > 0)&&(pProgressData->progress > 1000))\r
1246         {\r
1247                 progControl->SetPos((int)pProgressData->progress);\r
1248                 progControl->SetRange32(0, (int)pProgressData->total);\r
1249         }\r
1250         CString progText;\r
1251         if (pProgressData->overall_total < 1024)\r
1252                 m_sTotalBytesTransferred.Format(IDS_SVN_PROGRESS_TOTALBYTESTRANSFERRED, pProgressData->overall_total);  \r
1253         else if (pProgressData->overall_total < 1200000)\r
1254                 m_sTotalBytesTransferred.Format(IDS_SVN_PROGRESS_TOTALTRANSFERRED, pProgressData->overall_total / 1024);\r
1255         else\r
1256                 m_sTotalBytesTransferred.Format(IDS_SVN_PROGRESS_TOTALMBTRANSFERRED, (double)((double)pProgressData->overall_total / 1024000.0));\r
1257         progText.Format(IDS_SVN_PROGRESS_TOTALANDSPEED, (LPCTSTR)m_sTotalBytesTransferred, (LPCTSTR)pProgressData->SpeedString);\r
1258         SetDlgItemText(IDC_PROGRESSLABEL, progText);\r
1259 #endif\r
1260         return 0;\r
1261 }\r
1262 \r
1263 void CGitProgressDlg::OnTimer(UINT_PTR nIDEvent)\r
1264 {\r
1265         if (nIDEvent == TRANSFERTIMER)\r
1266         {\r
1267                 CString progText;\r
1268                 CString progSpeed;\r
1269                 progSpeed.Format(IDS_SVN_PROGRESS_BYTES_SEC, 0);\r
1270                 progText.Format(IDS_SVN_PROGRESS_TOTALANDSPEED, (LPCTSTR)m_sTotalBytesTransferred, (LPCTSTR)progSpeed);\r
1271                 SetDlgItemText(IDC_PROGRESSLABEL, progText);\r
1272                 KillTimer(TRANSFERTIMER);\r
1273         }\r
1274         if (nIDEvent == VISIBLETIMER)\r
1275         {\r
1276                 if (nEnsureVisibleCount)\r
1277                         m_ProgList.EnsureVisible(m_ProgList.GetItemCount()-1, false);\r
1278                 nEnsureVisibleCount = 0;\r
1279         }\r
1280 }\r
1281 \r
1282 void CGitProgressDlg::Sort()\r
1283 {\r
1284         if(m_arData.size() < 2)\r
1285         {\r
1286                 return;\r
1287         }\r
1288 \r
1289         // We need to sort the blocks which lie between the auxiliary entries\r
1290         // This is so that any aux data stays where it was\r
1291         NotificationDataVect::iterator actionBlockBegin;\r
1292         NotificationDataVect::iterator actionBlockEnd = m_arData.begin();       // We start searching from here\r
1293 \r
1294         for(;;)\r
1295         {\r
1296                 // Search to the start of the non-aux entry in the next block\r
1297                 actionBlockBegin = std::find_if(actionBlockEnd, m_arData.end(), std::not1(std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux)));\r
1298                 if(actionBlockBegin == m_arData.end())\r
1299                 {\r
1300                         // There are no more actions\r
1301                         break;\r
1302                 }\r
1303                 // Now search to find the end of the block\r
1304                 actionBlockEnd = std::find_if(actionBlockBegin+1, m_arData.end(), std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux));\r
1305                 // Now sort the block\r
1306                 std::sort(actionBlockBegin, actionBlockEnd, &CGitProgressDlg::SortCompare);\r
1307         }\r
1308 }\r
1309 \r
1310 bool CGitProgressDlg::SortCompare(const NotificationData * pData1, const NotificationData * pData2)\r
1311 {\r
1312         int result = 0;\r
1313         switch (m_nSortedColumn)\r
1314         {\r
1315         case 0:         //action column\r
1316                 result = pData1->sActionColumnText.Compare(pData2->sActionColumnText);\r
1317                 break;\r
1318         case 1:         //path column\r
1319                 // Compare happens after switch()\r
1320                 break;\r
1321         case 2:         //mime-type column\r
1322                 result = pData1->mime_type.Compare(pData2->mime_type);\r
1323                 break;\r
1324         default:\r
1325                 break;\r
1326         }\r
1327 \r
1328         // Sort by path if everything else is equal\r
1329         if (result == 0)\r
1330         {\r
1331                 result = CTGitPath::Compare(pData1->path, pData2->path);\r
1332         }\r
1333 \r
1334         if (!m_bAscending)\r
1335                 result = -result;\r
1336         return result < 0;\r
1337 }\r
1338 \r
1339 BOOL CGitProgressDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)\r
1340 {\r
1341         if (!GetDlgItem(IDOK)->IsWindowEnabled())\r
1342         {\r
1343                 // only show the wait cursor over the list control\r
1344                 if ((pWnd)&&(pWnd == GetDlgItem(IDC_SVNPROGRESS)))\r
1345                 {\r
1346                         HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));\r
1347                         SetCursor(hCur);\r
1348                         return TRUE;\r
1349                 }\r
1350         }\r
1351         HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));\r
1352         SetCursor(hCur);\r
1353         return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);\r
1354 }\r
1355 \r
1356 BOOL CGitProgressDlg::PreTranslateMessage(MSG* pMsg)\r
1357 {\r
1358         if (pMsg->message == WM_KEYDOWN)\r
1359         {\r
1360                 if (pMsg->wParam == VK_ESCAPE)\r
1361                 {\r
1362                         // pressing the ESC key should close the dialog. But since we disabled the escape\r
1363                         // key (so the user doesn't get the idea that he could simply undo an e.g. update)\r
1364                         // this won't work.\r
1365                         // So if the user presses the ESC key, change it to VK_RETURN so the dialog gets\r
1366                         // the impression that the OK button was pressed.\r
1367                         if ((!m_bThreadRunning)&&(!GetDlgItem(IDCANCEL)->IsWindowEnabled())\r
1368                                 &&(GetDlgItem(IDOK)->IsWindowEnabled())&&(GetDlgItem(IDOK)->IsWindowVisible()))\r
1369                         {\r
1370                                 // since we convert ESC to RETURN, make sure the OK button has the focus.\r
1371                                 GetDlgItem(IDOK)->SetFocus();\r
1372                                 pMsg->wParam = VK_RETURN;\r
1373                         }\r
1374                 }\r
1375                 if (pMsg->wParam == 'A')\r
1376                 {\r
1377                         if (GetKeyState(VK_CONTROL)&0x8000)\r
1378                         {\r
1379                                 // Ctrl-A -> select all\r
1380                                 m_ProgList.SetSelectionMark(0);\r
1381                                 for (int i=0; i<m_ProgList.GetItemCount(); ++i)\r
1382                                 {\r
1383                                         m_ProgList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);\r
1384                                 }\r
1385                         }\r
1386                 }\r
1387                 if ((pMsg->wParam == 'C')||(pMsg->wParam == VK_INSERT))\r
1388                 {\r
1389                         int selIndex = m_ProgList.GetSelectionMark();\r
1390                         if (selIndex >= 0)\r
1391                         {\r
1392                                 if (GetKeyState(VK_CONTROL)&0x8000)\r
1393                                 {\r
1394                                         //Ctrl-C -> copy to clipboard\r
1395                                         CString sClipdata;\r
1396                                         POSITION pos = m_ProgList.GetFirstSelectedItemPosition();\r
1397                                         if (pos != NULL)\r
1398                                         {\r
1399                                                 while (pos)\r
1400                                                 {\r
1401                                                         int nItem = m_ProgList.GetNextSelectedItem(pos);\r
1402                                                         CString sAction = m_ProgList.GetItemText(nItem, 0);\r
1403                                                         CString sPath = m_ProgList.GetItemText(nItem, 1);\r
1404                                                         CString sMime = m_ProgList.GetItemText(nItem, 2);\r
1405                                                         CString sLogCopyText;\r
1406                                                         sLogCopyText.Format(_T("%s: %s  %s\r\n"),\r
1407                                                                 (LPCTSTR)sAction, (LPCTSTR)sPath, (LPCTSTR)sMime);\r
1408                                                         sClipdata +=  sLogCopyText;\r
1409                                                 }\r
1410                                                 CStringUtils::WriteAsciiStringToClipboard(sClipdata);\r
1411                                         }\r
1412                                 }\r
1413                         }\r
1414                 } \r
1415         } // if (pMsg->message == WM_KEYDOWN)\r
1416         return __super::PreTranslateMessage(pMsg);\r
1417 }\r
1418 \r
1419 void CGitProgressDlg::OnContextMenu(CWnd* pWnd, CPoint point)\r
1420 {\r
1421 #if 0\r
1422         if (m_options & ProgOptDryRun)\r
1423                 return; // don't do anything in a dry-run.\r
1424 \r
1425         if (pWnd == &m_ProgList)\r
1426         {\r
1427                 int selIndex = m_ProgList.GetSelectionMark();\r
1428                 if ((point.x == -1) && (point.y == -1))\r
1429                 {\r
1430                         // Menu was invoked from the keyboard rather than by right-clicking\r
1431                         CRect rect;\r
1432                         m_ProgList.GetItemRect(selIndex, &rect, LVIR_LABEL);\r
1433                         m_ProgList.ClientToScreen(&rect);\r
1434                         point = rect.CenterPoint();\r
1435                 }\r
1436 \r
1437                 if ((selIndex >= 0)&&(!m_bThreadRunning))\r
1438                 {\r
1439                         // entry is selected, thread has finished with updating so show the popup menu\r
1440                         CIconMenu popup;\r
1441                         if (popup.CreatePopupMenu())\r
1442                         {\r
1443                                 bool bAdded = false;\r
1444                                 NotificationData * data = m_arData[selIndex];\r
1445                                 if ((data)&&(!data->path.IsDirectory()))\r
1446                                 {\r
1447                                         if (data->action == svn_wc_notify_update_update || data->action == svn_wc_notify_resolved)\r
1448                                         {\r
1449                                                 if (m_ProgList.GetSelectedCount() == 1)\r
1450                                                 {\r
1451                                                         popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);\r
1452                                                         bAdded = true;\r
1453                                                 }\r
1454                                         }\r
1455                                                 if (data->bConflictedActionItem)\r
1456                                                 {\r
1457                                                         if (m_ProgList.GetSelectedCount() == 1)\r
1458                                                         {\r
1459                                                                 popup.AppendMenuIcon(ID_EDITCONFLICT, IDS_MENUCONFLICT,IDI_CONFLICT);\r
1460                                                                 popup.SetDefaultItem(ID_EDITCONFLICT, FALSE);\r
1461                                                                 popup.AppendMenuIcon(ID_CONFLICTRESOLVE, IDS_SVNPROGRESS_MENUMARKASRESOLVED,IDI_RESOLVE);\r
1462                                                         }\r
1463                                                         popup.AppendMenuIcon(ID_CONFLICTUSETHEIRS, IDS_SVNPROGRESS_MENUUSETHEIRS,IDI_RESOLVE);\r
1464                                                         popup.AppendMenuIcon(ID_CONFLICTUSEMINE, IDS_SVNPROGRESS_MENUUSEMINE,IDI_RESOLVE);\r
1465                                                 }\r
1466                                                 else if ((data->content_state == svn_wc_notify_state_merged)||(GitProgress_Merge == m_Command)||(data->action == svn_wc_notify_resolved))\r
1467                                                         popup.SetDefaultItem(ID_COMPARE, FALSE);\r
1468                                         \r
1469                                         if (m_ProgList.GetSelectedCount() == 1)\r
1470                                         {\r
1471                                                 if ((data->action == svn_wc_notify_add)||\r
1472                                                         (data->action == svn_wc_notify_update_add)||\r
1473                                                         (data->action == svn_wc_notify_commit_added)||\r
1474                                                         (data->action == svn_wc_notify_commit_modified)||\r
1475                                                         (data->action == svn_wc_notify_restore)||\r
1476                                                         (data->action == svn_wc_notify_revert)||\r
1477                                                         (data->action == svn_wc_notify_resolved)||\r
1478                                                         (data->action == svn_wc_notify_commit_replaced)||\r
1479                                                         (data->action == svn_wc_notify_commit_modified)||\r
1480                                                         (data->action == svn_wc_notify_commit_postfix_txdelta)||\r
1481                                                         (data->action == svn_wc_notify_update_update))\r
1482                                                 {\r
1483                                                         popup.AppendMenuIcon(ID_LOG, IDS_MENULOG,IDI_LOG);\r
1484                                                         if (data->action == svn_wc_notify_update_update)\r
1485                                                                 popup.AppendMenu(MF_SEPARATOR, NULL);\r
1486                                                         popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);\r
1487                                                         popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);\r
1488                                                         bAdded = true;\r
1489                                                 }\r
1490                                         }\r
1491                                 } // if ((data)&&(!data->path.IsDirectory()))\r
1492                                 if (m_ProgList.GetSelectedCount() == 1)\r
1493                                 {\r
1494                                         if (data)\r
1495                                         {\r
1496                                                 CString sPath = GetPathFromColumnText(data->sPathColumnText);\r
1497                                                 if ((!sPath.IsEmpty())&&(!SVN::PathIsURL(CTGitPath(sPath))))\r
1498                                                 {\r
1499                                                         CTGitPath path = CTGitPath(sPath);\r
1500                                                         if (path.GetDirectory().Exists())\r
1501                                                         {\r
1502                                                                 popup.AppendMenuIcon(ID_EXPLORE, IDS_SVNPROGRESS_MENUOPENPARENT, IDI_EXPLORER);\r
1503                                                                 bAdded = true;\r
1504                                                         }\r
1505                                                 }\r
1506                                         }\r
1507                                 }\r
1508                                 if (m_ProgList.GetSelectedCount() > 0)\r
1509                                 {\r
1510                                         if (bAdded)\r
1511                                                 popup.AppendMenu(MF_SEPARATOR, NULL);\r
1512                                         popup.AppendMenuIcon(ID_COPY, IDS_LOG_POPUP_COPYTOCLIPBOARD,IDI_COPYCLIP);\r
1513                                         bAdded = true;\r
1514                                 }\r
1515                                 if (bAdded)\r
1516                                 {\r
1517                                         int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);\r
1518                                         DialogEnableWindow(IDOK, FALSE);\r
1519                                         this->SetPromptApp(&theApp);\r
1520                                         theApp.DoWaitCursor(1);\r
1521                                         bool bOpenWith = false;\r
1522                                         switch (cmd)\r
1523                                         {\r
1524                                         case ID_COPY:\r
1525                                                 {\r
1526                                                         CString sLines;\r
1527                                                         POSITION pos = m_ProgList.GetFirstSelectedItemPosition();\r
1528                                                         while (pos)\r
1529                                                         {\r
1530                                                                 int nItem = m_ProgList.GetNextSelectedItem(pos);\r
1531                                                                 NotificationData * data = m_arData[nItem];\r
1532                                                                 if (data)\r
1533                                                                 {\r
1534                                                                         sLines += data->sPathColumnText;\r
1535                                                                         sLines += _T("\r\n");\r
1536                                                                 }\r
1537                                                         }\r
1538                                                         sLines.TrimRight();\r
1539                                                         if (!sLines.IsEmpty())\r
1540                                                         {\r
1541                                                                 CStringUtils::WriteAsciiStringToClipboard(sLines, GetSafeHwnd());\r
1542                                                         }\r
1543                                                 }\r
1544                                                 break;\r
1545                                         case ID_EXPLORE:\r
1546                                                 {\r
1547                                                         CString sPath = GetPathFromColumnText(data->sPathColumnText);\r
1548 \r
1549                                                         CTGitPath path = CTGitPath(sPath);\r
1550                                                         ShellExecute(m_hWnd, _T("explore"), path.GetDirectory().GetWinPath(), NULL, path.GetDirectory().GetWinPath(), SW_SHOW);\r
1551                                                 }\r
1552                                                 break;\r
1553                                         case ID_COMPARE:\r
1554                                                 {\r
1555                                                         svn_revnum_t rev = -1;\r
1556                                                         StringRevMap::iterator it = m_UpdateStartRevMap.end();\r
1557                                                         if (data->basepath.IsEmpty())\r
1558                                                                 it = m_UpdateStartRevMap.begin();\r
1559                                                         else\r
1560                                                                 it = m_UpdateStartRevMap.find(data->basepath.GetSVNApiPath(pool));\r
1561                                                         if (it != m_UpdateStartRevMap.end())\r
1562                                                                 rev = it->second;\r
1563                                                         // if the file was merged during update, do a three way diff between OLD, MINE, THEIRS\r
1564                                                         if (data->content_state == svn_wc_notify_state_merged)\r
1565                                                         {\r
1566                                                                 CTGitPath basefile = CTempFiles::Instance().GetTempFilePath(false, data->path, rev);\r
1567                                                                 CTGitPath newfile = CTempFiles::Instance().GetTempFilePath(false, data->path, SVNRev::REV_HEAD);\r
1568                                                                 SVN svn;\r
1569                                                                 if (!svn.Cat(data->path, SVNRev(SVNRev::REV_WC), rev, basefile))\r
1570                                                                 {\r
1571                                                                         CMessageBox::Show(m_hWnd, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);\r
1572                                                                         DialogEnableWindow(IDOK, TRUE);\r
1573                                                                         break;\r
1574                                                                 }\r
1575                                                                 // If necessary, convert the line-endings on the file before diffing\r
1576                                                                 if ((DWORD)CRegDWORD(_T("Software\\TortoiseGit\\ConvertBase"), TRUE))\r
1577                                                                 {\r
1578                                                                         CTGitPath temporaryFile = CTempFiles::Instance().GetTempFilePath(false, data->path, SVNRev::REV_BASE);\r
1579                                                                         if (!svn.Cat(data->path, SVNRev(SVNRev::REV_BASE), SVNRev(SVNRev::REV_BASE), temporaryFile))\r
1580                                                                         {\r
1581                                                                                 temporaryFile.Reset();\r
1582                                                                                 break;\r
1583                                                                         }\r
1584                                                                         else\r
1585                                                                         {\r
1586                                                                                 newfile = temporaryFile;\r
1587                                                                         }\r
1588                                                                 }\r
1589 \r
1590                                                                 SetFileAttributes(newfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);\r
1591                                                                 SetFileAttributes(basefile.GetWinPath(), FILE_ATTRIBUTE_READONLY);\r
1592                                                                 CString revname, wcname, basename;\r
1593                                                                 revname.Format(_T("%s Revision %ld"), (LPCTSTR)data->path.GetUIFileOrDirectoryName(), rev);\r
1594                                                                 wcname.Format(IDS_DIFF_WCNAME, (LPCTSTR)data->path.GetUIFileOrDirectoryName());\r
1595                                                                 basename.Format(IDS_DIFF_BASENAME, (LPCTSTR)data->path.GetUIFileOrDirectoryName());\r
1596                                                                 CAppUtils::StartExtMerge(basefile, newfile, data->path, data->path, basename, revname, wcname, CString(), true);\r
1597                                                         }\r
1598                                                         else\r
1599                                                         {\r
1600                                                                 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, data->path, rev);\r
1601                                                                 SVN svn;\r
1602                                                                 if (!svn.Cat(data->path, SVNRev(SVNRev::REV_WC), rev, tempfile))\r
1603                                                                 {\r
1604                                                                         CMessageBox::Show(m_hWnd, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);\r
1605                                                                         DialogEnableWindow(IDOK, TRUE);\r
1606                                                                         break;\r
1607                                                                 }\r
1608                                                                 else\r
1609                                                                 {\r
1610                                                                         SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);\r
1611                                                                         CString revname, wcname;\r
1612                                                                         revname.Format(_T("%s Revision %ld"), (LPCTSTR)data->path.GetUIFileOrDirectoryName(), rev);\r
1613                                                                         wcname.Format(IDS_DIFF_WCNAME, (LPCTSTR)data->path.GetUIFileOrDirectoryName());\r
1614                                                                         CAppUtils::StartExtDiff(\r
1615                                                                                 tempfile, data->path, revname, wcname,\r
1616                                                                                 CAppUtils::DiffFlags().AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000)));\r
1617                                                                 }\r
1618                                                         }\r
1619                                                 }\r
1620                                                 break;\r
1621                                         case ID_EDITCONFLICT:\r
1622                                                 {\r
1623                                                         CString sPath = GetPathFromColumnText(data->sPathColumnText);\r
1624                                                         SVNDiff::StartConflictEditor(CTGitPath(sPath));\r
1625                                                 }\r
1626                                                 break;\r
1627                                         case ID_CONFLICTUSETHEIRS:\r
1628                                         case ID_CONFLICTUSEMINE:\r
1629                                         case ID_CONFLICTRESOLVE:\r
1630                                                 {\r
1631                                                         svn_wc_conflict_choice_t result = svn_wc_conflict_choose_merged;\r
1632                                                         switch (cmd)\r
1633                                                         {\r
1634                                                         case ID_CONFLICTUSETHEIRS:\r
1635                                                                 result = svn_wc_conflict_choose_theirs_full;\r
1636                                                                 break;\r
1637                                                         case ID_CONFLICTUSEMINE:\r
1638                                                                 result = svn_wc_conflict_choose_mine_full;\r
1639                                                                 break;\r
1640                                                         case ID_CONFLICTRESOLVE:\r
1641                                                                 result = svn_wc_conflict_choose_merged;\r
1642                                                                 break;\r
1643                                                         }\r
1644                                                         SVN svn;\r
1645                                                         POSITION pos = m_ProgList.GetFirstSelectedItemPosition();\r
1646                                                         CString sResolvedPaths;\r
1647                                                         while (pos)\r
1648                                                         {\r
1649                                                                 int nItem = m_ProgList.GetNextSelectedItem(pos);\r
1650                                                                 NotificationData * data = m_arData[nItem];\r
1651                                                                 if (data)\r
1652                                                                 {\r
1653                                                                         if (data->bConflictedActionItem)\r
1654                                                                         {\r
1655                                                                                 if (!svn.Resolve(data->path, result, FALSE))\r
1656                                                                                 {\r
1657                                                                                         CMessageBox::Show(m_hWnd, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);\r
1658                                                                                         DialogEnableWindow(IDOK, TRUE);\r
1659                                                                                         break;\r
1660                                                                                 }\r
1661                                                                                 else\r
1662                                                                                 {\r
1663                                                                                         data->color = ::GetSysColor(COLOR_WINDOWTEXT);\r
1664                                                                                         data->action = svn_wc_notify_resolved;\r
1665                                                                                         data->sActionColumnText.LoadString(IDS_SVNACTION_RESOLVE);\r
1666                                                                                         data->bConflictedActionItem = false;\r
1667                                                                                         m_nConflicts--;\r
1668 \r
1669                                                                                         if (m_nConflicts==0)\r
1670                                                                                         {\r
1671                                                                                                 // When the last conflict is resolved we remove\r
1672                                                                                                 // the warning which we assume is in the last line.\r
1673                                                                                                 int nIndex = m_ProgList.GetItemCount()-1;\r
1674                                                                                                 VERIFY(m_ProgList.DeleteItem(nIndex));\r
1675 \r
1676                                                                                                 delete m_arData[nIndex];\r
1677                                                                                                 m_arData.pop_back();\r
1678                                                                                         }\r
1679                                                                                         sResolvedPaths += data->path.GetWinPathString() + _T("\n");\r
1680                                                                                 }\r
1681                                                                         }\r
1682                                                                 }\r
1683                                                         }\r
1684                                                         m_ProgList.Invalidate();\r
1685                                                         CString info = BuildInfoString();\r
1686                                                         SetDlgItemText(IDC_INFOTEXT, info);\r
1687 \r
1688                                                         if (!sResolvedPaths.IsEmpty())\r
1689                                                         {\r
1690                                                                 CString msg;\r
1691                                                                 msg.Format(IDS_SVNPROGRESS_RESOLVED, (LPCTSTR)sResolvedPaths);\r
1692                                                                 CMessageBox::Show(m_hWnd, msg, _T("TortoiseSVN"), MB_OK | MB_ICONINFORMATION);\r
1693                                                         }\r
1694                                                 }\r
1695                                                 break;\r
1696                                         case ID_LOG:\r
1697                                                 {\r
1698                                                         CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100);\r
1699                                                         int limit = (int)(DWORD)reg;\r
1700                                                         svn_revnum_t rev = m_RevisionEnd;\r
1701                                                         if (!data->basepath.IsEmpty())\r
1702                                                         {\r
1703                                                                 StringRevMap::iterator it = m_FinishedRevMap.find(data->basepath.GetSVNApiPath(pool));\r
1704                                                                 if (it != m_FinishedRevMap.end())\r
1705                                                                         rev = it->second;\r
1706                                                         }\r
1707                                                         CLogDlg dlg;\r
1708                                                         // fetch the log from HEAD, not the revision we updated to:\r
1709                                                         // the path might be inside an external folder which has its own\r
1710                                                         // revisions.\r
1711                                                         CString sPath = GetPathFromColumnText(data->sPathColumnText);\r
1712                                                         dlg.SetParams(CTGitPath(sPath), SVNRev(), SVNRev::REV_HEAD, 1, limit, TRUE);\r
1713                                                         dlg.DoModal();\r
1714                                                 }\r
1715                                                 break;\r
1716                                         case ID_OPENWITH:\r
1717                                                 bOpenWith = true;\r
1718                                         case ID_OPEN:\r
1719                                                 {\r
1720                                                         int ret = 0;\r
1721                                                         CString sWinPath = GetPathFromColumnText(data->sPathColumnText);\r
1722                                                         if (!bOpenWith)\r
1723                                                                 ret = (int)ShellExecute(this->m_hWnd, NULL, (LPCTSTR)sWinPath, NULL, NULL, SW_SHOWNORMAL);\r
1724                                                         if ((ret <= HINSTANCE_ERROR)||bOpenWith)\r
1725                                                         {\r
1726                                                                 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");\r
1727                                                                 cmd += sWinPath + _T(" ");\r
1728                                                                 CAppUtils::LaunchApplication(cmd, NULL, false);\r
1729                                                         }\r
1730                                                 }\r
1731                                         }\r
1732                                         DialogEnableWindow(IDOK, TRUE);\r
1733                                         theApp.DoWaitCursor(-1);\r
1734                                 } // if (bAdded)\r
1735                         }\r
1736                 }\r
1737         }\r
1738 #endif\r
1739 }\r
1740 \r
1741 void CGitProgressDlg::OnEnSetfocusInfotext()\r
1742 {\r
1743         CString sTemp;\r
1744         GetDlgItemText(IDC_INFOTEXT, sTemp);\r
1745         if (sTemp.IsEmpty())\r
1746                 GetDlgItem(IDC_INFOTEXT)->HideCaret();\r
1747 }\r
1748 \r
1749 void CGitProgressDlg::OnLvnBegindragSvnprogress(NMHDR* , LRESULT *pResult)\r
1750 {\r
1751         //LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
1752 #if 0\r
1753         int selIndex = m_ProgList.GetSelectionMark();\r
1754         if (selIndex < 0)\r
1755                 return;\r
1756 \r
1757         CDropFiles dropFiles; // class for creating DROPFILES struct\r
1758 \r
1759         int index;\r
1760         POSITION pos = m_ProgList.GetFirstSelectedItemPosition();\r
1761         while ( (index = m_ProgList.GetNextSelectedItem(pos)) >= 0 )\r
1762         {\r
1763                 NotificationData * data = m_arData[index];\r
1764 \r
1765                 if ( data->kind==svn_node_file || data->kind==svn_node_dir )\r
1766                 {\r
1767                         CString sPath = GetPathFromColumnText(data->sPathColumnText);\r
1768 \r
1769                         dropFiles.AddFile( sPath );\r
1770                 }\r
1771         }\r
1772 \r
1773         if ( dropFiles.GetCount()>0 )\r
1774         {\r
1775                 dropFiles.CreateStructure();\r
1776         }\r
1777 #endif\r
1778         *pResult = 0;\r
1779 }\r
1780 \r
1781 void CGitProgressDlg::OnSize(UINT nType, int cx, int cy)\r
1782 {\r
1783         CResizableStandAloneDialog::OnSize(nType, cx, cy);\r
1784         if ((nType == SIZE_RESTORED)&&(m_bLastVisible))\r
1785         {\r
1786                 if(!m_ProgList.m_hWnd)\r
1787                         return;\r
1788 \r
1789                 int count = m_ProgList.GetItemCount();\r
1790                 if (count > 0)\r
1791                         m_ProgList.EnsureVisible(count-1, false);\r
1792         }\r
1793 }\r
1794 \r
1795 //////////////////////////////////////////////////////////////////////////\r
1796 /// commands\r
1797 //////////////////////////////////////////////////////////////////////////\r
1798 bool CGitProgressDlg::CmdAdd(CString& sWindowTitle, bool& localoperation)\r
1799 {\r
1800 \r
1801         localoperation = true;\r
1802         sWindowTitle.LoadString(IDS_PROGRS_TITLE_ADD);\r
1803         SetWindowText(sWindowTitle);\r
1804         SetBackgroundImage(IDI_ADD_BKG);\r
1805         ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_ADD)));\r
1806 \r
1807         for(int i=0;i<m_targetPathList.GetCount();i++)\r
1808         {\r
1809                 CString cmd,out;\r
1810                 cmd.Format(_T("git.exe add -f \"%s\""),m_targetPathList[i].GetGitPathString());\r
1811                 if(g_Git.Run(cmd,&out,CP_ACP))\r
1812                 {\r
1813                         CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
1814                         m_bErrorsOccurred=true;\r
1815                         return false;\r
1816                 }\r
1817                 Notify(m_targetPathList[i],git_wc_notify_add);\r
1818         }\r
1819 #if 0\r
1820         if (!Add(m_targetPathList, &m_ProjectProperties, svn_depth_empty, FALSE, TRUE, TRUE))\r
1821         {\r
1822                 ReportSVNError();\r
1823                 return false;\r
1824         }\r
1825 #endif\r
1826         //CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);\r
1827         m_bErrorsOccurred=false;\r
1828         return true;\r
1829 }\r
1830 \r
1831 bool CGitProgressDlg::CmdCheckout(CString& sWindowTitle, bool& /*localoperation*/)\r
1832 {\r
1833 #if 0\r
1834         ASSERT(m_targetPathList.GetCount() == 1);\r
1835         sWindowTitle.LoadString(IDS_PROGRS_TITLE_CHECKOUT);\r
1836         SetBackgroundImage(IDI_CHECKOUT_BKG);\r
1837         CTGitPathList urls;\r
1838         urls.LoadFromAsteriskSeparatedString(m_url.GetSVNPathString());\r
1839         CTGitPath checkoutdir = m_targetPathList[0];\r
1840         for (int i=0; i<urls.GetCount(); ++i)\r
1841         {\r
1842                 sWindowTitle = urls[i].GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle;\r
1843                 SetWindowText(sWindowTitle);\r
1844                 checkoutdir = m_targetPathList[0];\r
1845                 if (urls.GetCount() > 1)\r
1846                 {\r
1847                         CString fileordir = urls[i].GetFileOrDirectoryName();\r
1848                         fileordir = CPathUtils::PathUnescape(fileordir);\r
1849                         checkoutdir.AppendPathString(fileordir);\r
1850                 }\r
1851                 CString sCmdInfo;\r
1852                 sCmdInfo.Format(IDS_PROGRS_CMD_CHECKOUT, \r
1853                         (LPCTSTR)urls[i].GetSVNPathString(), (LPCTSTR)m_Revision.ToString(), \r
1854                         (LPCTSTR)SVNStatus::GetDepthString(m_depth), \r
1855                         m_options & ProgOptIgnoreExternals ? (LPCTSTR)sExtExcluded : (LPCTSTR)sExtIncluded);\r
1856                 ReportCmd(sCmdInfo);\r
1857 \r
1858                 if (!Checkout(urls[i], checkoutdir, m_Revision, m_Revision, m_depth, m_options & ProgOptIgnoreExternals))\r
1859                 {\r
1860                         if (m_ProgList.GetItemCount()!=0)\r
1861                         {\r
1862                                 ReportSVNError();\r
1863                                 return false;\r
1864                         }\r
1865                         // if the checkout fails with the peg revision set to the checkout revision,\r
1866                         // try again with HEAD as the peg revision.\r
1867                         else\r
1868                         {\r
1869                                 if (!Checkout(urls[i], checkoutdir, SVNRev::REV_HEAD, m_Revision, m_depth, m_options & ProgOptIgnoreExternals))\r
1870                                 {\r
1871                                         ReportSVNError();\r
1872                                         return false;\r
1873                                 }\r
1874                         }\r
1875                 }\r
1876         }\r
1877 #endif\r
1878         return true;\r
1879 }\r
1880 \r
1881 bool CGitProgressDlg::CmdCommit(CString& sWindowTitle, bool& /*localoperation*/)\r
1882 {\r
1883 #if 0\r
1884         sWindowTitle.LoadString(IDS_PROGRS_TITLE_COMMIT);\r
1885         SetWindowText(sWindowTitle);\r
1886         SetBackgroundImage(IDI_COMMIT_BKG);\r
1887         if (m_targetPathList.GetCount()==0)\r
1888         {\r
1889                 SetWindowText(sWindowTitle);\r
1890 \r
1891                 DialogEnableWindow(IDCANCEL, FALSE);\r
1892                 DialogEnableWindow(IDOK, TRUE);\r
1893 \r
1894                 InterlockedExchange(&m_bThreadRunning, FALSE);\r
1895                 return true;\r
1896         }\r
1897         if (m_targetPathList.GetCount()==1)\r
1898         {\r
1899                 sWindowTitle = m_targetPathList[0].GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle;\r
1900                 SetWindowText(sWindowTitle);\r
1901         }\r
1902         BOOL isTag = FALSE;\r
1903         BOOL bURLFetched = FALSE;\r
1904         CString url;\r
1905         for (int i=0; i<m_targetPathList.GetCount(); ++i)\r
1906         {\r
1907                 if (bURLFetched == FALSE)\r
1908                 {\r
1909                         url = GetURLFromPath(m_targetPathList[i]);\r
1910                         if (!url.IsEmpty())\r
1911                                 bURLFetched = TRUE;\r
1912                         CString urllower = url;\r
1913                         urllower.MakeLower();\r
1914                         // test if the commit goes to a tag.\r
1915                         // now since Subversion doesn't force users to\r
1916                         // create tags in the recommended /tags/ folder\r
1917                         // only a warning is shown. This won't work if the tags\r
1918                         // are stored in a non-recommended place, but the check\r
1919                         // still helps those who do.\r
1920                         if (urllower.Find(_T("/tags/"))>=0)\r
1921                                 isTag = TRUE;\r
1922                         break;\r
1923                 }\r
1924         }\r
1925         if (isTag)\r
1926         {\r
1927                 if (CMessageBox::Show(m_hWnd, IDS_PROGRS_COMMITT_TRUNK, IDS_APPNAME, MB_YESNO | MB_DEFBUTTON2 | MB_ICONEXCLAMATION)==IDNO)\r
1928                         return false;\r
1929         }\r
1930         DWORD exitcode = 0;\r
1931         CString error;\r
1932         if (CHooks::Instance().PreCommit(m_selectedPaths, m_depth, m_sMessage, exitcode, error))\r
1933         {\r
1934                 if (exitcode)\r
1935                 {\r
1936                         CString temp;\r
1937                         temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);\r
1938                         ReportError(temp);\r
1939                         return false;\r
1940                 }\r
1941         }\r
1942 \r
1943         ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_COMMIT)));\r
1944         CStringArray changelists;\r
1945     if (!m_changelist.IsEmpty())\r
1946             changelists.Add(m_changelist);\r
1947         bool commitSuccessful = true;\r
1948         if (!Commit(m_targetPathList, m_sMessage, changelists, m_keepchangelist, \r
1949                 m_depth, m_options & ProgOptKeeplocks))\r
1950         {\r
1951                 ReportSVNError();\r
1952                 error = GetLastErrorMessage();\r
1953                 // if a non-recursive commit failed with SVN_ERR_UNSUPPORTED_FEATURE,\r
1954                 // that means a folder deletion couldn't be committed.\r
1955                 if ((m_Revision != 0)&&(Err->apr_err == SVN_ERR_UNSUPPORTED_FEATURE))\r
1956                 {\r
1957                         ReportError(CString(MAKEINTRESOURCE(IDS_PROGRS_NONRECURSIVEHINT)));\r
1958                 }\r
1959                 commitSuccessful = false;\r
1960                 return false;\r
1961         }\r
1962         if (!PostCommitErr.IsEmpty())\r
1963         {\r
1964                 ReportWarning(PostCommitErr);\r
1965         }\r
1966         if (commitSuccessful)\r
1967         {\r
1968                 if (m_BugTraqProvider)\r
1969                 {\r
1970                         CComPtr<IBugTraqProvider2> pProvider = NULL;\r
1971                         HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider);\r
1972                         if (SUCCEEDED(hr))\r
1973                         {\r
1974                                 BSTR commonRoot = SysAllocString(m_targetPathList.GetCommonRoot().GetDirectory().GetWinPath());\r
1975                                 SAFEARRAY *pathList = SafeArrayCreateVector(VT_BSTR, 0, m_targetPathList.GetCount());\r
1976 \r
1977                                 for (LONG index = 0; index < m_targetPathList.GetCount(); ++index)\r
1978                                         SafeArrayPutElement(pathList, &index, m_targetPathList[index].GetSVNPathString().AllocSysString());\r
1979 \r
1980                                 BSTR logMessage = m_sMessage.AllocSysString();\r
1981 \r
1982                                 BSTR temp = NULL;\r
1983                                 if (FAILED(hr = pProvider->OnCommitFinished(GetSafeHwnd(), \r
1984                                         commonRoot,\r
1985                                         pathList,\r
1986                                         logMessage,\r
1987                                         (LONG)m_RevisionEnd,\r
1988                                         &temp)))\r
1989                                 {\r
1990                                         CString sErr = temp;\r
1991                                         if (!sErr.IsEmpty())\r
1992                                                 ReportError(temp);\r
1993                                 }\r
1994 \r
1995                                 SysFreeString(temp);\r
1996                         }\r
1997                 }\r
1998         }\r
1999         if (CHooks::Instance().PostCommit(m_selectedPaths, m_depth, m_RevisionEnd, m_sMessage, exitcode, error))\r
2000         {\r
2001                 if (exitcode)\r
2002                 {\r
2003                         CString temp;\r
2004                         temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);\r
2005                         ReportError(temp);\r
2006                         return false;\r
2007                 }\r
2008         }\r
2009 #endif\r
2010         return true;\r
2011 }\r
2012 \r
2013 bool CGitProgressDlg::CmdCopy(CString& sWindowTitle, bool& /*localoperation*/)\r
2014 {\r
2015 #if 0\r
2016         ASSERT(m_targetPathList.GetCount() == 1);\r
2017         sWindowTitle.LoadString(IDS_PROGRS_TITLE_COPY);\r
2018         SetWindowText(sWindowTitle);\r
2019         SetBackgroundImage(IDI_COPY_BKG);\r
2020 \r
2021         CString sCmdInfo;\r
2022         sCmdInfo.Format(IDS_PROGRS_CMD_COPY, \r
2023                 m_targetPathList[0].IsUrl() ? (LPCTSTR)m_targetPathList[0].GetSVNPathString() : m_targetPathList[0].GetWinPath(),\r
2024                 (LPCTSTR)m_url.GetSVNPathString(), (LPCTSTR)m_Revision.ToString());\r
2025         ReportCmd(sCmdInfo);\r
2026 \r
2027         if (!Copy(m_targetPathList, m_url, m_Revision, m_pegRev, m_sMessage))\r
2028         {\r
2029                 ReportSVNError();\r
2030                 return false;\r
2031         }\r
2032         if (m_options & ProgOptSwitchAfterCopy)\r
2033         {\r
2034                 sCmdInfo.Format(IDS_PROGRS_CMD_SWITCH, \r
2035                         m_targetPathList[0].GetWinPath(),\r
2036                         (LPCTSTR)m_url.GetSVNPathString(), (LPCTSTR)m_Revision.ToString());\r
2037                 ReportCmd(sCmdInfo);\r
2038                 if (!Switch(m_targetPathList[0], m_url, SVNRev::REV_HEAD, SVNRev::REV_HEAD, m_depth, TRUE, m_options & ProgOptIgnoreExternals))\r
2039                 {\r
2040                         if (!Switch(m_targetPathList[0], m_url, SVNRev::REV_HEAD, m_Revision, m_depth, TRUE, m_options & ProgOptIgnoreExternals))\r
2041                         {\r
2042                                 ReportSVNError();\r
2043                                 return false;\r
2044                         }\r
2045                 }\r
2046         }\r
2047         else\r
2048         {\r
2049                 if (SVN::PathIsURL(m_url))\r
2050                 {\r
2051                         CString sMsg(MAKEINTRESOURCE(IDS_PROGRS_COPY_WARNING));\r
2052                         ReportNotification(sMsg);\r
2053                 }\r
2054         }\r
2055 #endif\r
2056         return true;\r
2057 }\r
2058 \r
2059 bool CGitProgressDlg::CmdExport(CString& sWindowTitle, bool& /*localoperation*/)\r
2060 {\r
2061 #if 0\r
2062         ASSERT(m_targetPathList.GetCount() == 1);\r
2063         sWindowTitle.LoadString(IDS_PROGRS_TITLE_EXPORT);\r
2064         sWindowTitle = m_url.GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle;\r
2065         SetWindowText(sWindowTitle);\r
2066         SetBackgroundImage(IDI_EXPORT_BKG);\r
2067         CString eol;\r
2068         if (m_options & ProgOptEolCRLF)\r
2069                 eol = _T("CRLF");\r
2070         if (m_options & ProgOptEolLF)\r
2071                 eol = _T("LF");\r
2072         if (m_options & ProgOptEolCR)\r
2073                 eol = _T("CR");\r
2074         ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_EXPORT)));\r
2075         if (!Export(m_url, m_targetPathList[0], m_Revision, m_Revision, TRUE, m_options & ProgOptIgnoreExternals, m_depth, NULL, FALSE, eol))\r
2076         {\r
2077                 ReportSVNError();\r
2078                 return false;\r
2079         }\r
2080 #endif\r
2081         return true;\r
2082 }\r
2083 \r
2084 bool CGitProgressDlg::CmdImport(CString& sWindowTitle, bool& /*localoperation*/)\r
2085 {\r
2086 #if 0\r
2087         ASSERT(m_targetPathList.GetCount() == 1);\r
2088         sWindowTitle.LoadString(IDS_PROGRS_TITLE_IMPORT);\r
2089         sWindowTitle = m_targetPathList[0].GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle;\r
2090         SetWindowText(sWindowTitle);\r
2091         SetBackgroundImage(IDI_IMPORT_BKG);\r
2092         CString sCmdInfo;\r
2093         sCmdInfo.Format(IDS_PROGRS_CMD_IMPORT, \r
2094                 m_targetPathList[0].GetWinPath(), (LPCTSTR)m_url.GetSVNPathString(), \r
2095                 m_options & ProgOptIncludeIgnored ? (LPCTSTR)(_T(", ") + sIgnoredIncluded) : _T(""));\r
2096         ReportCmd(sCmdInfo);\r
2097         if (!Import(m_targetPathList[0], m_url, m_sMessage, &m_ProjectProperties, svn_depth_infinity, m_options & ProgOptIncludeIgnored ? true : false, false))\r
2098         {\r
2099                 ReportSVNError();\r
2100                 return false;\r
2101         }\r
2102 #endif\r
2103         return true;\r
2104 }\r
2105 \r
2106 bool CGitProgressDlg::CmdLock(CString& sWindowTitle, bool& /*localoperation*/)\r
2107 {\r
2108 #if 0\r
2109         sWindowTitle.LoadString(IDS_PROGRS_TITLE_LOCK);\r
2110         SetWindowText(sWindowTitle);\r
2111         SetBackgroundImage(IDI_LOCK_BKG);\r
2112         ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_LOCK)));\r
2113         if (!Lock(m_targetPathList, m_options & ProgOptLockForce, m_sMessage))\r
2114         {\r
2115                 ReportSVNError();\r
2116                 return false;\r
2117         }\r
2118         CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);\r
2119         if (m_bLockWarning)\r
2120         {\r
2121                 // the lock failed, because the file was outdated.\r
2122                 // ask the user whether to update the file and try again\r
2123                 if (CMessageBox::Show(m_hWnd, IDS_WARN_LOCKOUTDATED, IDS_APPNAME, MB_ICONQUESTION|MB_YESNO)==IDYES)\r
2124                 {\r
2125                         ReportString(CString(MAKEINTRESOURCE(IDS_SVNPROGRESS_UPDATEANDRETRY)), CString(MAKEINTRESOURCE(IDS_WARN_NOTE)));\r
2126                         if (!Update(m_targetPathList, SVNRev::REV_HEAD, svn_depth_files, false, true))\r
2127                         {\r
2128                                 ReportSVNError();\r
2129                                 return false;\r
2130                         }\r
2131                         if (!Lock(m_targetPathList, m_options & ProgOptLockForce, m_sMessage))\r
2132                         {\r
2133                                 ReportSVNError();\r
2134                                 return false;\r
2135                         }\r
2136                 }\r
2137         }\r
2138         if (m_bLockExists)\r
2139         {\r
2140                 // the locking failed because there already is a lock.\r
2141                 // if the locking-dialog is skipped in the settings, tell the\r
2142                 // user how to steal the lock anyway (i.e., how to get the lock\r
2143                 // dialog back without changing the settings)\r
2144                 if (!DWORD(CRegDWORD(_T("Software\\TortoiseGit\\ShowLockDlg"), TRUE)))\r
2145                 {\r
2146                         ReportString(CString(MAKEINTRESOURCE(IDS_SVNPROGRESS_LOCKHINT)), CString(MAKEINTRESOURCE(IDS_WARN_NOTE)));\r
2147                 }\r
2148                 return false;\r
2149         }\r
2150 #endif\r
2151         return true;\r
2152 }\r
2153 \r
2154 bool CGitProgressDlg::CmdMerge(CString& sWindowTitle, bool& /*localoperation*/)\r
2155 {\r
2156 #if 0\r
2157         bool bFailed = false;\r
2158         ASSERT(m_targetPathList.GetCount() == 1);\r
2159         sWindowTitle.LoadString(IDS_PROGRS_TITLE_MERGE);\r
2160         SetBackgroundImage(IDI_MERGE_BKG);\r
2161         if (m_options & ProgOptDryRun)\r
2162         {\r
2163                 sWindowTitle += _T(" ") + sDryRun;\r
2164         }\r
2165         if (m_options & ProgOptRecordOnly)\r
2166         {\r
2167                 sWindowTitle += _T(" ") + sRecordOnly;\r
2168         }\r
2169         SetWindowText(sWindowTitle);\r
2170 \r
2171         GetDlgItem(IDC_INFOTEXT)->ShowWindow(SW_HIDE);\r
2172         GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_SHOW);\r
2173         CRegDWORD nonint = CRegDWORD(_T("Software\\TortoiseGit\\MergeNonInteractive"), FALSE);\r
2174         if (DWORD(nonint))\r
2175         {\r
2176                 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_SETCHECK, BST_CHECKED, 0);\r
2177                 m_AlwaysConflicted = true;\r
2178         }\r
2179         // we only accept a revision list to merge for peg merges\r
2180         ATLASSERT((m_revisionArray.GetCount()==0) || (m_revisionArray.GetCount() && (m_url.IsEquivalentTo(m_url2))));\r
2181 \r
2182         if (m_url.IsEquivalentTo(m_url2))\r
2183         {\r
2184                 CString sSuggestedMessage;\r
2185                 CString sMergedLogMessage;\r
2186                 CString sSeparator = CRegString(_T("Software\\TortoiseGit\\MergeLogSeparator"), _T("........"));\r
2187                 CString temp;\r
2188 \r
2189                 // Merging revisions %s of %s to %s into %s, %s%s\r
2190                 CString sCmdInfo;\r
2191                 sCmdInfo.Format(IDS_PROGRS_CMD_MERGEPEG, \r
2192                         (LPCTSTR)m_revisionArray.ToListString(),\r
2193                         (LPCTSTR)m_url.GetSVNPathString(),\r
2194                         m_targetPathList[0].GetWinPath(),\r
2195                         m_options & ProgOptIgnoreAncestry ? (LPCTSTR)sIgnoreAncestry : (LPCTSTR)sRespectAncestry,\r
2196                         m_options & ProgOptDryRun ? ((LPCTSTR)_T(", ") + sDryRun) : _T(""));\r
2197                 ReportCmd(sCmdInfo);\r
2198 \r
2199                 if (!PegMerge(m_url, m_revisionArray, \r
2200                         m_pegRev.IsValid() ? m_pegRev : (m_url.IsUrl() ? SVNRev::REV_HEAD : SVNRev(SVNRev::REV_WC)),\r
2201                         m_targetPathList[0], true, m_depth, m_diffoptions, !!(m_options & ProgOptIgnoreAncestry), !!(m_options & ProgOptDryRun), !!(m_options & ProgOptRecordOnly)))\r
2202                 {\r
2203                         // if the merge fails with the peg revision set,\r
2204                         // try again with HEAD as the peg revision.\r
2205                         if (!PegMerge(m_url, m_revisionArray, SVNRev::REV_HEAD,\r
2206                                 m_targetPathList[0], true, m_depth, m_diffoptions, !!(m_options & ProgOptIgnoreAncestry), !!(m_options & ProgOptDryRun), !!(m_options & ProgOptRecordOnly)))\r
2207                         {\r
2208                                 ReportSVNError();\r
2209                                 bFailed = true;\r
2210                         }\r
2211                 }\r
2212         }\r
2213         else\r
2214         {\r
2215                 CString sCmdInfo;\r
2216                 sCmdInfo.Format(IDS_PROGRS_CMD_MERGEURL, \r
2217                         (LPCTSTR)m_url.GetSVNPathString(), (LPCTSTR)m_Revision.ToString(), \r
2218                         (LPCTSTR)m_url2.GetSVNPathString(), (LPCTSTR)m_RevisionEnd.ToString(),\r
2219                         m_targetPathList[0].GetWinPath(),\r
2220                         m_options & ProgOptIgnoreAncestry ? (LPCTSTR)sIgnoreAncestry : (LPCTSTR)sRespectAncestry,\r
2221                         m_options & ProgOptDryRun ? ((LPCTSTR)_T(", ") + sDryRun) : _T(""));\r
2222                 ReportCmd(sCmdInfo);\r
2223 \r
2224                 if (!Merge(m_url, m_Revision, m_url2, m_RevisionEnd, m_targetPathList[0], \r
2225                         true, m_depth, m_diffoptions, !!(m_options & ProgOptIgnoreAncestry), !!(m_options & ProgOptDryRun), !!(m_options & ProgOptRecordOnly)))\r
2226                 {\r
2227                         ReportSVNError();\r
2228                         bFailed = true;\r
2229                 }\r
2230         }\r
2231         GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);\r
2232         GetDlgItem(IDC_INFOTEXT)->ShowWindow(SW_SHOW);\r
2233         return !bFailed;\r
2234 #endif\r
2235         return true;\r
2236 }\r
2237 \r
2238 bool CGitProgressDlg::CmdMergeAll(CString& sWindowTitle, bool& /*localoperation*/)\r
2239 {\r
2240 #if 0\r
2241         ASSERT(m_targetPathList.GetCount() == 1);\r
2242         sWindowTitle.LoadString(IDS_PROGRS_TITLE_MERGE);\r
2243         SetBackgroundImage(IDI_MERGE_BKG);\r
2244         SetWindowText(sWindowTitle);\r
2245 \r
2246         ATLASSERT(m_targetPathList.GetCount() == 1);\r
2247 \r
2248         CString sCmdInfo;\r
2249         sCmdInfo.LoadString(IDS_PROGRS_INFOGETTINGINFO);\r
2250         ReportCmd(sCmdInfo);\r
2251         CTGitPathList suggestedSources;\r
2252         if (!SuggestMergeSources(m_targetPathList[0], m_Revision, suggestedSources))\r
2253         {\r
2254                 ReportSVNError();\r
2255                 return false;\r
2256         }\r
2257 \r
2258         if (suggestedSources.GetCount() == 0)\r
2259         {\r
2260                 CString sErr;\r
2261                 sErr.Format(IDS_PROGRS_MERGEALLNOSOURCES, m_targetPathList[0].GetWinPath());\r
2262                 ReportError(sErr);\r
2263                 return false;\r
2264         }\r
2265         sCmdInfo.Format(IDS_PROGRS_CMD_MERGEALL, \r
2266                 (LPCTSTR)suggestedSources[0].GetSVNPathString(),\r
2267                 m_targetPathList[0].GetWinPath(),\r
2268                 m_options & ProgOptIgnoreAncestry ? (LPCTSTR)sIgnoreAncestry : (LPCTSTR)sRespectAncestry);\r
2269         ReportCmd(sCmdInfo);\r
2270 \r
2271         GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_SHOW);\r
2272         CRegDWORD nonint = CRegDWORD(_T("Software\\TortoiseGit\\MergeNonInteractive"), FALSE);\r
2273         if (DWORD(nonint))\r
2274         {\r
2275                 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_SETCHECK, BST_CHECKED, 0);\r
2276                 m_AlwaysConflicted = true;\r
2277         }\r
2278 \r
2279         SVNRevRangeArray revarray;\r
2280         if (!PegMerge(suggestedSources[0], revarray, \r
2281                 SVNRev::REV_HEAD,\r
2282                 m_targetPathList[0], true, m_depth, m_diffoptions, !!(m_options & ProgOptIgnoreAncestry), FALSE))\r
2283         {\r
2284                 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);\r
2285                 ReportSVNError();\r
2286                 return false;\r
2287         }\r
2288 \r
2289         GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);\r
2290 #endif\r
2291         return true;\r
2292 }\r
2293 \r
2294 bool CGitProgressDlg::CmdMergeReintegrate(CString& sWindowTitle, bool& /*localoperation*/)\r
2295 {\r
2296 #if 0\r
2297         ASSERT(m_targetPathList.GetCount() == 1);\r
2298         sWindowTitle.LoadString(IDS_PROGRS_TITLE_MERGEREINTEGRATE);\r
2299         SetBackgroundImage(IDI_MERGE_BKG);\r
2300         SetWindowText(sWindowTitle);\r
2301 \r
2302         CString sCmdInfo;\r
2303         sCmdInfo.Format(IDS_PROGRS_CMD_MERGEREINTEGRATE, \r
2304                 (LPCTSTR)m_url.GetSVNPathString(),\r
2305                 m_targetPathList[0].GetWinPath());\r
2306         ReportCmd(sCmdInfo);\r
2307 \r
2308         GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_SHOW);\r
2309         CRegDWORD nonint = CRegDWORD(_T("Software\\TortoiseGit\\MergeNonInteractive"), FALSE);\r
2310         if (DWORD(nonint))\r
2311         {\r
2312                 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_SETCHECK, BST_CHECKED, 0);\r
2313                 m_AlwaysConflicted = true;\r
2314         }\r
2315 \r
2316         if (!MergeReintegrate(m_url, SVNRev::REV_HEAD, m_targetPathList[0], !!(m_options & ProgOptDryRun), m_diffoptions))\r
2317         {\r
2318                 ReportSVNError();\r
2319                 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);\r
2320                 return false;\r
2321         }\r
2322 \r
2323         GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);\r
2324 #endif\r
2325         return true;\r
2326 }\r
2327 \r
2328 bool CGitProgressDlg::CmdRename(CString& sWindowTitle, bool& localoperation)\r
2329 {\r
2330 #if 0\r
2331         ASSERT(m_targetPathList.GetCount() == 1);\r
2332         if ((!m_targetPathList[0].IsUrl())&&(!m_url.IsUrl()))\r
2333                 localoperation = true;\r
2334         sWindowTitle.LoadString(IDS_PROGRS_TITLE_RENAME);\r
2335         SetWindowText(sWindowTitle);\r
2336         SetBackgroundImage(IDI_RENAME_BKG);\r
2337         ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RENAME)));\r
2338         if (!Move(m_targetPathList, m_url, m_Revision, m_sMessage))\r
2339         {\r
2340                 ReportSVNError();\r
2341                 return false;\r
2342         }\r
2343 #endif\r
2344         return true;\r
2345 }\r
2346 \r
2347 bool CGitProgressDlg::CmdResolve(CString& sWindowTitle, bool& localoperation)\r
2348 {\r
2349 \r
2350         localoperation = true;\r
2351         ASSERT(m_targetPathList.GetCount() == 1);\r
2352         sWindowTitle.LoadString(IDS_PROGRS_TITLE_RESOLVE);\r
2353         SetWindowText(sWindowTitle);\r
2354         SetBackgroundImage(IDI_RESOLVE_BKG);\r
2355         // check if the file may still have conflict markers in it.\r
2356         BOOL bMarkers = FALSE;\r
2357 \r
2358         for(int i=0;i<m_targetPathList.GetCount();i++)\r
2359         {\r
2360                 CString cmd,out,tempmergefile;\r
2361                 cmd.Format(_T("git.exe add -f \"%s\""),m_targetPathList[i].GetGitPathString());\r
2362                 if(g_Git.Run(cmd,&out,CP_ACP))\r
2363                 {\r
2364                         CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
2365                         m_bErrorsOccurred=true;\r
2366                         return false;\r
2367                 }\r
2368                 \r
2369 \r
2370                 try\r
2371                 {\r
2372                         tempmergefile = CAppUtils::GetMergeTempFile(_T("LOCAL"),(CTGitPath &)m_targetPathList[i]);\r
2373                         CFile::Remove(tempmergefile);\r
2374                 }catch(...)\r
2375                 {\r
2376                 }\r
2377                 \r
2378                 try\r
2379                 {\r
2380                         tempmergefile = CAppUtils::GetMergeTempFile(_T("REMOTE"),(CTGitPath &)m_targetPathList[i]);\r
2381                         CFile::Remove(tempmergefile);\r
2382                 }catch(...)\r
2383                 {\r
2384                 }\r
2385 \r
2386                 try\r
2387                 {\r
2388                         tempmergefile = CAppUtils::GetMergeTempFile(_T("BASE"),(CTGitPath &)m_targetPathList[i]);\r
2389                         CFile::Remove(tempmergefile);\r
2390                 }catch(...)\r
2391                 {\r
2392                 }\r
2393                 \r
2394 \r
2395                 Notify(m_targetPathList[i],git_wc_notify_resolved);\r
2396         }\r
2397 #if 0\r
2398         if ((m_options & ProgOptSkipConflictCheck) == 0)\r
2399         {\r
2400                 try\r
2401                 {\r
2402                         for (INT_PTR fileindex=0; (fileindex<m_targetPathList.GetCount()) && (bMarkers==FALSE); ++fileindex)\r
2403                         {\r
2404                                 if (!m_targetPathList[fileindex].IsDirectory())\r
2405                                 {\r
2406                                         CStdioFile file(m_targetPathList[fileindex].GetWinPath(), CFile::typeBinary | CFile::modeRead);\r
2407                                         CString strLine = _T("");\r
2408                                         while (file.ReadString(strLine))\r
2409                                         {\r
2410                                                 if (strLine.Find(_T("<<<<<<<"))==0)\r
2411                                                 {\r
2412                                                         bMarkers = TRUE;\r
2413                                                         break;\r
2414                                                 }\r
2415                                         }\r
2416                                         file.Close();\r
2417                                 }\r
2418                         }\r
2419                 } \r
2420                 catch (CFileException* pE)\r
2421                 {\r
2422                         TRACE(_T("CFileException in Resolve!\n"));\r
2423                         TCHAR error[10000] = {0};\r
2424                         pE->GetErrorMessage(error, 10000);\r
2425                         ReportError(error);\r
2426                         pE->Delete();\r
2427                         return false;\r
2428                 }\r
2429         }\r
2430         if (bMarkers)\r
2431         {\r
2432                 if (CMessageBox::Show(m_hWnd, IDS_PROGRS_REVERTMARKERS, IDS_APPNAME, MB_YESNO | MB_ICONQUESTION)==IDYES)\r
2433                 {\r
2434                         ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE)));\r
2435                         for (INT_PTR fileindex=0; fileindex<m_targetPathList.GetCount(); ++fileindex)\r
2436                                 Resolve(m_targetPathList[fileindex], svn_wc_conflict_choose_merged, true);\r
2437                 }\r
2438         }\r
2439         else\r
2440         {\r
2441                 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE)));\r
2442                 for (INT_PTR fileindex=0; fileindex<m_targetPathList.GetCount(); ++fileindex)\r
2443                         Resolve(m_targetPathList[fileindex], svn_wc_conflict_choose_merged, true);\r
2444         }\r
2445 #endif\r
2446         CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);\r
2447 \r
2448         return true;\r
2449 }\r
2450 \r
2451 bool CGitProgressDlg::CmdRevert(CString& sWindowTitle, bool& localoperation)\r
2452 {\r
2453 #if 0\r
2454         localoperation = true;\r
2455         sWindowTitle.LoadString(IDS_PROGRS_TITLE_REVERT);\r
2456         SetWindowText(sWindowTitle);\r
2457         SetBackgroundImage(IDI_REVERT_BKG);\r
2458 \r
2459         CTGitPathList delList = m_selectedPaths;\r
2460         if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RevertWithRecycleBin"), TRUE)))\r
2461                 delList.DeleteAllFiles(true);\r
2462 \r
2463         ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_REVERT)));\r
2464         if (!Revert(m_targetPathList, CStringArray(), !!(m_options & ProgOptRecursive)))\r
2465         {\r
2466                 ReportSVNError();\r
2467                 return false;\r
2468         }\r
2469         CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);\r
2470 #endif\r
2471         return true;\r
2472 }\r
2473 \r
2474 bool CGitProgressDlg::CmdSwitch(CString& sWindowTitle, bool& /*localoperation*/)\r
2475 {\r
2476 #if 0\r
2477         ASSERT(m_targetPathList.GetCount() == 1);\r
2478         SVNStatus st;\r
2479         sWindowTitle.LoadString(IDS_PROGRS_TITLE_SWITCH);\r
2480         SetWindowText(sWindowTitle);\r
2481         SetBackgroundImage(IDI_SWITCH_BKG);\r
2482         LONG rev = 0;\r
2483         if (st.GetStatus(m_targetPathList[0]) != (-2))\r
2484         {\r
2485                 if (st.status->entry != NULL)\r
2486                 {\r
2487                         rev = st.status->entry->revision;\r
2488                 }\r
2489         }\r
2490 \r
2491         CString sCmdInfo;\r
2492         sCmdInfo.Format(IDS_PROGRS_CMD_SWITCH, \r
2493                 m_targetPathList[0].GetWinPath(), (LPCTSTR)m_url.GetSVNPathString(),\r
2494                 (LPCTSTR)m_Revision.ToString());\r
2495         ReportCmd(sCmdInfo);\r
2496 \r
2497         bool depthIsSticky = true;\r
2498         if (m_depth == svn_depth_unknown)\r
2499                 depthIsSticky = false;\r
2500         if (!Switch(m_targetPathList[0], m_url, m_Revision, m_Revision, m_depth, depthIsSticky, m_options & ProgOptIgnoreExternals))\r
2501         {\r
2502                 ReportSVNError();\r
2503    &nbs