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

stable reporegistry: better common path extraction on Windows

- lowercase the common path for consistency
- preserve original casing for the short path
- preserve backslashes

Changeset a2ff4157e207

Parent bc12bb65b708

by Eduard-Cristian Stefan

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

 
215
216
217
218
219
 
 
 
 
 
 
220
221
222
 
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
 
 
 
 
 
 
 
481
482
483
 
215
216
217
 
 
218
219
220
221
222
223
224
225
226
 
453
454
455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
456
457
458
459
460
461
462
463
464
465
@@ -215,8 +215,12 @@
  cpath = self.getCommonPath()   except:   cpath = '' - spath = os.path.normpath(self._root) - if cpath and spath.startswith(cpath): + spath2 = spath = os.path.normpath(self._root) + + if os.name == 'nt': + spath2 = spath2.lower() + + if cpath and spath2.startswith(cpath):   iShortPathStart = len(cpath) + 1   spath = spath[iShortPathStart:]   return hglib.tounicode(spath) @@ -449,35 +453,13 @@
  # If a group has no repo items, the common path is empty   self._commonpath = ''   else: - # Calculate the group common path - def splitPath(path): - path = os.path.normpath(path) - return path.split(os.path.sep)[:-1] - - cpath = splitPath(self.childs[0].rootpath()) - - for c in self.childs[1:]: - if not cpath: - # There is no common path - break - # Update the common path to the common path with the current - # child - childpath = splitPath(c.rootpath()) - # The common part cannot go beyond the smaller of the current - # common path and the current child - clen = min(len(cpath), len(childpath)) - cpath = cpath[:clen] - childpath = childpath[:clen] - if cpath == childpath: - # Trivial case - continue - for n in range(clen): - # From left to right, find the first path part that is not - # the same - if cpath[n] != childpath[n]: - cpath = cpath[:n] - break - self._commonpath = os.path.sep.join(cpath) + if os.name == 'nt': + childs = [child.rootpath().lower() + for child in self.childs] + else: + childs = [child.rootpath() + for child in self.childs] + self._commonpath = os.path.dirname(os.path.commonprefix(childs))   return self._commonpath     def getCommonPath(self):