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.
21 #include "TortoiseProc.h"
22 #include "messagebox.h"
23 #include "SVNProgressDlg.h"
27 #include "GitStatus.h"
29 #include "PathUtils.h"
30 #include "StringUtils.h"
32 #include "UnicodeUtils.h"
33 #include "SoundUtils.h"
36 #include "DropFiles.h"
37 //#include "GitLogHelper.h"
38 #include "RegHistory.h"
39 //#include "ConflictResolveDlg.h"
41 #include "ShellUpdater.h"
43 #include "BugTraqAssociations.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
69 IMPLEMENT_DYNAMIC(CGitProgressDlg
, CResizableStandAloneDialog
)
70 CGitProgressDlg::CGitProgressDlg(CWnd
* pParent
/*=NULL*/)
71 : CResizableStandAloneDialog(CGitProgressDlg::IDD
, pParent
)
75 , m_Revision(_T("HEAD"))
77 , m_bLockWarning(false)
78 , m_bLockExists(false)
79 , m_bThreadRunning(FALSE
)
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)
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
))
104 CGitProgressDlg::~CGitProgressDlg()
106 for (size_t i
=0; i
<m_arData
.size(); i
++)
110 if(m_pThread
!= NULL
)
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
)
126 ON_NOTIFY(NM_DBLCLK
, IDC_SVNPROGRESS
, OnNMDblclkSvnprogress
)
127 ON_NOTIFY(HDN_ITEMCLICK
, 0, OnHdnItemclickSvnprogress
)
130 ON_REGISTERED_MESSAGE(WM_GITPROGRESS
, OnGitProgress
)
132 ON_EN_SETFOCUS(IDC_INFOTEXT
, &CGitProgressDlg::OnEnSetfocusInfotext
)
133 ON_NOTIFY(LVN_BEGINDRAG
, IDC_SVNPROGRESS
, &CGitProgressDlg::OnLvnBegindragSvnprogress
)
135 ON_NOTIFY(LVN_GETDISPINFO
, IDC_SVNPROGRESS
, &CGitProgressDlg::OnLvnGetdispinfoSvnprogress
)
136 ON_BN_CLICKED(IDC_NONINTERACTIVE
, &CGitProgressDlg::OnBnClickedNoninteractive
)
137 ON_MESSAGE(WM_SHOWCONFLICTRESOLVER
, OnShowConflictResolver
)
140 BOOL
CGitProgressDlg::Cancel()
145 LRESULT
CGitProgressDlg::OnShowConflictResolver(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
148 CConflictResolveDlg
dlg(this);
149 const svn_wc_conflict_description_t
*description
= (svn_wc_conflict_description_t
*)lParam
;
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
;
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
;
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.
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;
215 nEnsureVisibleCount
= 0;
217 m_bLastVisible
= false;
222 BOOL
CGitProgressDlg::Notify(const CTGitPath
& path
, git_wc_notify_action_t action
,
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();
239 data
->action
= action
;
240 data
->sPathColumnText
=path
.GetGitPathString();
241 data
->bAuxItem
= false;
244 data
->mime_type
= mime_type
;
245 data
->content_state
= content_state
;
246 data
->prop_state
= prop_state
;
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
;
256 data
->merge_range
= *range
;
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))
264 // data->color = m_Colors.GetColor(CColors::Conflict);
265 // data->bConflictedActionItem = true;
266 // data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);
271 // m_bMergesAddsDeletesOccurred = true;
272 data
->sActionColumnText
.LoadString(IDS_SVNACTION_ADD
);
273 data
->color
= m_Colors
.GetColor(CColors::Added
);
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
);
282 case git_wc_notify_sendmail_error
:
283 data
->bAuxItem
= true;
284 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_ERROR
);
286 data
->sPathColumnText
= *strErr
;
288 data
->sPathColumnText
.Empty();
289 data
->color
= m_Colors
.GetColor(CColors::Modified
);
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
);
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
);
306 case git_wc_notify_resolved
:
307 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESOLVE
);
310 case git_wc_notify_revert
:
311 data
->sActionColumnText
.LoadString(IDS_SVNACTION_REVERT
);
315 case svn_wc_notify_commit_added
:
316 data
->sActionColumnText
.LoadString(IDS_SVNACTION_ADDING
);
317 data
->color
= m_Colors
.GetColor(CColors::Added
);
319 case svn_wc_notify_copy
:
320 data
->sActionColumnText
.LoadString(IDS_SVNACTION_COPY
);
322 case svn_wc_notify_commit_modified
:
323 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MODIFIED
);
324 data
->color
= m_Colors
.GetColor(CColors::Modified
);
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
);
332 case svn_wc_notify_commit_deleted
:
333 data
->sActionColumnText
.LoadString(IDS_SVNACTION_DELETING
);
334 data
->color
= m_Colors
.GetColor(CColors::Deleted
);
336 case svn_wc_notify_restore
:
337 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESTORE
);
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
);
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;
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
);
360 data
->sActionColumnText
.LoadString(IDS_SVNACTION_EXISTS
);
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
)))
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;
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
);
397 if (lock_state
== svn_wc_notify_lock_state_unlocked
)
399 CString
temp(MAKEINTRESOURCE(IDS_SVNACTION_UNLOCKED
));
400 data
->sActionColumnText
+= _T(", ") + temp
;
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;
411 case svn_wc_notify_update_completed
:
413 data
->sActionColumnText
.LoadString(IDS_SVNACTION_COMPLETED
);
414 data
->bAuxItem
= true;
415 bool bEmpty
= !!m_ExtStack
.IsEmpty();
417 data
->sPathColumnText
.Format(IDS_PROGRS_PATHATREV
, (LPCTSTR
)m_ExtStack
.RemoveHead(), rev
);
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
);
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
;
439 m_bFinishedItemAdded
= true;
442 case svn_wc_notify_commit_postfix_txdelta
:
443 data
->sActionColumnText
.LoadString(IDS_SVNACTION_POSTFIX
);
445 case svn_wc_notify_failed_revert
:
446 data
->sActionColumnText
.LoadString(IDS_SVNACTION_FAILEDREVERT
);
448 case svn_wc_notify_status_completed
:
449 case svn_wc_notify_status_external
:
450 data
->sActionColumnText
.LoadString(IDS_SVNACTION_STATUS
);
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
);
463 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SKIP
);
465 case svn_wc_notify_locked
:
466 if ((lock
)&&(lock
->owner
))
467 data
->sActionColumnText
.Format(IDS_SVNACTION_LOCKEDBY
, (LPCTSTR
)CUnicodeUtils::GetUnicode(lock
->owner
));
469 case svn_wc_notify_unlocked
:
470 data
->sActionColumnText
.LoadString(IDS_SVNACTION_UNLOCKED
);
472 case svn_wc_notify_failed_lock
:
473 data
->sActionColumnText
.LoadString(IDS_SVNACTION_FAILEDLOCK
);
474 m_arData
.push_back(data
);
476 ReportError(SVN::GetErrorString(err
));
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;
483 case svn_wc_notify_failed_unlock
:
484 data
->sActionColumnText
.LoadString(IDS_SVNACTION_FAILEDUNLOCK
);
485 m_arData
.push_back(data
);
487 ReportError(SVN::GetErrorString(err
));
489 if (err
->apr_err
== SVN_ERR_FS_OUT_OF_DATE
)
490 m_bLockWarning
= true;
492 case svn_wc_notify_changelist_set
:
493 data
->sActionColumnText
.Format(IDS_SVNACTION_CHANGELISTSET
, (LPCTSTR
)data
->changelistname
);
495 case svn_wc_notify_changelist_clear
:
496 data
->sActionColumnText
.LoadString(IDS_SVNACTION_CHANGELISTCLEAR
);
498 case svn_wc_notify_changelist_moved
:
499 data
->sActionColumnText
.Format(IDS_SVNACTION_CHANGELISTMOVED
, (LPCTSTR
)data
->changelistname
);
501 case svn_wc_notify_foreign_merge_begin
:
502 case svn_wc_notify_merge_begin
:
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
);
512 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINMULTIPLEREVERSE
, data
->merge_range
.start
, data
->merge_range
.end
+ 1);
513 data
->bAuxItem
= true;
518 } // switch (data->action)
526 m_arData
.push_back(data
);
528 if ((!data
->bAuxItem
) && (m_itemCount
> 0))
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))
541 // bSecondResized = TRUE;
549 CString
CGitProgressDlg::BuildInfoString()
552 if(this->m_Command
== GitProgress_Resolve
)
553 infotext
= _T("You need commit your change after resolve conflict");
570 for (size_t i
=0; i
<m_arData
.size(); ++i
)
572 const NotificationData
* dat
= m_arData
[i
];
575 case svn_wc_notify_add
:
576 case svn_wc_notify_update_add
:
577 case svn_wc_notify_commit_added
:
578 if (dat
->bConflictedActionItem
)
583 case svn_wc_notify_copy
:
586 case svn_wc_notify_delete
:
587 case svn_wc_notify_update_delete
:
588 case svn_wc_notify_commit_deleted
:
591 case svn_wc_notify_restore
:
594 case svn_wc_notify_revert
:
597 case svn_wc_notify_resolved
:
600 case svn_wc_notify_update_update
:
601 if (dat
->bConflictedActionItem
)
603 else if ((dat
->content_state
== svn_wc_notify_state_merged
) || (dat
->prop_state
== svn_wc_notify_state_merged
))
608 case svn_wc_notify_commit_modified
:
611 case svn_wc_notify_skip
:
614 case svn_wc_notify_commit_replaced
:
621 temp
.LoadString(IDS_SVNACTION_CONFLICTED
);
623 temp
.Format(_T(":%d "), conflicted
);
628 temp
.LoadString(IDS_SVNACTION_SKIP
);
630 infotext
.AppendFormat(_T(":%d "), skipped
);
634 temp
.LoadString(IDS_SVNACTION_MERGED
);
636 infotext
.AppendFormat(_T(":%d "), merged
);
640 temp
.LoadString(IDS_SVNACTION_ADD
);
642 infotext
.AppendFormat(_T(":%d "), added
);
646 temp
.LoadString(IDS_SVNACTION_DELETE
);
648 infotext
.AppendFormat(_T(":%d "), deleted
);
652 temp
.LoadString(IDS_SVNACTION_MODIFIED
);
654 infotext
.AppendFormat(_T(":%d "), modified
);
658 temp
.LoadString(IDS_SVNACTION_COPY
);
660 infotext
.AppendFormat(_T(":%d "), copied
);
664 temp
.LoadString(IDS_SVNACTION_REPLACED
);
666 infotext
.AppendFormat(_T(":%d "), replaced
);
670 temp
.LoadString(IDS_SVNACTION_UPDATE
);
672 infotext
.AppendFormat(_T(":%d "), updated
);
676 temp
.LoadString(IDS_SVNACTION_RESTORE
);
678 infotext
.AppendFormat(_T(":%d "), restored
);
682 temp
.LoadString(IDS_SVNACTION_REVERT
);
684 infotext
.AppendFormat(_T(":%d "), reverted
);
688 temp
.LoadString(IDS_SVNACTION_RESOLVE
);
690 infotext
.AppendFormat(_T(":%d "), resolved
);
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();
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
726 linewidth
= m_ProgList
.GetStringWidth(m_arData
[index
]->sActionColumnText
) + 12;
729 linewidth
= m_ProgList
.GetStringWidth(m_arData
[index
]->sPathColumnText
) + 12;
732 linewidth
= m_ProgList
.GetStringWidth(m_arData
[index
]->mime_type
) + 12;
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;
753 m_ProgList
.DeleteColumn(c
--);
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
);
765 ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED
)));
769 m_pThread
->m_bAutoDelete
= FALSE
;
770 m_pThread
->ResumeThread();
775 // Call this early so that the column headings aren't hidden before any
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);
791 CenterWindow(CWnd::FromHandle(hWndExplorer
));
792 EnableSaveRestore(_T("SVNProgressDlg"));
796 bool CGitProgressDlg::SetBackgroundImage(UINT nID
)
798 return CAppUtils::SetListCtrlBackgroundImage(m_ProgList
.GetSafeHwnd(), nID
);
802 void CGitProgressDlg::ReportSVNError()
804 ReportError(GetLastErrorMessage());
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'));
848 data
->sPathColumnText
= sMessage
;
849 data
->sPathColumnText
.Trim(_T("\n\r"));
851 if (sMessage
.Find('\n')>=0)
853 sMessage
= sMessage
.Mid(sMessage
.Find('\n'));
854 sMessage
.Trim(_T("\n\r"));
858 m_arData
.push_back(data
);
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
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
);
885 bSecondResized
= FALSE
;
886 m_bFinishedItemAdded
= false;
887 CTime startTime
= CTime::GetCurrentTime();
890 case GitProgress_Add
:
891 bSuccess
= CmdAdd(sWindowTitle
, localoperation
);
893 case GitProgress_Copy
:
894 bSuccess
= CmdCopy(sWindowTitle
, localoperation
);
896 case GitProgress_Export
:
897 bSuccess
= CmdExport(sWindowTitle
, localoperation
);
899 case GitProgress_Rename
:
900 bSuccess
= CmdRename(sWindowTitle
, localoperation
);
902 case GitProgress_Resolve
:
903 bSuccess
= CmdResolve(sWindowTitle
, localoperation
);
905 case GitProgress_Revert
:
906 bSuccess
= CmdRevert(sWindowTitle
, localoperation
);
908 case GitProgress_Switch
:
909 bSuccess
= CmdSwitch(sWindowTitle
, localoperation
);
911 case GitProgress_SendMail
:
912 bSuccess
= CmdSendMail(sWindowTitle
, localoperation
);
916 temp
.LoadString(IDS_PROGRS_TITLEFAILED
);
918 temp
.LoadString(IDS_PROGRS_TITLEFIN
);
919 sWindowTitle
= sWindowTitle
+ _T(" ") + temp
;
920 SetWindowText(sWindowTitle
);
922 KillTimer(TRANSFERTIMER
);
923 KillTimer(VISIBLETIMER
);
925 DialogEnableWindow(IDCANCEL
, FALSE
);
926 DialogEnableWindow(IDOK
, TRUE
);
928 CString info
= BuildInfoString();
930 info
.LoadString(IDS_PROGRS_INFOFAILED
);
931 SetDlgItemText(IDC_INFOTEXT
, info
);
933 SendMessage(DM_SETDEFID
, IDOK
);
934 GetDlgItem(IDOK
)->SetFocus();
937 if (!m_sTotalBytesTransferred
.IsEmpty())
939 CTimeSpan time
= CTime::GetCurrentTime() - startTime
;
940 temp
.Format(IDS_PROGRS_TIME
, (LONG
)time
.GetTotalMinutes(), (LONG
)time
.GetSeconds());
941 sFinalInfo
.Format(IDS_PROGRS_FINALINFO
, m_sTotalBytesTransferred
, (LPCTSTR
)temp
);
942 SetDlgItemText(IDC_PROGRESSLABEL
, sFinalInfo
);
945 GetDlgItem(IDC_PROGRESSLABEL
)->ShowWindow(SW_HIDE
);
947 GetDlgItem(IDC_PROGRESSBAR
)->ShowWindow(SW_HIDE
);
949 if (!m_bFinishedItemAdded
)
951 // there's no "finished: xxx" line at the end. We add one here to make
952 // sure the user sees that the command is actually finished.
953 NotificationData
* data
= new NotificationData();
954 data
->bAuxItem
= true;
955 data
->sActionColumnText
.LoadString(IDS_PROGRS_FINISHED
);
956 m_arData
.push_back(data
);
960 int count
= m_ProgList
.GetItemCount();
961 if ((count
> 0)&&(m_bLastVisible
))
962 m_ProgList
.EnsureVisible(count
-1, FALSE
);
967 logfile
.AddTimeLine();
968 for (size_t i
=0; i
<m_arData
.size(); i
++)
970 NotificationData
* data
= m_arData
[i
];
971 temp
.Format(_T("%-20s : %s"), (LPCTSTR
)data
->sActionColumnText
, (LPCTSTR
)data
->sPathColumnText
);
972 logfile
.AddLine(temp
);
974 if (!sFinalInfo
.IsEmpty())
975 logfile
.AddLine(sFinalInfo
);
980 InterlockedExchange(&m_bThreadRunning
, FALSE
);
983 DWORD dwAutoClose
= CRegStdDWORD(_T("Software\\TortoiseGit\\AutoClose"));
984 if (m_options
& ProgOptDryRun
)
985 dwAutoClose
= 0; // dry run means progress dialog doesn't auto close at all
988 if (m_dwCloseOnEnd
!= (DWORD
)-1)
989 dwAutoClose
= m_dwCloseOnEnd
; // command line value has priority over setting value
990 if ((dwAutoClose
== CLOSE_NOERRORS
)&&(!m_bErrorsOccurred
))
991 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
992 if ((dwAutoClose
== CLOSE_NOCONFLICTS
)&&(!m_bErrorsOccurred
)&&(m_nConflicts
==0))
993 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
994 if ((dwAutoClose
== CLOSE_NOMERGES
)&&(!m_bErrorsOccurred
)&&(m_nConflicts
==0)&&(!m_bMergesAddsDeletesOccurred
))
995 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
996 if ((dwAutoClose
== CLOSE_LOCAL
)&&(!m_bErrorsOccurred
)&&(m_nConflicts
==0)&&(localoperation
))
997 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
999 //Don't do anything here which might cause messages to be sent to the window
1000 //The window thread is probably now blocked in OnOK if we've done an auto close
1004 void CGitProgressDlg::OnBnClickedLogbutton()
1006 switch(this->m_Command
)
1008 case GitProgress_Add
:
1009 case GitProgress_Resolve
:
1012 cmd
= CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe");
1013 cmd
+= _T(" /command:commit");
1015 cmd
+= _T(" /path:\"")+g_Git
.m_CurrentDir
+_T("\"");
1017 CAppUtils::LaunchApplication(cmd
,NULL
,false);
1018 this->EndDialog(IDOK
);
1023 if (m_targetPathList
.GetCount() != 1)
1025 StringRevMap::iterator it
= m_UpdateStartRevMap
.begin();
1026 svn_revnum_t rev
= -1;
1027 if (it
!= m_UpdateStartRevMap
.end())
1032 dlg
.SetParams(m_targetPathList
[0], m_RevisionEnd
, m_RevisionEnd
, rev
, 0, TRUE
);
1038 void CGitProgressDlg::OnClose()
1042 TerminateThread(m_pThread
->m_hThread
, (DWORD
)-1);
1043 InterlockedExchange(&m_bThreadRunning
, FALSE
);
1047 m_bCancelled
= TRUE
;
1050 DialogEnableWindow(IDCANCEL
, TRUE
);
1054 void CGitProgressDlg::OnOK()
1056 if ((m_bCancelled
)&&(!m_bThreadRunning
))
1058 // I have made this wait a sensible amount of time (10 seconds) for the thread to finish
1059 // You must be careful in the thread that after posting the WM_COMMAND/IDOK message, you
1060 // don't do any more operations on the window which might require message passing
1061 // If you try to send windows messages once we're waiting here, then the thread can't finished
1062 // because the Window's message loop is blocked at this wait
1063 WaitForSingleObject(m_pThread
->m_hThread
, 10000);
1066 m_bCancelled
= TRUE
;
1069 void CGitProgressDlg::OnCancel()
1071 if ((m_bCancelled
)&&(!m_bThreadRunning
))
1072 __super::OnCancel();
1073 m_bCancelled
= TRUE
;
1076 void CGitProgressDlg::OnLvnGetdispinfoSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1078 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
1082 if (pDispInfo
->item
.mask
& LVIF_TEXT
)
1084 if (pDispInfo
->item
.iItem
< (int)m_arData
.size())
1086 const NotificationData
* data
= m_arData
[pDispInfo
->item
.iItem
];
1087 switch (pDispInfo
->item
.iSubItem
)
1090 lstrcpyn(m_columnbuf
, data
->sActionColumnText
, MAX_PATH
);
1093 lstrcpyn(m_columnbuf
, data
->sPathColumnText
, pDispInfo
->item
.cchTextMax
);
1094 if (!data
->bAuxItem
)
1096 int cWidth
= m_ProgList
.GetColumnWidth(1);
1097 cWidth
= max(12, cWidth
-12);
1098 CDC
* pDC
= m_ProgList
.GetDC();
1101 CFont
* pFont
= pDC
->SelectObject(m_ProgList
.GetFont());
1102 PathCompactPath(pDC
->GetSafeHdc(), m_columnbuf
, cWidth
);
1103 pDC
->SelectObject(pFont
);
1109 lstrcpyn(m_columnbuf
, data
->mime_type
, MAX_PATH
);
1114 pDispInfo
->item
.pszText
= m_columnbuf
;
1121 void CGitProgressDlg::OnNMCustomdrawSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1123 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
1125 // Take the default processing unless we set this to something else below.
1126 *pResult
= CDRF_DODEFAULT
;
1128 // First thing - check the draw stage. If it's the control's prepaint
1129 // stage, then tell Windows we want messages for every item.
1131 if ( CDDS_PREPAINT
== pLVCD
->nmcd
.dwDrawStage
)
1133 *pResult
= CDRF_NOTIFYITEMDRAW
;
1135 else if ( CDDS_ITEMPREPAINT
== pLVCD
->nmcd
.dwDrawStage
)
1137 // This is the prepaint stage for an item. Here's where we set the
1138 // item's text color. Our return value will tell Windows to draw the
1139 // item itself, but it will use the new color we set here.
1141 // Tell Windows to paint the control itself.
1142 *pResult
= CDRF_DODEFAULT
;
1144 ASSERT(pLVCD
->nmcd
.dwItemSpec
< m_arData
.size());
1145 if(pLVCD
->nmcd
.dwItemSpec
>= m_arData
.size())
1149 const NotificationData
* data
= m_arData
[pLVCD
->nmcd
.dwItemSpec
];
1150 ASSERT(data
!= NULL
);
1154 // Store the color back in the NMLVCUSTOMDRAW struct.
1155 pLVCD
->clrText
= data
->color
;
1159 void CGitProgressDlg::OnNMDblclkSvnprogress(NMHDR
* /*pNMHDR*/, LRESULT
* /*pResult*/)
1162 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1164 if (pNMLV
->iItem
< 0)
1166 if (m_options
& ProgOptDryRun
)
1167 return; //don't do anything in a dry-run.
1169 const NotificationData
* data
= m_arData
[pNMLV
->iItem
];
1173 if (data
->bConflictedActionItem
)
1175 // We've double-clicked on a conflicted item - do a three-way merge on it
1176 SVNDiff::StartConflictEditor(data
->path
);
1178 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
))
1180 // This is a modified file which has been merged on update. Diff it against base
1181 CTGitPath temporaryFile
;
1182 SVNDiff
diff(this, this->m_hWnd
, true);
1183 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1184 svn_revnum_t baseRev
= 0;
1185 diff
.DiffFileAgainstBase(data
->path
, baseRev
);
1187 else if ((!data
->bAuxItem
)&&(data
->path
.Exists())&&(!data
->path
.IsDirectory()))
1189 bool bOpenWith
= false;
1190 int ret
= (int)ShellExecute(m_hWnd
, NULL
, data
->path
.GetWinPath(), NULL
, NULL
, SW_SHOWNORMAL
);
1191 if (ret
<= HINSTANCE_ERROR
)
1195 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1196 cmd
+= data
->path
.GetWinPathString() + _T(" ");
1197 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1203 void CGitProgressDlg::OnHdnItemclickSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1205 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1206 if (m_bThreadRunning
)
1208 if (m_nSortedColumn
== phdr
->iItem
)
1209 m_bAscending
= !m_bAscending
;
1211 m_bAscending
= TRUE
;
1212 m_nSortedColumn
= phdr
->iItem
;
1216 m_ProgList
.SetRedraw(FALSE
);
1217 m_ProgList
.DeleteAllItems();
1218 m_ProgList
.SetItemCountEx (static_cast<int>(m_arData
.size()));
1220 m_ProgList
.SetRedraw(TRUE
);
1225 bool CGitProgressDlg::NotificationDataIsAux(const NotificationData
* pData
)
1227 return pData
->bAuxItem
;
1230 LRESULT
CGitProgressDlg::OnGitProgress(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
1233 SVNProgress
* pProgressData
= (SVNProgress
*)lParam
;
1234 CProgressCtrl
* progControl
= (CProgressCtrl
*)GetDlgItem(IDC_PROGRESSBAR
);
1235 if ((pProgressData
->total
> 1000)&&(!progControl
->IsWindowVisible()))
1237 progControl
->ShowWindow(SW_SHOW
);
1239 if (((pProgressData
->total
< 0)&&(pProgressData
->progress
> 1000)&&(progControl
->IsWindowVisible()))&&(m_itemCountTotal
<0))
1241 progControl
->ShowWindow(SW_HIDE
);
1243 if (!GetDlgItem(IDC_PROGRESSLABEL
)->IsWindowVisible())
1244 GetDlgItem(IDC_PROGRESSLABEL
)->ShowWindow(SW_SHOW
);
1245 SetTimer(TRANSFERTIMER
, 2000, NULL
);
1246 if ((pProgressData
->total
> 0)&&(pProgressData
->progress
> 1000))
1248 progControl
->SetPos((int)pProgressData
->progress
);
1249 progControl
->SetRange32(0, (int)pProgressData
->total
);
1252 if (pProgressData
->overall_total
< 1024)
1253 m_sTotalBytesTransferred
.Format(IDS_SVN_PROGRESS_TOTALBYTESTRANSFERRED
, pProgressData
->overall_total
);
1254 else if (pProgressData
->overall_total
< 1200000)
1255 m_sTotalBytesTransferred
.Format(IDS_SVN_PROGRESS_TOTALTRANSFERRED
, pProgressData
->overall_total
/ 1024);
1257 m_sTotalBytesTransferred
.Format(IDS_SVN_PROGRESS_TOTALMBTRANSFERRED
, (double)((double)pProgressData
->overall_total
/ 1024000.0));
1258 progText
.Format(IDS_SVN_PROGRESS_TOTALANDSPEED
, (LPCTSTR
)m_sTotalBytesTransferred
, (LPCTSTR
)pProgressData
->SpeedString
);
1259 SetDlgItemText(IDC_PROGRESSLABEL
, progText
);
1264 void CGitProgressDlg::OnTimer(UINT_PTR nIDEvent
)
1266 if (nIDEvent
== TRANSFERTIMER
)
1270 progSpeed
.Format(IDS_SVN_PROGRESS_BYTES_SEC
, 0);
1271 progText
.Format(IDS_SVN_PROGRESS_TOTALANDSPEED
, (LPCTSTR
)m_sTotalBytesTransferred
, (LPCTSTR
)progSpeed
);
1272 SetDlgItemText(IDC_PROGRESSLABEL
, progText
);
1273 KillTimer(TRANSFERTIMER
);
1275 if (nIDEvent
== VISIBLETIMER
)
1277 if (nEnsureVisibleCount
)
1278 m_ProgList
.EnsureVisible(m_ProgList
.GetItemCount()-1, false);
1279 nEnsureVisibleCount
= 0;
1283 void CGitProgressDlg::Sort()
1285 if(m_arData
.size() < 2)
1290 // We need to sort the blocks which lie between the auxiliary entries
1291 // This is so that any aux data stays where it was
1292 NotificationDataVect::iterator actionBlockBegin
;
1293 NotificationDataVect::iterator actionBlockEnd
= m_arData
.begin(); // We start searching from here
1297 // Search to the start of the non-aux entry in the next block
1298 actionBlockBegin
= std::find_if(actionBlockEnd
, m_arData
.end(), std::not1(std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux
)));
1299 if(actionBlockBegin
== m_arData
.end())
1301 // There are no more actions
1304 // Now search to find the end of the block
1305 actionBlockEnd
= std::find_if(actionBlockBegin
+1, m_arData
.end(), std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux
));
1306 // Now sort the block
1307 std::sort(actionBlockBegin
, actionBlockEnd
, &CGitProgressDlg::SortCompare
);
1311 bool CGitProgressDlg::SortCompare(const NotificationData
* pData1
, const NotificationData
* pData2
)
1314 switch (m_nSortedColumn
)
1316 case 0: //action column
1317 result
= pData1
->sActionColumnText
.Compare(pData2
->sActionColumnText
);
1319 case 1: //path column
1320 // Compare happens after switch()
1322 case 2: //mime-type column
1323 result
= pData1
->mime_type
.Compare(pData2
->mime_type
);
1329 // Sort by path if everything else is equal
1332 result
= CTGitPath::Compare(pData1
->path
, pData2
->path
);
1340 BOOL
CGitProgressDlg::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
1342 if (!GetDlgItem(IDOK
)->IsWindowEnabled())
1344 // only show the wait cursor over the list control
1345 if ((pWnd
)&&(pWnd
== GetDlgItem(IDC_SVNPROGRESS
)))
1347 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
1352 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
1354 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1357 BOOL
CGitProgressDlg::PreTranslateMessage(MSG
* pMsg
)
1359 if (pMsg
->message
== WM_KEYDOWN
)
1361 if (pMsg
->wParam
== VK_ESCAPE
)
1363 // pressing the ESC key should close the dialog. But since we disabled the escape
1364 // key (so the user doesn't get the idea that he could simply undo an e.g. update)
1366 // So if the user presses the ESC key, change it to VK_RETURN so the dialog gets
1367 // the impression that the OK button was pressed.
1368 if ((!m_bThreadRunning
)&&(!GetDlgItem(IDCANCEL
)->IsWindowEnabled())
1369 &&(GetDlgItem(IDOK
)->IsWindowEnabled())&&(GetDlgItem(IDOK
)->IsWindowVisible()))
1371 // since we convert ESC to RETURN, make sure the OK button has the focus.
1372 GetDlgItem(IDOK
)->SetFocus();
1373 pMsg
->wParam
= VK_RETURN
;
1376 if (pMsg
->wParam
== 'A')
1378 if (GetKeyState(VK_CONTROL
)&0x8000)
1380 // Ctrl-A -> select all
1381 m_ProgList
.SetSelectionMark(0);
1382 for (int i
=0; i
<m_ProgList
.GetItemCount(); ++i
)
1384 m_ProgList
.SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
1388 if ((pMsg
->wParam
== 'C')||(pMsg
->wParam
== VK_INSERT
))
1390 int selIndex
= m_ProgList
.GetSelectionMark();
1393 if (GetKeyState(VK_CONTROL
)&0x8000)
1395 //Ctrl-C -> copy to clipboard
1397 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1402 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1403 CString sAction
= m_ProgList
.GetItemText(nItem
, 0);
1404 CString sPath
= m_ProgList
.GetItemText(nItem
, 1);
1405 CString sMime
= m_ProgList
.GetItemText(nItem
, 2);
1406 CString sLogCopyText
;
1407 sLogCopyText
.Format(_T("%s: %s %s\r\n"),
1408 (LPCTSTR
)sAction
, (LPCTSTR
)sPath
, (LPCTSTR
)sMime
);
1409 sClipdata
+= sLogCopyText
;
1411 CStringUtils::WriteAsciiStringToClipboard(sClipdata
);
1416 } // if (pMsg->message == WM_KEYDOWN)
1417 return __super::PreTranslateMessage(pMsg
);
1420 void CGitProgressDlg::OnContextMenu(CWnd
* /*pWnd*/, CPoint
/*point*/)
1423 if (m_options
& ProgOptDryRun
)
1424 return; // don't do anything in a dry-run.
1426 if (pWnd
== &m_ProgList
)
1428 int selIndex
= m_ProgList
.GetSelectionMark();
1429 if ((point
.x
== -1) && (point
.y
== -1))
1431 // Menu was invoked from the keyboard rather than by right-clicking
1433 m_ProgList
.GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
1434 m_ProgList
.ClientToScreen(&rect
);
1435 point
= rect
.CenterPoint();
1438 if ((selIndex
>= 0)&&(!m_bThreadRunning
))
1440 // entry is selected, thread has finished with updating so show the popup menu
1442 if (popup
.CreatePopupMenu())
1444 bool bAdded
= false;
1445 NotificationData
* data
= m_arData
[selIndex
];
1446 if ((data
)&&(!data
->path
.IsDirectory()))
1448 if (data
->action
== svn_wc_notify_update_update
|| data
->action
== svn_wc_notify_resolved
)
1450 if (m_ProgList
.GetSelectedCount() == 1)
1452 popup
.AppendMenuIcon(ID_COMPARE
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
1456 if (data
->bConflictedActionItem
)
1458 if (m_ProgList
.GetSelectedCount() == 1)
1460 popup
.AppendMenuIcon(ID_EDITCONFLICT
, IDS_MENUCONFLICT
,IDI_CONFLICT
);
1461 popup
.SetDefaultItem(ID_EDITCONFLICT
, FALSE
);
1462 popup
.AppendMenuIcon(ID_CONFLICTRESOLVE
, IDS_SVNPROGRESS_MENUMARKASRESOLVED
,IDI_RESOLVE
);
1464 popup
.AppendMenuIcon(ID_CONFLICTUSETHEIRS
, IDS_SVNPROGRESS_MENUUSETHEIRS
,IDI_RESOLVE
);
1465 popup
.AppendMenuIcon(ID_CONFLICTUSEMINE
, IDS_SVNPROGRESS_MENUUSEMINE
,IDI_RESOLVE
);
1467 else if ((data
->content_state
== svn_wc_notify_state_merged
)||(GitProgress_Merge
== m_Command
)||(data
->action
== svn_wc_notify_resolved
))
1468 popup
.SetDefaultItem(ID_COMPARE
, FALSE
);
1470 if (m_ProgList
.GetSelectedCount() == 1)
1472 if ((data
->action
== svn_wc_notify_add
)||
1473 (data
->action
== svn_wc_notify_update_add
)||
1474 (data
->action
== svn_wc_notify_commit_added
)||
1475 (data
->action
== svn_wc_notify_commit_modified
)||
1476 (data
->action
== svn_wc_notify_restore
)||
1477 (data
->action
== svn_wc_notify_revert
)||
1478 (data
->action
== svn_wc_notify_resolved
)||
1479 (data
->action
== svn_wc_notify_commit_replaced
)||
1480 (data
->action
== svn_wc_notify_commit_modified
)||
1481 (data
->action
== svn_wc_notify_commit_postfix_txdelta
)||
1482 (data
->action
== svn_wc_notify_update_update
))
1484 popup
.AppendMenuIcon(ID_LOG
, IDS_MENULOG
,IDI_LOG
);
1485 if (data
->action
== svn_wc_notify_update_update
)
1486 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1487 popup
.AppendMenuIcon(ID_OPEN
, IDS_LOG_POPUP_OPEN
, IDI_OPEN
);
1488 popup
.AppendMenuIcon(ID_OPENWITH
, IDS_LOG_POPUP_OPENWITH
, IDI_OPEN
);
1492 } // if ((data)&&(!data->path.IsDirectory()))
1493 if (m_ProgList
.GetSelectedCount() == 1)
1497 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1498 if ((!sPath
.IsEmpty())&&(!SVN::PathIsURL(CTGitPath(sPath
))))
1500 CTGitPath path
= CTGitPath(sPath
);
1501 if (path
.GetDirectory().Exists())
1503 popup
.AppendMenuIcon(ID_EXPLORE
, IDS_SVNPROGRESS_MENUOPENPARENT
, IDI_EXPLORER
);
1509 if (m_ProgList
.GetSelectedCount() > 0)
1512 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1513 popup
.AppendMenuIcon(ID_COPY
, IDS_LOG_POPUP_COPYTOCLIPBOARD
,IDI_COPYCLIP
);
1518 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1519 DialogEnableWindow(IDOK
, FALSE
);
1520 this->SetPromptApp(&theApp
);
1521 theApp
.DoWaitCursor(1);
1522 bool bOpenWith
= false;
1528 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1531 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1532 NotificationData
* data
= m_arData
[nItem
];
1535 sLines
+= data
->sPathColumnText
;
1536 sLines
+= _T("\r\n");
1540 if (!sLines
.IsEmpty())
1542 CStringUtils::WriteAsciiStringToClipboard(sLines
, GetSafeHwnd());
1548 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1550 CTGitPath path
= CTGitPath(sPath
);
1551 ShellExecute(m_hWnd
, _T("explore"), path
.GetDirectory().GetWinPath(), NULL
, path
.GetDirectory().GetWinPath(), SW_SHOW
);
1556 svn_revnum_t rev
= -1;
1557 StringRevMap::iterator it
= m_UpdateStartRevMap
.end();
1558 if (data
->basepath
.IsEmpty())
1559 it
= m_UpdateStartRevMap
.begin();
1561 it
= m_UpdateStartRevMap
.find(data
->basepath
.GetSVNApiPath(pool
));
1562 if (it
!= m_UpdateStartRevMap
.end())
1564 // if the file was merged during update, do a three way diff between OLD, MINE, THEIRS
1565 if (data
->content_state
== svn_wc_notify_state_merged
)
1567 CTGitPath basefile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, rev
);
1568 CTGitPath newfile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, SVNRev::REV_HEAD
);
1570 if (!svn
.Cat(data
->path
, SVNRev(SVNRev::REV_WC
), rev
, basefile
))
1572 CMessageBox::Show(m_hWnd
, svn
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1573 DialogEnableWindow(IDOK
, TRUE
);
1576 // If necessary, convert the line-endings on the file before diffing
1577 if ((DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\ConvertBase"), TRUE
))
1579 CTGitPath temporaryFile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, SVNRev::REV_BASE
);
1580 if (!svn
.Cat(data
->path
, SVNRev(SVNRev::REV_BASE
), SVNRev(SVNRev::REV_BASE
), temporaryFile
))
1582 temporaryFile
.Reset();
1587 newfile
= temporaryFile
;
1591 SetFileAttributes(newfile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1592 SetFileAttributes(basefile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1593 CString revname
, wcname
, basename
;
1594 revname
.Format(_T("%s Revision %ld"), (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName(), rev
);
1595 wcname
.Format(IDS_DIFF_WCNAME
, (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName());
1596 basename
.Format(IDS_DIFF_BASENAME
, (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName());
1597 CAppUtils::StartExtMerge(basefile
, newfile
, data
->path
, data
->path
, basename
, revname
, wcname
, CString(), true);
1601 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, rev
);
1603 if (!svn
.Cat(data
->path
, SVNRev(SVNRev::REV_WC
), rev
, tempfile
))
1605 CMessageBox::Show(m_hWnd
, svn
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1606 DialogEnableWindow(IDOK
, TRUE
);
1611 SetFileAttributes(tempfile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1612 CString revname
, wcname
;
1613 revname
.Format(_T("%s Revision %ld"), (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName(), rev
);
1614 wcname
.Format(IDS_DIFF_WCNAME
, (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName());
1615 CAppUtils::StartExtDiff(
1616 tempfile
, data
->path
, revname
, wcname
,
1617 CAppUtils::DiffFlags().AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000)));
1622 case ID_EDITCONFLICT
:
1624 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1625 SVNDiff::StartConflictEditor(CTGitPath(sPath
));
1628 case ID_CONFLICTUSETHEIRS
:
1629 case ID_CONFLICTUSEMINE
:
1630 case ID_CONFLICTRESOLVE
:
1632 svn_wc_conflict_choice_t result
= svn_wc_conflict_choose_merged
;
1635 case ID_CONFLICTUSETHEIRS
:
1636 result
= svn_wc_conflict_choose_theirs_full
;
1638 case ID_CONFLICTUSEMINE
:
1639 result
= svn_wc_conflict_choose_mine_full
;
1641 case ID_CONFLICTRESOLVE
:
1642 result
= svn_wc_conflict_choose_merged
;
1646 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1647 CString sResolvedPaths
;
1650 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1651 NotificationData
* data
= m_arData
[nItem
];
1654 if (data
->bConflictedActionItem
)
1656 if (!svn
.Resolve(data
->path
, result
, FALSE
))
1658 CMessageBox::Show(m_hWnd
, svn
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1659 DialogEnableWindow(IDOK
, TRUE
);
1664 data
->color
= ::GetSysColor(COLOR_WINDOWTEXT
);
1665 data
->action
= svn_wc_notify_resolved
;
1666 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESOLVE
);
1667 data
->bConflictedActionItem
= false;
1670 if (m_nConflicts
==0)
1672 // When the last conflict is resolved we remove
1673 // the warning which we assume is in the last line.
1674 int nIndex
= m_ProgList
.GetItemCount()-1;
1675 VERIFY(m_ProgList
.DeleteItem(nIndex
));
1677 delete m_arData
[nIndex
];
1678 m_arData
.pop_back();
1680 sResolvedPaths
+= data
->path
.GetWinPathString() + _T("\n");
1685 m_ProgList
.Invalidate();
1686 CString info
= BuildInfoString();
1687 SetDlgItemText(IDC_INFOTEXT
, info
);
1689 if (!sResolvedPaths
.IsEmpty())
1692 msg
.Format(IDS_SVNPROGRESS_RESOLVED
, (LPCTSTR
)sResolvedPaths
);
1693 CMessageBox::Show(m_hWnd
, msg
, _T("TortoiseGit"), MB_OK
| MB_ICONINFORMATION
);
1699 CRegDWORD reg
= CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100);
1700 int limit
= (int)(DWORD
)reg
;
1701 svn_revnum_t rev
= m_RevisionEnd
;
1702 if (!data
->basepath
.IsEmpty())
1704 StringRevMap::iterator it
= m_FinishedRevMap
.find(data
->basepath
.GetSVNApiPath(pool
));
1705 if (it
!= m_FinishedRevMap
.end())
1709 // fetch the log from HEAD, not the revision we updated to:
1710 // the path might be inside an external folder which has its own
1712 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1713 dlg
.SetParams(CTGitPath(sPath
), SVNRev(), SVNRev::REV_HEAD
, 1, limit
, TRUE
);
1722 CString sWinPath
= GetPathFromColumnText(data
->sPathColumnText
);
1724 ret
= (int)ShellExecute(this->m_hWnd
, NULL
, (LPCTSTR
)sWinPath
, NULL
, NULL
, SW_SHOWNORMAL
);
1725 if ((ret
<= HINSTANCE_ERROR
)||bOpenWith
)
1727 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1728 cmd
+= sWinPath
+ _T(" ");
1729 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1733 DialogEnableWindow(IDOK
, TRUE
);
1734 theApp
.DoWaitCursor(-1);
1742 void CGitProgressDlg::OnEnSetfocusInfotext()
1745 GetDlgItemText(IDC_INFOTEXT
, sTemp
);
1746 if (sTemp
.IsEmpty())
1747 GetDlgItem(IDC_INFOTEXT
)->HideCaret();
1750 void CGitProgressDlg::OnLvnBegindragSvnprogress(NMHDR
* , LRESULT
*pResult
)
1752 //LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
1754 int selIndex
= m_ProgList
.GetSelectionMark();
1758 CDropFiles dropFiles
; // class for creating DROPFILES struct
1761 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1762 while ( (index
= m_ProgList
.GetNextSelectedItem(pos
)) >= 0 )
1764 NotificationData
* data
= m_arData
[index
];
1766 if ( data
->kind
==svn_node_file
|| data
->kind
==svn_node_dir
)
1768 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1770 dropFiles
.AddFile( sPath
);
1774 if ( dropFiles
.GetCount()>0 )
1776 dropFiles
.CreateStructure();
1782 void CGitProgressDlg::OnSize(UINT nType
, int cx
, int cy
)
1784 CResizableStandAloneDialog::OnSize(nType
, cx
, cy
);
1785 if ((nType
== SIZE_RESTORED
)&&(m_bLastVisible
))
1787 if(!m_ProgList
.m_hWnd
)
1790 int count
= m_ProgList
.GetItemCount();
1792 m_ProgList
.EnsureVisible(count
-1, false);
1796 //////////////////////////////////////////////////////////////////////////
1798 //////////////////////////////////////////////////////////////////////////
1799 bool CGitProgressDlg::CmdAdd(CString
& sWindowTitle
, bool& localoperation
)
1801 localoperation
= true;
1802 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_ADD
);
1803 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
1804 SetBackgroundImage(IDI_ADD_BKG
);
1805 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_ADD
)));
1807 for(int i
=0;i
<m_targetPathList
.GetCount();i
++)
1810 cmd
.Format(_T("git.exe add -f -- \"%s\""),m_targetPathList
[i
].GetGitPathString());
1811 if(g_Git
.Run(cmd
,&out
,CP_ACP
))
1813 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
1814 m_bErrorsOccurred
=true;
1817 Notify(m_targetPathList
[i
],git_wc_notify_add
);
1820 if (!Add(m_targetPathList
, &m_ProjectProperties
, svn_depth_empty
, FALSE
, TRUE
, TRUE
))
1826 //CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);
1827 m_bErrorsOccurred
=false;
1829 this->GetDlgItem(IDC_LOGBUTTON
)->SetWindowText(_T("Commit ..."));
1830 this->GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
1834 bool CGitProgressDlg::CmdCopy(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
1837 ASSERT(m_targetPathList
.GetCount() == 1);
1838 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_COPY
);
1839 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
1840 SetBackgroundImage(IDI_COPY_BKG
);
1843 sCmdInfo
.Format(IDS_PROGRS_CMD_COPY
,
1844 m_targetPathList
[0].IsUrl() ? (LPCTSTR
)m_targetPathList
[0].GetSVNPathString() : m_targetPathList
[0].GetWinPath(),
1845 (LPCTSTR
)m_url
.GetSVNPathString(), (LPCTSTR
)m_Revision
.ToString());
1846 ReportCmd(sCmdInfo
);
1848 if (!Copy(m_targetPathList
, m_url
, m_Revision
, m_pegRev
, m_sMessage
))
1853 if (m_options
& ProgOptSwitchAfterCopy
)
1855 sCmdInfo
.Format(IDS_PROGRS_CMD_SWITCH
,
1856 m_targetPathList
[0].GetWinPath(),
1857 (LPCTSTR
)m_url
.GetSVNPathString(), (LPCTSTR
)m_Revision
.ToString());
1858 ReportCmd(sCmdInfo
);
1859 if (!Switch(m_targetPathList
[0], m_url
, SVNRev::REV_HEAD
, SVNRev::REV_HEAD
, m_depth
, TRUE
, m_options
& ProgOptIgnoreExternals
))
1861 if (!Switch(m_targetPathList
[0], m_url
, SVNRev::REV_HEAD
, m_Revision
, m_depth
, TRUE
, m_options
& ProgOptIgnoreExternals
))
1870 if (SVN::PathIsURL(m_url
))
1872 CString
sMsg(MAKEINTRESOURCE(IDS_PROGRS_COPY_WARNING
));
1873 ReportNotification(sMsg
);
1880 bool CGitProgressDlg::CmdExport(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
1883 ASSERT(m_targetPathList
.GetCount() == 1);
1884 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_EXPORT
);
1885 sWindowTitle
= m_url
.GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle
;
1886 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
1887 SetBackgroundImage(IDI_EXPORT_BKG
);
1889 if (m_options
& ProgOptEolCRLF
)
1891 if (m_options
& ProgOptEolLF
)
1893 if (m_options
& ProgOptEolCR
)
1895 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_EXPORT
)));
1896 if (!Export(m_url
, m_targetPathList
[0], m_Revision
, m_Revision
, TRUE
, m_options
& ProgOptIgnoreExternals
, m_depth
, NULL
, FALSE
, eol
))
1905 bool CGitProgressDlg::CmdRename(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
1908 ASSERT(m_targetPathList
.GetCount() == 1);
1909 if ((!m_targetPathList
[0].IsUrl())&&(!m_url
.IsUrl()))
1910 localoperation
= true;
1911 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_RENAME
);
1912 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
1913 SetBackgroundImage(IDI_RENAME_BKG
);
1914 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RENAME
)));
1915 if (!Move(m_targetPathList
, m_url
, m_Revision
, m_sMessage
))
1924 bool CGitProgressDlg::CmdResolve(CString
& sWindowTitle
, bool& localoperation
)
1927 localoperation
= true;
1928 ASSERT(m_targetPathList
.GetCount() == 1);
1929 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_RESOLVE
);
1930 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
1931 SetBackgroundImage(IDI_RESOLVE_BKG
);
1932 // check if the file may still have conflict markers in it.
1933 //BOOL bMarkers = FALSE;
1935 for(int i
=0;i
<m_targetPathList
.GetCount();i
++)
1937 CString cmd
,out
,tempmergefile
;
1938 cmd
.Format(_T("git.exe add -f -- \"%s\""),m_targetPathList
[i
].GetGitPathString());
1939 if(g_Git
.Run(cmd
,&out
,CP_ACP
))
1941 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
1942 m_bErrorsOccurred
=true;
1946 CAppUtils::RemoveTempMergeFile((CTGitPath
&)m_targetPathList
[i
]);
1948 Notify(m_targetPathList
[i
],git_wc_notify_resolved
);
1951 if ((m_options
& ProgOptSkipConflictCheck
) == 0)
1955 for (INT_PTR fileindex
=0; (fileindex
<m_targetPathList
.GetCount()) && (bMarkers
==FALSE
); ++fileindex
)
1957 if (!m_targetPathList
[fileindex
].IsDirectory())
1959 CStdioFile
file(m_targetPathList
[fileindex
].GetWinPath(), CFile::typeBinary
| CFile::modeRead
);
1960 CString strLine
= _T("");
1961 while (file
.ReadString(strLine
))
1963 if (strLine
.Find(_T("<<<<<<<"))==0)
1973 catch (CFileException
* pE
)
1975 TRACE(_T("CFileException in Resolve!\n"));
1976 TCHAR error
[10000] = {0};
1977 pE
->GetErrorMessage(error
, 10000);
1985 if (CMessageBox::Show(m_hWnd
, IDS_PROGRS_REVERTMARKERS
, IDS_APPNAME
, MB_YESNO
| MB_ICONQUESTION
)==IDYES
)
1987 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE
)));
1988 for (INT_PTR fileindex
=0; fileindex
<m_targetPathList
.GetCount(); ++fileindex
)
1989 Resolve(m_targetPathList
[fileindex
], svn_wc_conflict_choose_merged
, true);
1994 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE
)));
1995 for (INT_PTR fileindex
=0; fileindex
<m_targetPathList
.GetCount(); ++fileindex
)
1996 Resolve(m_targetPathList
[fileindex
], svn_wc_conflict_choose_merged
, true);
1999 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList
);
2001 this->GetDlgItem(IDC_LOGBUTTON
)->SetWindowText(_T("Commit ..."));
2002 this->GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
2007 bool CGitProgressDlg::CmdRevert(CString
& sWindowTitle
, bool& localoperation
)
2010 localoperation
= true;
2011 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_REVERT
);
2012 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
2013 SetBackgroundImage(IDI_REVERT_BKG
);
2015 CTGitPathList delList
;
2016 for(int i
=0;i
<m_selectedPaths
.GetCount();i
++)
2020 path
.SetFromWin(g_Git
.m_CurrentDir
+_T("\\")+m_selectedPaths
[i
].GetWinPath());
2021 action
= m_selectedPaths
[i
].m_Action
;
2022 /* rename file can't delete because it needs original file*/
2023 if((!(action
& CTGitPath::LOGACTIONS_ADDED
)) &&
2024 (!(action
& CTGitPath::LOGACTIONS_REPLACED
)))
2025 delList
.AddPath(path
);
2027 if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RevertWithRecycleBin"), TRUE
)))
2028 delList
.DeleteAllFiles(true);
2030 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_REVERT
)));
2031 for(int i
=0;i
<m_selectedPaths
.GetCount();i
++)
2033 if(g_Git
.Revert(_T("HEAD"), (CTGitPath
&)m_selectedPaths
[i
]))
2035 CMessageBox::Show(NULL
,_T("Revert Fail"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2036 m_bErrorsOccurred
=true;
2039 Notify(m_selectedPaths
[i
],git_wc_notify_revert
);
2042 CShellUpdater::Instance().AddPathsForUpdate(m_selectedPaths
);
2047 bool CGitProgressDlg::CmdSwitch(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
2050 ASSERT(m_targetPathList
.GetCount() == 1);
2052 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_SWITCH
);
2053 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
2054 SetBackgroundImage(IDI_SWITCH_BKG
);
2056 if (st
.GetStatus(m_targetPathList
[0]) != (-2))
2058 if (st
.status
->entry
!= NULL
)
2060 rev
= st
.status
->entry
->revision
;
2065 sCmdInfo
.Format(IDS_PROGRS_CMD_SWITCH
,
2066 m_targetPathList
[0].GetWinPath(), (LPCTSTR
)m_url
.GetSVNPathString(),
2067 (LPCTSTR
)m_Revision
.ToString());
2068 ReportCmd(sCmdInfo
);
2070 bool depthIsSticky
= true;
2071 if (m_depth
== svn_depth_unknown
)
2072 depthIsSticky
= false;
2073 if (!Switch(m_targetPathList
[0], m_url
, m_Revision
, m_Revision
, m_depth
, depthIsSticky
, m_options
& ProgOptIgnoreExternals
))
2078 m_UpdateStartRevMap
[m_targetPathList
[0].GetSVNApiPath(pool
)] = rev
;
2079 if ((m_RevisionEnd
>= 0)&&(rev
>= 0)
2080 &&((LONG
)m_RevisionEnd
> (LONG
)rev
))
2082 GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
2088 void CGitProgressDlg::OnBnClickedNoninteractive()
2090 LRESULT res
= ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE
)->GetSafeHwnd(), BM_GETCHECK
, 0, 0);
2091 m_AlwaysConflicted
= (res
== BST_CHECKED
);
2092 CRegDWORD nonint
= CRegDWORD(_T("Software\\TortoiseGit\\MergeNonInteractive"), FALSE
);
2093 nonint
= m_AlwaysConflicted
;
2096 CString
CGitProgressDlg::GetPathFromColumnText(const CString
& sColumnText
)
2098 CString sPath
= CPathUtils::ParsePathInString(sColumnText
);
2099 if (sPath
.Find(':')<0)
2101 // the path is not absolute: add the common root of all paths to it
2102 sPath
= m_targetPathList
.GetCommonRoot().GetDirectory().GetWinPathString() + _T("\\") + CPathUtils::ParsePathInString(sColumnText
);
2107 bool CGitProgressDlg::CmdSendMail(CString
& sWindowTitle
, bool& /*localoperation*/)
2109 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_SENDMAIL
);
2110 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
2111 //SetBackgroundImage(IDI_ADD_BKG);
2112 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_SENDMAIL
)));
2114 if(this->m_SendMailFlags
&SENDMAIL_COMBINED
)
2118 Notify(path
,git_wc_notify_sendmail_start
);
2123 if(!!CPatch::SendPatchesCombined(m_targetPathList
,m_SendMailTO
,m_SendMailCC
,m_SendMailSubject
,!!(this->m_SendMailFlags
&SENDMAIL_ATTACHMENT
),!!(this->m_SendMailFlags
&SENDMAIL_MAPI
),&err
))
2125 Notify(path
,git_wc_notify_sendmail_error
,ret
,&err
);
2135 Notify(path
,git_wc_notify_sendmail_retry
,ret
,&err
);
2139 CString
str(_T("User Canceled"));
2140 Notify(path
,git_wc_notify_sendmail_error
,ret
,&str
);
2145 Notify(path
,git_wc_notify_sendmail_done
,ret
);
2149 for(int i
=0;ret
&& i
<m_targetPathList
.GetCount();i
++)
2152 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_start
);
2157 if(!!patch
.Send((CString
&)m_targetPathList
[i
].GetWinPathString(),this->m_SendMailTO
,
2158 this->m_SendMailCC
,!!(this->m_SendMailFlags
&SENDMAIL_ATTACHMENT
),!!(this->m_SendMailFlags
&SENDMAIL_MAPI
)))
2160 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_error
,ret
,&patch
.m_LastError
);
2171 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_retry
,ret
,&patch
.m_LastError
);
2175 CString
str(_T("User Canceled"));
2176 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_error
,ret
,&str
);
2181 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_done
,ret
);