Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

shellext: remove unused HgRepoRoot

Changeset 1372217a0c1d

Parent 1c9faadf11e3

by Adrian Buehlmann

Changes to 4 files · Browse files at 1372217a0c1d Showing diff from parent 1c9faadf11e3 Diff from another changeset...

Change 1 of 1 Show Entire File win32/​shellext/​HgRepoRoot.cpp Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,94 +0,0 @@
- -// Copyright (C) 2009 Adrian Buehlmann -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. - -#include "stdafx.h" - -#include "HgRepoRoot.h" -#include "TortoiseUtils.h" - - -bool HgRepoRoot::is_subdir(const std::string& refp, const std::string& p) -{ - // refp = "foo\bar" - // p = "foo\bar\ping" -> return true - - if (refp.size() > p.size()) - return false; - - if (p.compare(0, refp.size(), refp) != 0) - return false; - - if (refp.size() == p.size()) - return true; - - // p is longer than refp - - char c = p[refp.size()]; - - // refp = "foo\bar" - // p = "foo\bar2", c is '2' -> return false - - if (c == '\\' || c == '/') - return true; - - return false; -} - - -const std::string& HgRepoRoot::get(const std::string& path) -{ - static E cache; - - if (!cache.hgroot_.empty() - && is_subdir(cache.hgroot_, path)) - { - unsigned tc = GetTickCount(); - if (tc - cache.tickcount_ < 2000) - { - ++cache.hitcount_; - return cache.hgroot_; - } - } - - TDEBUG_TRACE("HgRepoRoot::get: calling GetHgRepoRoot('" << path << ")"); - - std::string r = GetHgRepoRoot(path); - - bool show_hitcount = !cache.hgroot_.empty() && cache.hitcount_ > 0; - if (show_hitcount) - TDEBUG_TRACE("HgRepoRoot::get: '" - << cache.hgroot_ << "' had " << cache.hitcount_ << " hits"); - - cache.hitcount_ = 0; - - if (r.empty()) - { - cache.hgroot_.clear(); - cache.tickcount_ = 0; - } - else - { - if (show_hitcount) - { - const char* verb = (r != cache.hgroot_ ? "caching" : "refreshing" ); - TDEBUG_TRACE("HgRepoRoot::get: " << verb << " '" << cache.hgroot_ << "'"); - } - cache.hgroot_ = r; - cache.tickcount_ = GetTickCount(); - } - - return cache.hgroot_; -}
Change 1 of 1 Show Entire File win32/​shellext/​HgRepoRoot.h Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,37 +0,0 @@
- -// Copyright (C) 2009 Adrian Buehlmann -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. - -#ifndef _HG_REPO_ROOT_H -#define _HG_REPO_ROOT_H - -class HgRepoRoot -{ - struct E - { - std::string hgroot_; - unsigned tickcount_; - unsigned hitcount_; - E(): tickcount_(0), hitcount_(0) {} - }; - - // true, if p is a subdir of refp, or identical - static bool is_subdir(const std::string& refp, const std::string& p); - -public: - static const std::string& get(const std::string& path); -}; - -#endif
 
15
16
17
18
19
20
21
 
15
16
17
 
18
19
20
@@ -15,7 +15,6 @@
  dirstate.o \   Dirstatecache.o \   DirectoryStatus.o \ - HgRepoRoot.o \   QueryDirstate.o    BASE_LDFLAGS=-lole32 -lkernel32 -luser32 -lgdi32 -lshlwapi -lwininet \
 
21
22
23
24
25
26
27
 
21
22
23
 
24
25
26
@@ -21,7 +21,6 @@
 #include "dirstate.h"  #include "DirectoryStatus.h"  #include "Dirstatecache.h" -#include "HgRepoRoot.h"  #include "Winstat.h"  #include "TortoiseUtils.h"