drop lock/unlock
[TortoiseGit.git] / src / TortoiseProc / SVNProgressDlg.cpp
blobad035a51ea1ede1350700f82a731ba49065b2eeb
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - TortoiseGit
4 // Copyright (C) 2003-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "TortoiseProc.h"
22 #include "messagebox.h"
23 #include "SVNProgressDlg.h"
24 #include "LogDlg.h"
25 #include "TGitPath.h"
26 #include "Registry.h"
27 #include "GitStatus.h"
28 #include "AppUtils.h"
29 #include "PathUtils.h"
30 #include "StringUtils.h"
31 #include "TempFile.h"
32 #include "UnicodeUtils.h"
33 #include "SoundUtils.h"
34 #include "GitDiff.h"
35 #include "Hooks.h"
36 #include "DropFiles.h"
37 //#include "GitLogHelper.h"
38 #include "RegHistory.h"
39 //#include "ConflictResolveDlg.h"
40 #include "LogFile.h"
41 #include "ShellUpdater.h"
42 #include "IconMenu.h"
43 #include "BugTraqAssociations.h"
44 #include "patch.h"
46 static UINT WM_GITPROGRESS = RegisterWindowMessage(_T("TORTOISEGIT_GITPROGRESS_MSG"));
48 BOOL CGitProgressDlg::m_bAscending = FALSE;
49 int CGitProgressDlg::m_nSortedColumn = -1;
51 #define TRANSFERTIMER 100
52 #define VISIBLETIMER 101
54 enum SVNProgressDlgContextMenuCommands
56 // needs to start with 1, since 0 is the return value if *nothing* is clicked on in the context menu
57 ID_COMPARE = 1,
58 ID_EDITCONFLICT,
59 ID_CONFLICTRESOLVE,
60 ID_CONFLICTUSETHEIRS,
61 ID_CONFLICTUSEMINE,
62 ID_LOG,
63 ID_OPEN,
64 ID_OPENWITH,
65 ID_EXPLORE,
66 ID_COPY
69 IMPLEMENT_DYNAMIC(CGitProgressDlg, CResizableStandAloneDialog)
70 CGitProgressDlg::CGitProgressDlg(CWnd* pParent /*=NULL*/)
71 : CResizableStandAloneDialog(CGitProgressDlg::IDD, pParent)
72 , m_bCancelled(FALSE)
73 , m_pThread(NULL)
74 #if 0
75 , m_Revision(_T("HEAD"))
76 //, m_RevisionEnd(0)
77 , m_bLockWarning(false)
78 , m_bLockExists(false)
79 , m_bThreadRunning(FALSE)
80 , m_nConflicts(0)
81 , m_bErrorsOccurred(FALSE)
82 , m_bMergesAddsDeletesOccurred(FALSE)
84 , m_options(ProgOptNone)
85 , m_dwCloseOnEnd((DWORD)-1)
86 , m_bFinishedItemAdded(false)
87 , m_bLastVisible(false)
88 // , m_depth(svn_depth_unknown)
89 , m_itemCount(-1)
90 , m_itemCountTotal(-1)
91 , m_AlwaysConflicted(false)
92 , m_BugTraqProvider(NULL)
93 , sIgnoredIncluded(MAKEINTRESOURCE(IDS_PROGRS_IGNOREDINCLUDED))
94 , sExtExcluded(MAKEINTRESOURCE(IDS_PROGRS_EXTERNALSEXCLUDED))
95 , sExtIncluded(MAKEINTRESOURCE(IDS_PROGRS_EXTERNALSINCLUDED))
96 , sIgnoreAncestry(MAKEINTRESOURCE(IDS_PROGRS_IGNOREANCESTRY))
97 , sRespectAncestry(MAKEINTRESOURCE(IDS_PROGRS_RESPECTANCESTRY))
98 , sDryRun(MAKEINTRESOURCE(IDS_PROGRS_DRYRUN))
99 , sRecordOnly(MAKEINTRESOURCE(IDS_MERGE_RECORDONLY))
100 #endif
104 CGitProgressDlg::~CGitProgressDlg()
106 for (size_t i=0; i<m_arData.size(); i++)
108 delete m_arData[i];
110 if(m_pThread != NULL)
112 delete m_pThread;
116 void CGitProgressDlg::DoDataExchange(CDataExchange* pDX)
118 CResizableStandAloneDialog::DoDataExchange(pDX);
119 DDX_Control(pDX, IDC_SVNPROGRESS, m_ProgList);
122 BEGIN_MESSAGE_MAP(CGitProgressDlg, CResizableStandAloneDialog)
123 ON_BN_CLICKED(IDC_LOGBUTTON, OnBnClickedLogbutton)
124 ON_NOTIFY(NM_CUSTOMDRAW, IDC_SVNPROGRESS, OnNMCustomdrawSvnprogress)
125 ON_WM_CLOSE()
126 ON_NOTIFY(NM_DBLCLK, IDC_SVNPROGRESS, OnNMDblclkSvnprogress)
127 ON_NOTIFY(HDN_ITEMCLICK, 0, OnHdnItemclickSvnprogress)
128 ON_WM_SETCURSOR()
129 ON_WM_CONTEXTMENU()
130 ON_REGISTERED_MESSAGE(WM_GITPROGRESS, OnGitProgress)
131 ON_WM_TIMER()
132 ON_EN_SETFOCUS(IDC_INFOTEXT, &CGitProgressDlg::OnEnSetfocusInfotext)
133 ON_NOTIFY(LVN_BEGINDRAG, IDC_SVNPROGRESS, &CGitProgressDlg::OnLvnBegindragSvnprogress)
134 ON_WM_SIZE()
135 ON_NOTIFY(LVN_GETDISPINFO, IDC_SVNPROGRESS, &CGitProgressDlg::OnLvnGetdispinfoSvnprogress)
136 ON_BN_CLICKED(IDC_NONINTERACTIVE, &CGitProgressDlg::OnBnClickedNoninteractive)
137 ON_MESSAGE(WM_SHOWCONFLICTRESOLVER, OnShowConflictResolver)
138 END_MESSAGE_MAP()
140 BOOL CGitProgressDlg::Cancel()
142 return m_bCancelled;
145 LRESULT CGitProgressDlg::OnShowConflictResolver(WPARAM /*wParam*/, LPARAM /*lParam*/)
147 #if 0
148 CConflictResolveDlg dlg(this);
149 const svn_wc_conflict_description_t *description = (svn_wc_conflict_description_t *)lParam;
150 if (description)
152 dlg.SetConflictDescription(description);
153 if (dlg.DoModal() == IDOK)
155 if (dlg.GetResult() == svn_wc_conflict_choose_postpone)
157 // if the result is conflicted and the dialog returned IDOK,
158 // that means we should not ask again in case of a conflict
159 m_AlwaysConflicted = true;
160 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_SETCHECK, BST_CHECKED, 0);
163 m_mergedfile = dlg.GetMergedFile();
164 m_bCancelled = dlg.IsCancelled();
165 return dlg.GetResult();
168 return svn_wc_conflict_choose_postpone;
169 #endif
170 return 0;
172 #if 0
173 svn_wc_conflict_choice_t CGitProgressDlg::ConflictResolveCallback(const svn_wc_conflict_description_t *description, CString& mergedfile)
175 // we only bother the user when merging
176 if (((m_Command == GitProgress_Merge)||(m_Command == GitProgress_MergeAll)||(m_Command == GitProgress_MergeReintegrate))&&(!m_AlwaysConflicted)&&(description))
178 // we're in a worker thread here. That means we must not show a dialog from the thread
179 // but let the UI thread do it.
180 // To do that, we send a message to the UI thread and let it show the conflict resolver dialog.
181 LRESULT dlgResult = ::SendMessage(GetSafeHwnd(), WM_SHOWCONFLICTRESOLVER, 0, (LPARAM)description);
182 mergedfile = m_mergedfile;
183 return (svn_wc_conflict_choice_t)dlgResult;
186 return svn_wc_conflict_choose_postpone;
188 #endif
189 void CGitProgressDlg::AddItemToList()
191 int totalcount = m_ProgList.GetItemCount();
193 m_ProgList.SetItemCountEx(totalcount+1, LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL);
194 // make columns width fit
195 if (iFirstResized < 30)
197 // only resize the columns for the first 30 or so entries.
198 // after that, don't resize them anymore because that's an
199 // expensive function call and the columns will be sized
200 // close enough already.
201 ResizeColumns();
202 iFirstResized++;
205 // Make sure the item is *entirely* visible even if the horizontal
206 // scroll bar is visible.
207 int count = m_ProgList.GetCountPerPage();
208 if (totalcount <= (m_ProgList.GetTopIndex() + count + nEnsureVisibleCount + 2))
210 nEnsureVisibleCount++;
211 m_bLastVisible = true;
213 else
215 nEnsureVisibleCount = 0;
216 if (IsIconic() == 0)
217 m_bLastVisible = false;
222 BOOL CGitProgressDlg::Notify(const CTGitPath& path, git_wc_notify_action_t action,
223 int /*status*/ ,
224 CString *strErr
226 svn_node_kind_t kind, const CString& mime_type,
227 svn_wc_notify_state_t content_state,
228 svn_wc_notify_state_t prop_state, LONG rev,
229 const svn_lock_t * lock, svn_wc_notify_lock_state_t lock_state,
230 const CString& changelistname,
231 svn_merge_range_t * range,
232 svn_error_t * err, apr_pool_t * pool
235 bool bNoNotify = false;
236 bool bDoAddData = true;
237 NotificationData * data = new NotificationData();
238 data->path = path;
239 data->action = action;
240 data->sPathColumnText=path.GetGitPathString();
241 data->bAuxItem = false;
242 #if 0
243 data->kind = kind;
244 data->mime_type = mime_type;
245 data->content_state = content_state;
246 data->prop_state = prop_state;
247 data->rev = rev;
248 data->lock_state = lock_state;
249 data->changelistname = changelistname;
250 if ((lock)&&(lock->owner))
251 data->owner = CUnicodeUtils::GetUnicode(lock->owner);
252 data->sPathColumnText = path.GetUIPathString();
253 if (!m_basePath.IsEmpty())
254 data->basepath = m_basePath;
255 if (range)
256 data->merge_range = *range;
257 #endif
258 switch (data->action)
260 case git_wc_notify_add:
261 //case svn_wc_notify_update_add:
262 // if ((data->content_state == svn_wc_notify_state_conflicted) || (data->prop_state == svn_wc_notify_state_conflicted))
263 // {
264 // data->color = m_Colors.GetColor(CColors::Conflict);
265 // data->bConflictedActionItem = true;
266 // data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);
267 // m_nConflicts++;
268 // }
269 // else
270 // {
271 // m_bMergesAddsDeletesOccurred = true;
272 data->sActionColumnText.LoadString(IDS_SVNACTION_ADD);
273 data->color = m_Colors.GetColor(CColors::Added);
274 // }
275 break;
276 case git_wc_notify_sendmail_start:
277 data->bAuxItem = true;
278 data->sActionColumnText.LoadString(IDS_SVNACTION_SENDMAIL_START);
279 data->color = m_Colors.GetColor(CColors::Modified);
280 break;
282 case git_wc_notify_sendmail_error:
283 data->bAuxItem = true;
284 data->sActionColumnText.LoadString(IDS_SVNACTION_SENDMAIL_ERROR);
285 if(strErr)
286 data->sPathColumnText = *strErr;
287 else
288 data->sPathColumnText.Empty();
289 data->color = m_Colors.GetColor(CColors::Modified);
290 break;
292 case git_wc_notify_sendmail_done:
294 data->sActionColumnText.LoadString(IDS_SVNACTION_SENDMAIL_DONE);
295 data->sPathColumnText.Empty();
296 data->color = m_Colors.GetColor(CColors::Modified);
297 break;
299 case git_wc_notify_sendmail_retry:
300 data->sActionColumnText.LoadString(IDS_SVNACTION_SENDMAIL_RETRY);
301 data->sPathColumnText.Empty();
302 data->color = m_Colors.GetColor(CColors::Modified);
303 break;
306 case git_wc_notify_resolved:
307 data->sActionColumnText.LoadString(IDS_SVNACTION_RESOLVE);
308 break;
310 case git_wc_notify_revert:
311 data->sActionColumnText.LoadString(IDS_SVNACTION_REVERT);
312 break;
314 #if 0
315 case svn_wc_notify_commit_added:
316 data->sActionColumnText.LoadString(IDS_SVNACTION_ADDING);
317 data->color = m_Colors.GetColor(CColors::Added);
318 break;
319 case svn_wc_notify_copy:
320 data->sActionColumnText.LoadString(IDS_SVNACTION_COPY);
321 break;
322 case svn_wc_notify_commit_modified:
323 data->sActionColumnText.LoadString(IDS_SVNACTION_MODIFIED);
324 data->color = m_Colors.GetColor(CColors::Modified);
325 break;
326 case svn_wc_notify_delete:
327 case svn_wc_notify_update_delete:
328 data->sActionColumnText.LoadString(IDS_SVNACTION_DELETE);
329 m_bMergesAddsDeletesOccurred = true;
330 data->color = m_Colors.GetColor(CColors::Deleted);
331 break;
332 case svn_wc_notify_commit_deleted:
333 data->sActionColumnText.LoadString(IDS_SVNACTION_DELETING);
334 data->color = m_Colors.GetColor(CColors::Deleted);
335 break;
336 case svn_wc_notify_restore:
337 data->sActionColumnText.LoadString(IDS_SVNACTION_RESTORE);
338 break;
340 case svn_wc_notify_update_replace:
341 case svn_wc_notify_commit_replaced:
342 data->sActionColumnText.LoadString(IDS_SVNACTION_REPLACED);
343 data->color = m_Colors.GetColor(CColors::Deleted);
344 break;
345 case svn_wc_notify_exists:
346 if ((data->content_state == svn_wc_notify_state_conflicted) || (data->prop_state == svn_wc_notify_state_conflicted))
348 data->color = m_Colors.GetColor(CColors::Conflict);
349 data->bConflictedActionItem = true;
350 m_nConflicts++;
351 data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);
353 else if ((data->content_state == svn_wc_notify_state_merged) || (data->prop_state == svn_wc_notify_state_merged))
355 data->color = m_Colors.GetColor(CColors::Merged);
356 m_bMergesAddsDeletesOccurred = true;
357 data->sActionColumnText.LoadString(IDS_SVNACTION_MERGED);
359 else
360 data->sActionColumnText.LoadString(IDS_SVNACTION_EXISTS);
361 break;
362 case svn_wc_notify_update_update:
363 // if this is an inoperative dir change, don't show the notification.
364 // an inoperative dir change is when a directory gets updated without
365 // any real change in either text or properties.
366 if ((kind == svn_node_dir)
367 && ((prop_state == svn_wc_notify_state_inapplicable)
368 || (prop_state == svn_wc_notify_state_unknown)
369 || (prop_state == svn_wc_notify_state_unchanged)))
371 bNoNotify = true;
372 break;
374 if ((data->content_state == svn_wc_notify_state_conflicted) || (data->prop_state == svn_wc_notify_state_conflicted))
376 data->color = m_Colors.GetColor(CColors::Conflict);
377 data->bConflictedActionItem = true;
378 m_nConflicts++;
379 data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);
381 else if ((data->content_state == svn_wc_notify_state_merged) || (data->prop_state == svn_wc_notify_state_merged))
383 data->color = m_Colors.GetColor(CColors::Merged);
384 m_bMergesAddsDeletesOccurred = true;
385 data->sActionColumnText.LoadString(IDS_SVNACTION_MERGED);
387 else if (((data->content_state != svn_wc_notify_state_unchanged)&&(data->content_state != svn_wc_notify_state_unknown)) ||
388 ((data->prop_state != svn_wc_notify_state_unchanged)&&(data->prop_state != svn_wc_notify_state_unknown)))
390 data->sActionColumnText.LoadString(IDS_SVNACTION_UPDATE);
392 else
394 bNoNotify = true;
395 break;
397 if (lock_state == svn_wc_notify_lock_state_unlocked)
399 CString temp(MAKEINTRESOURCE(IDS_SVNACTION_UNLOCKED));
400 data->sActionColumnText += _T(", ") + temp;
402 break;
404 case svn_wc_notify_update_external:
405 // For some reason we build a list of externals...
406 m_ExtStack.AddHead(path.GetUIPathString());
407 data->sActionColumnText.LoadString(IDS_SVNACTION_EXTERNAL);
408 data->bAuxItem = true;
409 break;
411 case svn_wc_notify_update_completed:
413 data->sActionColumnText.LoadString(IDS_SVNACTION_COMPLETED);
414 data->bAuxItem = true;
415 bool bEmpty = !!m_ExtStack.IsEmpty();
416 if (!bEmpty)
417 data->sPathColumnText.Format(IDS_PROGRS_PATHATREV, (LPCTSTR)m_ExtStack.RemoveHead(), rev);
418 else
419 data->sPathColumnText.Format(IDS_PROGRS_ATREV, rev);
421 if ((m_nConflicts>0)&&(bEmpty))
423 // We're going to add another aux item - let's shove this current onto the list first
424 // I don't really like this, but it will do for the moment.
425 m_arData.push_back(data);
426 AddItemToList();
428 data = new NotificationData();
429 data->bAuxItem = true;
430 data->sActionColumnText.LoadString(IDS_PROGRS_CONFLICTSOCCURED_WARNING);
431 data->sPathColumnText.LoadString(IDS_PROGRS_CONFLICTSOCCURED);
432 data->color = m_Colors.GetColor(CColors::Conflict);
433 CSoundUtils::PlayTSVNWarning();
434 // This item will now be added after the switch statement
436 if (!m_basePath.IsEmpty())
437 m_FinishedRevMap[m_basePath.GetSVNApiPath(pool)] = rev;
438 m_RevisionEnd = rev;
439 m_bFinishedItemAdded = true;
441 break;
442 case svn_wc_notify_commit_postfix_txdelta:
443 data->sActionColumnText.LoadString(IDS_SVNACTION_POSTFIX);
444 break;
445 case svn_wc_notify_failed_revert:
446 data->sActionColumnText.LoadString(IDS_SVNACTION_FAILEDREVERT);
447 break;
448 case svn_wc_notify_status_completed:
449 case svn_wc_notify_status_external:
450 data->sActionColumnText.LoadString(IDS_SVNACTION_STATUS);
451 break;
452 case svn_wc_notify_skip:
453 if ((content_state == svn_wc_notify_state_missing)||(content_state == svn_wc_notify_state_obstructed)||(content_state == svn_wc_notify_state_conflicted))
455 data->sActionColumnText.LoadString(IDS_SVNACTION_SKIPMISSING);
457 // The color settings dialog describes the red color with
458 // "possible or real conflict / obstructed" which also applies to
459 // skipped targets during a merge. So we just use the same color.
460 data->color = m_Colors.GetColor(CColors::Conflict);
462 else
463 data->sActionColumnText.LoadString(IDS_SVNACTION_SKIP);
464 break;
465 case svn_wc_notify_locked:
466 if ((lock)&&(lock->owner))
467 data->sActionColumnText.Format(IDS_SVNACTION_LOCKEDBY, (LPCTSTR)CUnicodeUtils::GetUnicode(lock->owner));
468 break;
469 case svn_wc_notify_unlocked:
470 data->sActionColumnText.LoadString(IDS_SVNACTION_UNLOCKED);
471 break;
472 case svn_wc_notify_failed_lock:
473 data->sActionColumnText.LoadString(IDS_SVNACTION_FAILEDLOCK);
474 m_arData.push_back(data);
475 AddItemToList();
476 ReportError(SVN::GetErrorString(err));
477 bDoAddData = false;
478 if (err->apr_err == SVN_ERR_FS_OUT_OF_DATE)
479 m_bLockWarning = true;
480 if (err->apr_err == SVN_ERR_FS_PATH_ALREADY_LOCKED)
481 m_bLockExists = true;
482 break;
483 case svn_wc_notify_failed_unlock:
484 data->sActionColumnText.LoadString(IDS_SVNACTION_FAILEDUNLOCK);
485 m_arData.push_back(data);
486 AddItemToList();
487 ReportError(SVN::GetErrorString(err));
488 bDoAddData = false;
489 if (err->apr_err == SVN_ERR_FS_OUT_OF_DATE)
490 m_bLockWarning = true;
491 break;
492 case svn_wc_notify_changelist_set:
493 data->sActionColumnText.Format(IDS_SVNACTION_CHANGELISTSET, (LPCTSTR)data->changelistname);
494 break;
495 case svn_wc_notify_changelist_clear:
496 data->sActionColumnText.LoadString(IDS_SVNACTION_CHANGELISTCLEAR);
497 break;
498 case svn_wc_notify_changelist_moved:
499 data->sActionColumnText.Format(IDS_SVNACTION_CHANGELISTMOVED, (LPCTSTR)data->changelistname);
500 break;
501 case svn_wc_notify_foreign_merge_begin:
502 case svn_wc_notify_merge_begin:
503 if (range == NULL)
504 data->sActionColumnText.LoadString(IDS_SVNACTION_MERGEBEGINNONE);
505 else if ((data->merge_range.start == data->merge_range.end) || (data->merge_range.start == data->merge_range.end - 1))
506 data->sActionColumnText.Format(IDS_SVNACTION_MERGEBEGINSINGLE, data->merge_range.end);
507 else if (data->merge_range.start - 1 == data->merge_range.end)
508 data->sActionColumnText.Format(IDS_SVNACTION_MERGEBEGINSINGLEREVERSE, data->merge_range.start);
509 else if (data->merge_range.start < data->merge_range.end)
510 data->sActionColumnText.Format(IDS_SVNACTION_MERGEBEGINMULTIPLE, data->merge_range.start + 1, data->merge_range.end);
511 else
512 data->sActionColumnText.Format(IDS_SVNACTION_MERGEBEGINMULTIPLEREVERSE, data->merge_range.start, data->merge_range.end + 1);
513 data->bAuxItem = true;
514 break;
515 #endif
516 default:
517 break;
518 } // switch (data->action)
520 if (bNoNotify)
521 delete data;
522 else
524 if (bDoAddData)
526 m_arData.push_back(data);
527 AddItemToList();
528 if ((!data->bAuxItem) && (m_itemCount > 0))
530 m_itemCount--;
532 CProgressCtrl * progControl = (CProgressCtrl *)GetDlgItem(IDC_PROGRESSBAR);
533 progControl->ShowWindow(SW_SHOW);
534 progControl->SetPos(m_itemCountTotal - m_itemCount);
535 progControl->SetRange32(0, m_itemCountTotal);
538 //if ((action == svn_wc_notify_commit_postfix_txdelta)&&(bSecondResized == FALSE))
540 // ResizeColumns();
541 // bSecondResized = TRUE;
545 return TRUE;
549 CString CGitProgressDlg::BuildInfoString()
551 CString infotext;
552 if(this->m_Command == GitProgress_Resolve)
553 infotext = _T("You need commit your change after resolve conflict");
554 #if 0
556 CString temp;
557 int added = 0;
558 int copied = 0;
559 int deleted = 0;
560 int restored = 0;
561 int reverted = 0;
562 int resolved = 0;
563 int conflicted = 0;
564 int updated = 0;
565 int merged = 0;
566 int modified = 0;
567 int skipped = 0;
568 int replaced = 0;
570 for (size_t i=0; i<m_arData.size(); ++i)
572 const NotificationData * dat = m_arData[i];
573 switch (dat->action)
575 case svn_wc_notify_add:
576 case svn_wc_notify_update_add:
577 case svn_wc_notify_commit_added:
578 if (dat->bConflictedActionItem)
579 conflicted++;
580 else
581 added++;
582 break;
583 case svn_wc_notify_copy:
584 copied++;
585 break;
586 case svn_wc_notify_delete:
587 case svn_wc_notify_update_delete:
588 case svn_wc_notify_commit_deleted:
589 deleted++;
590 break;
591 case svn_wc_notify_restore:
592 restored++;
593 break;
594 case svn_wc_notify_revert:
595 reverted++;
596 break;
597 case svn_wc_notify_resolved:
598 resolved++;
599 break;
600 case svn_wc_notify_update_update:
601 if (dat->bConflictedActionItem)
602 conflicted++;
603 else if ((dat->content_state == svn_wc_notify_state_merged) || (dat->prop_state == svn_wc_notify_state_merged))
604 merged++;
605 else
606 updated++;
607 break;
608 case svn_wc_notify_commit_modified:
609 modified++;
610 break;
611 case svn_wc_notify_skip:
612 skipped++;
613 break;
614 case svn_wc_notify_commit_replaced:
615 replaced++;
616 break;
619 if (conflicted)
621 temp.LoadString(IDS_SVNACTION_CONFLICTED);
622 infotext += temp;
623 temp.Format(_T(":%d "), conflicted);
624 infotext += temp;
626 if (skipped)
628 temp.LoadString(IDS_SVNACTION_SKIP);
629 infotext += temp;
630 infotext.AppendFormat(_T(":%d "), skipped);
632 if (merged)
634 temp.LoadString(IDS_SVNACTION_MERGED);
635 infotext += temp;
636 infotext.AppendFormat(_T(":%d "), merged);
638 if (added)
640 temp.LoadString(IDS_SVNACTION_ADD);
641 infotext += temp;
642 infotext.AppendFormat(_T(":%d "), added);
644 if (deleted)
646 temp.LoadString(IDS_SVNACTION_DELETE);
647 infotext += temp;
648 infotext.AppendFormat(_T(":%d "), deleted);
650 if (modified)
652 temp.LoadString(IDS_SVNACTION_MODIFIED);
653 infotext += temp;
654 infotext.AppendFormat(_T(":%d "), modified);
656 if (copied)
658 temp.LoadString(IDS_SVNACTION_COPY);
659 infotext += temp;
660 infotext.AppendFormat(_T(":%d "), copied);
662 if (replaced)
664 temp.LoadString(IDS_SVNACTION_REPLACED);
665 infotext += temp;
666 infotext.AppendFormat(_T(":%d "), replaced);
668 if (updated)
670 temp.LoadString(IDS_SVNACTION_UPDATE);
671 infotext += temp;
672 infotext.AppendFormat(_T(":%d "), updated);
674 if (restored)
676 temp.LoadString(IDS_SVNACTION_RESTORE);
677 infotext += temp;
678 infotext.AppendFormat(_T(":%d "), restored);
680 if (reverted)
682 temp.LoadString(IDS_SVNACTION_REVERT);
683 infotext += temp;
684 infotext.AppendFormat(_T(":%d "), reverted);
686 if (resolved)
688 temp.LoadString(IDS_SVNACTION_RESOLVE);
689 infotext += temp;
690 infotext.AppendFormat(_T(":%d "), resolved);
692 #endif
693 return infotext;
696 void CGitProgressDlg::SetSelectedList(const CTGitPathList& selPaths)
698 m_selectedPaths = selPaths;
701 void CGitProgressDlg::ResizeColumns()
703 m_ProgList.SetRedraw(FALSE);
705 TCHAR textbuf[MAX_PATH];
707 int maxcol = ((CHeaderCtrl*)(m_ProgList.GetDlgItem(0)))->GetItemCount()-1;
708 for (int col = 0; col <= maxcol; col++)
710 // find the longest width of all items
711 int count = m_ProgList.GetItemCount();
712 HDITEM hdi = {0};
713 hdi.mask = HDI_TEXT;
714 hdi.pszText = textbuf;
715 hdi.cchTextMax = sizeof(textbuf);
716 ((CHeaderCtrl*)(m_ProgList.GetDlgItem(0)))->GetItem(col, &hdi);
717 int cx = m_ProgList.GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
719 for (int index = 0; index<count; ++index)
721 // get the width of the string and add 12 pixels for the column separator and margins
722 int linewidth = cx;
723 switch (col)
725 case 0:
726 linewidth = m_ProgList.GetStringWidth(m_arData[index]->sActionColumnText) + 12;
727 break;
728 case 1:
729 linewidth = m_ProgList.GetStringWidth(m_arData[index]->sPathColumnText) + 12;
730 break;
731 case 2:
732 linewidth = m_ProgList.GetStringWidth(m_arData[index]->mime_type) + 12;
733 break;
735 if (cx < linewidth)
736 cx = linewidth;
738 m_ProgList.SetColumnWidth(col, cx);
741 m_ProgList.SetRedraw(TRUE);
744 BOOL CGitProgressDlg::OnInitDialog()
746 __super::OnInitDialog();
748 m_ProgList.SetExtendedStyle (LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
750 m_ProgList.DeleteAllItems();
751 int c = ((CHeaderCtrl*)(m_ProgList.GetDlgItem(0)))->GetItemCount()-1;
752 while (c>=0)
753 m_ProgList.DeleteColumn(c--);
754 CString temp;
755 temp.LoadString(IDS_PROGRS_ACTION);
756 m_ProgList.InsertColumn(0, temp);
757 temp.LoadString(IDS_PROGRS_PATH);
758 m_ProgList.InsertColumn(1, temp);
759 temp.LoadString(IDS_PROGRS_MIMETYPE);
760 m_ProgList.InsertColumn(2, temp);
762 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
763 if (m_pThread==NULL)
765 ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
767 else
769 m_pThread->m_bAutoDelete = FALSE;
770 m_pThread->ResumeThread();
773 UpdateData(FALSE);
775 // Call this early so that the column headings aren't hidden before any
776 // text gets added.
777 ResizeColumns();
779 SetTimer(VISIBLETIMER, 300, NULL);
781 AddAnchor(IDC_SVNPROGRESS, TOP_LEFT, BOTTOM_RIGHT);
782 AddAnchor(IDC_PROGRESSLABEL, BOTTOM_LEFT, BOTTOM_CENTER);
783 AddAnchor(IDC_PROGRESSBAR, BOTTOM_CENTER, BOTTOM_RIGHT);
784 AddAnchor(IDC_INFOTEXT, BOTTOM_LEFT, BOTTOM_RIGHT);
785 AddAnchor(IDC_NONINTERACTIVE, BOTTOM_LEFT, BOTTOM_RIGHT);
786 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
787 AddAnchor(IDOK, BOTTOM_RIGHT);
788 AddAnchor(IDC_LOGBUTTON, BOTTOM_RIGHT);
789 //SetPromptParentWindow(this->m_hWnd);
790 if (hWndExplorer)
791 CenterWindow(CWnd::FromHandle(hWndExplorer));
792 EnableSaveRestore(_T("SVNProgressDlg"));
793 return TRUE;
796 bool CGitProgressDlg::SetBackgroundImage(UINT nID)
798 return CAppUtils::SetListCtrlBackgroundImage(m_ProgList.GetSafeHwnd(), nID);
801 #if 0
802 void CGitProgressDlg::ReportSVNError()
804 ReportError(GetLastErrorMessage());
806 #endif
808 void CGitProgressDlg::ReportError(const CString& sError)
810 CSoundUtils::PlayTGitError();
811 ReportString(sError, CString(MAKEINTRESOURCE(IDS_ERR_ERROR)), m_Colors.GetColor(CColors::Conflict));
812 m_bErrorsOccurred = true;
815 void CGitProgressDlg::ReportWarning(const CString& sWarning)
817 CSoundUtils::PlayTGitWarning();
818 ReportString(sWarning, CString(MAKEINTRESOURCE(IDS_WARN_WARNING)), m_Colors.GetColor(CColors::Conflict));
821 void CGitProgressDlg::ReportNotification(const CString& sNotification)
823 CSoundUtils::PlayTGitNotification();
824 ReportString(sNotification, CString(MAKEINTRESOURCE(IDS_WARN_NOTE)));
827 void CGitProgressDlg::ReportCmd(const CString& sCmd)
829 ReportString(sCmd, CString(MAKEINTRESOURCE(IDS_PROGRS_CMDINFO)), m_Colors.GetColor(CColors::Cmd));
832 void CGitProgressDlg::ReportString(CString sMessage, const CString& sMsgKind, COLORREF color)
834 // instead of showing a dialog box with the error message or notification,
835 // just insert the error text into the list control.
836 // that way the user isn't 'interrupted' by a dialog box popping up!
838 // the message may be split up into different lines
839 // so add a new entry for each line of the message
840 while (!sMessage.IsEmpty())
842 NotificationData * data = new NotificationData();
843 data->bAuxItem = true;
844 data->sActionColumnText = sMsgKind;
845 if (sMessage.Find('\n')>=0)
846 data->sPathColumnText = sMessage.Left(sMessage.Find('\n'));
847 else
848 data->sPathColumnText = sMessage;
849 data->sPathColumnText.Trim(_T("\n\r"));
850 data->color = color;
851 if (sMessage.Find('\n')>=0)
853 sMessage = sMessage.Mid(sMessage.Find('\n'));
854 sMessage.Trim(_T("\n\r"));
856 else
857 sMessage.Empty();
858 m_arData.push_back(data);
859 AddItemToList();
863 UINT CGitProgressDlg::ProgressThreadEntry(LPVOID pVoid)
865 return ((CGitProgressDlg*)pVoid)->ProgressThread();
868 UINT CGitProgressDlg::ProgressThread()
870 // The SetParams function should have loaded something for us
872 CString temp;
873 CString sWindowTitle;
874 bool localoperation = false;
875 bool bSuccess = false;
876 m_AlwaysConflicted = false;
878 DialogEnableWindow(IDOK, FALSE);
879 DialogEnableWindow(IDCANCEL, TRUE);
880 // SetAndClearProgressInfo(m_hWnd);
881 m_itemCount = m_itemCountTotal;
883 InterlockedExchange(&m_bThreadRunning, TRUE);
884 iFirstResized = 0;
885 bSecondResized = FALSE;
886 m_bFinishedItemAdded = false;
887 CTime startTime = CTime::GetCurrentTime();
888 switch (m_Command)
890 case GitProgress_Add:
891 bSuccess = CmdAdd(sWindowTitle, localoperation);
892 break;
893 case GitProgress_Commit:
894 bSuccess = CmdCommit(sWindowTitle, localoperation);
895 break;
896 case GitProgress_Copy:
897 bSuccess = CmdCopy(sWindowTitle, localoperation);
898 break;
899 case GitProgress_Export:
900 bSuccess = CmdExport(sWindowTitle, localoperation);
901 break;
902 case GitProgress_Merge:
903 bSuccess = CmdMerge(sWindowTitle, localoperation);
904 break;
905 case GitProgress_MergeReintegrate:
906 bSuccess = CmdMergeReintegrate(sWindowTitle, localoperation);
907 break;
908 case GitProgress_Rename:
909 bSuccess = CmdRename(sWindowTitle, localoperation);
910 break;
911 case GitProgress_Resolve:
912 bSuccess = CmdResolve(sWindowTitle, localoperation);
913 break;
914 case GitProgress_Revert:
915 bSuccess = CmdRevert(sWindowTitle, localoperation);
916 break;
917 case GitProgress_Switch:
918 bSuccess = CmdSwitch(sWindowTitle, localoperation);
919 break;
920 case GitProgress_SendMail:
921 bSuccess = CmdSendMail(sWindowTitle, localoperation);
922 break;
924 if (!bSuccess)
925 temp.LoadString(IDS_PROGRS_TITLEFAILED);
926 else
927 temp.LoadString(IDS_PROGRS_TITLEFIN);
928 sWindowTitle = sWindowTitle + _T(" ") + temp;
929 SetWindowText(sWindowTitle);
931 KillTimer(TRANSFERTIMER);
932 KillTimer(VISIBLETIMER);
934 DialogEnableWindow(IDCANCEL, FALSE);
935 DialogEnableWindow(IDOK, TRUE);
937 CString info = BuildInfoString();
938 if (!bSuccess)
939 info.LoadString(IDS_PROGRS_INFOFAILED);
940 SetDlgItemText(IDC_INFOTEXT, info);
941 ResizeColumns();
942 SendMessage(DM_SETDEFID, IDOK);
943 GetDlgItem(IDOK)->SetFocus();
945 CString sFinalInfo;
946 if (!m_sTotalBytesTransferred.IsEmpty())
948 CTimeSpan time = CTime::GetCurrentTime() - startTime;
949 temp.Format(IDS_PROGRS_TIME, (LONG)time.GetTotalMinutes(), (LONG)time.GetSeconds());
950 sFinalInfo.Format(IDS_PROGRS_FINALINFO, m_sTotalBytesTransferred, (LPCTSTR)temp);
951 SetDlgItemText(IDC_PROGRESSLABEL, sFinalInfo);
953 else
954 GetDlgItem(IDC_PROGRESSLABEL)->ShowWindow(SW_HIDE);
956 GetDlgItem(IDC_PROGRESSBAR)->ShowWindow(SW_HIDE);
958 if (!m_bFinishedItemAdded)
960 // there's no "finished: xxx" line at the end. We add one here to make
961 // sure the user sees that the command is actually finished.
962 NotificationData * data = new NotificationData();
963 data->bAuxItem = true;
964 data->sActionColumnText.LoadString(IDS_PROGRS_FINISHED);
965 m_arData.push_back(data);
966 AddItemToList();
969 int count = m_ProgList.GetItemCount();
970 if ((count > 0)&&(m_bLastVisible))
971 m_ProgList.EnsureVisible(count-1, FALSE);
973 CLogFile logfile;
974 if (logfile.Open())
976 logfile.AddTimeLine();
977 for (size_t i=0; i<m_arData.size(); i++)
979 NotificationData * data = m_arData[i];
980 temp.Format(_T("%-20s : %s"), (LPCTSTR)data->sActionColumnText, (LPCTSTR)data->sPathColumnText);
981 logfile.AddLine(temp);
983 if (!sFinalInfo.IsEmpty())
984 logfile.AddLine(sFinalInfo);
985 logfile.Close();
988 m_bCancelled = TRUE;
989 InterlockedExchange(&m_bThreadRunning, FALSE);
990 RefreshCursor();
992 DWORD dwAutoClose = CRegStdDWORD(_T("Software\\TortoiseGit\\AutoClose"));
993 if (m_options & ProgOptDryRun)
994 dwAutoClose = 0; // dry run means progress dialog doesn't auto close at all
995 if (!m_bLastVisible)
996 dwAutoClose = 0;
997 if (m_dwCloseOnEnd != (DWORD)-1)
998 dwAutoClose = m_dwCloseOnEnd; // command line value has priority over setting value
999 if ((dwAutoClose == CLOSE_NOERRORS)&&(!m_bErrorsOccurred))
1000 PostMessage(WM_COMMAND, 1, (LPARAM)GetDlgItem(IDOK)->m_hWnd);
1001 if ((dwAutoClose == CLOSE_NOCONFLICTS)&&(!m_bErrorsOccurred)&&(m_nConflicts==0))
1002 PostMessage(WM_COMMAND, 1, (LPARAM)GetDlgItem(IDOK)->m_hWnd);
1003 if ((dwAutoClose == CLOSE_NOMERGES)&&(!m_bErrorsOccurred)&&(m_nConflicts==0)&&(!m_bMergesAddsDeletesOccurred))
1004 PostMessage(WM_COMMAND, 1, (LPARAM)GetDlgItem(IDOK)->m_hWnd);
1005 if ((dwAutoClose == CLOSE_LOCAL)&&(!m_bErrorsOccurred)&&(m_nConflicts==0)&&(localoperation))
1006 PostMessage(WM_COMMAND, 1, (LPARAM)GetDlgItem(IDOK)->m_hWnd);
1008 //Don't do anything here which might cause messages to be sent to the window
1009 //The window thread is probably now blocked in OnOK if we've done an auto close
1010 return 0;
1013 void CGitProgressDlg::OnBnClickedLogbutton()
1015 switch(this->m_Command)
1017 case GitProgress_Add:
1018 case GitProgress_Resolve:
1020 CString cmd;
1021 cmd = CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe");
1022 cmd += _T(" /command:commit");
1024 cmd += _T(" /path:\"")+g_Git.m_CurrentDir+_T("\"");
1026 CAppUtils::LaunchApplication(cmd,NULL,false);
1027 this->EndDialog(IDOK);
1028 break;
1031 #if 0
1032 if (m_targetPathList.GetCount() != 1)
1033 return;
1034 StringRevMap::iterator it = m_UpdateStartRevMap.begin();
1035 svn_revnum_t rev = -1;
1036 if (it != m_UpdateStartRevMap.end())
1038 rev = it->second;
1040 CLogDlg dlg;
1041 dlg.SetParams(m_targetPathList[0], m_RevisionEnd, m_RevisionEnd, rev, 0, TRUE);
1042 dlg.DoModal();
1043 #endif
1047 void CGitProgressDlg::OnClose()
1049 if (m_bCancelled)
1051 TerminateThread(m_pThread->m_hThread, (DWORD)-1);
1052 InterlockedExchange(&m_bThreadRunning, FALSE);
1054 else
1056 m_bCancelled = TRUE;
1057 return;
1059 DialogEnableWindow(IDCANCEL, TRUE);
1060 __super::OnClose();
1063 void CGitProgressDlg::OnOK()
1065 if ((m_bCancelled)&&(!m_bThreadRunning))
1067 // I have made this wait a sensible amount of time (10 seconds) for the thread to finish
1068 // You must be careful in the thread that after posting the WM_COMMAND/IDOK message, you
1069 // don't do any more operations on the window which might require message passing
1070 // If you try to send windows messages once we're waiting here, then the thread can't finished
1071 // because the Window's message loop is blocked at this wait
1072 WaitForSingleObject(m_pThread->m_hThread, 10000);
1073 __super::OnOK();
1075 m_bCancelled = TRUE;
1078 void CGitProgressDlg::OnCancel()
1080 if ((m_bCancelled)&&(!m_bThreadRunning))
1081 __super::OnCancel();
1082 m_bCancelled = TRUE;
1085 void CGitProgressDlg::OnLvnGetdispinfoSvnprogress(NMHDR *pNMHDR, LRESULT *pResult)
1087 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
1089 if (pDispInfo)
1091 if (pDispInfo->item.mask & LVIF_TEXT)
1093 if (pDispInfo->item.iItem < (int)m_arData.size())
1095 const NotificationData * data = m_arData[pDispInfo->item.iItem];
1096 switch (pDispInfo->item.iSubItem)
1098 case 0:
1099 lstrcpyn(m_columnbuf, data->sActionColumnText, MAX_PATH);
1100 break;
1101 case 1:
1102 lstrcpyn(m_columnbuf, data->sPathColumnText, pDispInfo->item.cchTextMax);
1103 if (!data->bAuxItem)
1105 int cWidth = m_ProgList.GetColumnWidth(1);
1106 cWidth = max(12, cWidth-12);
1107 CDC * pDC = m_ProgList.GetDC();
1108 if (pDC != NULL)
1110 CFont * pFont = pDC->SelectObject(m_ProgList.GetFont());
1111 PathCompactPath(pDC->GetSafeHdc(), m_columnbuf, cWidth);
1112 pDC->SelectObject(pFont);
1113 ReleaseDC(pDC);
1116 break;
1117 case 2:
1118 lstrcpyn(m_columnbuf, data->mime_type, MAX_PATH);
1119 break;
1120 default:
1121 m_columnbuf[0] = 0;
1123 pDispInfo->item.pszText = m_columnbuf;
1127 *pResult = 0;
1130 void CGitProgressDlg::OnNMCustomdrawSvnprogress(NMHDR *pNMHDR, LRESULT *pResult)
1132 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
1134 // Take the default processing unless we set this to something else below.
1135 *pResult = CDRF_DODEFAULT;
1137 // First thing - check the draw stage. If it's the control's prepaint
1138 // stage, then tell Windows we want messages for every item.
1140 if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
1142 *pResult = CDRF_NOTIFYITEMDRAW;
1144 else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
1146 // This is the prepaint stage for an item. Here's where we set the
1147 // item's text color. Our return value will tell Windows to draw the
1148 // item itself, but it will use the new color we set here.
1150 // Tell Windows to paint the control itself.
1151 *pResult = CDRF_DODEFAULT;
1153 ASSERT(pLVCD->nmcd.dwItemSpec < m_arData.size());
1154 if(pLVCD->nmcd.dwItemSpec >= m_arData.size())
1156 return;
1158 const NotificationData * data = m_arData[pLVCD->nmcd.dwItemSpec];
1159 ASSERT(data != NULL);
1160 if (data == NULL)
1161 return;
1163 // Store the color back in the NMLVCUSTOMDRAW struct.
1164 pLVCD->clrText = data->color;
1168 void CGitProgressDlg::OnNMDblclkSvnprogress(NMHDR * /*pNMHDR*/, LRESULT * /*pResult*/)
1170 #if 0
1171 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
1172 *pResult = 0;
1173 if (pNMLV->iItem < 0)
1174 return;
1175 if (m_options & ProgOptDryRun)
1176 return; //don't do anything in a dry-run.
1178 const NotificationData * data = m_arData[pNMLV->iItem];
1179 if (data == NULL)
1180 return;
1182 if (data->bConflictedActionItem)
1184 // We've double-clicked on a conflicted item - do a three-way merge on it
1185 SVNDiff::StartConflictEditor(data->path);
1187 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))
1189 // This is a modified file which has been merged on update. Diff it against base
1190 CTGitPath temporaryFile;
1191 SVNDiff diff(this, this->m_hWnd, true);
1192 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
1193 svn_revnum_t baseRev = 0;
1194 diff.DiffFileAgainstBase(data->path, baseRev);
1196 else if ((!data->bAuxItem)&&(data->path.Exists())&&(!data->path.IsDirectory()))
1198 bool bOpenWith = false;
1199 int ret = (int)ShellExecute(m_hWnd, NULL, data->path.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
1200 if (ret <= HINSTANCE_ERROR)
1201 bOpenWith = true;
1202 if (bOpenWith)
1204 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1205 cmd += data->path.GetWinPathString() + _T(" ");
1206 CAppUtils::LaunchApplication(cmd, NULL, false);
1209 #endif
1212 void CGitProgressDlg::OnHdnItemclickSvnprogress(NMHDR *pNMHDR, LRESULT *pResult)
1214 LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
1215 if (m_bThreadRunning)
1216 return;
1217 if (m_nSortedColumn == phdr->iItem)
1218 m_bAscending = !m_bAscending;
1219 else
1220 m_bAscending = TRUE;
1221 m_nSortedColumn = phdr->iItem;
1222 Sort();
1224 CString temp;
1225 m_ProgList.SetRedraw(FALSE);
1226 m_ProgList.DeleteAllItems();
1227 m_ProgList.SetItemCountEx (static_cast<int>(m_arData.size()));
1229 m_ProgList.SetRedraw(TRUE);
1231 *pResult = 0;
1234 bool CGitProgressDlg::NotificationDataIsAux(const NotificationData* pData)
1236 return pData->bAuxItem;
1239 LRESULT CGitProgressDlg::OnGitProgress(WPARAM /*wParam*/, LPARAM /*lParam*/)
1241 #if 0
1242 SVNProgress * pProgressData = (SVNProgress *)lParam;
1243 CProgressCtrl * progControl = (CProgressCtrl *)GetDlgItem(IDC_PROGRESSBAR);
1244 if ((pProgressData->total > 1000)&&(!progControl->IsWindowVisible()))
1246 progControl->ShowWindow(SW_SHOW);
1248 if (((pProgressData->total < 0)&&(pProgressData->progress > 1000)&&(progControl->IsWindowVisible()))&&(m_itemCountTotal<0))
1250 progControl->ShowWindow(SW_HIDE);
1252 if (!GetDlgItem(IDC_PROGRESSLABEL)->IsWindowVisible())
1253 GetDlgItem(IDC_PROGRESSLABEL)->ShowWindow(SW_SHOW);
1254 SetTimer(TRANSFERTIMER, 2000, NULL);
1255 if ((pProgressData->total > 0)&&(pProgressData->progress > 1000))
1257 progControl->SetPos((int)pProgressData->progress);
1258 progControl->SetRange32(0, (int)pProgressData->total);
1260 CString progText;
1261 if (pProgressData->overall_total < 1024)
1262 m_sTotalBytesTransferred.Format(IDS_SVN_PROGRESS_TOTALBYTESTRANSFERRED, pProgressData->overall_total);
1263 else if (pProgressData->overall_total < 1200000)
1264 m_sTotalBytesTransferred.Format(IDS_SVN_PROGRESS_TOTALTRANSFERRED, pProgressData->overall_total / 1024);
1265 else
1266 m_sTotalBytesTransferred.Format(IDS_SVN_PROGRESS_TOTALMBTRANSFERRED, (double)((double)pProgressData->overall_total / 1024000.0));
1267 progText.Format(IDS_SVN_PROGRESS_TOTALANDSPEED, (LPCTSTR)m_sTotalBytesTransferred, (LPCTSTR)pProgressData->SpeedString);
1268 SetDlgItemText(IDC_PROGRESSLABEL, progText);
1269 #endif
1270 return 0;
1273 void CGitProgressDlg::OnTimer(UINT_PTR nIDEvent)
1275 if (nIDEvent == TRANSFERTIMER)
1277 CString progText;
1278 CString progSpeed;
1279 progSpeed.Format(IDS_SVN_PROGRESS_BYTES_SEC, 0);
1280 progText.Format(IDS_SVN_PROGRESS_TOTALANDSPEED, (LPCTSTR)m_sTotalBytesTransferred, (LPCTSTR)progSpeed);
1281 SetDlgItemText(IDC_PROGRESSLABEL, progText);
1282 KillTimer(TRANSFERTIMER);
1284 if (nIDEvent == VISIBLETIMER)
1286 if (nEnsureVisibleCount)
1287 m_ProgList.EnsureVisible(m_ProgList.GetItemCount()-1, false);
1288 nEnsureVisibleCount = 0;
1292 void CGitProgressDlg::Sort()
1294 if(m_arData.size() < 2)
1296 return;
1299 // We need to sort the blocks which lie between the auxiliary entries
1300 // This is so that any aux data stays where it was
1301 NotificationDataVect::iterator actionBlockBegin;
1302 NotificationDataVect::iterator actionBlockEnd = m_arData.begin(); // We start searching from here
1304 for(;;)
1306 // Search to the start of the non-aux entry in the next block
1307 actionBlockBegin = std::find_if(actionBlockEnd, m_arData.end(), std::not1(std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux)));
1308 if(actionBlockBegin == m_arData.end())
1310 // There are no more actions
1311 break;
1313 // Now search to find the end of the block
1314 actionBlockEnd = std::find_if(actionBlockBegin+1, m_arData.end(), std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux));
1315 // Now sort the block
1316 std::sort(actionBlockBegin, actionBlockEnd, &CGitProgressDlg::SortCompare);
1320 bool CGitProgressDlg::SortCompare(const NotificationData * pData1, const NotificationData * pData2)
1322 int result = 0;
1323 switch (m_nSortedColumn)
1325 case 0: //action column
1326 result = pData1->sActionColumnText.Compare(pData2->sActionColumnText);
1327 break;
1328 case 1: //path column
1329 // Compare happens after switch()
1330 break;
1331 case 2: //mime-type column
1332 result = pData1->mime_type.Compare(pData2->mime_type);
1333 break;
1334 default:
1335 break;
1338 // Sort by path if everything else is equal
1339 if (result == 0)
1341 result = CTGitPath::Compare(pData1->path, pData2->path);
1344 if (!m_bAscending)
1345 result = -result;
1346 return result < 0;
1349 BOOL CGitProgressDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
1351 if (!GetDlgItem(IDOK)->IsWindowEnabled())
1353 // only show the wait cursor over the list control
1354 if ((pWnd)&&(pWnd == GetDlgItem(IDC_SVNPROGRESS)))
1356 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
1357 SetCursor(hCur);
1358 return TRUE;
1361 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
1362 SetCursor(hCur);
1363 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
1366 BOOL CGitProgressDlg::PreTranslateMessage(MSG* pMsg)
1368 if (pMsg->message == WM_KEYDOWN)
1370 if (pMsg->wParam == VK_ESCAPE)
1372 // pressing the ESC key should close the dialog. But since we disabled the escape
1373 // key (so the user doesn't get the idea that he could simply undo an e.g. update)
1374 // this won't work.
1375 // So if the user presses the ESC key, change it to VK_RETURN so the dialog gets
1376 // the impression that the OK button was pressed.
1377 if ((!m_bThreadRunning)&&(!GetDlgItem(IDCANCEL)->IsWindowEnabled())
1378 &&(GetDlgItem(IDOK)->IsWindowEnabled())&&(GetDlgItem(IDOK)->IsWindowVisible()))
1380 // since we convert ESC to RETURN, make sure the OK button has the focus.
1381 GetDlgItem(IDOK)->SetFocus();
1382 pMsg->wParam = VK_RETURN;
1385 if (pMsg->wParam == 'A')
1387 if (GetKeyState(VK_CONTROL)&0x8000)
1389 // Ctrl-A -> select all
1390 m_ProgList.SetSelectionMark(0);
1391 for (int i=0; i<m_ProgList.GetItemCount(); ++i)
1393 m_ProgList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
1397 if ((pMsg->wParam == 'C')||(pMsg->wParam == VK_INSERT))
1399 int selIndex = m_ProgList.GetSelectionMark();
1400 if (selIndex >= 0)
1402 if (GetKeyState(VK_CONTROL)&0x8000)
1404 //Ctrl-C -> copy to clipboard
1405 CString sClipdata;
1406 POSITION pos = m_ProgList.GetFirstSelectedItemPosition();
1407 if (pos != NULL)
1409 while (pos)
1411 int nItem = m_ProgList.GetNextSelectedItem(pos);
1412 CString sAction = m_ProgList.GetItemText(nItem, 0);
1413 CString sPath = m_ProgList.GetItemText(nItem, 1);
1414 CString sMime = m_ProgList.GetItemText(nItem, 2);
1415 CString sLogCopyText;
1416 sLogCopyText.Format(_T("%s: %s %s\r\n"),
1417 (LPCTSTR)sAction, (LPCTSTR)sPath, (LPCTSTR)sMime);
1418 sClipdata += sLogCopyText;
1420 CStringUtils::WriteAsciiStringToClipboard(sClipdata);
1425 } // if (pMsg->message == WM_KEYDOWN)
1426 return __super::PreTranslateMessage(pMsg);
1429 void CGitProgressDlg::OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/)
1431 #if 0
1432 if (m_options & ProgOptDryRun)
1433 return; // don't do anything in a dry-run.
1435 if (pWnd == &m_ProgList)
1437 int selIndex = m_ProgList.GetSelectionMark();
1438 if ((point.x == -1) && (point.y == -1))
1440 // Menu was invoked from the keyboard rather than by right-clicking
1441 CRect rect;
1442 m_ProgList.GetItemRect(selIndex, &rect, LVIR_LABEL);
1443 m_ProgList.ClientToScreen(&rect);
1444 point = rect.CenterPoint();
1447 if ((selIndex >= 0)&&(!m_bThreadRunning))
1449 // entry is selected, thread has finished with updating so show the popup menu
1450 CIconMenu popup;
1451 if (popup.CreatePopupMenu())
1453 bool bAdded = false;
1454 NotificationData * data = m_arData[selIndex];
1455 if ((data)&&(!data->path.IsDirectory()))
1457 if (data->action == svn_wc_notify_update_update || data->action == svn_wc_notify_resolved)
1459 if (m_ProgList.GetSelectedCount() == 1)
1461 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
1462 bAdded = true;
1465 if (data->bConflictedActionItem)
1467 if (m_ProgList.GetSelectedCount() == 1)
1469 popup.AppendMenuIcon(ID_EDITCONFLICT, IDS_MENUCONFLICT,IDI_CONFLICT);
1470 popup.SetDefaultItem(ID_EDITCONFLICT, FALSE);
1471 popup.AppendMenuIcon(ID_CONFLICTRESOLVE, IDS_SVNPROGRESS_MENUMARKASRESOLVED,IDI_RESOLVE);
1473 popup.AppendMenuIcon(ID_CONFLICTUSETHEIRS, IDS_SVNPROGRESS_MENUUSETHEIRS,IDI_RESOLVE);
1474 popup.AppendMenuIcon(ID_CONFLICTUSEMINE, IDS_SVNPROGRESS_MENUUSEMINE,IDI_RESOLVE);
1476 else if ((data->content_state == svn_wc_notify_state_merged)||(GitProgress_Merge == m_Command)||(data->action == svn_wc_notify_resolved))
1477 popup.SetDefaultItem(ID_COMPARE, FALSE);
1479 if (m_ProgList.GetSelectedCount() == 1)
1481 if ((data->action == svn_wc_notify_add)||
1482 (data->action == svn_wc_notify_update_add)||
1483 (data->action == svn_wc_notify_commit_added)||
1484 (data->action == svn_wc_notify_commit_modified)||
1485 (data->action == svn_wc_notify_restore)||
1486 (data->action == svn_wc_notify_revert)||
1487 (data->action == svn_wc_notify_resolved)||
1488 (data->action == svn_wc_notify_commit_replaced)||
1489 (data->action == svn_wc_notify_commit_modified)||
1490 (data->action == svn_wc_notify_commit_postfix_txdelta)||
1491 (data->action == svn_wc_notify_update_update))
1493 popup.AppendMenuIcon(ID_LOG, IDS_MENULOG,IDI_LOG);
1494 if (data->action == svn_wc_notify_update_update)
1495 popup.AppendMenu(MF_SEPARATOR, NULL);
1496 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
1497 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
1498 bAdded = true;
1501 } // if ((data)&&(!data->path.IsDirectory()))
1502 if (m_ProgList.GetSelectedCount() == 1)
1504 if (data)
1506 CString sPath = GetPathFromColumnText(data->sPathColumnText);
1507 if ((!sPath.IsEmpty())&&(!SVN::PathIsURL(CTGitPath(sPath))))
1509 CTGitPath path = CTGitPath(sPath);
1510 if (path.GetDirectory().Exists())
1512 popup.AppendMenuIcon(ID_EXPLORE, IDS_SVNPROGRESS_MENUOPENPARENT, IDI_EXPLORER);
1513 bAdded = true;
1518 if (m_ProgList.GetSelectedCount() > 0)
1520 if (bAdded)
1521 popup.AppendMenu(MF_SEPARATOR, NULL);
1522 popup.AppendMenuIcon(ID_COPY, IDS_LOG_POPUP_COPYTOCLIPBOARD,IDI_COPYCLIP);
1523 bAdded = true;
1525 if (bAdded)
1527 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
1528 DialogEnableWindow(IDOK, FALSE);
1529 this->SetPromptApp(&theApp);
1530 theApp.DoWaitCursor(1);
1531 bool bOpenWith = false;
1532 switch (cmd)
1534 case ID_COPY:
1536 CString sLines;
1537 POSITION pos = m_ProgList.GetFirstSelectedItemPosition();
1538 while (pos)
1540 int nItem = m_ProgList.GetNextSelectedItem(pos);
1541 NotificationData * data = m_arData[nItem];
1542 if (data)
1544 sLines += data->sPathColumnText;
1545 sLines += _T("\r\n");
1548 sLines.TrimRight();
1549 if (!sLines.IsEmpty())
1551 CStringUtils::WriteAsciiStringToClipboard(sLines, GetSafeHwnd());
1554 break;
1555 case ID_EXPLORE:
1557 CString sPath = GetPathFromColumnText(data->sPathColumnText);
1559 CTGitPath path = CTGitPath(sPath);
1560 ShellExecute(m_hWnd, _T("explore"), path.GetDirectory().GetWinPath(), NULL, path.GetDirectory().GetWinPath(), SW_SHOW);
1562 break;
1563 case ID_COMPARE:
1565 svn_revnum_t rev = -1;
1566 StringRevMap::iterator it = m_UpdateStartRevMap.end();
1567 if (data->basepath.IsEmpty())
1568 it = m_UpdateStartRevMap.begin();
1569 else
1570 it = m_UpdateStartRevMap.find(data->basepath.GetSVNApiPath(pool));
1571 if (it != m_UpdateStartRevMap.end())
1572 rev = it->second;
1573 // if the file was merged during update, do a three way diff between OLD, MINE, THEIRS
1574 if (data->content_state == svn_wc_notify_state_merged)
1576 CTGitPath basefile = CTempFiles::Instance().GetTempFilePath(false, data->path, rev);
1577 CTGitPath newfile = CTempFiles::Instance().GetTempFilePath(false, data->path, SVNRev::REV_HEAD);
1578 SVN svn;
1579 if (!svn.Cat(data->path, SVNRev(SVNRev::REV_WC), rev, basefile))
1581 CMessageBox::Show(m_hWnd, svn.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
1582 DialogEnableWindow(IDOK, TRUE);
1583 break;
1585 // If necessary, convert the line-endings on the file before diffing
1586 if ((DWORD)CRegDWORD(_T("Software\\TortoiseGit\\ConvertBase"), TRUE))
1588 CTGitPath temporaryFile = CTempFiles::Instance().GetTempFilePath(false, data->path, SVNRev::REV_BASE);
1589 if (!svn.Cat(data->path, SVNRev(SVNRev::REV_BASE), SVNRev(SVNRev::REV_BASE), temporaryFile))
1591 temporaryFile.Reset();
1592 break;
1594 else
1596 newfile = temporaryFile;
1600 SetFileAttributes(newfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
1601 SetFileAttributes(basefile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
1602 CString revname, wcname, basename;
1603 revname.Format(_T("%s Revision %ld"), (LPCTSTR)data->path.GetUIFileOrDirectoryName(), rev);
1604 wcname.Format(IDS_DIFF_WCNAME, (LPCTSTR)data->path.GetUIFileOrDirectoryName());
1605 basename.Format(IDS_DIFF_BASENAME, (LPCTSTR)data->path.GetUIFileOrDirectoryName());
1606 CAppUtils::StartExtMerge(basefile, newfile, data->path, data->path, basename, revname, wcname, CString(), true);
1608 else
1610 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, data->path, rev);
1611 SVN svn;
1612 if (!svn.Cat(data->path, SVNRev(SVNRev::REV_WC), rev, tempfile))
1614 CMessageBox::Show(m_hWnd, svn.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
1615 DialogEnableWindow(IDOK, TRUE);
1616 break;
1618 else
1620 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
1621 CString revname, wcname;
1622 revname.Format(_T("%s Revision %ld"), (LPCTSTR)data->path.GetUIFileOrDirectoryName(), rev);
1623 wcname.Format(IDS_DIFF_WCNAME, (LPCTSTR)data->path.GetUIFileOrDirectoryName());
1624 CAppUtils::StartExtDiff(
1625 tempfile, data->path, revname, wcname,
1626 CAppUtils::DiffFlags().AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000)));
1630 break;
1631 case ID_EDITCONFLICT:
1633 CString sPath = GetPathFromColumnText(data->sPathColumnText);
1634 SVNDiff::StartConflictEditor(CTGitPath(sPath));
1636 break;
1637 case ID_CONFLICTUSETHEIRS:
1638 case ID_CONFLICTUSEMINE:
1639 case ID_CONFLICTRESOLVE:
1641 svn_wc_conflict_choice_t result = svn_wc_conflict_choose_merged;
1642 switch (cmd)
1644 case ID_CONFLICTUSETHEIRS:
1645 result = svn_wc_conflict_choose_theirs_full;
1646 break;
1647 case ID_CONFLICTUSEMINE:
1648 result = svn_wc_conflict_choose_mine_full;
1649 break;
1650 case ID_CONFLICTRESOLVE:
1651 result = svn_wc_conflict_choose_merged;
1652 break;
1654 SVN svn;
1655 POSITION pos = m_ProgList.GetFirstSelectedItemPosition();
1656 CString sResolvedPaths;
1657 while (pos)
1659 int nItem = m_ProgList.GetNextSelectedItem(pos);
1660 NotificationData * data = m_arData[nItem];
1661 if (data)
1663 if (data->bConflictedActionItem)
1665 if (!svn.Resolve(data->path, result, FALSE))
1667 CMessageBox::Show(m_hWnd, svn.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
1668 DialogEnableWindow(IDOK, TRUE);
1669 break;
1671 else
1673 data->color = ::GetSysColor(COLOR_WINDOWTEXT);
1674 data->action = svn_wc_notify_resolved;
1675 data->sActionColumnText.LoadString(IDS_SVNACTION_RESOLVE);
1676 data->bConflictedActionItem = false;
1677 m_nConflicts--;
1679 if (m_nConflicts==0)
1681 // When the last conflict is resolved we remove
1682 // the warning which we assume is in the last line.
1683 int nIndex = m_ProgList.GetItemCount()-1;
1684 VERIFY(m_ProgList.DeleteItem(nIndex));
1686 delete m_arData[nIndex];
1687 m_arData.pop_back();
1689 sResolvedPaths += data->path.GetWinPathString() + _T("\n");
1694 m_ProgList.Invalidate();
1695 CString info = BuildInfoString();
1696 SetDlgItemText(IDC_INFOTEXT, info);
1698 if (!sResolvedPaths.IsEmpty())
1700 CString msg;
1701 msg.Format(IDS_SVNPROGRESS_RESOLVED, (LPCTSTR)sResolvedPaths);
1702 CMessageBox::Show(m_hWnd, msg, _T("TortoiseGit"), MB_OK | MB_ICONINFORMATION);
1705 break;
1706 case ID_LOG:
1708 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100);
1709 int limit = (int)(DWORD)reg;
1710 svn_revnum_t rev = m_RevisionEnd;
1711 if (!data->basepath.IsEmpty())
1713 StringRevMap::iterator it = m_FinishedRevMap.find(data->basepath.GetSVNApiPath(pool));
1714 if (it != m_FinishedRevMap.end())
1715 rev = it->second;
1717 CLogDlg dlg;
1718 // fetch the log from HEAD, not the revision we updated to:
1719 // the path might be inside an external folder which has its own
1720 // revisions.
1721 CString sPath = GetPathFromColumnText(data->sPathColumnText);
1722 dlg.SetParams(CTGitPath(sPath), SVNRev(), SVNRev::REV_HEAD, 1, limit, TRUE);
1723 dlg.DoModal();
1725 break;
1726 case ID_OPENWITH:
1727 bOpenWith = true;
1728 case ID_OPEN:
1730 int ret = 0;
1731 CString sWinPath = GetPathFromColumnText(data->sPathColumnText);
1732 if (!bOpenWith)
1733 ret = (int)ShellExecute(this->m_hWnd, NULL, (LPCTSTR)sWinPath, NULL, NULL, SW_SHOWNORMAL);
1734 if ((ret <= HINSTANCE_ERROR)||bOpenWith)
1736 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1737 cmd += sWinPath + _T(" ");
1738 CAppUtils::LaunchApplication(cmd, NULL, false);
1742 DialogEnableWindow(IDOK, TRUE);
1743 theApp.DoWaitCursor(-1);
1744 } // if (bAdded)
1748 #endif
1751 void CGitProgressDlg::OnEnSetfocusInfotext()
1753 CString sTemp;
1754 GetDlgItemText(IDC_INFOTEXT, sTemp);
1755 if (sTemp.IsEmpty())
1756 GetDlgItem(IDC_INFOTEXT)->HideCaret();
1759 void CGitProgressDlg::OnLvnBegindragSvnprogress(NMHDR* , LRESULT *pResult)
1761 //LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
1762 #if 0
1763 int selIndex = m_ProgList.GetSelectionMark();
1764 if (selIndex < 0)
1765 return;
1767 CDropFiles dropFiles; // class for creating DROPFILES struct
1769 int index;
1770 POSITION pos = m_ProgList.GetFirstSelectedItemPosition();
1771 while ( (index = m_ProgList.GetNextSelectedItem(pos)) >= 0 )
1773 NotificationData * data = m_arData[index];
1775 if ( data->kind==svn_node_file || data->kind==svn_node_dir )
1777 CString sPath = GetPathFromColumnText(data->sPathColumnText);
1779 dropFiles.AddFile( sPath );
1783 if ( dropFiles.GetCount()>0 )
1785 dropFiles.CreateStructure();
1787 #endif
1788 *pResult = 0;
1791 void CGitProgressDlg::OnSize(UINT nType, int cx, int cy)
1793 CResizableStandAloneDialog::OnSize(nType, cx, cy);
1794 if ((nType == SIZE_RESTORED)&&(m_bLastVisible))
1796 if(!m_ProgList.m_hWnd)
1797 return;
1799 int count = m_ProgList.GetItemCount();
1800 if (count > 0)
1801 m_ProgList.EnsureVisible(count-1, false);
1805 //////////////////////////////////////////////////////////////////////////
1806 /// commands
1807 //////////////////////////////////////////////////////////////////////////
1808 bool CGitProgressDlg::CmdAdd(CString& sWindowTitle, bool& localoperation)
1810 localoperation = true;
1811 sWindowTitle.LoadString(IDS_PROGRS_TITLE_ADD);
1812 CAppUtils::SetWindowTitle(m_hWnd, m_targetPathList.GetCommonRoot().GetUIPathString(), sWindowTitle);
1813 SetBackgroundImage(IDI_ADD_BKG);
1814 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_ADD)));
1816 for(int i=0;i<m_targetPathList.GetCount();i++)
1818 CString cmd,out;
1819 cmd.Format(_T("git.exe add -f -- \"%s\""),m_targetPathList[i].GetGitPathString());
1820 if(g_Git.Run(cmd,&out,CP_ACP))
1822 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
1823 m_bErrorsOccurred=true;
1824 return false;
1826 Notify(m_targetPathList[i],git_wc_notify_add);
1828 #if 0
1829 if (!Add(m_targetPathList, &m_ProjectProperties, svn_depth_empty, FALSE, TRUE, TRUE))
1831 ReportSVNError();
1832 return false;
1834 #endif
1835 //CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);
1836 m_bErrorsOccurred=false;
1838 this->GetDlgItem(IDC_LOGBUTTON)->SetWindowText(_T("Commit ..."));
1839 this->GetDlgItem(IDC_LOGBUTTON)->ShowWindow(SW_SHOW);
1840 return true;
1843 bool CGitProgressDlg::CmdCommit(CString& /*sWindowTitle*/, bool& /*localoperation*/)
1845 #if 0
1846 sWindowTitle.LoadString(IDS_PROGRS_TITLE_COMMIT);
1847 SetWindowText(sWindowTitle); // needs to be updated
1848 SetBackgroundImage(IDI_COMMIT_BKG);
1849 if (m_targetPathList.GetCount()==0)
1851 SetWindowText(sWindowTitle); // needs to be updated, see TSVN rev. 21375
1853 DialogEnableWindow(IDCANCEL, FALSE);
1854 DialogEnableWindow(IDOK, TRUE);
1856 InterlockedExchange(&m_bThreadRunning, FALSE);
1857 return true;
1859 if (m_targetPathList.GetCount()==1)
1861 sWindowTitle = m_targetPathList[0].GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle;
1862 SetWindowText(sWindowTitle); // needs to be updated, see TSVN rev. 21375
1864 BOOL isTag = FALSE;
1865 BOOL bURLFetched = FALSE;
1866 CString url;
1867 for (int i=0; i<m_targetPathList.GetCount(); ++i)
1869 if (bURLFetched == FALSE)
1871 url = GetURLFromPath(m_targetPathList[i]);
1872 if (!url.IsEmpty())
1873 bURLFetched = TRUE;
1874 CString urllower = url;
1875 urllower.MakeLower();
1876 // test if the commit goes to a tag.
1877 // now since Subversion doesn't force users to
1878 // create tags in the recommended /tags/ folder
1879 // only a warning is shown. This won't work if the tags
1880 // are stored in a non-recommended place, but the check
1881 // still helps those who do.
1882 if (urllower.Find(_T("/tags/"))>=0)
1883 isTag = TRUE;
1884 break;
1887 if (isTag)
1889 if (CMessageBox::Show(m_hWnd, IDS_PROGRS_COMMITT_TRUNK, IDS_APPNAME, MB_YESNO | MB_DEFBUTTON2 | MB_ICONEXCLAMATION)==IDNO)
1890 return false;
1892 DWORD exitcode = 0;
1893 CString error;
1894 if (CHooks::Instance().PreCommit(m_selectedPaths, m_depth, m_sMessage, exitcode, error))
1896 if (exitcode)
1898 CString temp;
1899 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
1900 ReportError(temp);
1901 return false;
1905 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_COMMIT)));
1906 CStringArray changelists;
1907 if (!m_changelist.IsEmpty())
1908 changelists.Add(m_changelist);
1909 bool commitSuccessful = true;
1910 if (!Commit(m_targetPathList, m_sMessage, changelists, m_keepchangelist,
1911 m_depth, m_options & ProgOptKeeplocks))
1913 ReportSVNError();
1914 error = GetLastErrorMessage();
1915 // if a non-recursive commit failed with SVN_ERR_UNSUPPORTED_FEATURE,
1916 // that means a folder deletion couldn't be committed.
1917 if ((m_Revision != 0)&&(Err->apr_err == SVN_ERR_UNSUPPORTED_FEATURE))
1919 ReportError(CString(MAKEINTRESOURCE(IDS_PROGRS_NONRECURSIVEHINT)));
1921 commitSuccessful = false;
1922 return false;
1924 if (!PostCommitErr.IsEmpty())
1926 ReportWarning(PostCommitErr);
1928 if (commitSuccessful)
1930 if (m_BugTraqProvider)
1932 CComPtr<IBugTraqProvider2> pProvider = NULL;
1933 HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider);
1934 if (SUCCEEDED(hr))
1936 BSTR commonRoot = SysAllocString(m_targetPathList.GetCommonRoot().GetDirectory().GetWinPath());
1937 SAFEARRAY *pathList = SafeArrayCreateVector(VT_BSTR, 0, m_targetPathList.GetCount());
1939 for (LONG index = 0; index < m_targetPathList.GetCount(); ++index)
1940 SafeArrayPutElement(pathList, &index, m_targetPathList[index].GetSVNPathString().AllocSysString());
1942 BSTR logMessage = m_sMessage.AllocSysString();
1944 BSTR temp = NULL;
1945 if (FAILED(hr = pProvider->OnCommitFinished(GetSafeHwnd(),
1946 commonRoot,
1947 pathList,
1948 logMessage,
1949 (LONG)m_RevisionEnd,
1950 &temp)))
1952 CString sErr = temp;
1953 if (!sErr.IsEmpty())
1954 ReportError(temp);
1957 SysFreeString(temp);
1961 if (CHooks::Instance().PostCommit(m_selectedPaths, m_depth, m_RevisionEnd, m_sMessage, exitcode, error))
1963 if (exitcode)
1965 CString temp;
1966 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
1967 ReportError(temp);
1968 return false;
1971 #endif
1972 return true;
1975 bool CGitProgressDlg::CmdCopy(CString& /*sWindowTitle*/, bool& /*localoperation*/)
1977 #if 0
1978 ASSERT(m_targetPathList.GetCount() == 1);
1979 sWindowTitle.LoadString(IDS_PROGRS_TITLE_COPY);
1980 SetWindowText(sWindowTitle); // needs to be updated, see TSVN rev. 21375
1981 SetBackgroundImage(IDI_COPY_BKG);
1983 CString sCmdInfo;
1984 sCmdInfo.Format(IDS_PROGRS_CMD_COPY,
1985 m_targetPathList[0].IsUrl() ? (LPCTSTR)m_targetPathList[0].GetSVNPathString() : m_targetPathList[0].GetWinPath(),
1986 (LPCTSTR)m_url.GetSVNPathString(), (LPCTSTR)m_Revision.ToString());
1987 ReportCmd(sCmdInfo);
1989 if (!Copy(m_targetPathList, m_url, m_Revision, m_pegRev, m_sMessage))
1991 ReportSVNError();
1992 return false;
1994 if (m_options & ProgOptSwitchAfterCopy)
1996 sCmdInfo.Format(IDS_PROGRS_CMD_SWITCH,
1997 m_targetPathList[0].GetWinPath(),
1998 (LPCTSTR)m_url.GetSVNPathString(), (LPCTSTR)m_Revision.ToString());
1999 ReportCmd(sCmdInfo);
2000 if (!Switch(m_targetPathList[0], m_url, SVNRev::REV_HEAD, SVNRev::REV_HEAD, m_depth, TRUE, m_options & ProgOptIgnoreExternals))
2002 if (!Switch(m_targetPathList[0], m_url, SVNRev::REV_HEAD, m_Revision, m_depth, TRUE, m_options & ProgOptIgnoreExternals))
2004 ReportSVNError();
2005 return false;
2009 else
2011 if (SVN::PathIsURL(m_url))
2013 CString sMsg(MAKEINTRESOURCE(IDS_PROGRS_COPY_WARNING));
2014 ReportNotification(sMsg);
2017 #endif
2018 return true;
2021 bool CGitProgressDlg::CmdExport(CString& /*sWindowTitle*/, bool& /*localoperation*/)
2023 #if 0
2024 ASSERT(m_targetPathList.GetCount() == 1);
2025 sWindowTitle.LoadString(IDS_PROGRS_TITLE_EXPORT);
2026 sWindowTitle = m_url.GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle;
2027 SetWindowText(sWindowTitle); // needs to be updated, see TSVN rev. 21375
2028 SetBackgroundImage(IDI_EXPORT_BKG);
2029 CString eol;
2030 if (m_options & ProgOptEolCRLF)
2031 eol = _T("CRLF");
2032 if (m_options & ProgOptEolLF)
2033 eol = _T("LF");
2034 if (m_options & ProgOptEolCR)
2035 eol = _T("CR");
2036 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_EXPORT)));
2037 if (!Export(m_url, m_targetPathList[0], m_Revision, m_Revision, TRUE, m_options & ProgOptIgnoreExternals, m_depth, NULL, FALSE, eol))
2039 ReportSVNError();
2040 return false;
2042 #endif
2043 return true;
2046 bool CGitProgressDlg::CmdMerge(CString& /*sWindowTitle*/, bool& /*localoperation*/)
2048 #if 0
2049 bool bFailed = false;
2050 ASSERT(m_targetPathList.GetCount() == 1);
2051 sWindowTitle.LoadString(IDS_PROGRS_TITLE_MERGE);
2052 SetBackgroundImage(IDI_MERGE_BKG);
2053 if (m_options & ProgOptDryRun)
2055 sWindowTitle += _T(" ") + sDryRun;
2057 if (m_options & ProgOptRecordOnly)
2059 sWindowTitle += _T(" ") + sRecordOnly;
2061 SetWindowText(sWindowTitle); // needs to be updated, see TSVN rev. 21375
2063 GetDlgItem(IDC_INFOTEXT)->ShowWindow(SW_HIDE);
2064 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_SHOW);
2065 CRegDWORD nonint = CRegDWORD(_T("Software\\TortoiseGit\\MergeNonInteractive"), FALSE);
2066 if (DWORD(nonint))
2068 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_SETCHECK, BST_CHECKED, 0);
2069 m_AlwaysConflicted = true;
2071 // we only accept a revision list to merge for peg merges
2072 ATLASSERT((m_revisionArray.GetCount()==0) || (m_revisionArray.GetCount() && (m_url.IsEquivalentTo(m_url2))));
2074 if (m_url.IsEquivalentTo(m_url2))
2076 CString sSuggestedMessage;
2077 CString sMergedLogMessage;
2078 CString sSeparator = CRegString(_T("Software\\TortoiseGit\\MergeLogSeparator"), _T("........"));
2079 CString temp;
2081 // Merging revisions %s of %s to %s into %s, %s%s
2082 CString sCmdInfo;
2083 sCmdInfo.Format(IDS_PROGRS_CMD_MERGEPEG,
2084 (LPCTSTR)m_revisionArray.ToListString(),
2085 (LPCTSTR)m_url.GetSVNPathString(),
2086 m_targetPathList[0].GetWinPath(),
2087 m_options & ProgOptIgnoreAncestry ? (LPCTSTR)sIgnoreAncestry : (LPCTSTR)sRespectAncestry,
2088 m_options & ProgOptDryRun ? ((LPCTSTR)_T(", ") + sDryRun) : _T(""));
2089 ReportCmd(sCmdInfo);
2091 if (!PegMerge(m_url, m_revisionArray,
2092 m_pegRev.IsValid() ? m_pegRev : (m_url.IsUrl() ? SVNRev::REV_HEAD : SVNRev(SVNRev::REV_WC)),
2093 m_targetPathList[0], true, m_depth, m_diffoptions, !!(m_options & ProgOptIgnoreAncestry), !!(m_options & ProgOptDryRun), !!(m_options & ProgOptRecordOnly)))
2095 // if the merge fails with the peg revision set,
2096 // try again with HEAD as the peg revision.
2097 if (!PegMerge(m_url, m_revisionArray, SVNRev::REV_HEAD,
2098 m_targetPathList[0], true, m_depth, m_diffoptions, !!(m_options & ProgOptIgnoreAncestry), !!(m_options & ProgOptDryRun), !!(m_options & ProgOptRecordOnly)))
2100 ReportSVNError();
2101 bFailed = true;
2105 else
2107 CString sCmdInfo;
2108 sCmdInfo.Format(IDS_PROGRS_CMD_MERGEURL,
2109 (LPCTSTR)m_url.GetSVNPathString(), (LPCTSTR)m_Revision.ToString(),
2110 (LPCTSTR)m_url2.GetSVNPathString(), (LPCTSTR)m_RevisionEnd.ToString(),
2111 m_targetPathList[0].GetWinPath(),
2112 m_options & ProgOptIgnoreAncestry ? (LPCTSTR)sIgnoreAncestry : (LPCTSTR)sRespectAncestry,
2113 m_options & ProgOptDryRun ? ((LPCTSTR)_T(", ") + sDryRun) : _T(""));
2114 ReportCmd(sCmdInfo);
2116 if (!Merge(m_url, m_Revision, m_url2, m_RevisionEnd, m_targetPathList[0],
2117 true, m_depth, m_diffoptions, !!(m_options & ProgOptIgnoreAncestry), !!(m_options & ProgOptDryRun), !!(m_options & ProgOptRecordOnly)))
2119 ReportSVNError();
2120 bFailed = true;
2123 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);
2124 GetDlgItem(IDC_INFOTEXT)->ShowWindow(SW_SHOW);
2125 return !bFailed;
2126 #endif
2127 return true;
2130 bool CGitProgressDlg::CmdMergeReintegrate(CString& /*sWindowTitle*/, bool& /*localoperation*/)
2132 #if 0
2133 ASSERT(m_targetPathList.GetCount() == 1);
2134 sWindowTitle.LoadString(IDS_PROGRS_TITLE_MERGEREINTEGRATE);
2135 SetBackgroundImage(IDI_MERGE_BKG);
2136 SetWindowText(sWindowTitle); // needs to be updated, see TSVN rev. 21375
2138 CString sCmdInfo;
2139 sCmdInfo.Format(IDS_PROGRS_CMD_MERGEREINTEGRATE,
2140 (LPCTSTR)m_url.GetSVNPathString(),
2141 m_targetPathList[0].GetWinPath());
2142 ReportCmd(sCmdInfo);
2144 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_SHOW);
2145 CRegDWORD nonint = CRegDWORD(_T("Software\\TortoiseGit\\MergeNonInteractive"), FALSE);
2146 if (DWORD(nonint))
2148 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_SETCHECK, BST_CHECKED, 0);
2149 m_AlwaysConflicted = true;
2152 if (!MergeReintegrate(m_url, SVNRev::REV_HEAD, m_targetPathList[0], !!(m_options & ProgOptDryRun), m_diffoptions))
2154 ReportSVNError();
2155 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);
2156 return false;
2159 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);
2160 #endif
2161 return true;
2164 bool CGitProgressDlg::CmdRename(CString& /*sWindowTitle*/, bool& /*localoperation*/)
2166 #if 0
2167 ASSERT(m_targetPathList.GetCount() == 1);
2168 if ((!m_targetPathList[0].IsUrl())&&(!m_url.IsUrl()))
2169 localoperation = true;
2170 sWindowTitle.LoadString(IDS_PROGRS_TITLE_RENAME);
2171 SetWindowText(sWindowTitle); // needs to be updated, see TSVN rev. 21375
2172 SetBackgroundImage(IDI_RENAME_BKG);
2173 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RENAME)));
2174 if (!Move(m_targetPathList, m_url, m_Revision, m_sMessage))
2176 ReportSVNError();
2177 return false;
2179 #endif
2180 return true;
2183 bool CGitProgressDlg::CmdResolve(CString& sWindowTitle, bool& localoperation)
2186 localoperation = true;
2187 ASSERT(m_targetPathList.GetCount() == 1);
2188 sWindowTitle.LoadString(IDS_PROGRS_TITLE_RESOLVE);
2189 CAppUtils::SetWindowTitle(m_hWnd, m_targetPathList.GetCommonRoot().GetUIPathString(), sWindowTitle);
2190 SetBackgroundImage(IDI_RESOLVE_BKG);
2191 // check if the file may still have conflict markers in it.
2192 //BOOL bMarkers = FALSE;
2194 for(int i=0;i<m_targetPathList.GetCount();i++)
2196 CString cmd,out,tempmergefile;
2197 cmd.Format(_T("git.exe add -f -- \"%s\""),m_targetPathList[i].GetGitPathString());
2198 if(g_Git.Run(cmd,&out,CP_ACP))
2200 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
2201 m_bErrorsOccurred=true;
2202 return false;
2205 CAppUtils::RemoveTempMergeFile((CTGitPath &)m_targetPathList[i]);
2207 Notify(m_targetPathList[i],git_wc_notify_resolved);
2209 #if 0
2210 if ((m_options & ProgOptSkipConflictCheck) == 0)
2214 for (INT_PTR fileindex=0; (fileindex<m_targetPathList.GetCount()) && (bMarkers==FALSE); ++fileindex)
2216 if (!m_targetPathList[fileindex].IsDirectory())
2218 CStdioFile file(m_targetPathList[fileindex].GetWinPath(), CFile::typeBinary | CFile::modeRead);
2219 CString strLine = _T("");
2220 while (file.ReadString(strLine))
2222 if (strLine.Find(_T("<<<<<<<"))==0)
2224 bMarkers = TRUE;
2225 break;
2228 file.Close();
2232 catch (CFileException* pE)
2234 TRACE(_T("CFileException in Resolve!\n"));
2235 TCHAR error[10000] = {0};
2236 pE->GetErrorMessage(error, 10000);
2237 ReportError(error);
2238 pE->Delete();
2239 return false;
2242 if (bMarkers)
2244 if (CMessageBox::Show(m_hWnd, IDS_PROGRS_REVERTMARKERS, IDS_APPNAME, MB_YESNO | MB_ICONQUESTION)==IDYES)
2246 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE)));
2247 for (INT_PTR fileindex=0; fileindex<m_targetPathList.GetCount(); ++fileindex)
2248 Resolve(m_targetPathList[fileindex], svn_wc_conflict_choose_merged, true);
2251 else
2253 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE)));
2254 for (INT_PTR fileindex=0; fileindex<m_targetPathList.GetCount(); ++fileindex)
2255 Resolve(m_targetPathList[fileindex], svn_wc_conflict_choose_merged, true);
2257 #endif
2258 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);
2260 this->GetDlgItem(IDC_LOGBUTTON)->SetWindowText(_T("Commit ..."));
2261 this->GetDlgItem(IDC_LOGBUTTON)->ShowWindow(SW_SHOW);
2263 return true;
2266 bool CGitProgressDlg::CmdRevert(CString& sWindowTitle, bool& localoperation)
2269 localoperation = true;
2270 sWindowTitle.LoadString(IDS_PROGRS_TITLE_REVERT);
2271 CAppUtils::SetWindowTitle(m_hWnd, m_targetPathList.GetCommonRoot().GetUIPathString(), sWindowTitle);
2272 SetBackgroundImage(IDI_REVERT_BKG);
2274 CTGitPathList delList;
2275 for(int i=0;i<m_selectedPaths.GetCount();i++)
2277 CTGitPath path;
2278 int action;
2279 path.SetFromWin(g_Git.m_CurrentDir+_T("\\")+m_selectedPaths[i].GetWinPath());
2280 action = m_selectedPaths[i].m_Action;
2281 /* rename file can't delete because it needs original file*/
2282 if((!(action & CTGitPath::LOGACTIONS_ADDED)) &&
2283 (!(action & CTGitPath::LOGACTIONS_REPLACED)))
2284 delList.AddPath(path);
2286 if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RevertWithRecycleBin"), TRUE)))
2287 delList.DeleteAllFiles(true);
2289 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_REVERT)));
2290 for(int i=0;i<m_selectedPaths.GetCount();i++)
2292 if(g_Git.Revert(_T("HEAD"), (CTGitPath&)m_selectedPaths[i]))
2294 CMessageBox::Show(NULL,_T("Revert Fail"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);
2295 m_bErrorsOccurred=true;
2296 return false;
2298 Notify(m_selectedPaths[i],git_wc_notify_revert);
2301 CShellUpdater::Instance().AddPathsForUpdate(m_selectedPaths);
2303 return true;
2306 bool CGitProgressDlg::CmdSwitch(CString& /*sWindowTitle*/, bool& /*localoperation*/)
2308 #if 0
2309 ASSERT(m_targetPathList.GetCount() == 1);
2310 SVNStatus st;
2311 sWindowTitle.LoadString(IDS_PROGRS_TITLE_SWITCH);
2312 SetWindowText(sWindowTitle); // needs to be updated, see TSVN rev. 21375
2313 SetBackgroundImage(IDI_SWITCH_BKG);
2314 LONG rev = 0;
2315 if (st.GetStatus(m_targetPathList[0]) != (-2))
2317 if (st.status->entry != NULL)
2319 rev = st.status->entry->revision;
2323 CString sCmdInfo;
2324 sCmdInfo.Format(IDS_PROGRS_CMD_SWITCH,
2325 m_targetPathList[0].GetWinPath(), (LPCTSTR)m_url.GetSVNPathString(),
2326 (LPCTSTR)m_Revision.ToString());
2327 ReportCmd(sCmdInfo);
2329 bool depthIsSticky = true;
2330 if (m_depth == svn_depth_unknown)
2331 depthIsSticky = false;
2332 if (!Switch(m_targetPathList[0], m_url, m_Revision, m_Revision, m_depth, depthIsSticky, m_options & ProgOptIgnoreExternals))
2334 ReportSVNError();
2335 return false;
2337 m_UpdateStartRevMap[m_targetPathList[0].GetSVNApiPath(pool)] = rev;
2338 if ((m_RevisionEnd >= 0)&&(rev >= 0)
2339 &&((LONG)m_RevisionEnd > (LONG)rev))
2341 GetDlgItem(IDC_LOGBUTTON)->ShowWindow(SW_SHOW);
2343 #endif
2344 return true;
2347 void CGitProgressDlg::OnBnClickedNoninteractive()
2349 LRESULT res = ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_GETCHECK, 0, 0);
2350 m_AlwaysConflicted = (res == BST_CHECKED);
2351 CRegDWORD nonint = CRegDWORD(_T("Software\\TortoiseGit\\MergeNonInteractive"), FALSE);
2352 nonint = m_AlwaysConflicted;
2355 CString CGitProgressDlg::GetPathFromColumnText(const CString& sColumnText)
2357 CString sPath = CPathUtils::ParsePathInString(sColumnText);
2358 if (sPath.Find(':')<0)
2360 // the path is not absolute: add the common root of all paths to it
2361 sPath = m_targetPathList.GetCommonRoot().GetDirectory().GetWinPathString() + _T("\\") + CPathUtils::ParsePathInString(sColumnText);
2363 return sPath;
2366 bool CGitProgressDlg::CmdSendMail(CString& sWindowTitle, bool& /*localoperation*/)
2368 sWindowTitle.LoadString(IDS_PROGRS_TITLE_SENDMAIL);
2369 CAppUtils::SetWindowTitle(m_hWnd, m_targetPathList.GetCommonRoot().GetUIPathString(), sWindowTitle);
2370 //SetBackgroundImage(IDI_ADD_BKG);
2371 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_SENDMAIL)));
2372 bool ret=true;
2373 if(this->m_SendMailFlags&SENDMAIL_COMBINED)
2375 CString error;
2376 CTGitPath path;
2377 Notify(path,git_wc_notify_sendmail_start);
2378 CString err;
2379 int retry=0;
2380 while(retry <3)
2382 if(!!CPatch::SendPatchesCombined(m_targetPathList,m_SendMailTO,m_SendMailCC,m_SendMailSubject,!!(this->m_SendMailFlags&SENDMAIL_ATTACHMENT),!!(this->m_SendMailFlags&SENDMAIL_MAPI),&err))
2384 Notify(path,git_wc_notify_sendmail_error,ret,&err);
2385 ret = false;
2387 else
2389 break;
2392 retry++;
2393 if (retry < 3)
2394 Notify(path,git_wc_notify_sendmail_retry,ret,&err);
2395 Sleep(2000);
2396 if(m_bCancelled)
2398 CString str(_T("User Canceled"));
2399 Notify(path,git_wc_notify_sendmail_error,ret,&str);
2400 return false;
2403 if (ret)
2404 Notify(path,git_wc_notify_sendmail_done,ret);
2406 else
2408 for(int i=0;ret && i<m_targetPathList.GetCount();i++)
2410 CPatch patch;
2411 Notify(m_targetPathList[i],git_wc_notify_sendmail_start);
2413 int retry=0;
2414 while(retry<3)
2416 if(!!patch.Send((CString&)m_targetPathList[i].GetWinPathString(),this->m_SendMailTO,
2417 this->m_SendMailCC,!!(this->m_SendMailFlags&SENDMAIL_ATTACHMENT),!!(this->m_SendMailFlags&SENDMAIL_MAPI)))
2419 Notify(m_targetPathList[i],git_wc_notify_sendmail_error,ret,&patch.m_LastError);
2420 ret = false;
2423 else
2425 ret = true;
2426 break;
2428 retry++;
2429 if (retry < 3)
2430 Notify(m_targetPathList[i],git_wc_notify_sendmail_retry,ret,&patch.m_LastError);
2431 Sleep(2000);
2432 if(m_bCancelled)
2434 CString str(_T("User Canceled"));
2435 Notify(m_targetPathList[i],git_wc_notify_sendmail_error,ret,&str);
2436 return false;
2439 if (ret)
2440 Notify(m_targetPathList[i],git_wc_notify_sendmail_done,ret);
2443 return ret;