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 "GITProgressDlg.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"
47 static UINT WM_GITPROGRESS
= RegisterWindowMessage(_T("TORTOISEGIT_GITPROGRESS_MSG"));
49 BOOL
CGitProgressDlg::m_bAscending
= FALSE
;
50 int CGitProgressDlg::m_nSortedColumn
= -1;
52 #define TRANSFERTIMER 100
53 #define VISIBLETIMER 101
55 enum GITProgressDlgContextMenuCommands
57 // needs to start with 1, since 0 is the return value if *nothing* is clicked on in the context menu
70 IMPLEMENT_DYNAMIC(CGitProgressDlg
, CResizableStandAloneDialog
)
71 CGitProgressDlg::CGitProgressDlg(CWnd
* pParent
/*=NULL*/)
72 : CResizableStandAloneDialog(CGitProgressDlg::IDD
, pParent
)
76 , m_Revision(_T("HEAD"))
78 , m_bLockWarning(false)
79 , m_bLockExists(false)
80 , m_bThreadRunning(FALSE
)
82 , m_bErrorsOccurred(FALSE
)
83 , m_bMergesAddsDeletesOccurred(FALSE
)
85 , m_options(ProgOptNone
)
86 , m_dwCloseOnEnd((DWORD
)-1)
87 , m_bFinishedItemAdded(false)
88 , m_bLastVisible(false)
89 // , m_depth(svn_depth_unknown)
91 , m_itemCountTotal(-1)
92 , m_AlwaysConflicted(false)
93 , m_BugTraqProvider(NULL
)
94 , sIgnoredIncluded(MAKEINTRESOURCE(IDS_PROGRS_IGNOREDINCLUDED
))
95 , sExtExcluded(MAKEINTRESOURCE(IDS_PROGRS_EXTERNALSEXCLUDED
))
96 , sExtIncluded(MAKEINTRESOURCE(IDS_PROGRS_EXTERNALSINCLUDED
))
97 , sIgnoreAncestry(MAKEINTRESOURCE(IDS_PROGRS_IGNOREANCESTRY
))
98 , sRespectAncestry(MAKEINTRESOURCE(IDS_PROGRS_RESPECTANCESTRY
))
99 , sDryRun(MAKEINTRESOURCE(IDS_PROGRS_DRYRUN
))
100 , sRecordOnly(MAKEINTRESOURCE(IDS_MERGE_RECORDONLY
))
105 CGitProgressDlg::~CGitProgressDlg()
107 for (size_t i
=0; i
<m_arData
.size(); i
++)
111 if(m_pThread
!= NULL
)
117 void CGitProgressDlg::DoDataExchange(CDataExchange
* pDX
)
119 CResizableStandAloneDialog::DoDataExchange(pDX
);
120 DDX_Control(pDX
, IDC_SVNPROGRESS
, m_ProgList
);
123 BEGIN_MESSAGE_MAP(CGitProgressDlg
, CResizableStandAloneDialog
)
124 ON_BN_CLICKED(IDC_LOGBUTTON
, OnBnClickedLogbutton
)
125 ON_NOTIFY(NM_CUSTOMDRAW
, IDC_SVNPROGRESS
, OnNMCustomdrawSvnprogress
)
127 ON_NOTIFY(NM_DBLCLK
, IDC_SVNPROGRESS
, OnNMDblclkSvnprogress
)
128 ON_NOTIFY(HDN_ITEMCLICK
, 0, OnHdnItemclickSvnprogress
)
131 ON_REGISTERED_MESSAGE(WM_GITPROGRESS
, OnGitProgress
)
133 ON_EN_SETFOCUS(IDC_INFOTEXT
, &CGitProgressDlg::OnEnSetfocusInfotext
)
134 ON_NOTIFY(LVN_BEGINDRAG
, IDC_SVNPROGRESS
, &CGitProgressDlg::OnLvnBegindragSvnprogress
)
136 ON_NOTIFY(LVN_GETDISPINFO
, IDC_SVNPROGRESS
, &CGitProgressDlg::OnLvnGetdispinfoSvnprogress
)
137 ON_BN_CLICKED(IDC_NONINTERACTIVE
, &CGitProgressDlg::OnBnClickedNoninteractive
)
138 ON_MESSAGE(WM_SHOWCONFLICTRESOLVER
, OnShowConflictResolver
)
141 BOOL
CGitProgressDlg::Cancel()
146 LRESULT
CGitProgressDlg::OnShowConflictResolver(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
149 CConflictResolveDlg
dlg(this);
150 const svn_wc_conflict_description_t
*description
= (svn_wc_conflict_description_t
*)lParam
;
153 dlg
.SetConflictDescription(description
);
154 if (dlg
.DoModal() == IDOK
)
156 if (dlg
.GetResult() == svn_wc_conflict_choose_postpone
)
158 // if the result is conflicted and the dialog returned IDOK,
159 // that means we should not ask again in case of a conflict
160 m_AlwaysConflicted
= true;
161 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE
)->GetSafeHwnd(), BM_SETCHECK
, BST_CHECKED
, 0);
164 m_mergedfile
= dlg
.GetMergedFile();
165 m_bCancelled
= dlg
.IsCancelled();
166 return dlg
.GetResult();
169 return svn_wc_conflict_choose_postpone
;
174 svn_wc_conflict_choice_t
CGitProgressDlg::ConflictResolveCallback(const svn_wc_conflict_description_t
*description
, CString
& mergedfile
)
176 // we only bother the user when merging
177 if (((m_Command
== GitProgress_Merge
)||(m_Command
== GitProgress_MergeAll
)||(m_Command
== GitProgress_MergeReintegrate
))&&(!m_AlwaysConflicted
)&&(description
))
179 // we're in a worker thread here. That means we must not show a dialog from the thread
180 // but let the UI thread do it.
181 // To do that, we send a message to the UI thread and let it show the conflict resolver dialog.
182 LRESULT dlgResult
= ::SendMessage(GetSafeHwnd(), WM_SHOWCONFLICTRESOLVER
, 0, (LPARAM
)description
);
183 mergedfile
= m_mergedfile
;
184 return (svn_wc_conflict_choice_t
)dlgResult
;
187 return svn_wc_conflict_choose_postpone
;
190 void CGitProgressDlg::AddItemToList()
192 int totalcount
= m_ProgList
.GetItemCount();
194 m_ProgList
.SetItemCountEx(totalcount
+1, LVSICF_NOSCROLL
|LVSICF_NOINVALIDATEALL
);
195 // make columns width fit
196 if (iFirstResized
< 30)
198 // only resize the columns for the first 30 or so entries.
199 // after that, don't resize them anymore because that's an
200 // expensive function call and the columns will be sized
201 // close enough already.
206 // Make sure the item is *entirely* visible even if the horizontal
207 // scroll bar is visible.
208 int count
= m_ProgList
.GetCountPerPage();
209 if (totalcount
<= (m_ProgList
.GetTopIndex() + count
+ nEnsureVisibleCount
+ 2))
211 nEnsureVisibleCount
++;
212 m_bLastVisible
= true;
216 nEnsureVisibleCount
= 0;
218 m_bLastVisible
= false;
223 BOOL
CGitProgressDlg::Notify(const CTGitPath
& path
, git_wc_notify_action_t action
,
227 svn_node_kind_t kind, const CString& mime_type,
228 svn_wc_notify_state_t content_state,
229 svn_wc_notify_state_t prop_state, LONG rev,
230 const svn_lock_t * lock, svn_wc_notify_lock_state_t lock_state,
231 const CString& changelistname,
232 svn_merge_range_t * range,
233 svn_error_t * err, apr_pool_t * pool
236 bool bNoNotify
= false;
237 bool bDoAddData
= true;
238 NotificationData
* data
= new NotificationData();
240 data
->action
= action
;
241 data
->sPathColumnText
=path
.GetGitPathString();
242 data
->bAuxItem
= false;
245 data
->mime_type
= mime_type
;
246 data
->content_state
= content_state
;
247 data
->prop_state
= prop_state
;
249 data
->lock_state
= lock_state
;
250 data
->changelistname
= changelistname
;
251 if ((lock
)&&(lock
->owner
))
252 data
->owner
= CUnicodeUtils::GetUnicode(lock
->owner
);
253 data
->sPathColumnText
= path
.GetUIPathString();
254 if (!m_basePath
.IsEmpty())
255 data
->basepath
= m_basePath
;
257 data
->merge_range
= *range
;
259 switch (data
->action
)
261 case git_wc_notify_add
:
262 //case svn_wc_notify_update_add:
263 // if ((data->content_state == svn_wc_notify_state_conflicted) || (data->prop_state == svn_wc_notify_state_conflicted))
265 // data->color = m_Colors.GetColor(CColors::Conflict);
266 // data->bConflictedActionItem = true;
267 // data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);
272 // m_bMergesAddsDeletesOccurred = true;
273 data
->sActionColumnText
.LoadString(IDS_SVNACTION_ADD
);
274 data
->color
= m_Colors
.GetColor(CColors::Added
);
277 case git_wc_notify_sendmail_start
:
278 data
->bAuxItem
= true;
279 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_START
);
280 data
->color
= m_Colors
.GetColor(CColors::Modified
);
283 case git_wc_notify_sendmail_error
:
284 data
->bAuxItem
= true;
285 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_ERROR
);
287 data
->sPathColumnText
= *strErr
;
289 data
->sPathColumnText
.Empty();
290 data
->color
= m_Colors
.GetColor(CColors::Modified
);
293 case git_wc_notify_sendmail_done
:
295 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_DONE
);
296 data
->sPathColumnText
.Empty();
297 data
->color
= m_Colors
.GetColor(CColors::Modified
);
300 case git_wc_notify_sendmail_retry
:
301 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_RETRY
);
302 data
->sPathColumnText
.Empty();
303 data
->color
= m_Colors
.GetColor(CColors::Modified
);
307 case git_wc_notify_resolved
:
308 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESOLVE
);
311 case git_wc_notify_revert
:
312 data
->sActionColumnText
.LoadString(IDS_SVNACTION_REVERT
);
316 case svn_wc_notify_commit_added
:
317 data
->sActionColumnText
.LoadString(IDS_SVNACTION_ADDING
);
318 data
->color
= m_Colors
.GetColor(CColors::Added
);
320 case svn_wc_notify_copy
:
321 data
->sActionColumnText
.LoadString(IDS_SVNACTION_COPY
);
323 case svn_wc_notify_commit_modified
:
324 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MODIFIED
);
325 data
->color
= m_Colors
.GetColor(CColors::Modified
);
327 case svn_wc_notify_delete
:
328 case svn_wc_notify_update_delete
:
329 data
->sActionColumnText
.LoadString(IDS_SVNACTION_DELETE
);
330 m_bMergesAddsDeletesOccurred
= true;
331 data
->color
= m_Colors
.GetColor(CColors::Deleted
);
333 case svn_wc_notify_commit_deleted
:
334 data
->sActionColumnText
.LoadString(IDS_SVNACTION_DELETING
);
335 data
->color
= m_Colors
.GetColor(CColors::Deleted
);
337 case svn_wc_notify_restore
:
338 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESTORE
);
341 case svn_wc_notify_update_replace
:
342 case svn_wc_notify_commit_replaced
:
343 data
->sActionColumnText
.LoadString(IDS_SVNACTION_REPLACED
);
344 data
->color
= m_Colors
.GetColor(CColors::Deleted
);
346 case svn_wc_notify_exists
:
347 if ((data
->content_state
== svn_wc_notify_state_conflicted
) || (data
->prop_state
== svn_wc_notify_state_conflicted
))
349 data
->color
= m_Colors
.GetColor(CColors::Conflict
);
350 data
->bConflictedActionItem
= true;
352 data
->sActionColumnText
.LoadString(IDS_SVNACTION_CONFLICTED
);
354 else if ((data
->content_state
== svn_wc_notify_state_merged
) || (data
->prop_state
== svn_wc_notify_state_merged
))
356 data
->color
= m_Colors
.GetColor(CColors::Merged
);
357 m_bMergesAddsDeletesOccurred
= true;
358 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MERGED
);
361 data
->sActionColumnText
.LoadString(IDS_SVNACTION_EXISTS
);
363 case svn_wc_notify_update_update
:
364 // if this is an inoperative dir change, don't show the notification.
365 // an inoperative dir change is when a directory gets updated without
366 // any real change in either text or properties.
367 if ((kind
== svn_node_dir
)
368 && ((prop_state
== svn_wc_notify_state_inapplicable
)
369 || (prop_state
== svn_wc_notify_state_unknown
)
370 || (prop_state
== svn_wc_notify_state_unchanged
)))
375 if ((data
->content_state
== svn_wc_notify_state_conflicted
) || (data
->prop_state
== svn_wc_notify_state_conflicted
))
377 data
->color
= m_Colors
.GetColor(CColors::Conflict
);
378 data
->bConflictedActionItem
= true;
380 data
->sActionColumnText
.LoadString(IDS_SVNACTION_CONFLICTED
);
382 else if ((data
->content_state
== svn_wc_notify_state_merged
) || (data
->prop_state
== svn_wc_notify_state_merged
))
384 data
->color
= m_Colors
.GetColor(CColors::Merged
);
385 m_bMergesAddsDeletesOccurred
= true;
386 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MERGED
);
388 else if (((data
->content_state
!= svn_wc_notify_state_unchanged
)&&(data
->content_state
!= svn_wc_notify_state_unknown
)) ||
389 ((data
->prop_state
!= svn_wc_notify_state_unchanged
)&&(data
->prop_state
!= svn_wc_notify_state_unknown
)))
391 data
->sActionColumnText
.LoadString(IDS_SVNACTION_UPDATE
);
398 if (lock_state
== svn_wc_notify_lock_state_unlocked
)
400 CString
temp(MAKEINTRESOURCE(IDS_SVNACTION_UNLOCKED
));
401 data
->sActionColumnText
+= _T(", ") + temp
;
405 case svn_wc_notify_update_external
:
406 // For some reason we build a list of externals...
407 m_ExtStack
.AddHead(path
.GetUIPathString());
408 data
->sActionColumnText
.LoadString(IDS_SVNACTION_EXTERNAL
);
409 data
->bAuxItem
= true;
412 case svn_wc_notify_update_completed
:
414 data
->sActionColumnText
.LoadString(IDS_SVNACTION_COMPLETED
);
415 data
->bAuxItem
= true;
416 bool bEmpty
= !!m_ExtStack
.IsEmpty();
418 data
->sPathColumnText
.Format(IDS_PROGRS_PATHATREV
, (LPCTSTR
)m_ExtStack
.RemoveHead(), rev
);
420 data
->sPathColumnText
.Format(IDS_PROGRS_ATREV
, rev
);
422 if ((m_nConflicts
>0)&&(bEmpty
))
424 // We're going to add another aux item - let's shove this current onto the list first
425 // I don't really like this, but it will do for the moment.
426 m_arData
.push_back(data
);
429 data
= new NotificationData();
430 data
->bAuxItem
= true;
431 data
->sActionColumnText
.LoadString(IDS_PROGRS_CONFLICTSOCCURED_WARNING
);
432 data
->sPathColumnText
.LoadString(IDS_PROGRS_CONFLICTSOCCURED
);
433 data
->color
= m_Colors
.GetColor(CColors::Conflict
);
434 CSoundUtils::PlayTSVNWarning();
435 // This item will now be added after the switch statement
437 if (!m_basePath
.IsEmpty())
438 m_FinishedRevMap
[m_basePath
.GetSVNApiPath(pool
)] = rev
;
440 m_bFinishedItemAdded
= true;
443 case svn_wc_notify_commit_postfix_txdelta
:
444 data
->sActionColumnText
.LoadString(IDS_SVNACTION_POSTFIX
);
446 case svn_wc_notify_failed_revert
:
447 data
->sActionColumnText
.LoadString(IDS_SVNACTION_FAILEDREVERT
);
449 case svn_wc_notify_status_completed
:
450 case svn_wc_notify_status_external
:
451 data
->sActionColumnText
.LoadString(IDS_SVNACTION_STATUS
);
453 case svn_wc_notify_skip
:
454 if ((content_state
== svn_wc_notify_state_missing
)||(content_state
== svn_wc_notify_state_obstructed
)||(content_state
== svn_wc_notify_state_conflicted
))
456 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SKIPMISSING
);
458 // The color settings dialog describes the red color with
459 // "possible or real conflict / obstructed" which also applies to
460 // skipped targets during a merge. So we just use the same color.
461 data
->color
= m_Colors
.GetColor(CColors::Conflict
);
464 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SKIP
);
466 case svn_wc_notify_locked
:
467 if ((lock
)&&(lock
->owner
))
468 data
->sActionColumnText
.Format(IDS_SVNACTION_LOCKEDBY
, (LPCTSTR
)CUnicodeUtils::GetUnicode(lock
->owner
));
470 case svn_wc_notify_unlocked
:
471 data
->sActionColumnText
.LoadString(IDS_SVNACTION_UNLOCKED
);
473 case svn_wc_notify_failed_lock
:
474 data
->sActionColumnText
.LoadString(IDS_SVNACTION_FAILEDLOCK
);
475 m_arData
.push_back(data
);
477 ReportError(SVN::GetErrorString(err
));
479 if (err
->apr_err
== SVN_ERR_FS_OUT_OF_DATE
)
480 m_bLockWarning
= true;
481 if (err
->apr_err
== SVN_ERR_FS_PATH_ALREADY_LOCKED
)
482 m_bLockExists
= true;
484 case svn_wc_notify_failed_unlock
:
485 data
->sActionColumnText
.LoadString(IDS_SVNACTION_FAILEDUNLOCK
);
486 m_arData
.push_back(data
);
488 ReportError(SVN::GetErrorString(err
));
490 if (err
->apr_err
== SVN_ERR_FS_OUT_OF_DATE
)
491 m_bLockWarning
= true;
493 case svn_wc_notify_changelist_set
:
494 data
->sActionColumnText
.Format(IDS_SVNACTION_CHANGELISTSET
, (LPCTSTR
)data
->changelistname
);
496 case svn_wc_notify_changelist_clear
:
497 data
->sActionColumnText
.LoadString(IDS_SVNACTION_CHANGELISTCLEAR
);
499 case svn_wc_notify_changelist_moved
:
500 data
->sActionColumnText
.Format(IDS_SVNACTION_CHANGELISTMOVED
, (LPCTSTR
)data
->changelistname
);
502 case svn_wc_notify_foreign_merge_begin
:
503 case svn_wc_notify_merge_begin
:
505 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MERGEBEGINNONE
);
506 else if ((data
->merge_range
.start
== data
->merge_range
.end
) || (data
->merge_range
.start
== data
->merge_range
.end
- 1))
507 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINSINGLE
, data
->merge_range
.end
);
508 else if (data
->merge_range
.start
- 1 == data
->merge_range
.end
)
509 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINSINGLEREVERSE
, data
->merge_range
.start
);
510 else if (data
->merge_range
.start
< data
->merge_range
.end
)
511 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINMULTIPLE
, data
->merge_range
.start
+ 1, data
->merge_range
.end
);
513 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINMULTIPLEREVERSE
, data
->merge_range
.start
, data
->merge_range
.end
+ 1);
514 data
->bAuxItem
= true;
519 } // switch (data->action)
527 m_arData
.push_back(data
);
529 if ((!data
->bAuxItem
) && (m_itemCount
> 0))
533 CProgressCtrl
* progControl
= (CProgressCtrl
*)GetDlgItem(IDC_PROGRESSBAR
);
534 progControl
->ShowWindow(SW_SHOW
);
535 progControl
->SetPos(m_itemCountTotal
- m_itemCount
);
536 progControl
->SetRange32(0, m_itemCountTotal
);
539 //if ((action == svn_wc_notify_commit_postfix_txdelta)&&(bSecondResized == FALSE))
542 // bSecondResized = TRUE;
550 CString
CGitProgressDlg::BuildInfoString()
553 if(this->m_Command
== GitProgress_Resolve
)
554 infotext
= _T("You need commit your change after resolve conflict");
571 for (size_t i
=0; i
<m_arData
.size(); ++i
)
573 const NotificationData
* dat
= m_arData
[i
];
576 case svn_wc_notify_add
:
577 case svn_wc_notify_update_add
:
578 case svn_wc_notify_commit_added
:
579 if (dat
->bConflictedActionItem
)
584 case svn_wc_notify_copy
:
587 case svn_wc_notify_delete
:
588 case svn_wc_notify_update_delete
:
589 case svn_wc_notify_commit_deleted
:
592 case svn_wc_notify_restore
:
595 case svn_wc_notify_revert
:
598 case svn_wc_notify_resolved
:
601 case svn_wc_notify_update_update
:
602 if (dat
->bConflictedActionItem
)
604 else if ((dat
->content_state
== svn_wc_notify_state_merged
) || (dat
->prop_state
== svn_wc_notify_state_merged
))
609 case svn_wc_notify_commit_modified
:
612 case svn_wc_notify_skip
:
615 case svn_wc_notify_commit_replaced
:
622 temp
.LoadString(IDS_SVNACTION_CONFLICTED
);
624 temp
.Format(_T(":%d "), conflicted
);
629 temp
.LoadString(IDS_SVNACTION_SKIP
);
631 infotext
.AppendFormat(_T(":%d "), skipped
);
635 temp
.LoadString(IDS_SVNACTION_MERGED
);
637 infotext
.AppendFormat(_T(":%d "), merged
);
641 temp
.LoadString(IDS_SVNACTION_ADD
);
643 infotext
.AppendFormat(_T(":%d "), added
);
647 temp
.LoadString(IDS_SVNACTION_DELETE
);
649 infotext
.AppendFormat(_T(":%d "), deleted
);
653 temp
.LoadString(IDS_SVNACTION_MODIFIED
);
655 infotext
.AppendFormat(_T(":%d "), modified
);
659 temp
.LoadString(IDS_SVNACTION_COPY
);
661 infotext
.AppendFormat(_T(":%d "), copied
);
665 temp
.LoadString(IDS_SVNACTION_REPLACED
);
667 infotext
.AppendFormat(_T(":%d "), replaced
);
671 temp
.LoadString(IDS_SVNACTION_UPDATE
);
673 infotext
.AppendFormat(_T(":%d "), updated
);
677 temp
.LoadString(IDS_SVNACTION_RESTORE
);
679 infotext
.AppendFormat(_T(":%d "), restored
);
683 temp
.LoadString(IDS_SVNACTION_REVERT
);
685 infotext
.AppendFormat(_T(":%d "), reverted
);
689 temp
.LoadString(IDS_SVNACTION_RESOLVE
);
691 infotext
.AppendFormat(_T(":%d "), resolved
);
697 void CGitProgressDlg::SetSelectedList(const CTGitPathList
& selPaths
)
699 m_selectedPaths
= selPaths
;
702 void CGitProgressDlg::ResizeColumns()
704 m_ProgList
.SetRedraw(FALSE
);
706 TCHAR textbuf
[MAX_PATH
];
708 int maxcol
= ((CHeaderCtrl
*)(m_ProgList
.GetDlgItem(0)))->GetItemCount()-1;
709 for (int col
= 0; col
<= maxcol
; col
++)
711 // find the longest width of all items
712 int count
= m_ProgList
.GetItemCount();
715 hdi
.pszText
= textbuf
;
716 hdi
.cchTextMax
= sizeof(textbuf
);
717 ((CHeaderCtrl
*)(m_ProgList
.GetDlgItem(0)))->GetItem(col
, &hdi
);
718 int cx
= m_ProgList
.GetStringWidth(hdi
.pszText
)+20; // 20 pixels for col separator and margin
720 for (int index
= 0; index
<count
; ++index
)
722 // get the width of the string and add 12 pixels for the column separator and margins
727 linewidth
= m_ProgList
.GetStringWidth(m_arData
[index
]->sActionColumnText
) + 12;
730 linewidth
= m_ProgList
.GetStringWidth(m_arData
[index
]->sPathColumnText
) + 12;
733 linewidth
= m_ProgList
.GetStringWidth(m_arData
[index
]->mime_type
) + 12;
739 m_ProgList
.SetColumnWidth(col
, cx
);
742 m_ProgList
.SetRedraw(TRUE
);
745 BOOL
CGitProgressDlg::OnInitDialog()
747 __super::OnInitDialog();
749 m_ProgList
.SetExtendedStyle (LVS_EX_FULLROWSELECT
| LVS_EX_DOUBLEBUFFER
);
751 m_ProgList
.DeleteAllItems();
752 int c
= ((CHeaderCtrl
*)(m_ProgList
.GetDlgItem(0)))->GetItemCount()-1;
754 m_ProgList
.DeleteColumn(c
--);
756 temp
.LoadString(IDS_PROGRS_ACTION
);
757 m_ProgList
.InsertColumn(0, temp
);
758 temp
.LoadString(IDS_PROGRS_PATH
);
759 m_ProgList
.InsertColumn(1, temp
);
760 temp
.LoadString(IDS_PROGRS_MIMETYPE
);
761 m_ProgList
.InsertColumn(2, temp
);
763 m_pThread
= AfxBeginThread(ProgressThreadEntry
, this, THREAD_PRIORITY_NORMAL
,0,CREATE_SUSPENDED
);
766 ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED
)));
770 m_pThread
->m_bAutoDelete
= FALSE
;
771 m_pThread
->ResumeThread();
776 // Call this early so that the column headings aren't hidden before any
780 SetTimer(VISIBLETIMER
, 300, NULL
);
782 AddAnchor(IDC_SVNPROGRESS
, TOP_LEFT
, BOTTOM_RIGHT
);
783 AddAnchor(IDC_PROGRESSLABEL
, BOTTOM_LEFT
, BOTTOM_CENTER
);
784 AddAnchor(IDC_PROGRESSBAR
, BOTTOM_CENTER
, BOTTOM_RIGHT
);
785 AddAnchor(IDC_INFOTEXT
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
786 AddAnchor(IDC_NONINTERACTIVE
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
787 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
788 AddAnchor(IDOK
, BOTTOM_RIGHT
);
789 AddAnchor(IDC_LOGBUTTON
, BOTTOM_RIGHT
);
790 //SetPromptParentWindow(this->m_hWnd);
792 CenterWindow(CWnd::FromHandle(hWndExplorer
));
793 EnableSaveRestore(_T("GITProgressDlg"));
797 bool CGitProgressDlg::SetBackgroundImage(UINT nID
)
799 return CAppUtils::SetListCtrlBackgroundImage(m_ProgList
.GetSafeHwnd(), nID
);
802 void CGitProgressDlg::ReportGitError()
804 ReportError(CString(git_lasterror()));
807 void CGitProgressDlg::ReportError(const CString
& sError
)
809 CSoundUtils::PlayTGitError();
810 ReportString(sError
, CString(MAKEINTRESOURCE(IDS_ERR_ERROR
)), m_Colors
.GetColor(CColors::Conflict
));
811 m_bErrorsOccurred
= true;
814 void CGitProgressDlg::ReportWarning(const CString
& sWarning
)
816 CSoundUtils::PlayTGitWarning();
817 ReportString(sWarning
, CString(MAKEINTRESOURCE(IDS_WARN_WARNING
)), m_Colors
.GetColor(CColors::Conflict
));
820 void CGitProgressDlg::ReportNotification(const CString
& sNotification
)
822 CSoundUtils::PlayTGitNotification();
823 ReportString(sNotification
, CString(MAKEINTRESOURCE(IDS_WARN_NOTE
)));
826 void CGitProgressDlg::ReportCmd(const CString
& sCmd
)
828 ReportString(sCmd
, CString(MAKEINTRESOURCE(IDS_PROGRS_CMDINFO
)), m_Colors
.GetColor(CColors::Cmd
));
831 void CGitProgressDlg::ReportString(CString sMessage
, const CString
& sMsgKind
, COLORREF color
)
833 // instead of showing a dialog box with the error message or notification,
834 // just insert the error text into the list control.
835 // that way the user isn't 'interrupted' by a dialog box popping up!
837 // the message may be split up into different lines
838 // so add a new entry for each line of the message
839 while (!sMessage
.IsEmpty())
841 NotificationData
* data
= new NotificationData();
842 data
->bAuxItem
= true;
843 data
->sActionColumnText
= sMsgKind
;
844 if (sMessage
.Find('\n')>=0)
845 data
->sPathColumnText
= sMessage
.Left(sMessage
.Find('\n'));
847 data
->sPathColumnText
= sMessage
;
848 data
->sPathColumnText
.Trim(_T("\n\r"));
850 if (sMessage
.Find('\n')>=0)
852 sMessage
= sMessage
.Mid(sMessage
.Find('\n'));
853 sMessage
.Trim(_T("\n\r"));
857 m_arData
.push_back(data
);
862 UINT
CGitProgressDlg::ProgressThreadEntry(LPVOID pVoid
)
864 return ((CGitProgressDlg
*)pVoid
)->ProgressThread();
867 UINT
CGitProgressDlg::ProgressThread()
869 // The SetParams function should have loaded something for us
872 CString sWindowTitle
;
873 bool localoperation
= false;
874 bool bSuccess
= false;
875 m_AlwaysConflicted
= false;
877 DialogEnableWindow(IDOK
, FALSE
);
878 DialogEnableWindow(IDCANCEL
, TRUE
);
879 // SetAndClearProgressInfo(m_hWnd);
880 m_itemCount
= m_itemCountTotal
;
882 InterlockedExchange(&m_bThreadRunning
, TRUE
);
884 bSecondResized
= FALSE
;
885 m_bFinishedItemAdded
= false;
886 CTime startTime
= CTime::GetCurrentTime();
889 case GitProgress_Add
:
890 bSuccess
= CmdAdd(sWindowTitle
, localoperation
);
892 case GitProgress_Copy
:
893 bSuccess
= CmdCopy(sWindowTitle
, localoperation
);
895 case GitProgress_Export
:
896 bSuccess
= CmdExport(sWindowTitle
, localoperation
);
898 case GitProgress_Rename
:
899 bSuccess
= CmdRename(sWindowTitle
, localoperation
);
901 case GitProgress_Resolve
:
902 bSuccess
= CmdResolve(sWindowTitle
, localoperation
);
904 case GitProgress_Revert
:
905 bSuccess
= CmdRevert(sWindowTitle
, localoperation
);
907 case GitProgress_Switch
:
908 bSuccess
= CmdSwitch(sWindowTitle
, localoperation
);
910 case GitProgress_SendMail
:
911 bSuccess
= CmdSendMail(sWindowTitle
, localoperation
);
915 temp
.LoadString(IDS_PROGRS_TITLEFAILED
);
917 temp
.LoadString(IDS_PROGRS_TITLEFIN
);
918 sWindowTitle
= sWindowTitle
+ _T(" ") + temp
;
919 SetWindowText(sWindowTitle
);
921 KillTimer(TRANSFERTIMER
);
922 KillTimer(VISIBLETIMER
);
924 DialogEnableWindow(IDCANCEL
, FALSE
);
925 DialogEnableWindow(IDOK
, TRUE
);
927 CString info
= BuildInfoString();
929 info
.LoadString(IDS_PROGRS_INFOFAILED
);
930 SetDlgItemText(IDC_INFOTEXT
, info
);
932 SendMessage(DM_SETDEFID
, IDOK
);
933 GetDlgItem(IDOK
)->SetFocus();
936 if (!m_sTotalBytesTransferred
.IsEmpty())
938 CTimeSpan time
= CTime::GetCurrentTime() - startTime
;
939 temp
.Format(IDS_PROGRS_TIME
, (LONG
)time
.GetTotalMinutes(), (LONG
)time
.GetSeconds());
940 sFinalInfo
.Format(IDS_PROGRS_FINALINFO
, m_sTotalBytesTransferred
, (LPCTSTR
)temp
);
941 SetDlgItemText(IDC_PROGRESSLABEL
, sFinalInfo
);
944 GetDlgItem(IDC_PROGRESSLABEL
)->ShowWindow(SW_HIDE
);
946 GetDlgItem(IDC_PROGRESSBAR
)->ShowWindow(SW_HIDE
);
948 if (!m_bFinishedItemAdded
)
950 // there's no "finished: xxx" line at the end. We add one here to make
951 // sure the user sees that the command is actually finished.
952 NotificationData
* data
= new NotificationData();
953 data
->bAuxItem
= true;
954 data
->sActionColumnText
.LoadString(IDS_PROGRS_FINISHED
);
955 m_arData
.push_back(data
);
959 int count
= m_ProgList
.GetItemCount();
960 if ((count
> 0)&&(m_bLastVisible
))
961 m_ProgList
.EnsureVisible(count
-1, FALSE
);
966 logfile
.AddTimeLine();
967 for (size_t i
=0; i
<m_arData
.size(); i
++)
969 NotificationData
* data
= m_arData
[i
];
970 temp
.Format(_T("%-20s : %s"), (LPCTSTR
)data
->sActionColumnText
, (LPCTSTR
)data
->sPathColumnText
);
971 logfile
.AddLine(temp
);
973 if (!sFinalInfo
.IsEmpty())
974 logfile
.AddLine(sFinalInfo
);
979 InterlockedExchange(&m_bThreadRunning
, FALSE
);
982 DWORD dwAutoClose
= CRegStdDWORD(_T("Software\\TortoiseGit\\AutoClose"));
983 if (m_options
& ProgOptDryRun
)
984 dwAutoClose
= 0; // dry run means progress dialog doesn't auto close at all
987 if (m_dwCloseOnEnd
!= (DWORD
)-1)
988 dwAutoClose
= m_dwCloseOnEnd
; // command line value has priority over setting value
989 if ((dwAutoClose
== CLOSE_NOERRORS
)&&(!m_bErrorsOccurred
))
990 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
991 if ((dwAutoClose
== CLOSE_NOCONFLICTS
)&&(!m_bErrorsOccurred
)&&(m_nConflicts
==0))
992 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
993 if ((dwAutoClose
== CLOSE_NOMERGES
)&&(!m_bErrorsOccurred
)&&(m_nConflicts
==0)&&(!m_bMergesAddsDeletesOccurred
))
994 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
995 if ((dwAutoClose
== CLOSE_LOCAL
)&&(!m_bErrorsOccurred
)&&(m_nConflicts
==0)&&(localoperation
))
996 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
998 //Don't do anything here which might cause messages to be sent to the window
999 //The window thread is probably now blocked in OnOK if we've done an auto close
1003 void CGitProgressDlg::OnBnClickedLogbutton()
1005 switch(this->m_Command
)
1007 case GitProgress_Add
:
1008 case GitProgress_Resolve
:
1011 cmd
= CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe");
1012 cmd
+= _T(" /command:commit");
1014 cmd
+= _T(" /path:\"")+g_Git
.m_CurrentDir
+_T("\"");
1016 CAppUtils::LaunchApplication(cmd
,NULL
,false);
1017 this->EndDialog(IDOK
);
1022 if (m_targetPathList
.GetCount() != 1)
1024 StringRevMap::iterator it
= m_UpdateStartRevMap
.begin();
1025 svn_revnum_t rev
= -1;
1026 if (it
!= m_UpdateStartRevMap
.end())
1031 dlg
.SetParams(m_targetPathList
[0], m_RevisionEnd
, m_RevisionEnd
, rev
, 0, TRUE
);
1037 void CGitProgressDlg::OnClose()
1041 TerminateThread(m_pThread
->m_hThread
, (DWORD
)-1);
1042 InterlockedExchange(&m_bThreadRunning
, FALSE
);
1046 m_bCancelled
= TRUE
;
1049 DialogEnableWindow(IDCANCEL
, TRUE
);
1053 void CGitProgressDlg::OnOK()
1055 if ((m_bCancelled
)&&(!m_bThreadRunning
))
1057 // I have made this wait a sensible amount of time (10 seconds) for the thread to finish
1058 // You must be careful in the thread that after posting the WM_COMMAND/IDOK message, you
1059 // don't do any more operations on the window which might require message passing
1060 // If you try to send windows messages once we're waiting here, then the thread can't finished
1061 // because the Window's message loop is blocked at this wait
1062 WaitForSingleObject(m_pThread
->m_hThread
, 10000);
1065 m_bCancelled
= TRUE
;
1068 void CGitProgressDlg::OnCancel()
1070 if ((m_bCancelled
)&&(!m_bThreadRunning
))
1071 __super::OnCancel();
1072 m_bCancelled
= TRUE
;
1075 void CGitProgressDlg::OnLvnGetdispinfoSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1077 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
1081 if (pDispInfo
->item
.mask
& LVIF_TEXT
)
1083 if (pDispInfo
->item
.iItem
< (int)m_arData
.size())
1085 const NotificationData
* data
= m_arData
[pDispInfo
->item
.iItem
];
1086 switch (pDispInfo
->item
.iSubItem
)
1089 lstrcpyn(m_columnbuf
, data
->sActionColumnText
, MAX_PATH
);
1092 lstrcpyn(m_columnbuf
, data
->sPathColumnText
, pDispInfo
->item
.cchTextMax
);
1093 if (!data
->bAuxItem
)
1095 int cWidth
= m_ProgList
.GetColumnWidth(1);
1096 cWidth
= max(12, cWidth
-12);
1097 CDC
* pDC
= m_ProgList
.GetDC();
1100 CFont
* pFont
= pDC
->SelectObject(m_ProgList
.GetFont());
1101 PathCompactPath(pDC
->GetSafeHdc(), m_columnbuf
, cWidth
);
1102 pDC
->SelectObject(pFont
);
1108 lstrcpyn(m_columnbuf
, data
->mime_type
, MAX_PATH
);
1113 pDispInfo
->item
.pszText
= m_columnbuf
;
1120 void CGitProgressDlg::OnNMCustomdrawSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1122 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
1124 // Take the default processing unless we set this to something else below.
1125 *pResult
= CDRF_DODEFAULT
;
1127 // First thing - check the draw stage. If it's the control's prepaint
1128 // stage, then tell Windows we want messages for every item.
1130 if ( CDDS_PREPAINT
== pLVCD
->nmcd
.dwDrawStage
)
1132 *pResult
= CDRF_NOTIFYITEMDRAW
;
1134 else if ( CDDS_ITEMPREPAINT
== pLVCD
->nmcd
.dwDrawStage
)
1136 // This is the prepaint stage for an item. Here's where we set the
1137 // item's text color. Our return value will tell Windows to draw the
1138 // item itself, but it will use the new color we set here.
1140 // Tell Windows to paint the control itself.
1141 *pResult
= CDRF_DODEFAULT
;
1143 ASSERT(pLVCD
->nmcd
.dwItemSpec
< m_arData
.size());
1144 if(pLVCD
->nmcd
.dwItemSpec
>= m_arData
.size())
1148 const NotificationData
* data
= m_arData
[pLVCD
->nmcd
.dwItemSpec
];
1149 ASSERT(data
!= NULL
);
1153 // Store the color back in the NMLVCUSTOMDRAW struct.
1154 pLVCD
->clrText
= data
->color
;
1158 void CGitProgressDlg::OnNMDblclkSvnprogress(NMHDR
* /*pNMHDR*/, LRESULT
* /*pResult*/)
1161 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1163 if (pNMLV
->iItem
< 0)
1165 if (m_options
& ProgOptDryRun
)
1166 return; //don't do anything in a dry-run.
1168 const NotificationData
* data
= m_arData
[pNMLV
->iItem
];
1172 if (data
->bConflictedActionItem
)
1174 // We've double-clicked on a conflicted item - do a three-way merge on it
1175 SVNDiff::StartConflictEditor(data
->path
);
1177 else if ((data
->action
== svn_wc_notify_update_update
) && ((data
->content_state
== svn_wc_notify_state_merged
)||(GitProgress_Merge
== m_Command
)) || (data
->action
== svn_wc_notify_resolved
))
1179 // This is a modified file which has been merged on update. Diff it against base
1180 CTGitPath temporaryFile
;
1181 SVNDiff
diff(this, this->m_hWnd
, true);
1182 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1183 svn_revnum_t baseRev
= 0;
1184 diff
.DiffFileAgainstBase(data
->path
, baseRev
);
1186 else if ((!data
->bAuxItem
)&&(data
->path
.Exists())&&(!data
->path
.IsDirectory()))
1188 bool bOpenWith
= false;
1189 int ret
= (int)ShellExecute(m_hWnd
, NULL
, data
->path
.GetWinPath(), NULL
, NULL
, SW_SHOWNORMAL
);
1190 if (ret
<= HINSTANCE_ERROR
)
1194 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1195 cmd
+= data
->path
.GetWinPathString() + _T(" ");
1196 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1202 void CGitProgressDlg::OnHdnItemclickSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1204 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1205 if (m_bThreadRunning
)
1207 if (m_nSortedColumn
== phdr
->iItem
)
1208 m_bAscending
= !m_bAscending
;
1210 m_bAscending
= TRUE
;
1211 m_nSortedColumn
= phdr
->iItem
;
1215 m_ProgList
.SetRedraw(FALSE
);
1216 m_ProgList
.DeleteAllItems();
1217 m_ProgList
.SetItemCountEx (static_cast<int>(m_arData
.size()));
1219 m_ProgList
.SetRedraw(TRUE
);
1224 bool CGitProgressDlg::NotificationDataIsAux(const NotificationData
* pData
)
1226 return pData
->bAuxItem
;
1229 LRESULT
CGitProgressDlg::OnGitProgress(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
1232 SVNProgress
* pProgressData
= (SVNProgress
*)lParam
;
1233 CProgressCtrl
* progControl
= (CProgressCtrl
*)GetDlgItem(IDC_PROGRESSBAR
);
1234 if ((pProgressData
->total
> 1000)&&(!progControl
->IsWindowVisible()))
1236 progControl
->ShowWindow(SW_SHOW
);
1238 if (((pProgressData
->total
< 0)&&(pProgressData
->progress
> 1000)&&(progControl
->IsWindowVisible()))&&(m_itemCountTotal
<0))
1240 progControl
->ShowWindow(SW_HIDE
);
1242 if (!GetDlgItem(IDC_PROGRESSLABEL
)->IsWindowVisible())
1243 GetDlgItem(IDC_PROGRESSLABEL
)->ShowWindow(SW_SHOW
);
1244 SetTimer(TRANSFERTIMER
, 2000, NULL
);
1245 if ((pProgressData
->total
> 0)&&(pProgressData
->progress
> 1000))
1247 progControl
->SetPos((int)pProgressData
->progress
);
1248 progControl
->SetRange32(0, (int)pProgressData
->total
);
1251 if (pProgressData
->overall_total
< 1024)
1252 m_sTotalBytesTransferred
.Format(IDS_SVN_PROGRESS_TOTALBYTESTRANSFERRED
, pProgressData
->overall_total
);
1253 else if (pProgressData
->overall_total
< 1200000)
1254 m_sTotalBytesTransferred
.Format(IDS_SVN_PROGRESS_TOTALTRANSFERRED
, pProgressData
->overall_total
/ 1024);
1256 m_sTotalBytesTransferred
.Format(IDS_SVN_PROGRESS_TOTALMBTRANSFERRED
, (double)((double)pProgressData
->overall_total
/ 1024000.0));
1257 progText
.Format(IDS_SVN_PROGRESS_TOTALANDSPEED
, (LPCTSTR
)m_sTotalBytesTransferred
, (LPCTSTR
)pProgressData
->SpeedString
);
1258 SetDlgItemText(IDC_PROGRESSLABEL
, progText
);
1263 void CGitProgressDlg::OnTimer(UINT_PTR nIDEvent
)
1265 if (nIDEvent
== TRANSFERTIMER
)
1269 progSpeed
.Format(IDS_SVN_PROGRESS_BYTES_SEC
, 0);
1270 progText
.Format(IDS_SVN_PROGRESS_TOTALANDSPEED
, (LPCTSTR
)m_sTotalBytesTransferred
, (LPCTSTR
)progSpeed
);
1271 SetDlgItemText(IDC_PROGRESSLABEL
, progText
);
1272 KillTimer(TRANSFERTIMER
);
1274 if (nIDEvent
== VISIBLETIMER
)
1276 if (nEnsureVisibleCount
)
1277 m_ProgList
.EnsureVisible(m_ProgList
.GetItemCount()-1, false);
1278 nEnsureVisibleCount
= 0;
1282 void CGitProgressDlg::Sort()
1284 if(m_arData
.size() < 2)
1289 // We need to sort the blocks which lie between the auxiliary entries
1290 // This is so that any aux data stays where it was
1291 NotificationDataVect::iterator actionBlockBegin
;
1292 NotificationDataVect::iterator actionBlockEnd
= m_arData
.begin(); // We start searching from here
1296 // Search to the start of the non-aux entry in the next block
1297 actionBlockBegin
= std::find_if(actionBlockEnd
, m_arData
.end(), std::not1(std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux
)));
1298 if(actionBlockBegin
== m_arData
.end())
1300 // There are no more actions
1303 // Now search to find the end of the block
1304 actionBlockEnd
= std::find_if(actionBlockBegin
+1, m_arData
.end(), std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux
));
1305 // Now sort the block
1306 std::sort(actionBlockBegin
, actionBlockEnd
, &CGitProgressDlg::SortCompare
);
1310 bool CGitProgressDlg::SortCompare(const NotificationData
* pData1
, const NotificationData
* pData2
)
1313 switch (m_nSortedColumn
)
1315 case 0: //action column
1316 result
= pData1
->sActionColumnText
.Compare(pData2
->sActionColumnText
);
1318 case 1: //path column
1319 // Compare happens after switch()
1321 case 2: //mime-type column
1322 result
= pData1
->mime_type
.Compare(pData2
->mime_type
);
1328 // Sort by path if everything else is equal
1331 result
= CTGitPath::Compare(pData1
->path
, pData2
->path
);
1339 BOOL
CGitProgressDlg::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
1341 if (!GetDlgItem(IDOK
)->IsWindowEnabled())
1343 // only show the wait cursor over the list control
1344 if ((pWnd
)&&(pWnd
== GetDlgItem(IDC_SVNPROGRESS
)))
1346 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
1351 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
1353 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1356 BOOL
CGitProgressDlg::PreTranslateMessage(MSG
* pMsg
)
1358 if (pMsg
->message
== WM_KEYDOWN
)
1360 if (pMsg
->wParam
== VK_ESCAPE
)
1362 // pressing the ESC key should close the dialog. But since we disabled the escape
1363 // key (so the user doesn't get the idea that he could simply undo an e.g. update)
1365 // So if the user presses the ESC key, change it to VK_RETURN so the dialog gets
1366 // the impression that the OK button was pressed.
1367 if ((!m_bThreadRunning
)&&(!GetDlgItem(IDCANCEL
)->IsWindowEnabled())
1368 &&(GetDlgItem(IDOK
)->IsWindowEnabled())&&(GetDlgItem(IDOK
)->IsWindowVisible()))
1370 // since we convert ESC to RETURN, make sure the OK button has the focus.
1371 GetDlgItem(IDOK
)->SetFocus();
1372 pMsg
->wParam
= VK_RETURN
;
1375 if (pMsg
->wParam
== 'A')
1377 if (GetKeyState(VK_CONTROL
)&0x8000)
1379 // Ctrl-A -> select all
1380 m_ProgList
.SetSelectionMark(0);
1381 for (int i
=0; i
<m_ProgList
.GetItemCount(); ++i
)
1383 m_ProgList
.SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
1387 if ((pMsg
->wParam
== 'C')||(pMsg
->wParam
== VK_INSERT
))
1389 int selIndex
= m_ProgList
.GetSelectionMark();
1392 if (GetKeyState(VK_CONTROL
)&0x8000)
1394 //Ctrl-C -> copy to clipboard
1396 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1401 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1402 CString sAction
= m_ProgList
.GetItemText(nItem
, 0);
1403 CString sPath
= m_ProgList
.GetItemText(nItem
, 1);
1404 CString sMime
= m_ProgList
.GetItemText(nItem
, 2);
1405 CString sLogCopyText
;
1406 sLogCopyText
.Format(_T("%s: %s %s\r\n"),
1407 (LPCTSTR
)sAction
, (LPCTSTR
)sPath
, (LPCTSTR
)sMime
);
1408 sClipdata
+= sLogCopyText
;
1410 CStringUtils::WriteAsciiStringToClipboard(sClipdata
);
1415 } // if (pMsg->message == WM_KEYDOWN)
1416 return __super::PreTranslateMessage(pMsg
);
1419 void CGitProgressDlg::OnContextMenu(CWnd
* /*pWnd*/, CPoint
/*point*/)
1422 if (m_options
& ProgOptDryRun
)
1423 return; // don't do anything in a dry-run.
1425 if (pWnd
== &m_ProgList
)
1427 int selIndex
= m_ProgList
.GetSelectionMark();
1428 if ((point
.x
== -1) && (point
.y
== -1))
1430 // Menu was invoked from the keyboard rather than by right-clicking
1432 m_ProgList
.GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
1433 m_ProgList
.ClientToScreen(&rect
);
1434 point
= rect
.CenterPoint();
1437 if ((selIndex
>= 0)&&(!m_bThreadRunning
))
1439 // entry is selected, thread has finished with updating so show the popup menu
1441 if (popup
.CreatePopupMenu())
1443 bool bAdded
= false;
1444 NotificationData
* data
= m_arData
[selIndex
];
1445 if ((data
)&&(!data
->path
.IsDirectory()))
1447 if (data
->action
== svn_wc_notify_update_update
|| data
->action
== svn_wc_notify_resolved
)
1449 if (m_ProgList
.GetSelectedCount() == 1)
1451 popup
.AppendMenuIcon(ID_COMPARE
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
1455 if (data
->bConflictedActionItem
)
1457 if (m_ProgList
.GetSelectedCount() == 1)
1459 popup
.AppendMenuIcon(ID_EDITCONFLICT
, IDS_MENUCONFLICT
,IDI_CONFLICT
);
1460 popup
.SetDefaultItem(ID_EDITCONFLICT
, FALSE
);
1461 popup
.AppendMenuIcon(ID_CONFLICTRESOLVE
, IDS_SVNPROGRESS_MENUMARKASRESOLVED
,IDI_RESOLVE
);
1463 popup
.AppendMenuIcon(ID_CONFLICTUSETHEIRS
, IDS_SVNPROGRESS_MENUUSETHEIRS
,IDI_RESOLVE
);
1464 popup
.AppendMenuIcon(ID_CONFLICTUSEMINE
, IDS_SVNPROGRESS_MENUUSEMINE
,IDI_RESOLVE
);
1466 else if ((data
->content_state
== svn_wc_notify_state_merged
)||(GitProgress_Merge
== m_Command
)||(data
->action
== svn_wc_notify_resolved
))
1467 popup
.SetDefaultItem(ID_COMPARE
, FALSE
);
1469 if (m_ProgList
.GetSelectedCount() == 1)
1471 if ((data
->action
== svn_wc_notify_add
)||
1472 (data
->action
== svn_wc_notify_update_add
)||
1473 (data
->action
== svn_wc_notify_commit_added
)||
1474 (data
->action
== svn_wc_notify_commit_modified
)||
1475 (data
->action
== svn_wc_notify_restore
)||
1476 (data
->action
== svn_wc_notify_revert
)||
1477 (data
->action
== svn_wc_notify_resolved
)||
1478 (data
->action
== svn_wc_notify_commit_replaced
)||
1479 (data
->action
== svn_wc_notify_commit_modified
)||
1480 (data
->action
== svn_wc_notify_commit_postfix_txdelta
)||
1481 (data
->action
== svn_wc_notify_update_update
))
1483 popup
.AppendMenuIcon(ID_LOG
, IDS_MENULOG
,IDI_LOG
);
1484 if (data
->action
== svn_wc_notify_update_update
)
1485 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1486 popup
.AppendMenuIcon(ID_OPEN
, IDS_LOG_POPUP_OPEN
, IDI_OPEN
);
1487 popup
.AppendMenuIcon(ID_OPENWITH
, IDS_LOG_POPUP_OPENWITH
, IDI_OPEN
);
1491 } // if ((data)&&(!data->path.IsDirectory()))
1492 if (m_ProgList
.GetSelectedCount() == 1)
1496 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1497 if ((!sPath
.IsEmpty())&&(!SVN::PathIsURL(CTGitPath(sPath
))))
1499 CTGitPath path
= CTGitPath(sPath
);
1500 if (path
.GetDirectory().Exists())
1502 popup
.AppendMenuIcon(ID_EXPLORE
, IDS_SVNPROGRESS_MENUOPENPARENT
, IDI_EXPLORER
);
1508 if (m_ProgList
.GetSelectedCount() > 0)
1511 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1512 popup
.AppendMenuIcon(ID_COPY
, IDS_LOG_POPUP_COPYTOCLIPBOARD
,IDI_COPYCLIP
);
1517 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1518 DialogEnableWindow(IDOK
, FALSE
);
1519 this->SetPromptApp(&theApp
);
1520 theApp
.DoWaitCursor(1);
1521 bool bOpenWith
= false;
1527 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1530 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1531 NotificationData
* data
= m_arData
[nItem
];
1534 sLines
+= data
->sPathColumnText
;
1535 sLines
+= _T("\r\n");
1539 if (!sLines
.IsEmpty())
1541 CStringUtils::WriteAsciiStringToClipboard(sLines
, GetSafeHwnd());
1547 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1549 CTGitPath path
= CTGitPath(sPath
);
1550 ShellExecute(m_hWnd
, _T("explore"), path
.GetDirectory().GetWinPath(), NULL
, path
.GetDirectory().GetWinPath(), SW_SHOW
);
1555 svn_revnum_t rev
= -1;
1556 StringRevMap::iterator it
= m_UpdateStartRevMap
.end();
1557 if (data
->basepath
.IsEmpty())
1558 it
= m_UpdateStartRevMap
.begin();
1560 it
= m_UpdateStartRevMap
.find(data
->basepath
.GetSVNApiPath(pool
));
1561 if (it
!= m_UpdateStartRevMap
.end())
1563 // if the file was merged during update, do a three way diff between OLD, MINE, THEIRS
1564 if (data
->content_state
== svn_wc_notify_state_merged
)
1566 CTGitPath basefile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, rev
);
1567 CTGitPath newfile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, SVNRev::REV_HEAD
);
1569 if (!svn
.Cat(data
->path
, SVNRev(SVNRev::REV_WC
), rev
, basefile
))
1571 CMessageBox::Show(m_hWnd
, svn
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1572 DialogEnableWindow(IDOK
, TRUE
);
1575 // If necessary, convert the line-endings on the file before diffing
1576 if ((DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\ConvertBase"), TRUE
))
1578 CTGitPath temporaryFile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, SVNRev::REV_BASE
);
1579 if (!svn
.Cat(data
->path
, SVNRev(SVNRev::REV_BASE
), SVNRev(SVNRev::REV_BASE
), temporaryFile
))
1581 temporaryFile
.Reset();
1586 newfile
= temporaryFile
;
1590 SetFileAttributes(newfile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1591 SetFileAttributes(basefile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1592 CString revname
, wcname
, basename
;
1593 revname
.Format(_T("%s Revision %ld"), (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName(), rev
);
1594 wcname
.Format(IDS_DIFF_WCNAME
, (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName());
1595 basename
.Format(IDS_DIFF_BASENAME
, (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName());
1596 CAppUtils::StartExtMerge(basefile
, newfile
, data
->path
, data
->path
, basename
, revname
, wcname
, CString(), true);
1600 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, rev
);
1602 if (!svn
.Cat(data
->path
, SVNRev(SVNRev::REV_WC
), rev
, tempfile
))
1604 CMessageBox::Show(m_hWnd
, svn
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1605 DialogEnableWindow(IDOK
, TRUE
);
1610 SetFileAttributes(tempfile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1611 CString revname
, wcname
;
1612 revname
.Format(_T("%s Revision %ld"), (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName(), rev
);
1613 wcname
.Format(IDS_DIFF_WCNAME
, (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName());
1614 CAppUtils::StartExtDiff(
1615 tempfile
, data
->path
, revname
, wcname
,
1616 CAppUtils::DiffFlags().AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000)));
1621 case ID_EDITCONFLICT
:
1623 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1624 SVNDiff::StartConflictEditor(CTGitPath(sPath
));
1627 case ID_CONFLICTUSETHEIRS
:
1628 case ID_CONFLICTUSEMINE
:
1629 case ID_CONFLICTRESOLVE
:
1631 svn_wc_conflict_choice_t result
= svn_wc_conflict_choose_merged
;
1634 case ID_CONFLICTUSETHEIRS
:
1635 result
= svn_wc_conflict_choose_theirs_full
;
1637 case ID_CONFLICTUSEMINE
:
1638 result
= svn_wc_conflict_choose_mine_full
;
1640 case ID_CONFLICTRESOLVE
:
1641 result
= svn_wc_conflict_choose_merged
;
1645 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1646 CString sResolvedPaths
;
1649 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1650 NotificationData
* data
= m_arData
[nItem
];
1653 if (data
->bConflictedActionItem
)
1655 if (!svn
.Resolve(data
->path
, result
, FALSE
))
1657 CMessageBox::Show(m_hWnd
, svn
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1658 DialogEnableWindow(IDOK
, TRUE
);
1663 data
->color
= ::GetSysColor(COLOR_WINDOWTEXT
);
1664 data
->action
= svn_wc_notify_resolved
;
1665 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESOLVE
);
1666 data
->bConflictedActionItem
= false;
1669 if (m_nConflicts
==0)
1671 // When the last conflict is resolved we remove
1672 // the warning which we assume is in the last line.
1673 int nIndex
= m_ProgList
.GetItemCount()-1;
1674 VERIFY(m_ProgList
.DeleteItem(nIndex
));
1676 delete m_arData
[nIndex
];
1677 m_arData
.pop_back();
1679 sResolvedPaths
+= data
->path
.GetWinPathString() + _T("\n");
1684 m_ProgList
.Invalidate();
1685 CString info
= BuildInfoString();
1686 SetDlgItemText(IDC_INFOTEXT
, info
);
1688 if (!sResolvedPaths
.IsEmpty())
1691 msg
.Format(IDS_SVNPROGRESS_RESOLVED
, (LPCTSTR
)sResolvedPaths
);
1692 CMessageBox::Show(m_hWnd
, msg
, _T("TortoiseGit"), MB_OK
| MB_ICONINFORMATION
);
1698 svn_revnum_t rev
= m_RevisionEnd
;
1699 if (!data
->basepath
.IsEmpty())
1701 StringRevMap::iterator it
= m_FinishedRevMap
.find(data
->basepath
.GetSVNApiPath(pool
));
1702 if (it
!= m_FinishedRevMap
.end())
1706 // fetch the log from HEAD, not the revision we updated to:
1707 // the path might be inside an external folder which has its own
1709 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1710 dlg
.SetParams(CTGitPath(sPath
), SVNRev(), SVNRev::REV_HEAD
, 1, -1, TRUE
);
1719 CString sWinPath
= GetPathFromColumnText(data
->sPathColumnText
);
1721 ret
= (int)ShellExecute(this->m_hWnd
, NULL
, (LPCTSTR
)sWinPath
, NULL
, NULL
, SW_SHOWNORMAL
);
1722 if ((ret
<= HINSTANCE_ERROR
)||bOpenWith
)
1724 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1725 cmd
+= sWinPath
+ _T(" ");
1726 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1730 DialogEnableWindow(IDOK
, TRUE
);
1731 theApp
.DoWaitCursor(-1);
1739 void CGitProgressDlg::OnEnSetfocusInfotext()
1742 GetDlgItemText(IDC_INFOTEXT
, sTemp
);
1743 if (sTemp
.IsEmpty())
1744 GetDlgItem(IDC_INFOTEXT
)->HideCaret();
1747 void CGitProgressDlg::OnLvnBegindragSvnprogress(NMHDR
* , LRESULT
*pResult
)
1749 //LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
1751 int selIndex
= m_ProgList
.GetSelectionMark();
1755 CDropFiles dropFiles
; // class for creating DROPFILES struct
1758 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1759 while ( (index
= m_ProgList
.GetNextSelectedItem(pos
)) >= 0 )
1761 NotificationData
* data
= m_arData
[index
];
1763 if ( data
->kind
==svn_node_file
|| data
->kind
==svn_node_dir
)
1765 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1767 dropFiles
.AddFile( sPath
);
1771 if ( dropFiles
.GetCount()>0 )
1773 dropFiles
.CreateStructure();
1779 void CGitProgressDlg::OnSize(UINT nType
, int cx
, int cy
)
1781 CResizableStandAloneDialog::OnSize(nType
, cx
, cy
);
1782 if ((nType
== SIZE_RESTORED
)&&(m_bLastVisible
))
1784 if(!m_ProgList
.m_hWnd
)
1787 int count
= m_ProgList
.GetItemCount();
1789 m_ProgList
.EnsureVisible(count
-1, false);
1793 //////////////////////////////////////////////////////////////////////////
1795 //////////////////////////////////////////////////////////////////////////
1796 bool CGitProgressDlg::CmdAdd(CString
& sWindowTitle
, bool& localoperation
)
1798 localoperation
= true;
1799 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_ADD
);
1800 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
1801 SetBackgroundImage(IDI_ADD_BKG
);
1802 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_ADD
)));
1804 git_repository
*repo
= NULL
;
1807 CStringA gitdir
= CUnicodeUtils::GetMulti(CTGitPath(g_Git
.m_CurrentDir
).GetGitPathString() + _T("/.git"), CP_ACP
);
1808 if (git_repository_open(&repo
, gitdir
.GetBuffer()))
1813 if (git_repository_index(&index
, repo
))
1816 git_repository_free(repo
);
1819 if (git_index_read(index
))
1822 git_index_free(index
);
1823 git_repository_free(repo
);
1827 for(int i
=0;i
<m_targetPathList
.GetCount();i
++)
1829 if (git_index_add(index
, CStringA(CUnicodeUtils::GetMulti(m_targetPathList
[i
].GetGitPathString(), CP_ACP
)).GetBuffer(), 0))
1832 git_index_free(index
);
1833 git_repository_free(repo
);
1836 Notify(m_targetPathList
[i
],git_wc_notify_add
);
1839 if (git_index_write(index
))
1842 git_index_free(index
);
1843 git_repository_free(repo
);
1847 git_index_free(index
);
1848 git_repository_free(repo
);
1850 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList
);
1851 m_bErrorsOccurred
=false;
1853 this->GetDlgItem(IDC_LOGBUTTON
)->SetWindowText(_T("Commit ..."));
1854 this->GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
1858 bool CGitProgressDlg::CmdCopy(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
1861 ASSERT(m_targetPathList
.GetCount() == 1);
1862 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_COPY
);
1863 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
1864 SetBackgroundImage(IDI_COPY_BKG
);
1867 sCmdInfo
.Format(IDS_PROGRS_CMD_COPY
,
1868 m_targetPathList
[0].IsUrl() ? (LPCTSTR
)m_targetPathList
[0].GetSVNPathString() : m_targetPathList
[0].GetWinPath(),
1869 (LPCTSTR
)m_url
.GetSVNPathString(), (LPCTSTR
)m_Revision
.ToString());
1870 ReportCmd(sCmdInfo
);
1872 if (!Copy(m_targetPathList
, m_url
, m_Revision
, m_pegRev
, m_sMessage
))
1877 if (m_options
& ProgOptSwitchAfterCopy
)
1879 sCmdInfo
.Format(IDS_PROGRS_CMD_SWITCH
,
1880 m_targetPathList
[0].GetWinPath(),
1881 (LPCTSTR
)m_url
.GetSVNPathString(), (LPCTSTR
)m_Revision
.ToString());
1882 ReportCmd(sCmdInfo
);
1883 if (!Switch(m_targetPathList
[0], m_url
, SVNRev::REV_HEAD
, SVNRev::REV_HEAD
, m_depth
, TRUE
, m_options
& ProgOptIgnoreExternals
))
1885 if (!Switch(m_targetPathList
[0], m_url
, SVNRev::REV_HEAD
, m_Revision
, m_depth
, TRUE
, m_options
& ProgOptIgnoreExternals
))
1894 if (SVN::PathIsURL(m_url
))
1896 CString
sMsg(MAKEINTRESOURCE(IDS_PROGRS_COPY_WARNING
));
1897 ReportNotification(sMsg
);
1904 bool CGitProgressDlg::CmdExport(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
1907 ASSERT(m_targetPathList
.GetCount() == 1);
1908 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_EXPORT
);
1909 sWindowTitle
= m_url
.GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle
;
1910 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
1911 SetBackgroundImage(IDI_EXPORT_BKG
);
1913 if (m_options
& ProgOptEolCRLF
)
1915 if (m_options
& ProgOptEolLF
)
1917 if (m_options
& ProgOptEolCR
)
1919 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_EXPORT
)));
1920 if (!Export(m_url
, m_targetPathList
[0], m_Revision
, m_Revision
, TRUE
, m_options
& ProgOptIgnoreExternals
, m_depth
, NULL
, FALSE
, eol
))
1929 bool CGitProgressDlg::CmdRename(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
1932 ASSERT(m_targetPathList
.GetCount() == 1);
1933 if ((!m_targetPathList
[0].IsUrl())&&(!m_url
.IsUrl()))
1934 localoperation
= true;
1935 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_RENAME
);
1936 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
1937 SetBackgroundImage(IDI_RENAME_BKG
);
1938 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RENAME
)));
1939 if (!Move(m_targetPathList
, m_url
, m_Revision
, m_sMessage
))
1948 bool CGitProgressDlg::CmdResolve(CString
& sWindowTitle
, bool& localoperation
)
1951 localoperation
= true;
1952 ASSERT(m_targetPathList
.GetCount() == 1);
1953 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_RESOLVE
);
1954 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
1955 SetBackgroundImage(IDI_RESOLVE_BKG
);
1956 // check if the file may still have conflict markers in it.
1957 //BOOL bMarkers = FALSE;
1959 for(int i
=0;i
<m_targetPathList
.GetCount();i
++)
1961 CString cmd
,out
,tempmergefile
;
1962 cmd
.Format(_T("git.exe add -f -- \"%s\""),m_targetPathList
[i
].GetGitPathString());
1963 if(g_Git
.Run(cmd
,&out
,CP_ACP
))
1965 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
1966 m_bErrorsOccurred
=true;
1970 CAppUtils::RemoveTempMergeFile((CTGitPath
&)m_targetPathList
[i
]);
1972 Notify(m_targetPathList
[i
],git_wc_notify_resolved
);
1975 if ((m_options
& ProgOptSkipConflictCheck
) == 0)
1979 for (INT_PTR fileindex
=0; (fileindex
<m_targetPathList
.GetCount()) && (bMarkers
==FALSE
); ++fileindex
)
1981 if (!m_targetPathList
[fileindex
].IsDirectory())
1983 CStdioFile
file(m_targetPathList
[fileindex
].GetWinPath(), CFile::typeBinary
| CFile::modeRead
);
1984 CString strLine
= _T("");
1985 while (file
.ReadString(strLine
))
1987 if (strLine
.Find(_T("<<<<<<<"))==0)
1997 catch (CFileException
* pE
)
1999 TRACE(_T("CFileException in Resolve!\n"));
2000 TCHAR error
[10000] = {0};
2001 pE
->GetErrorMessage(error
, 10000);
2009 if (CMessageBox::Show(m_hWnd
, IDS_PROGRS_REVERTMARKERS
, IDS_APPNAME
, MB_YESNO
| MB_ICONQUESTION
)==IDYES
)
2011 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE
)));
2012 for (INT_PTR fileindex
=0; fileindex
<m_targetPathList
.GetCount(); ++fileindex
)
2013 Resolve(m_targetPathList
[fileindex
], svn_wc_conflict_choose_merged
, true);
2018 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE
)));
2019 for (INT_PTR fileindex
=0; fileindex
<m_targetPathList
.GetCount(); ++fileindex
)
2020 Resolve(m_targetPathList
[fileindex
], svn_wc_conflict_choose_merged
, true);
2023 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList
);
2025 this->GetDlgItem(IDC_LOGBUTTON
)->SetWindowText(_T("Commit ..."));
2026 this->GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
2031 bool CGitProgressDlg::CmdRevert(CString
& sWindowTitle
, bool& localoperation
)
2034 localoperation
= true;
2035 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_REVERT
);
2036 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
2037 SetBackgroundImage(IDI_REVERT_BKG
);
2039 CTGitPathList delList
;
2040 for(int i
=0;i
<m_selectedPaths
.GetCount();i
++)
2044 path
.SetFromWin(g_Git
.m_CurrentDir
+_T("\\")+m_selectedPaths
[i
].GetWinPath());
2045 action
= m_selectedPaths
[i
].m_Action
;
2046 /* rename file can't delete because it needs original file*/
2047 if((!(action
& CTGitPath::LOGACTIONS_ADDED
)) &&
2048 (!(action
& CTGitPath::LOGACTIONS_REPLACED
)))
2049 delList
.AddPath(path
);
2051 if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RevertWithRecycleBin"), TRUE
)))
2052 delList
.DeleteAllFiles(true);
2054 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_REVERT
)));
2055 for(int i
=0;i
<m_selectedPaths
.GetCount();i
++)
2057 if(g_Git
.Revert(_T("HEAD"), (CTGitPath
&)m_selectedPaths
[i
]))
2059 CMessageBox::Show(NULL
,_T("Revert Fail"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2060 m_bErrorsOccurred
=true;
2063 Notify(m_selectedPaths
[i
],git_wc_notify_revert
);
2066 CShellUpdater::Instance().AddPathsForUpdate(m_selectedPaths
);
2071 bool CGitProgressDlg::CmdSwitch(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
2074 ASSERT(m_targetPathList
.GetCount() == 1);
2076 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_SWITCH
);
2077 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
2078 SetBackgroundImage(IDI_SWITCH_BKG
);
2080 if (st
.GetStatus(m_targetPathList
[0]) != (-2))
2082 if (st
.status
->entry
!= NULL
)
2084 rev
= st
.status
->entry
->revision
;
2089 sCmdInfo
.Format(IDS_PROGRS_CMD_SWITCH
,
2090 m_targetPathList
[0].GetWinPath(), (LPCTSTR
)m_url
.GetSVNPathString(),
2091 (LPCTSTR
)m_Revision
.ToString());
2092 ReportCmd(sCmdInfo
);
2094 bool depthIsSticky
= true;
2095 if (m_depth
== svn_depth_unknown
)
2096 depthIsSticky
= false;
2097 if (!Switch(m_targetPathList
[0], m_url
, m_Revision
, m_Revision
, m_depth
, depthIsSticky
, m_options
& ProgOptIgnoreExternals
))
2102 m_UpdateStartRevMap
[m_targetPathList
[0].GetSVNApiPath(pool
)] = rev
;
2103 if ((m_RevisionEnd
>= 0)&&(rev
>= 0)
2104 &&((LONG
)m_RevisionEnd
> (LONG
)rev
))
2106 GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
2112 void CGitProgressDlg::OnBnClickedNoninteractive()
2114 LRESULT res
= ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE
)->GetSafeHwnd(), BM_GETCHECK
, 0, 0);
2115 m_AlwaysConflicted
= (res
== BST_CHECKED
);
2116 CRegDWORD nonint
= CRegDWORD(_T("Software\\TortoiseGit\\MergeNonInteractive"), FALSE
);
2117 nonint
= m_AlwaysConflicted
;
2120 CString
CGitProgressDlg::GetPathFromColumnText(const CString
& sColumnText
)
2122 CString sPath
= CPathUtils::ParsePathInString(sColumnText
);
2123 if (sPath
.Find(':')<0)
2125 // the path is not absolute: add the common root of all paths to it
2126 sPath
= m_targetPathList
.GetCommonRoot().GetDirectory().GetWinPathString() + _T("\\") + CPathUtils::ParsePathInString(sColumnText
);
2131 bool CGitProgressDlg::CmdSendMail(CString
& sWindowTitle
, bool& /*localoperation*/)
2133 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_SENDMAIL
);
2134 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
2135 //SetBackgroundImage(IDI_ADD_BKG);
2136 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_SENDMAIL
)));
2138 if(this->m_SendMailFlags
&SENDMAIL_COMBINED
)
2142 Notify(path
,git_wc_notify_sendmail_start
);
2147 if(!!CPatch::SendPatchesCombined(m_targetPathList
,m_SendMailTO
,m_SendMailCC
,m_SendMailSubject
,!!(this->m_SendMailFlags
&SENDMAIL_ATTACHMENT
),!!(this->m_SendMailFlags
&SENDMAIL_MAPI
),&err
))
2149 Notify(path
,git_wc_notify_sendmail_error
,ret
,&err
);
2159 Notify(path
,git_wc_notify_sendmail_retry
,ret
,&err
);
2163 CString
str(_T("User Canceled"));
2164 Notify(path
,git_wc_notify_sendmail_error
,ret
,&str
);
2169 Notify(path
,git_wc_notify_sendmail_done
,ret
);
2173 for(int i
=0;ret
&& i
<m_targetPathList
.GetCount();i
++)
2176 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_start
);
2181 if(!!patch
.Send((CString
&)m_targetPathList
[i
].GetWinPathString(),this->m_SendMailTO
,
2182 this->m_SendMailCC
,!!(this->m_SendMailFlags
&SENDMAIL_ATTACHMENT
),!!(this->m_SendMailFlags
&SENDMAIL_MAPI
)))
2184 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_error
,ret
,&patch
.m_LastError
);
2195 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_retry
,ret
,&patch
.m_LastError
);
2199 CString
str(_T("User Canceled"));
2200 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_error
,ret
,&str
);
2205 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_done
,ret
);