# HG changeset patch
# User Adrian Buehlmann <[email protected]>
# Date 1247411546 -7200
# Node ID 935f8fa4a4d47c39b2254a28cf5c994b859f9ad8
# Parent c477cecc73a67fe1691e5136a5319c126fce5833
shellext: teach DirectoryStatus to detect '@@noicons' in .hg/thgstatus
this will allow to disable the overlay icons per repository if
.hg/thgstatus begins with the string '@@noicons'
diff --git a/win32/shellext/DirectoryStatus.cpp
b/win32/shellext/DirectoryStatus.cpp
--- a/win32/shellext/DirectoryStatus.cpp
+++ b/win32/shellext/DirectoryStatus.cpp
@@ -59,6 +59,7 @@ char DirectoryStatus::status(const std::
int DirectoryStatus::read(const std::string& hgroot, const std::string& cwd)
{
v_.clear();
+ noicons_ = false;
std::string p = hgroot + "\\.hg\\thgstatus";
@@ -71,37 +72,65 @@ int DirectoryStatus::read(const std::str
return 0;
}
- char state;
- std::vector<char> path(MAX_PATH);
-
DirectoryStatus::E e;
- while (fread(&state, sizeof(state), 1, f) == 1)
+ int res = 1;
+ const std::string noicons = "@@noicons";
+
+ std::vector<char> vline(200);
+
+ for (;;)
{
- e.status_ = state;
+ vline.clear();
+ char t;
- path.clear();
- char t;
- while (fread(&t, sizeof(t), 1, f) == 1 && t != '\n')
+ for (;;)
{
- path.push_back(t);
- if (path.size() > 1000)
- return 0;
+ if (fread(&t, sizeof(t), 1, f) != 1)
+ goto close;
+ if (t == '\n')
+ break;
+ vline.push_back(t);
+ if (vline.size() > 1000)
+ {
+ res = 0;
+ goto close;
+ }
+ }
+ vline.push_back(0);
+
+ std::string line = &vline[0];
+
+ if (line.substr(0, noicons.size()) == noicons)
+ {
+ noicons_ = true;
+ goto close;
+ }
+
+ if (line.empty())
+ goto close;
+
+ e.status_ = line[0];
+
+ std::string path;
+ if (line.size() > 1)
+ {
+ path = line.c_str() + 1;
}
path.push_back('/');
- path.push_back(0);
- e.path_ = &path[0];
+ e.path_ = path;
v_.push_back(e);
}
+close:
fclose(f);
TDEBUG_TRACE("DirectoryStatus::read(" << hgroot << "): done. "
- << v_.size() << " entries read");
+ << v_.size() << " entries read. noicons_ = " << noicons_ );
- return 1;
+ return res;
}
diff --git a/win32/shellext/DirectoryStatus.h b/win32/shellext/DirectoryStatus.h
--- a/win32/shellext/DirectoryStatus.h
+++ b/win32/shellext/DirectoryStatus.h
@@ -30,11 +30,15 @@ class DirectoryStatus
typedef std::vector<E> V;
V v_;
+ bool noicons_;
public:
+ DirectoryStatus(): noicons_(false) {}
+
static DirectoryStatus* get(
const std::string& hgroot, const std::string& cwd);
char status(const std::string& relpath) const;
+ bool noicons() const { return noicons_; }
private:
int read(const std::string& hgroot, const std::string& cwd);
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Tortoisehg-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop