by
Changes to 10 files · Browse files at 429f63e37356 Showing diff from parent b54fad379ebb f663d3dc2675 Diff from another changeset...
@@ -154,6 +154,8 @@
def run(self):
try:
+ for k, v in self.ui.configitems('defaults'):
+ self.ui.setconfig('defaults', k, '')
ret = hglib.dispatch._dispatch(self.ui, self.args)
if ret:
self.ui.write(_('[command returned code %d]\n') % int(ret))
|
@@ -317,9 +317,15 @@ roots, notifypaths = getrepos([path])
if roots:
for r in sorted(roots):
+ tfn = os.path.join(r, '.hg', 'thgstatus')
try:
- os.remove(os.path.join(r, '.hg', 'thgstatus'))
- except OSError:
+ f = open(tfn, 'rb')
+ e = f.readline()
+ f.close()
+ if not e.startswith('@@noicons'):
+ os.remove(tfn)
+ except (IOError, OSError):
+ print "IOError or OSError while trying to remove %s" % tfn
pass
if notifypaths:
shlib.shell_notify(list(notifypaths))
|
@@ -128,9 +128,10 @@ for a in args:
q.put(str(a))
u = Qui()
+ for k, v in u.configitems('defaults'):
+ u.setconfig('defaults', k, '')
return dispatch._dispatch(u, list(args))
-
def displaytime(date):
return util.datestr(date, '%Y-%m-%d %H:%M:%S %1%2')
|
@@ -103,6 +103,8 @@ for dn in sorted(dirstatus):
s = dirstatus[dn]
e = f.readline()
+ if e.startswith('@@noicons'):
+ break
if e == '' or e[0] != s or e[1:-1] != dn:
update = True
break
|
@@ -59,6 +59,7 @@ 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 @@ 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;
}
|
@@ -30,11 +30,15 @@
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);
|
@@ -175,17 +175,26 @@ relpath[i] = '/';
}
+ DirectoryStatus* pdirsta = DirectoryStatus::get(cur.hgroot, cur.basedir);
+ if (pdirsta && pdirsta->noicons())
+ {
+ last = cur;
+ return 0;
+ }
+
if (cur.isdir)
{
if (!relpath.empty())
{
Dirstate* pds2 = Dirstatecache::get(cur.hgroot, cur.basedir);
if (pds2 && !pds2->root().getdir(relpath))
+ {
+ last = cur;
return 0; // unknown dir -> no icon
+ }
}
- DirectoryStatus* pds = DirectoryStatus::get(cur.hgroot, cur.basedir);
- outStatus = (pds ? pds->status(relpath) : '?');
+ outStatus = (pdirsta ? pdirsta->status(relpath) : '?');
}
else
{
|
@@ -3,6 +3,7 @@
#include <vector>
#include <assert.h>
+#include <map>
#include <io.h>
#include "FCNTL.H"
@@ -177,23 +178,46 @@}
+// not reentrant
HICON GetTortoiseIcon(const std::string& iconname)
{
+ typedef std::map<std::string, HICON> IconCacheT;
+ static IconCacheT iconcache_;
+
std::string thgdir = GetTHgProgRoot();
if (thgdir.empty())
{
TDEBUG_TRACE("GetTortoiseIcon: THG root is empty");
- return NULL;
+ return 0;
}
- std::string iconpath = thgdir + "\\icons\\" + iconname;
+ const std::string iconpath = thgdir + "\\icons\\" + iconname;
+
+ IconCacheT::const_iterator i = iconcache_.find(iconpath);
+ if (i != iconcache_.end())
+ return i->second;
+
+ if (iconcache_.size() > 200)
+ {
+ TDEBUG_TRACE("**** GetTortoiseIcon: error: too many icons in cache");
+ return 0;
+ }
+
HICON h = (HICON) LoadImageA(0, iconpath.c_str(), IMAGE_ICON,
16, 16, LR_LOADFROMFILE);
if (!h)
{
- TDEBUG_TRACE(" GetTortoiseIcon: can't find " + iconpath);
+ TDEBUG_TRACE("GetTortoiseIcon: can't find " + iconpath);
+ return 0;
}
-
+
+ iconcache_[iconpath] = h;
+
+ TDEBUG_TRACE(
+ "GetTortoiseIcon: added '" << iconpath << "' to iconcache_"
+ " (" << iconcache_.size() << " icons in cache)"
+ );
+
return h;
}
|
|
|
|
|
Loading...