mercurial/dirstate.py
changeset 43106 d783f945a701
parent 43090 1f339b503a40
child 43117 8ff1ecfadcd1
equal deleted inserted replaced
43105:649d3ac37a12 43106:d783f945a701
   280 
   280 
   281     def __iter__(self):
   281     def __iter__(self):
   282         return iter(sorted(self._map))
   282         return iter(sorted(self._map))
   283 
   283 
   284     def items(self):
   284     def items(self):
   285         return self._map.iteritems()
   285         return pycompat.iteritems(self._map)
   286 
   286 
   287     iteritems = items
   287     iteritems = items
   288 
   288 
   289     def parents(self):
   289     def parents(self):
   290         return [self._validate(p) for p in self._pl]
   290         return [self._validate(p) for p in self._pl]
   668         self._plchangecallbacks[category] = callback
   668         self._plchangecallbacks[category] = callback
   669 
   669 
   670     def _writedirstate(self, st):
   670     def _writedirstate(self, st):
   671         # notify callbacks about parents change
   671         # notify callbacks about parents change
   672         if self._origpl is not None and self._origpl != self._pl:
   672         if self._origpl is not None and self._origpl != self._pl:
   673             for c, callback in sorted(self._plchangecallbacks.iteritems()):
   673             for c, callback in sorted(
       
   674                 pycompat.iteritems(self._plchangecallbacks)
       
   675             ):
   674                 callback(self, self._origpl, self._pl)
   676                 callback(self, self._origpl, self._pl)
   675             self._origpl = None
   677             self._origpl = None
   676         # use the modification time of the newly created temporary file as the
   678         # use the modification time of the newly created temporary file as the
   677         # filesystem's notion of 'now'
   679         # filesystem's notion of 'now'
   678         now = util.fstat(st)[stat.ST_MTIME] & _rangemask
   680         now = util.fstat(st)[stat.ST_MTIME] & _rangemask
   680         # enough 'delaywrite' prevents 'pack_dirstate' from dropping
   682         # enough 'delaywrite' prevents 'pack_dirstate' from dropping
   681         # timestamp of each entries in dirstate, because of 'now > mtime'
   683         # timestamp of each entries in dirstate, because of 'now > mtime'
   682         delaywrite = self._ui.configint(b'debug', b'dirstate.delaywrite')
   684         delaywrite = self._ui.configint(b'debug', b'dirstate.delaywrite')
   683         if delaywrite > 0:
   685         if delaywrite > 0:
   684             # do we have any files to delay for?
   686             # do we have any files to delay for?
   685             items = self._map.iteritems()
   687             items = pycompat.iteritems(self._map)
   686             for f, e in items:
   688             for f, e in items:
   687                 if e[0] == b'n' and e[3] == now:
   689                 if e[0] == b'n' and e[3] == now:
   688                     import time  # to avoid useless import
   690                     import time  # to avoid useless import
   689 
   691 
   690                     # rather than sleep n seconds, sleep until the next
   692                     # rather than sleep n seconds, sleep until the next
   861         # match the case in the filesystem, if there are multiple files that
   863         # match the case in the filesystem, if there are multiple files that
   862         # normalize to the same path.
   864         # normalize to the same path.
   863         if match.isexact() and self._checkcase:
   865         if match.isexact() and self._checkcase:
   864             normed = {}
   866             normed = {}
   865 
   867 
   866             for f, st in results.iteritems():
   868             for f, st in pycompat.iteritems(results):
   867                 if st is None:
   869                 if st is None:
   868                     continue
   870                     continue
   869 
   871 
   870                 nc = util.normcase(f)
   872                 nc = util.normcase(f)
   871                 paths = normed.get(nc)
   873                 paths = normed.get(nc)
   874                     paths = set()
   876                     paths = set()
   875                     normed[nc] = paths
   877                     normed[nc] = paths
   876 
   878 
   877                 paths.add(f)
   879                 paths.add(f)
   878 
   880 
   879             for norm, paths in normed.iteritems():
   881             for norm, paths in pycompat.iteritems(normed):
   880                 if len(paths) > 1:
   882                 if len(paths) > 1:
   881                     for path in paths:
   883                     for path in paths:
   882                         folded = self._discoverpath(
   884                         folded = self._discoverpath(
   883                             path, norm, True, None, self._map.dirfoldmap
   885                             path, norm, True, None, self._map.dirfoldmap
   884                         )
   886                         )
  1109         # We need to do full walks when either
  1111         # We need to do full walks when either
  1110         # - we're listing all clean files, or
  1112         # - we're listing all clean files, or
  1111         # - match.traversedir does something, because match.traversedir should
  1113         # - match.traversedir does something, because match.traversedir should
  1112         #   be called for every dir in the working dir
  1114         #   be called for every dir in the working dir
  1113         full = listclean or match.traversedir is not None
  1115         full = listclean or match.traversedir is not None
  1114         for fn, st in self.walk(
  1116         for fn, st in pycompat.iteritems(
  1115             match, subrepos, listunknown, listignored, full=full
  1117             self.walk(match, subrepos, listunknown, listignored, full=full)
  1116         ).iteritems():
  1118         ):
  1117             if not dcontains(fn):
  1119             if not dcontains(fn):
  1118                 if (listignored or mexact(fn)) and dirignore(fn):
  1120                 if (listignored or mexact(fn)) and dirignore(fn):
  1119                     if listignored:
  1121                     if listignored:
  1120                         iadd(fn)
  1122                         iadd(fn)
  1121                 else:
  1123                 else:
  1322         util.clearcachedproperty(self, b"dirfoldmap")
  1324         util.clearcachedproperty(self, b"dirfoldmap")
  1323         util.clearcachedproperty(self, b"nonnormalset")
  1325         util.clearcachedproperty(self, b"nonnormalset")
  1324         util.clearcachedproperty(self, b"otherparentset")
  1326         util.clearcachedproperty(self, b"otherparentset")
  1325 
  1327 
  1326     def items(self):
  1328     def items(self):
  1327         return self._map.iteritems()
  1329         return pycompat.iteritems(self._map)
  1328 
  1330 
  1329     # forward for python2,3 compat
  1331     # forward for python2,3 compat
  1330     iteritems = items
  1332     iteritems = items
  1331 
  1333 
  1332     def __len__(self):
  1334     def __len__(self):
  1410         try:
  1412         try:
  1411             return parsers.nonnormalotherparententries(self._map)
  1413             return parsers.nonnormalotherparententries(self._map)
  1412         except AttributeError:
  1414         except AttributeError:
  1413             nonnorm = set()
  1415             nonnorm = set()
  1414             otherparent = set()
  1416             otherparent = set()
  1415             for fname, e in self._map.iteritems():
  1417             for fname, e in pycompat.iteritems(self._map):
  1416                 if e[0] != b'n' or e[3] == -1:
  1418                 if e[0] != b'n' or e[3] == -1:
  1417                     nonnorm.add(fname)
  1419                     nonnorm.add(fname)
  1418                 if e[0] == b'n' and e[2] == -2:
  1420                 if e[0] == b'n' and e[2] == -2:
  1419                     otherparent.add(fname)
  1421                     otherparent.add(fname)
  1420             return nonnorm, otherparent
  1422             return nonnorm, otherparent
  1433                 self._map, util.normcasespec, util.normcasefallback
  1435                 self._map, util.normcasespec, util.normcasefallback
  1434             )
  1436             )
  1435 
  1437 
  1436         f = {}
  1438         f = {}
  1437         normcase = util.normcase
  1439         normcase = util.normcase
  1438         for name, s in self._map.iteritems():
  1440         for name, s in pycompat.iteritems(self._map):
  1439             if s[0] != b'r':
  1441             if s[0] != b'r':
  1440                 f[normcase(name)] = name
  1442                 f[normcase(name)] = name
  1441         f[b'.'] = b'.'  # prevents useless util.fspath() invocation
  1443         f[b'.'] = b'.'  # prevents useless util.fspath() invocation
  1442         return f
  1444         return f
  1443 
  1445