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

shellext/dirstate: refactor HgQueryDirstateDirectory

Changeset ca44ea97e583

Parent e0f05652b363

by Adrian Buehlmann

Changes to one file · Browse files at ca44ea97e583 Showing diff from parent e0f05652b363 Diff from another changeset...

 
288
289
290
291
292
293
294
295
296
297
298
299
300
301
 
 
 
 
 
 
 
 
 
302
303
304
 
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
 
288
289
290
 
 
 
 
291
292
293
294
 
 
 
295
296
297
298
299
300
301
302
303
304
305
306
 
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
@@ -288,17 +288,19 @@
 {   const dirstate* pd;   struct _stat stat; - unsigned ix; - size_t len, rootlen; - char temp[2*MAX_PATH+10]; - int a = 0, m = 0;     if (!HgQueryDirstate(hgroot, abspath, relpathloc, &pd, &stat))   return 0;   - rootlen = strlen(hgroot); - len = strlen(relpathloc); - for (ix = 0; ix < pd->num_entries && !m; ix++) + bool added = false; + bool modified = false; + + size_t rootlen = strlen(hgroot); + size_t len = strlen(relpathloc); + + char temp[2*MAX_PATH+10] = ""; + + for (unsigned ix = 0; ix < pd->num_entries && !modified; ix++)   {   if (0 != strncmp(relpathloc, pd->entries[ix].name, len))   continue; @@ -306,28 +308,28 @@
  switch (pd->entries[ix].state)   {   case 'n': - if (!m) + if (!modified)   {   temp[0] = '\0';   strncat(temp, hgroot, MAX_PATH);   strcat(temp, "/");   strncat(temp, pd->entries[ix].name, MAX_PATH);   if (0 == lstat(temp, &stat)) - m = (mapdirstate(&pd->entries[ix], &stat) == 'M'); + modified = (mapdirstate(&pd->entries[ix], &stat) == 'M');   }   break;   case 'm': - m = 1; + modified = true;   break;   case 'a': - a = 1; + added = true;   break;   }   }   - if (m) + if (modified)   *outStatus = 'M'; - else if (a) + else if (added)   *outStatus = 'A';   else   *outStatus = 'C';