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_Commit
:
894 bSuccess
= CmdCommit(sWindowTitle
, localoperation
);
896 case GitProgress_Copy
:
897 bSuccess
= CmdCopy(sWindowTitle
, localoperation
);
899 case GitProgress_Export
:
900 bSuccess
= CmdExport(sWindowTitle
, localoperation
);
902 case GitProgress_Merge
:
903 bSuccess
= CmdMerge(sWindowTitle
, localoperation
);
905 case GitProgress_MergeReintegrate
:
906 bSuccess
= CmdMergeReintegrate(sWindowTitle
, localoperation
);
908 case GitProgress_Rename
:
909 bSuccess
= CmdRename(sWindowTitle
, localoperation
);
911 case GitProgress_Resolve
:
912 bSuccess
= CmdResolve(sWindowTitle
, localoperation
);
914 case GitProgress_Revert
:
915 bSuccess
= CmdRevert(sWindowTitle
, localoperation
);
917 case GitProgress_Switch
:
918 bSuccess
= CmdSwitch(sWindowTitle
, localoperation
);
920 case GitProgress_SendMail
:
921 bSuccess
= CmdSendMail(sWindowTitle
, localoperation
);
925 temp
.LoadString(IDS_PROGRS_TITLEFAILED
);
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();
939 info
.LoadString(IDS_PROGRS_INFOFAILED
);
940 SetDlgItemText(IDC_INFOTEXT
, info
);
942 SendMessage(DM_SETDEFID
, IDOK
);
943 GetDlgItem(IDOK
)->SetFocus();
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
);
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
);
969 int count
= m_ProgList
.GetItemCount();
970 if ((count
> 0)&&(m_bLastVisible
))
971 m_ProgList
.EnsureVisible(count
-1, FALSE
);
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
);
989 InterlockedExchange(&m_bThreadRunning
, FALSE
);
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
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
1013 void CGitProgressDlg::OnBnClickedLogbutton()
1015 switch(this->m_Command
)
1017 case GitProgress_Add
:
1018 case GitProgress_Resolve
:
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
);
1032 if (m_targetPathList
.GetCount() != 1)
1034 StringRevMap::iterator it
= m_UpdateStartRevMap
.begin();
1035 svn_revnum_t rev
= -1;
1036 if (it
!= m_UpdateStartRevMap
.end())
1041 dlg
.SetParams(m_targetPathList
[0], m_RevisionEnd
, m_RevisionEnd
, rev
, 0, TRUE
);
1047 void CGitProgressDlg::OnClose()
1051 TerminateThread(m_pThread
->m_hThread
, (DWORD
)-1);
1052 InterlockedExchange(&m_bThreadRunning
, FALSE
);
1056 m_bCancelled
= TRUE
;
1059 DialogEnableWindow(IDCANCEL
, TRUE
);
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);
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
);
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
)
1099 lstrcpyn(m_columnbuf
, data
->sActionColumnText
, MAX_PATH
);
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();
1110 CFont
* pFont
= pDC
->SelectObject(m_ProgList
.GetFont());
1111 PathCompactPath(pDC
->GetSafeHdc(), m_columnbuf
, cWidth
);
1112 pDC
->SelectObject(pFont
);
1118 lstrcpyn(m_columnbuf
, data
->mime_type
, MAX_PATH
);
1123 pDispInfo
->item
.pszText
= m_columnbuf
;
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())
1158 const NotificationData
* data
= m_arData
[pLVCD
->nmcd
.dwItemSpec
];
1159 ASSERT(data
!= NULL
);
1163 // Store the color back in the NMLVCUSTOMDRAW struct.
1164 pLVCD
->clrText
= data
->color
;
1168 void CGitProgressDlg::OnNMDblclkSvnprogress(NMHDR
* /*pNMHDR*/, LRESULT
* /*pResult*/)
1171 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1173 if (pNMLV
->iItem
< 0)
1175 if (m_options
& ProgOptDryRun
)
1176 return; //don't do anything in a dry-run.
1178 const NotificationData
* data
= m_arData
[pNMLV
->iItem
];
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
)
1204 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1205 cmd
+= data
->path
.GetWinPathString() + _T(" ");
1206 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1212 void CGitProgressDlg::OnHdnItemclickSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1214 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1215 if (m_bThreadRunning
)
1217 if (m_nSortedColumn
== phdr
->iItem
)
1218 m_bAscending
= !m_bAscending
;
1220 m_bAscending
= TRUE
;
1221 m_nSortedColumn
= phdr
->iItem
;
1225 m_ProgList
.SetRedraw(FALSE
);
1226 m_ProgList
.DeleteAllItems();
1227 m_ProgList
.SetItemCountEx (static_cast<int>(m_arData
.size()));
1229 m_ProgList
.SetRedraw(TRUE
);
1234 bool CGitProgressDlg::NotificationDataIsAux(const NotificationData
* pData
)
1236 return pData
->bAuxItem
;
1239 LRESULT
CGitProgressDlg::OnGitProgress(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
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
);
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);
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
);
1273 void CGitProgressDlg::OnTimer(UINT_PTR nIDEvent
)
1275 if (nIDEvent
== TRANSFERTIMER
)
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)
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
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
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
)
1323 switch (m_nSortedColumn
)
1325 case 0: //action column
1326 result
= pData1
->sActionColumnText
.Compare(pData2
->sActionColumnText
);
1328 case 1: //path column
1329 // Compare happens after switch()
1331 case 2: //mime-type column
1332 result
= pData1
->mime_type
.Compare(pData2
->mime_type
);
1338 // Sort by path if everything else is equal
1341 result
= CTGitPath::Compare(pData1
->path
, pData2
->path
);
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
));
1361 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
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)
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();
1402 if (GetKeyState(VK_CONTROL
)&0x8000)
1404 //Ctrl-C -> copy to clipboard
1406 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
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*/)
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
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
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
);
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
);
1501 } // if ((data)&&(!data->path.IsDirectory()))
1502 if (m_ProgList
.GetSelectedCount() == 1)
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
);
1518 if (m_ProgList
.GetSelectedCount() > 0)
1521 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1522 popup
.AppendMenuIcon(ID_COPY
, IDS_LOG_POPUP_COPYTOCLIPBOARD
,IDI_COPYCLIP
);
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;
1537 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1540 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1541 NotificationData
* data
= m_arData
[nItem
];
1544 sLines
+= data
->sPathColumnText
;
1545 sLines
+= _T("\r\n");
1549 if (!sLines
.IsEmpty())
1551 CStringUtils::WriteAsciiStringToClipboard(sLines
, GetSafeHwnd());
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
);
1565 svn_revnum_t rev
= -1;
1566 StringRevMap::iterator it
= m_UpdateStartRevMap
.end();
1567 if (data
->basepath
.IsEmpty())
1568 it
= m_UpdateStartRevMap
.begin();
1570 it
= m_UpdateStartRevMap
.find(data
->basepath
.GetSVNApiPath(pool
));
1571 if (it
!= m_UpdateStartRevMap
.end())
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
);
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
);
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();
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);
1610 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, rev
);
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
);
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)));
1631 case ID_EDITCONFLICT
:
1633 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1634 SVNDiff::StartConflictEditor(CTGitPath(sPath
));
1637 case ID_CONFLICTUSETHEIRS
:
1638 case ID_CONFLICTUSEMINE
:
1639 case ID_CONFLICTRESOLVE
:
1641 svn_wc_conflict_choice_t result
= svn_wc_conflict_choose_merged
;
1644 case ID_CONFLICTUSETHEIRS
:
1645 result
= svn_wc_conflict_choose_theirs_full
;
1647 case ID_CONFLICTUSEMINE
:
1648 result
= svn_wc_conflict_choose_mine_full
;
1650 case ID_CONFLICTRESOLVE
:
1651 result
= svn_wc_conflict_choose_merged
;
1655 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1656 CString sResolvedPaths
;
1659 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1660 NotificationData
* data
= m_arData
[nItem
];
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
);
1673 data
->color
= ::GetSysColor(COLOR_WINDOWTEXT
);
1674 data
->action
= svn_wc_notify_resolved
;
1675 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESOLVE
);
1676 data
->bConflictedActionItem
= false;
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())
1701 msg
.Format(IDS_SVNPROGRESS_RESOLVED
, (LPCTSTR
)sResolvedPaths
);
1702 CMessageBox::Show(m_hWnd
, msg
, _T("TortoiseGit"), MB_OK
| MB_ICONINFORMATION
);
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())
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
1721 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1722 dlg
.SetParams(CTGitPath(sPath
), SVNRev(), SVNRev::REV_HEAD
, 1, limit
, TRUE
);
1731 CString sWinPath
= GetPathFromColumnText(data
->sPathColumnText
);
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);
1751 void CGitProgressDlg::OnEnSetfocusInfotext()
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);
1763 int selIndex
= m_ProgList
.GetSelectionMark();
1767 CDropFiles dropFiles
; // class for creating DROPFILES struct
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();
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
)
1799 int count
= m_ProgList
.GetItemCount();
1801 m_ProgList
.EnsureVisible(count
-1, false);
1805 //////////////////////////////////////////////////////////////////////////
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
++)
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;
1826 Notify(m_targetPathList
[i
],git_wc_notify_add
);
1829 if (!Add(m_targetPathList
, &m_ProjectProperties
, svn_depth_empty
, FALSE
, TRUE
, TRUE
))
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
);
1843 bool CGitProgressDlg::CmdCommit(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
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
);
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
1865 BOOL bURLFetched
= FALSE
;
1867 for (int i
=0; i
<m_targetPathList
.GetCount(); ++i
)
1869 if (bURLFetched
== FALSE
)
1871 url
= GetURLFromPath(m_targetPathList
[i
]);
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)
1889 if (CMessageBox::Show(m_hWnd
, IDS_PROGRS_COMMITT_TRUNK
, IDS_APPNAME
, MB_YESNO
| MB_DEFBUTTON2
| MB_ICONEXCLAMATION
)==IDNO
)
1894 if (CHooks::Instance().PreCommit(m_selectedPaths
, m_depth
, m_sMessage
, exitcode
, error
))
1899 temp
.Format(IDS_ERR_HOOKFAILED
, (LPCTSTR
)error
);
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
))
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;
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
);
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();
1945 if (FAILED(hr
= pProvider
->OnCommitFinished(GetSafeHwnd(),
1949 (LONG
)m_RevisionEnd
,
1952 CString sErr
= temp
;
1953 if (!sErr
.IsEmpty())
1957 SysFreeString(temp
);
1961 if (CHooks::Instance().PostCommit(m_selectedPaths
, m_depth
, m_RevisionEnd
, m_sMessage
, exitcode
, error
))
1966 temp
.Format(IDS_ERR_HOOKFAILED
, (LPCTSTR
)error
);
1975 bool CGitProgressDlg::CmdCopy(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
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
);
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
))
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
))
2011 if (SVN::PathIsURL(m_url
))
2013 CString
sMsg(MAKEINTRESOURCE(IDS_PROGRS_COPY_WARNING
));
2014 ReportNotification(sMsg
);
2021 bool CGitProgressDlg::CmdExport(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
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
);
2030 if (m_options
& ProgOptEolCRLF
)
2032 if (m_options
& ProgOptEolLF
)
2034 if (m_options
& ProgOptEolCR
)
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
))
2046 bool CGitProgressDlg::CmdMerge(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
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
);
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("........"));
2081 // Merging revisions %s of %s to %s into %s, %s%s
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
)))
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
)))
2123 GetDlgItem(IDC_NONINTERACTIVE
)->ShowWindow(SW_HIDE
);
2124 GetDlgItem(IDC_INFOTEXT
)->ShowWindow(SW_SHOW
);
2130 bool CGitProgressDlg::CmdMergeReintegrate(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
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
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
);
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
))
2155 GetDlgItem(IDC_NONINTERACTIVE
)->ShowWindow(SW_HIDE
);
2159 GetDlgItem(IDC_NONINTERACTIVE
)->ShowWindow(SW_HIDE
);
2164 bool CGitProgressDlg::CmdRename(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
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
))
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;
2205 CAppUtils::RemoveTempMergeFile((CTGitPath
&)m_targetPathList
[i
]);
2207 Notify(m_targetPathList
[i
],git_wc_notify_resolved
);
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)
2232 catch (CFileException
* pE
)
2234 TRACE(_T("CFileException in Resolve!\n"));
2235 TCHAR error
[10000] = {0};
2236 pE
->GetErrorMessage(error
, 10000);
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);
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);
2258 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList
);
2260 this->GetDlgItem(IDC_LOGBUTTON
)->SetWindowText(_T("Commit ..."));
2261 this->GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
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
++)
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;
2298 Notify(m_selectedPaths
[i
],git_wc_notify_revert
);
2301 CShellUpdater::Instance().AddPathsForUpdate(m_selectedPaths
);
2306 bool CGitProgressDlg::CmdSwitch(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
2309 ASSERT(m_targetPathList
.GetCount() == 1);
2311 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_SWITCH
);
2312 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
2313 SetBackgroundImage(IDI_SWITCH_BKG
);
2315 if (st
.GetStatus(m_targetPathList
[0]) != (-2))
2317 if (st
.status
->entry
!= NULL
)
2319 rev
= st
.status
->entry
->revision
;
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
))
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
);
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
);
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
)));
2373 if(this->m_SendMailFlags
&SENDMAIL_COMBINED
)
2377 Notify(path
,git_wc_notify_sendmail_start
);
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
);
2394 Notify(path
,git_wc_notify_sendmail_retry
,ret
,&err
);
2398 CString
str(_T("User Canceled"));
2399 Notify(path
,git_wc_notify_sendmail_error
,ret
,&str
);
2404 Notify(path
,git_wc_notify_sendmail_done
,ret
);
2408 for(int i
=0;ret
&& i
<m_targetPathList
.GetCount();i
++)
2411 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_start
);
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
);
2430 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_retry
,ret
,&patch
.m_LastError
);
2434 CString
str(_T("User Canceled"));
2435 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_error
,ret
,&str
);
2440 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_done
,ret
);