Changeset ca343468d05b…
Parent b24bad149059…
by
Changes to 15 files · Browse files at ca343468d05b Showing diff from parent b24bad149059 Diff from another changeset...
@@ -27,11 +27,17 @@ m_pParent(pParent), m_strName(strName)
{
if (strName.IsEmpty())
+ {
m_strPath = strBasePath;
+ }
else if (strBasePath.IsEmpty())
+ {
m_strPath = strName;
+ }
else
+ {
m_strPath = strBasePath + '/' + strName;
+ }
}
CDirectory::~CDirectory()
@@ -45,8 +51,7 @@
int SplitBase(const CString& strPath, CString& strBase, CString& strRest)
{
- if (strPath.IsEmpty())
- return 0;
+ if (strPath.IsEmpty()) return 0;
int nPos = strPath.Find('/');
if (nPos == -1)
@@ -56,8 +61,7 @@ return 1;
}
- if (nPos == 0 || nPos == strPath.GetLength() - 1)
- return 0;
+ if (nPos == 0 || nPos == strPath.GetLength() - 1) return 0;
strBase = strPath.Left(nPos);
strRest = strPath.Mid(nPos + 1);
@@ -136,8 +140,7 @@ while (position != NULL)
{
const CDirentry& rItem = pCur->m_listFiles.GetNext(position);
- if (rItem.m_strName == strRelPath)
- return &rItem;
+ if (rItem.m_strName == strRelPath) return &rItem;
}
return 0;
}
@@ -185,8 +188,7 @@ CDirectory* pItem = pCur->m_listSubdirs.GetNext(position);
if (pItem->m_strName == strSearch)
{
- if (bLeaf)
- return pItem;
+ if (bLeaf) return pItem;
pCur = pItem;
strRelPath = strRest;
goto loopstart;
@@ -225,11 +227,13 @@ rItem.m_strName);
t = rItem.m_uMTime;
errno_t err = ctime_s(ctime_res, 26, &t);
- if (err == 0) {
+ if (err == 0)
+ {
str = ctime_res;
str.Truncate(str.GetLength() - 1); // strip ending '\n'
}
- else {
+ else
+ {
str = "unset";
}
printf("%c %6o %10u %-24s %s\n", rItem.m_chState, rItem.m_uMode, rItem.m_uSize,
|
@@ -39,14 +39,14 @@ break;
}
if (rEntry.chStatus == 'a')
+ {
bAdded = true;
+ }
}
}
- if (bModified)
- return 'M';
- if (bAdded)
- return 'A';
+ if (bModified) return 'M';
+ if (bAdded) return 'A';
return 'C';
}
@@ -80,10 +80,8 @@
for (;;)
{
- if (fread(&chStatus, sizeof(char), 1, pFile) != 1)
- goto close;
- if (chStatus == '\n')
- break;
+ if (fread(&chStatus, sizeof(char), 1, pFile) != 1) goto close;
+ if (chStatus == '\n') break;
strLine.AppendChar(chStatus);
if (strLine.GetLength() > 1000)
{
@@ -98,9 +96,7 @@ goto close;
}
- if (strLine.IsEmpty())
- goto close;
-
+ if (strLine.IsEmpty()) goto close;
e.chStatus = strLine[0];
CString strPath;
|
@@ -22,8 +22,7 @@
int CDirentry::Read(FILE* pFile, CString& strRelPath)
{
- if (fread(&m_chState, sizeof(char), 1, pFile) != 1)
- return 0;
+ if (fread(&m_chState, sizeof(char), 1, pFile) != 1) return 0;
unsigned nLength = 0;
|
@@ -40,11 +40,8 @@ CString strRelPath;
while (e.Read(pFile, strRelPath))
{
- if (e.Unset())
- bUnset = true;
-
- if (e.m_chState == 'a')
- ++pd->m_nNumAdded;
+ if (e.Unset()) bUnset = true;
+ if (e.m_chState == 'a') ++pd->m_nNumAdded;
pd->Add(strRelPath, e);
}
@@ -71,7 +68,8 @@{
bool bUnset;
CAutoPtr<CDirstate> pDirstate = CDirstate::Read(".hg/dirstate", bUnset);
- if ((CDirstate*)pDirstate == NULL) {
+ if ((CDirstate*)pDirstate == NULL)
+ {
printf("error: could not read .hg/dirstate\n");
return;
}
|
@@ -37,8 +37,7 @@ while (position != NULL)
{
CEntry& rItem = Cache().GetAt(position);
- if (strHgRoot == rItem.strHgRoot && bUseKbfiles == rItem.bUseKbfiles)
- break;
+ if (strHgRoot == rItem.strHgRoot && bUseKbfiles == rItem.bUseKbfiles) break;
Cache().GetNext(position);
}
@@ -94,11 +93,9 @@ {
bUnset = rItem.bUnset;
- if (!bNewStat)
- return rItem.pDirstate;
+ if (!bNewStat) return rItem.pDirstate;
- if (rItem.llMTime == stat.ullMTime
- && rItem.llSize == stat.ullSize)
+ if (rItem.llMTime == stat.ullMTime && rItem.llSize == stat.ullSize)
{
return rItem.pDirstate;
}
@@ -157,8 +154,7 @@
void CDirstateCache::Invalidate(const CString& strHgRoot, bool bUseKbfiles)
{
- if (strHgRoot.IsEmpty())
- return;
+ if (strHgRoot.IsEmpty()) return;
POSITION position = Cache().GetHeadPosition();
while (position != NULL)
|
@@ -49,8 +49,7 @@
HBITMAP CIconBitmapUtils::IconToBitmap(HICON hIcon)
{
- if (!hIcon)
- return NULL;
+ if (!hIcon) return NULL;
RECT rect;
@@ -60,12 +59,10 @@ rect.left = rect.top = 0;
HWND hwndDesktop = ::GetDesktopWindow();
- if (hwndDesktop == NULL)
- return NULL;
+ if (hwndDesktop == NULL) return NULL;
HDC hScreenDC = ::GetDC(hwndDesktop);
- if (hScreenDC == NULL)
- return NULL;
+ if (hScreenDC == NULL) return NULL;
// Create a compatible DC
HDC hDestDC = ::CreateCompatibleDC(hScreenDC);
@@ -86,8 +83,7 @@
// Select it into the compatible DC
HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hDestDC, hBitmap);
- if (hOldBitmap == NULL)
- return NULL;
+ if (hOldBitmap == NULL) return NULL;
// Fill the background of the compatible DC with the white color
// that is taken by menu routines as transparent
@@ -107,8 +103,7 @@
HBITMAP CIconBitmapUtils::IconToBitmapPARGB32(HICON hIcon)
{
- if (!hIcon)
- return NULL;
+ if (!hIcon) return NULL;
if (m_pfnBeginBufferedPaint == NULL || m_pfnEndBufferedPaint == NULL ||
m_pfnGetBufferedPaintBits == NULL)
|
@@ -21,8 +21,7 @@ bool KilnGetUrl(const CString& strPath, CString* pstrKilnUrl)
{
CString strHgRoot;
- if (!GetHgRoot(strPath, strHgRoot))
- return false;
+ if (!GetHgRoot(strPath, strHgRoot)) return false;
// Try to get the default path from hgrc.
CString strHgrcPath = strHgRoot + "\\.hg\\hgrc";
@@ -31,16 +30,17 @@ DWORD nSize = ::GetPrivateProfileString("paths", "default", "", lpszBuf,
MAX_PATH, strHgrcPath);
strDefaultPath.ReleaseBuffer(nSize);
- if (strDefaultPath.IsEmpty())
- return false;
+ if (strDefaultPath.IsEmpty()) return false;
// Check whether the repository is a Kiln repository.
CString strLower = strDefaultPath;
strLower.MakeLower();
if (strLower.Find("kilnhg.com/") == -1 && strLower.Find("/kiln/") == -1)
+ {
return false;
- if (pstrKilnUrl != NULL)
- *pstrKilnUrl = strDefaultPath;
+ }
+
+ if (pstrKilnUrl != NULL) *pstrKilnUrl = strDefaultPath;
return true;
}
|
|
@@ -46,13 +46,11 @@
bool bRes = false;
- if (strPath.IsEmpty() || strPath == "\\")
- return bRes;
+ if (strPath.IsEmpty() || strPath == "\\") return bRes;
CString strHgPath = strPath + "\\.hg";
- if (::PathIsUNCServerShare(strHgPath))
- return bRes;
+ if (::PathIsUNCServerShare(strHgPath)) return bRes;
unsigned tc0 = ::GetTickCount();
bRes = ::PathIsDirectory(strHgPath) != 0;
@@ -187,14 +185,9 @@int GetRelPath(const CString& strHgRoot, const CString& strPath, CString& strRes)
{
int nOffset = strHgRoot.GetLength();
- if (nOffset == 0)
- return 0;
-
- if (nOffset > strPath.GetLength())
- return 0;
-
- if (strPath[nOffset] == '\\')
- nOffset++;
+ if (nOffset == 0) return 0;
+ if (nOffset > strPath.GetLength()) return 0;
+ if (strPath[nOffset] == '\\') nOffset++;
strRes = strPath.Mid(nOffset);
return 1;
@@ -204,8 +197,7 @@{
static CQueryState qsLast;
- if (strPath.IsEmpty())
- return 0;
+ if (strPath.IsEmpty()) return 0;
CQueryState qsCur;
@@ -226,11 +218,8 @@ return 0;
}
- if (FindHgRoot('0', qsCur, qsLast, bOutdated) == 0)
- return 0;
-
- if (qsCur.strHgRoot.IsEmpty())
- return 0;
+ if (FindHgRoot('0', qsCur, qsLast, bOutdated) == 0) return 0;
+ if (qsCur.strHgRoot.IsEmpty()) return 0;
strHgRoot = qsCur.strHgRoot;
return 1;
@@ -243,8 +232,7 @@
static CQueryState qsLast;
- if (strPath.IsEmpty())
- return 0;
+ if (strPath.IsEmpty()) return 0;
CQueryState qsCur;
@@ -267,8 +255,7 @@ return 0;
}
- if (FindHgRoot(chClass, qsCur, qsLast, bOutdated) == 0)
- return 0;
+ if (FindHgRoot(chClass, qsCur, qsLast, bOutdated) == 0) return 0;
int nOffset = qsCur.strHgRoot.GetLength();
if (nOffset == 0)
@@ -283,8 +270,7 @@
for (int i = 0; i < strRelPath.GetLength(); ++i)
{
- if (strRelPath[i] == '\\')
- strRelPath.SetAt(i, '/');
+ if (strRelPath[i] == '\\') strRelPath.SetAt(i, '/');
}
CDirectoryStatus* pDirStatus = CDirectoryStatus::Get(qsCur.strHgRoot, qsCur.strBaseDir);
@@ -365,8 +351,7 @@
chOutStatus = e->Status(stat);
- if (bUnset)
- goto exit;
+ if (bUnset) goto exit;
bool bUpdate = false;
@@ -380,8 +365,7 @@ char chBaseDirStatus = pDirStatus->Status(strRelBase);
ATLTRACE("%s chBaseDirStatus = '%c'\n", (LPCTSTR)dp, chBaseDirStatus);
- if (chBaseDirStatus != 'M')
- bUpdate = true;
+ if (chBaseDirStatus != 'M') bUpdate = true;
}
}
else if (chOutStatus == 'P')
|
@@ -23,9 +23,7 @@
HKEY hKey = 0;
LONG lRes = ::RegOpenKeyEx(HKEY_CURRENT_USER, lpszSubKey, 0, KEY_READ, &hKey);
-
- if (lRes != ERROR_SUCCESS || hKey == 0)
- return 0;
+ if (lRes != ERROR_SUCCESS || hKey == 0) return 0;
DWORD cbData = MAX_PATH;
LPTSTR lpszData = strRes.GetBuffer(cbData);
|
@@ -22,8 +22,7 @@ {
DWORD dwSize = 260;
char szBuf[260];
- if (!::GetUserName(szBuf, &dwSize))
- return "";
+ if (!::GetUserName(szBuf, &dwSize)) return "";
CString strRes = "\\\\.\\pipe\\TortoiseHgRpcServer-bc0c27107423-";
strRes += szBuf;
return strRes;
@@ -32,9 +31,7 @@int CTHgStatus::SendRequest(const CString& strRequest)
{
static const CString strPipeName = GetPipeName();
-
- if (strPipeName.IsEmpty())
- return 0;
+ if (strPipeName.IsEmpty()) return 0;
BOOL fSuccess;
DWORD cbRead;
|
@@ -223,8 +223,7 @@ (LPCWSTR)strSubKey);
}
- if (hKey)
- ::RegCloseKey(hKey);
+ if (hKey) ::RegCloseKey(hKey);
}
void CTortoiseHgCmenuBase::InitMenuMaps(const CMenuDescription *pMenuDescs, int nCount)
@@ -440,8 +439,7 @@
void CTortoiseHgCmenuBase::TweakMenuForVista(HMENU hMenu)
{
- if (!CSysInfo::IsVistaOrLater())
- return;
+ if (!CSysInfo::IsVistaOrLater()) return;
MENUINFO mi;
memset(&mi, 0, sizeof(MENUINFO));
@@ -565,7 +563,9 @@ if (listPromoted.Find(strName) != NULL)
{
if ((strName == "kiln" || strName == "kilnfiles") && !KilnGetUrl(strCwd))
+ {
continue;
+ }
InsertMenuItemByName(hMenu, strName, indexMenu++, idCmd++, idCmdFirst, L"Hg ");
}
}
@@ -591,8 +591,11 @@ CString strName = ppszEntries[i];
if (listPromoted.Find(strName) == NULL)
{
- if ((strName == "kiln" || strName == "kilnfiles") && !KilnGetUrl(strCwd))
+ if ((strName == "kiln" || strName == "kilnfiles") &&
+ !KilnGetUrl(strCwd))
+ {
continue;
+ }
InsertMenuItemByName(hSubMenu, strName, indexSubMenu++, idCmd++,
idCmdFirst, L"");
bIsSeparator = false;
@@ -792,8 +795,7 @@ case WM_MEASUREITEM:
{
MEASUREITEMSTRUCT* lpmis = (MEASUREITEMSTRUCT*)lParam;
- if (lpmis == NULL)
- break;
+ if (lpmis == NULL) break;
lpmis->itemWidth += 2;
if(lpmis->itemHeight < 16)
lpmis->itemHeight = 16;
@@ -804,8 +806,7 @@ case WM_DRAWITEM:
{
DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam;
- if (!lpdis || (lpdis->CtlType != ODT_MENU) || !lpdis->itemData)
- break; //not for a menu
+ if (!lpdis || (lpdis->CtlType != ODT_MENU) || !lpdis->itemData) break;
::DrawIconEx(lpdis->hDC, lpdis->rcItem.left - 16,
lpdis->rcItem.top + (lpdis->rcItem.bottom - lpdis->rcItem.top - 16) / 2,
(HICON)lpdis->itemData, 16, 16, 0, 0, DI_NORMAL);
@@ -838,12 +839,18 @@ strHgCmd = strDir + "\\hgtk.exe";
hFind = ::FindFirstFile(strHgCmd, &data);
if (hFind == INVALID_HANDLE_VALUE)
+ {
strHgCmd = strDir + "\\thg.cmd";
+ }
else
+ {
::FindClose(hFind);
+ }
}
else
+ {
::FindClose(hFind);
+ }
strHgCmd = Quote(strHgCmd) + " --nofork " + strCmd;
|
@@ -57,30 +57,26 @@
if (GetRegistryConfig("LocalDisksOnly", strCval) != 0 && strCval != "0")
{
- if (::PathIsNetworkPath(strPath))
- return S_FALSE;
+ if (::PathIsNetworkPath(strPath)) return S_FALSE;
if (strPath.GetLength() > 2 && strPath[1] == ':')
{
CString strDrive = "C:\\";
strDrive.SetAt(0, strPath[0]);
- if (::GetDriveType(strDrive) == DRIVE_REMOTE)
- return S_FALSE;
+ if (::GetDriveType(strDrive) == DRIVE_REMOTE) return S_FALSE;
}
}
char chFilterStatus = 0;
- if (m_chTortoiseClass == 'A')
- chFilterStatus = 'A';
+ if (m_chTortoiseClass == 'A') chFilterStatus = 'A';
char chStatus = 0;
if (!HgQueryDirstate(m_chTortoiseClass, strPath, chFilterStatus, chStatus))
+ {
return S_FALSE;
+ }
- if (chStatus == m_chTortoiseClass)
- return S_OK;
-
- return S_FALSE;
+ return (chStatus == m_chTortoiseClass) ? S_OK : S_FALSE;
}
CTortoiseHgOverlay::CTortoiseHgOverlay(char chClass) :
|
@@ -26,8 +26,7 @@ static CBitmapCache bmpcache;
const CBitmapCache::CPair* p = bmpcache.Lookup(strIconName);
- if (p != NULL)
- return p->m_value;
+ if (p != NULL) return p->m_value;
if (bmpcache.GetCount() > 200)
{
@@ -36,8 +35,7 @@ }
HICON hIcon = GetTortoiseIcon(strIconName);
- if (!hIcon)
- return 0;
+ if (!hIcon) return 0;
HBITMAP hBitmap = bmpUtils.IconToBitmapPARGB32(hIcon);
if (!hBitmap)
|
|
|
@@ -28,7 +28,9 @@ LONG lpcbLonger = MAX_PATH * sizeof(TCHAR);
if (::RegQueryValue(hKey, lpszKeyName, lpszValue, &lpcbLonger) != ERROR_SUCCESS)
+ {
return "";
+ }
return lpszValue;
}
@@ -93,24 +95,22 @@
CString DirName(const CString& strFileName)
{
- if (strFileName.IsEmpty())
- return strFileName;
+ if (strFileName.IsEmpty()) return strFileName;
int nPos = strFileName.ReverseFind('\\');
- if (nPos == -1)
- return "";
+ if (nPos == -1) return "";
CString strDirName = strFileName.Left(nPos);
if (!strDirName.IsEmpty() && strDirName[strDirName.GetLength()-1] == ':')
+ {
strDirName.AppendChar('\\');
+ }
return strDirName;
}
CString BaseName(const CString& strFileName)
{
- if (strFileName.IsEmpty())
- return strFileName;
+ if (strFileName.IsEmpty()) return strFileName;
int nPos = strFileName.ReverseFind('\\');
- if (nPos == -1)
- return strFileName;
+ if (nPos == -1) return strFileName;
return strFileName.Mid(nPos+1);
}
@@ -130,8 +130,7 @@ CString strIconPath = thgdir + "\\icons\\" + strIconName;
const CIconCache::CPair* p = iconcache.Lookup(strIconName);
- if (p != NULL)
- return p->m_value;
+ if (p != NULL) return p->m_value;
if (iconcache.GetCount() > 200)
{
@@ -171,7 +170,9 @@ break;
}
else if (::PathIsDirectory(strHgDir))
+ {
break;
+ }
CString strOldPath = strPath;
strPath = DirName(strPath);
if (strPath == strOldPath)
@@ -198,8 +199,7 @@ FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
0, OPEN_EXISTING, 0, 0);
- if (hFile == INVALID_HANDLE_VALUE)
- return 0;
+ if (hFile == INVALID_HANDLE_VALUE) return 0;
// get C runtime file descriptor from file handle
int fd = _open_osfhandle((intptr_t)hFile, _O_RDONLY);
@@ -226,36 +226,27 @@int GetRegSZValueW(HKEY hKey, LPCWSTR lpszName, CStringW& strRes)
{
strRes = L"";
-
- if (!hKey)
- return 0;
+ if (!hKey) return 0;
DWORD cbData = 600;
LPWSTR lpszData = strRes.GetBuffer(cbData);
LONG lRes = ::RegQueryValueExW(hKey, lpszName, 0, 0, (LPBYTE)lpszData, &cbData);
strRes.ReleaseBuffer(cbData);
- if (lRes == ERROR_SUCCESS)
- return 1;
-
+ if (lRes == ERROR_SUCCESS) return 1;
ATLTRACE(L"GetRegSZValueW('%s') failed\n", lpszName);
-
return 0;
}
// true if a starts with b
bool StartsWith(const CString& strWhole, const CString& strPrefix)
{
- if (strWhole.IsEmpty() || strPrefix.IsEmpty())
- return false;
-
- if (strPrefix.GetLength() > strWhole.GetLength())
- return false;
+ if (strWhole.IsEmpty() || strPrefix.IsEmpty()) return false;
+ if (strPrefix.GetLength() > strWhole.GetLength()) return false;
for (int i = 0; i < strPrefix.GetLength(); ++i)
{
- if (strWhole[i] != strPrefix[i])
- return false;
+ if (strWhole[i] != strPrefix[i]) return false;
}
return true;
|
@@ -28,8 +28,7 @@ HANDLE hFind;
hFind = ::FindFirstFile(lpszFile, &data);
- if (hFind == INVALID_HANDLE_VALUE)
- return -1;
+ if (hFind == INVALID_HANDLE_VALUE) return -1;
::FindClose(hFind);
ullMTime = (((ULONGLONG)data.ftLastWriteTime.dwHighDateTime << 32) +
|
Loading...