Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

fogcreek Merge with stable

Changeset eacaa46c6eae

Parents 0524579d8c04

Parents 49d1b27ed01a

by David Golub

Changes to 9 files · Browse files at eacaa46c6eae Showing diff from parent 0524579d8c04 49d1b27ed01a Diff from another changeset...

Change 1 of 1 Show Entire File .hgeol Stacked
 
 
 
 
 
 
 
 
1
2
3
4
5
6
@@ -0,0 +1,6 @@
+[patterns] +**.py = native +**.py.out = native + +[repository] +native = LF
 
6
7
8
 
9
10
11
 
47
48
49
50
 
51
52
53
 
72
73
74
 
75
76
77
 
301
302
303
 
 
 
304
305
306
 
323
324
325
 
 
 
326
327
328
 
364
365
366
 
 
 
367
368
 
6
7
8
9
10
11
12
 
48
49
50
 
51
52
53
54
 
73
74
75
76
77
78
79
 
303
304
305
306
307
308
309
310
311
 
328
329
330
331
332
333
334
335
336
 
372
373
374
375
376
377
378
379
@@ -6,6 +6,7 @@
 # GNU General Public License version 2, incorporated herein by reference.    import os +import re    from mercurial import error, match, patch, util, mdiff  from mercurial import ui as uimod @@ -47,7 +48,7 @@
  return None   try:   data = fctx.data() - if '\0' in data: + if '\0' in data or re.match(r'^\.kbf/', wfile):   self.error = p + _('File is binary.\n')   return None   except (EnvironmentError, util.Abort), e: @@ -72,6 +73,7 @@
  return 'C'   return None   + isbfile = False   repo = ctx._repo   self.flabel += u'<b>%s</b>' % hglib.tounicode(wfile)   @@ -301,6 +303,9 @@
  else:   self.contents = olddata   self.flabel += _(' <i>(was deleted)</i>') + elif '.kbf/' + wfile in ctx.p1(): + self.error = 'binary file' + self.flabel += _(' <i>(was deleted)</i>')   else:   self.flabel += _(' <i>(was added, now missing)</i>')   return @@ -323,6 +328,9 @@
  return     if status in ('M', 'A'): + if '.kbf/' + wfile in ctx: + wfile = '.kbf/' + wfile + isbfile = True   res = self.checkMaxDiff(ctx, wfile, maxdiff)   if res is None:   return @@ -364,5 +372,8 @@
  revs = [str(ctx), str(ctx2)]   diffopts = patch.diffopts(repo.ui, {})   diffopts.git = False + if isbfile: + olddata += '\0' + newdata += '\0'   self.diff = mdiff.unidiff(olddata, olddate, newdata, newdate,   oldname, wfile, revs, diffopts)
 
14
15
16
 
 
17
18
19
 
144
145
146
 
147
148
149
 
14
15
16
17
18
19
20
21
 
146
147
148
149
150
151
152
@@ -14,6 +14,8 @@
 # this program; if not, write to the Free Software Foundation, Inc.,  # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.   +import re +  from tortoisehg.util import hglib, patchctx    from tortoisehg.hgqt.qtlib import geticon, getoverlaidicon @@ -144,6 +146,7 @@
  for lst, flag in ((added, 'A'), (modified, 'M'), (removed, 'R')):   for f in filter(func, lst):   wasmerged = ismerge and f in ctxfiles + f = re.sub(r'^\.kbf/', '', f)   files.append({'path': f, 'status': flag, 'parent': parent,   'wasmerged': wasmerged})   return files
 
136
137
138
139
 
 
 
 
140
141
 
142
143
144
 
136
137
138
 
139
140
141
142
143
 
144
145
146
147
@@ -136,9 +136,12 @@
  parent=self)   return   if self.command == 'remove': - wctx = self.repo[None] + self.repo.bfstatus = True + repostate = self.repo.status() + self.repo.bfstatus = False + unknown, ignored = repostate[4:6]   for wfile in files: - if wfile not in wctx: + if wfile in unknown or wfile in ignored:   try:   util.unlink(wfile)   except EnvironmentError:
 
413
414
415
 
416
 
417
418
419
 
425
426
427
 
428
 
429
430
431
 
432
 
433
434
435
 
413
414
415
416
417
418
419
420
421
 
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
@@ -413,7 +413,9 @@
  # status and commit only pre-check MAR files   precheckfn = lambda x: x < 4   m = hglib.match(self.repo[None], self.pats) + self.repo.bfstatus = True   status = self.repo.status(match=m, **stopts) + self.repo.bfstatus = False   # Record all matched files as initially checked   for i, stat in enumerate(StatusType.preferredOrder):   if stat == 'S': @@ -425,11 +427,15 @@
  wctx = context.workingctx(self.repo, changes=status)   self.patchecked = patchecked   elif self.pctx: + self.repo.bfstatus = True   status = self.repo.status(node1=self.pctx.p1().node(), **stopts) + self.repo.bfstatus = False   wctx = context.workingctx(self.repo, changes=status)   else:   wctx = self.repo[None] + self.repo.bfstatus = True   wctx.status(**stopts) + self.repo.bfstatus = False   self.wctx = wctx     wctx.dirtySubrepos = []
 
90
91
92
 
93
 
94
95
96
 
90
91
92
93
94
95
96
97
98
@@ -90,7 +90,9 @@
  time.sleep(tdelta)     repo = hg.repository(ui, root) # a fresh repo object is needed + repo.bfstatus = True   repostate = repo.status() # will update .hg/dirstate as a side effect + repo.bfstatus = False   modified, added, removed, deleted = repostate[:4]     dirstatus = {}
 
31
32
33
34
 
 
35
36
37
 
40
41
42
43
 
44
45
46
47
48
 
 
49
50
51
 
71
72
73
 
74
75
76
 
159
160
161
162
 
163
164
165
 
168
169
170
171
 
172
173
174
 
31
32
33
 
34
35
36
37
38
 
41
42
43
 
44
45
46
47
48
 
49
50
51
52
53
 
73
74
75
76
77
78
79
 
162
163
164
 
165
166
167
168
 
171
172
173
 
174
175
176
177
@@ -31,7 +31,8 @@
     Dirstate* Dirstatecache::get( - const std::string& hgroot, const std::string& cwd, bool& unset) + const std::string& hgroot, const std::string& cwd, bool& unset, + bool usekbfiles)  {   unset = false;   @@ -40,12 +41,13 @@
  Iter iter = cache().begin();   for (;iter != cache().end(); ++iter)   { - if (hgroot == iter->hgroot) + if (hgroot == iter->hgroot && usekbfiles == iter->usekbfiles)   break;   }     Winstat64 stat; - std::string path = hgroot + "\\.hg\\dirstate"; + std::string path = hgroot + (usekbfiles ? "\\.hg\\kilnbfiles\\dirstate" + : "\\.hg\\dirstate");     unsigned tc = GetTickCount();   bool new_stat = false; @@ -71,6 +73,7 @@
    E e;   e.hgroot = hgroot; + e.usekbfiles = usekbfiles;   cache().push_front(e);   iter = cache().begin();   iter->tickcount = tc; @@ -159,7 +162,7 @@
 }     -void Dirstatecache::invalidate(const std::string& hgroot) +void Dirstatecache::invalidate(const std::string& hgroot, bool usekbfiles)  {   typedef std::list<E>::iterator Iter;   @@ -168,7 +171,7 @@
    for (Iter i = cache().begin(); i != cache().end(); ++i)   { - if (hgroot == i->hgroot) + if (hgroot == i->hgroot && usekbfiles == i->usekbfiles)   {   delete i->dstate;   i->dstate = 0;
 
34
35
36
 
37
38
39
40
41
42
43
 
 
44
45
46
 
48
49
50
51
52
 
 
 
53
54
55
 
34
35
36
37
38
39
40
41
42
43
 
44
45
46
47
48
 
50
51
52
 
 
53
54
55
56
57
58
@@ -34,13 +34,15 @@
  std::string hgroot;   unsigned tickcount;   bool unset; + bool usekbfiles;     E():   dstate(0),   dstate_mtime(0),   dstate_size(0),   tickcount(0), - unset(false) + unset(false), + usekbfiles(false)   {}   };   @@ -48,8 +50,9 @@
   public:   static Dirstate* get( - const std::string& hgroot, const std::string& cwd, bool& unset); - static void invalidate(const std::string& hgroot); + const std::string& hgroot, const std::string& cwd, bool& unset, + bool usekbfiles = false); + static void invalidate(const std::string& hgroot, bool usekbfiles = false);  };    #endif
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
 
 
 
 
 
 
 
306
307
308
309
310
311
312
313
314
315
 
316
317
318
319
 
 
 
 
 
 
 
 
 
 
 
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
 
 
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
 
320
321
322
 
 
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
   // Copyright (C) 2009 Benjamin Pollack  // 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 "QueryDirstate.h"  #include "dirstate.h"  #include "DirectoryStatus.h"  #include "Dirstatecache.h"  #include "Winstat.h"  #include "TortoiseUtils.h"  #include "Thgstatus.h"    #include <shlwapi.h>      class QueryState  {  public:   std::string path;   bool isdir;   std::string basedir;   std::string hgroot;     char status;   unsigned tickcount;     QueryState(): isdir(false), status('0'), tickcount(0) {}  };      bool hasHgDir(char cls, const std::string& path, unsigned& ticks)  {   ticks = 0;     bool res = false;     if (path.empty() || path == "\\")   return res;     const std::string p = path + "\\.hg";     if (::PathIsUNCServerShare(p.c_str()))   return res;     unsigned tc0 = ::GetTickCount();   res = ::PathIsDirectory(p.c_str()) != 0;   unsigned tc1 = ::GetTickCount();     ticks = tc1 - tc0;     if (ticks > 5 /* ms */)   {   // trace slower PathIsDirectory calls (untypical on local discs)   TDEBUG_TRACE(   "[" << cls << "] hasHgDir: PathIsDirectory(\"" << p << "\")" <<   " -> " << res << ", in " << ticks << " ticks"   );   }     return res;  }      int findHgRoot(char cls, QueryState& cur, QueryState& last, bool outdated)  {   std::string dp = "["; dp += cls; dp += "] findHgRoot";     {   std::string p = cur.path;   p.push_back('\\'); - if (p.find("\\.hg\\") != std::string::npos) + if (p.find("\\.hg\\") != std::string::npos || p.find("\\.kbf\\") != std::string::npos)   { - // ignore files and dirs named '.hg' + // ignore files and dirs named '.hg' or '.kbf'   last = cur;   return 0;   }   }     if (!outdated && !last.hgroot.empty()   && cur.path.size() >= last.hgroot.size()   && StartsWith(cur.path, last.hgroot + "\\"))   {   cur.hgroot = last.hgroot;   return 1;   }     unsigned ticks = 0;   bool file_access_is_unacceptably_slow = false;     if (!PathIsNetworkPath(cur.path.c_str()))   {   // checking if we have a repo root, visible from its parent dir     const bool has_hg = hasHgDir(cls, cur.path, ticks);     if (ticks > 5000 /* ms */)   {   file_access_is_unacceptably_slow = true;   goto exit;   }     if (has_hg)   {   cur.hgroot = cur.path;   TDEBUG_TRACE(dp << "(" << cur.path << "): hgroot = cur.path");   return 1;   }   }     cur.basedir = DirName(cur.path);     if (!outdated && !last.basedir.empty() && cur.basedir == last.basedir)   {   cur.hgroot = last.hgroot;   return 1;   }     for (std::string p = cur.basedir;;)   {   bool has_hg = hasHgDir(cls, p, ticks);   if (ticks > 5000 /* ms */)   {   const std::string reason = "ignoring slow \"" + p + "\"";   Thgstatus::error(reason);   file_access_is_unacceptably_slow = true;   goto exit;   }     if (has_hg)   {   cur.hgroot = p;   TDEBUG_TRACE(   dp << "(" << cur.path << "): hgroot = '" << cur.hgroot   << "' (found repo)"   );   return 1;   }   std::string p2 = DirName(p);   if (p2.size() == p.size())   break;   p.swap(p2);   }    exit:   if (file_access_is_unacceptably_slow)   {   TDEBUG_TRACE(   "******" << dp << "(" << cur.path << "): ignored, "   << "call took too long (" << ticks << " ticks)");   }   else   {   TDEBUG_TRACE(dp << "(" << cur.path << "): NO repo found");   }   last = cur;   return 0;  }      int get_relpath(   const std::string& hgroot,   const std::string& path,   std::string& res  )  {   size_t offset = hgroot.size();   if (offset == 0)   return 0;     if (offset > path.size())   return 0;     if (path[offset] == '\\')   offset++;     const char* relpathptr = path.c_str() + offset;     res = relpathptr;   return 1;  }      int HgQueryDirstate(   const char cls,   const std::string& path,   const char& filterStatus,   char& outStatus  )  {   std::string dp = "["; dp += cls; dp += "] HgQueryDirstate: ";     static QueryState last;     if (path.empty())   return 0;     QueryState cur;     cur.path = path;   cur.tickcount = ::GetTickCount();     const bool outdated = cur.tickcount - last.tickcount > 2000;     if (!outdated && last.path == path)   {   outStatus = last.status;   if (outStatus == 'P')   outStatus = 'M';   return 1;   }     if (::PathIsRoot(path.c_str()))   {   last = cur;   return 0;   }     if (findHgRoot(cls, cur, last, outdated) == 0)   return 0;     size_t offset = cur.hgroot.length();     if (offset == 0)   {   last = cur;   return 0;   }     if (path[offset] == '\\')   offset++;   const char* relpathptr = path.c_str() + offset;     std::string relpath = relpathptr;     for (size_t i = 0; i < relpath.size(); ++i)   {   if (relpath[i] == '\\')   relpath[i] = '/';   }     DirectoryStatus* pdirsta = DirectoryStatus::get(cur.hgroot, cur.basedir);   if (pdirsta && pdirsta->noicons())   {   last = cur;   return 0;   }     if (relpath.empty())   {   outStatus = (pdirsta ? pdirsta->status(relpath) : '?');   cur.status = outStatus;   cur.tickcount = ::GetTickCount();   last = cur;   return 1;   }     bool unset = false;     Dirstate* pds = Dirstatecache::get(cur.hgroot, cur.basedir, unset);   if (!pds)   {   TDEBUG_TRACE(   dp << "Dirstatecache::get(" << cur.hgroot   << ") returns no Dirstate"   );   last = cur;   return 0;   }     Winstat stat;   if (0 != stat.lstat(path.c_str()))   {   TDEBUG_TRACE(dp << "lstat(" << path << ") failed");   last = cur;   return 0;   }   cur.isdir = stat.isdir;  #if 0   TDEBUG_TRACE(   dp << "stat.lstat(\"" << cur.path << "\") "   << "-> stat.isdir is " << stat.isdir   );  #endif     if (cur.isdir)   {   if (!relpath.empty() && !pds->root().getdir(relpath))   { - last = cur; - return 0; // unknown dir -> no icon + // attempt to get status from kbfiles + pds = Dirstatecache::get(cur.hgroot, cur.basedir, unset, true); + if (!pds || !pds->root().getdir(relpath)) + { + last = cur; + return 0; // unknown dir -> no icon + }   }     outStatus = (pdirsta ? pdirsta->status(relpath) : '?');   cur.status = outStatus;   cur.tickcount = ::GetTickCount();   last = cur;   return 1;   }   - const Direntry* const e = pds->root().get(relpath); + const Direntry* e = pds->root().get(relpath);   if (!e)   { - last = cur; - return 0; + // attempt to get status from kbfiles + pds = Dirstatecache::get(cur.hgroot, cur.basedir, unset, true); + if (pds) + { + e = pds->root().get(relpath); + } + if (!e) + { + last = cur; + return 0; + }   }     outStatus = e->status(stat);     if (unset)   goto exit;     bool update = false;     if (outStatus == 'M')   {   std::string relbase;   if (pdirsta && get_relpath(cur.hgroot, cur.basedir, relbase))   {   TDEBUG_TRACE(dp << "relbase = '" << relbase << "'");     char basedir_status = pdirsta->status(relbase);   TDEBUG_TRACE(dp << "basedir_status = " << basedir_status);     if (basedir_status != 'M')   update = true;   }   }   else if (outStatus == 'P')   {   static unsigned lasttickcount;     const unsigned tc = ::GetTickCount();   const bool outdated = tc - lasttickcount > 6000;     if (outdated) // protect against endless update loops   {   update = true;   lasttickcount = tc;   }     TDEBUG_TRACE(dp << "outStatus is 'P'");   }     if (update)   {   TDEBUG_TRACE(dp << "calling Thgstatus::update");   Thgstatus::update(path);   }     exit:   cur.status = outStatus;   if (outStatus == 'P')   outStatus = 'M';   cur.tickcount = ::GetTickCount();   last = cur;   return 1;  }