Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG3cacb74c3a22: treemanifests: skip extraneous check for item before calling _loadlazy
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/manifest.py (27 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| spectral | Oct 2 2018, 4:41 PM |
| return self.iterkeys() | return self.iterkeys() | ||||
| def __contains__(self, f): | def __contains__(self, f): | ||||
| if f is None: | if f is None: | ||||
| return False | return False | ||||
| self._load() | self._load() | ||||
| dir, subpath = _splittopdir(f) | dir, subpath = _splittopdir(f) | ||||
| if dir: | if dir: | ||||
| if dir in self._lazydirs: | |||||
| self._loadlazy(dir) | self._loadlazy(dir) | ||||
| if dir not in self._dirs: | if dir not in self._dirs: | ||||
| return False | return False | ||||
| return self._dirs[dir].__contains__(subpath) | return self._dirs[dir].__contains__(subpath) | ||||
| else: | else: | ||||
| return f in self._files | return f in self._files | ||||
| def get(self, f, default=None): | def get(self, f, default=None): | ||||
| self._load() | self._load() | ||||
| dir, subpath = _splittopdir(f) | dir, subpath = _splittopdir(f) | ||||
| if dir: | if dir: | ||||
| if dir in self._lazydirs: | |||||
| self._loadlazy(dir) | self._loadlazy(dir) | ||||
| if dir not in self._dirs: | if dir not in self._dirs: | ||||
| return default | return default | ||||
| return self._dirs[dir].get(subpath, default) | return self._dirs[dir].get(subpath, default) | ||||
| else: | else: | ||||
| return self._files.get(f, default) | return self._files.get(f, default) | ||||
| def __getitem__(self, f): | def __getitem__(self, f): | ||||
| self._load() | self._load() | ||||
| dir, subpath = _splittopdir(f) | dir, subpath = _splittopdir(f) | ||||
| if dir: | if dir: | ||||
| if dir in self._lazydirs: | |||||
| self._loadlazy(dir) | self._loadlazy(dir) | ||||
| return self._dirs[dir].__getitem__(subpath) | return self._dirs[dir].__getitem__(subpath) | ||||
| else: | else: | ||||
| return self._files[f] | return self._files[f] | ||||
| def flags(self, f): | def flags(self, f): | ||||
| self._load() | self._load() | ||||
| dir, subpath = _splittopdir(f) | dir, subpath = _splittopdir(f) | ||||
| if dir: | if dir: | ||||
| if dir in self._lazydirs: | |||||
| self._loadlazy(dir) | self._loadlazy(dir) | ||||
| if dir not in self._dirs: | if dir not in self._dirs: | ||||
| return '' | return '' | ||||
| return self._dirs[dir].flags(subpath) | return self._dirs[dir].flags(subpath) | ||||
| else: | else: | ||||
| if f in self._lazydirs or f in self._dirs: | if f in self._lazydirs or f in self._dirs: | ||||
| return '' | return '' | ||||
| return self._flags.get(f, '') | return self._flags.get(f, '') | ||||
| def find(self, f): | def find(self, f): | ||||
| self._load() | self._load() | ||||
| dir, subpath = _splittopdir(f) | dir, subpath = _splittopdir(f) | ||||
| if dir: | if dir: | ||||
| if dir in self._lazydirs: | |||||
| self._loadlazy(dir) | self._loadlazy(dir) | ||||
| return self._dirs[dir].find(subpath) | return self._dirs[dir].find(subpath) | ||||
| else: | else: | ||||
| return self._files[f], self._flags.get(f, '') | return self._files[f], self._flags.get(f, '') | ||||
| def __delitem__(self, f): | def __delitem__(self, f): | ||||
| self._load() | self._load() | ||||
| dir, subpath = _splittopdir(f) | dir, subpath = _splittopdir(f) | ||||
| if dir: | if dir: | ||||
| if dir in self._lazydirs: | |||||
| self._loadlazy(dir) | self._loadlazy(dir) | ||||
| self._dirs[dir].__delitem__(subpath) | self._dirs[dir].__delitem__(subpath) | ||||
| # If the directory is now empty, remove it | # If the directory is now empty, remove it | ||||
| if self._dirs[dir]._isempty(): | if self._dirs[dir]._isempty(): | ||||
| del self._dirs[dir] | del self._dirs[dir] | ||||
| else: | else: | ||||
| del self._files[f] | del self._files[f] | ||||
| if f in self._flags: | if f in self._flags: | ||||
| del self._flags[f] | del self._flags[f] | ||||
| self._dirty = True | self._dirty = True | ||||
| def __setitem__(self, f, n): | def __setitem__(self, f, n): | ||||
| assert n is not None | assert n is not None | ||||
| self._load() | self._load() | ||||
| dir, subpath = _splittopdir(f) | dir, subpath = _splittopdir(f) | ||||
| if dir: | if dir: | ||||
| if dir in self._lazydirs: | |||||
| self._loadlazy(dir) | self._loadlazy(dir) | ||||
| if dir not in self._dirs: | if dir not in self._dirs: | ||||
| self._dirs[dir] = treemanifest(self._subpath(dir)) | self._dirs[dir] = treemanifest(self._subpath(dir)) | ||||
| self._dirs[dir].__setitem__(subpath, n) | self._dirs[dir].__setitem__(subpath, n) | ||||
| else: | else: | ||||
| self._files[f] = n[:21] # to match manifestdict's behavior | self._files[f] = n[:21] # to match manifestdict's behavior | ||||
| self._dirty = True | self._dirty = True | ||||
| def _load(self): | def _load(self): | ||||
| if self._loadfunc is not _noop: | if self._loadfunc is not _noop: | ||||
| lf, self._loadfunc = self._loadfunc, _noop | lf, self._loadfunc = self._loadfunc, _noop | ||||
| lf(self) | lf(self) | ||||
| elif self._copyfunc is not _noop: | elif self._copyfunc is not _noop: | ||||
| cf, self._copyfunc = self._copyfunc, _noop | cf, self._copyfunc = self._copyfunc, _noop | ||||
| cf(self) | cf(self) | ||||
| def setflag(self, f, flags): | def setflag(self, f, flags): | ||||
| """Set the flags (symlink, executable) for path f.""" | """Set the flags (symlink, executable) for path f.""" | ||||
| self._load() | self._load() | ||||
| dir, subpath = _splittopdir(f) | dir, subpath = _splittopdir(f) | ||||
| if dir: | if dir: | ||||
| if dir in self._lazydirs: | |||||
| self._loadlazy(dir) | self._loadlazy(dir) | ||||
| if dir not in self._dirs: | if dir not in self._dirs: | ||||
| self._dirs[dir] = treemanifest(self._subpath(dir)) | self._dirs[dir] = treemanifest(self._subpath(dir)) | ||||
| self._dirs[dir].setflag(subpath, flags) | self._dirs[dir].setflag(subpath, flags) | ||||
| else: | else: | ||||
| self._flags[f] = flags | self._flags[f] = flags | ||||
| self._dirty = True | self._dirty = True | ||||
| def copy(self): | def copy(self): | ||||
| def dirs(self): | def dirs(self): | ||||
| return self._alldirs | return self._alldirs | ||||
| def hasdir(self, dir): | def hasdir(self, dir): | ||||
| self._load() | self._load() | ||||
| topdir, subdir = _splittopdir(dir) | topdir, subdir = _splittopdir(dir) | ||||
| if topdir: | if topdir: | ||||
| if topdir in self._lazydirs: | |||||
| self._loadlazy(topdir) | self._loadlazy(topdir) | ||||
| if topdir in self._dirs: | if topdir in self._dirs: | ||||
| return self._dirs[topdir].hasdir(subdir) | return self._dirs[topdir].hasdir(subdir) | ||||
| return False | return False | ||||
| dirslash = dir + '/' | dirslash = dir + '/' | ||||
| return dirslash in self._dirs or dirslash in self._lazydirs | return dirslash in self._dirs or dirslash in self._lazydirs | ||||
| def walk(self, match): | def walk(self, match): | ||||
| '''Generates matching file names. | '''Generates matching file names. | ||||