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

shellext: simplify Directory::path()

Changeset 870d9217bdea

Parent 7051753b84f2

by Adrian Buehlmann

Changes to 3 files · Browse files at 870d9217bdea Showing diff from parent 7051753b84f2 Diff from another changeset...

 
81
82
83
84
 
85
86
87
 
149
150
151
152
 
153
 
 
 
154
155
156
157
158
159
160
161
 
 
 
162
163
164
 
176
177
178
179
 
180
181
182
183
184
185
186
 
187
188
189
 
81
82
83
 
84
85
86
87
 
149
150
151
 
152
153
154
155
156
157
 
 
 
 
 
 
 
158
159
160
161
162
163
 
175
176
177
 
178
179
180
181
182
183
 
 
184
185
186
187
@@ -81,7 +81,7 @@
    if (!d)   { - d = new Directory(this, base); + d = new Directory(this, base, path());   subdirs_.push_back(d);   }   @@ -149,16 +149,15 @@
 }     -std::string Directory::path(const std::string& n) const +std::string Directory::path() const  { + if (basepath_.empty()) + return name_; +   if (name_.empty()) - return n; - std::string res = name_; - if (!n.empty()) - res += "/" + n; - if (!parent_) - return res; - return parent_->path(res); + return basepath_; + + return basepath_ + "/" + name_;  }     @@ -176,14 +175,13 @@
  }     Winstat stat; - const std::string hrs = hgroot + '\\'; + const std::string basepath = hgroot + "/" + path() + "/";   for (FilesT::iterator i = files_.begin(); i != files_.end(); ++i)   {   if (i->state == 'r')   return 'M'; // file was removed, report dir as modified   - std::string p = hrs + path(i->name); - + std::string p = basepath + i->name;   if (0 != stat.lstat(p.c_str()))   return 'M'; // file is missing, report dir as modified  
 
21
22
23
 
24
25
26
27
28
29
30
31
32
 
 
 
 
33
34
35
 
38
39
40
41
42
 
 
 
43
44
45
 
46
47
48
 
21
22
23
24
25
26
27
28
29
30
 
 
 
31
32
33
34
35
36
37
 
40
41
42
 
 
43
44
45
46
47
 
48
49
50
51
@@ -21,15 +21,17 @@
 #include "Direntry.h"    #include <vector> +#include <string>      class Directory  {   typedef std::vector<Directory*> DirsT;   typedef std::vector<Direntry> FilesT; - - Directory* parent_; - std::string name_; + + Directory* const parent_; + const std::string name_; + const std::string basepath_;     DirsT subdirs_;   FilesT files_; @@ -38,11 +40,12 @@
  char status_;    public: - Directory(Directory* p, const std::string& n): - parent_(p), name_(n), tickcount_(0), status_(-1) {} + Directory(Directory* p, const std::string& n, const std::string& basepath): + parent_(p), name_(n), basepath_(basepath), tickcount_(0), status_(-1) {} +   ~Directory();   - std::string path(const std::string& n = "") const; + std::string path() const;     int add(const std::string& relpath, Direntry& e);  
 
55
56
57
58
 
59
60
61
 
55
56
57
 
58
59
60
61
@@ -55,7 +55,7 @@
   private:   Dirstate() - : root_(0, ""), num_added_(0), num_entries_(0) {} + : root_(0, "", ""), num_added_(0), num_entries_(0) {}  };