Details
Details
- Reviewers
pulkit - Group Reviewers
hg-reviewers
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
| pulkit |
| hg-reviewers |
| No Linters Available |
| No Unit Test Coverage |
| Path | Packages | |||
|---|---|---|---|---|
| M | hgext/git/dirstate.py (4 lines) | |||
| M | hgext/git/manifest.py (8 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| e9deee017d5a | 867ba2d4102d | Pulkit Goyal | Feb 28 2020, 8:19 AM |
| return nodemod.nullid | return nodemod.nullid | ||||
| def setparents(self, p1, p2=nodemod.nullid): | def setparents(self, p1, p2=nodemod.nullid): | ||||
| assert p2 == nodemod.nullid, b'TODO merging support' | assert p2 == nodemod.nullid, b'TODO merging support' | ||||
| self.git.head.set_target(gitutil.togitnode(p1)) | self.git.head.set_target(gitutil.togitnode(p1)) | ||||
| @util.propertycache | @util.propertycache | ||||
| def identity(self): | def identity(self): | ||||
| self.identity = util.filestat.frompath( | return util.filestat.frompath( | ||||
| os.path.join(self.root, b'.git', b'index') | os.path.join(self._root, b'.git', b'index') | ||||
| ) | ) | ||||
| def branch(self): | def branch(self): | ||||
| return b'default' | return b'default' | ||||
| def parents(self): | def parents(self): | ||||
| # TODO how on earth do we find p2 if a merge is in flight? | # TODO how on earth do we find p2 if a merge is in flight? | ||||
| return self.p1(), nodemod.nullid | return self.p1(), nodemod.nullid | ||||
| val = self._pending_changes[path] | val = self._pending_changes[path] | ||||
| if val is None: | if val is None: | ||||
| raise KeyError | raise KeyError | ||||
| return val | return val | ||||
| t = self._tree | t = self._tree | ||||
| comps = upath.split('/') | comps = upath.split('/') | ||||
| for comp in comps[:-1]: | for comp in comps[:-1]: | ||||
| te = self._tree[comp] | te = self._tree[comp] | ||||
| t = self.gitrepo[te.id] | t = self._git_repo[te.id] | ||||
| ent = t[comps[-1]] | ent = t[comps[-1]] | ||||
| if ent.filemode == pygit2.GIT_FILEMODE_BLOB: | if ent.filemode == pygit2.GIT_FILEMODE_BLOB: | ||||
| flags = b'' | flags = b'' | ||||
| elif ent.filemode == pygit2.GIT_FILEMODE_BLOB_EXECUTABLE: | elif ent.filemode == pygit2.GIT_FILEMODE_BLOB_EXECUTABLE: | ||||
| flags = b'x' | flags = b'x' | ||||
| elif ent.filemode == pygit2.GIT_FILEMODE_LINK: | elif ent.filemode == pygit2.GIT_FILEMODE_LINK: | ||||
| flags = b'l' | flags = b'l' | ||||
| else: | else: | ||||
| raise ValueError('unsupported mode %s' % oct(ent.filemode)) | raise ValueError('unsupported mode %s' % oct(ent.filemode)) | ||||
| return ent.id.raw, flags | return ent.id.raw, flags | ||||
| def __getitem__(self, path): | def __getitem__(self, path): | ||||
| return self._resolve_entry(path)[0] | return self._resolve_entry(path)[0] | ||||
| def find(self, path): | def find(self, path): | ||||
| return self._resolve_entry(path) | return self._resolve_entry(path) | ||||
| def __len__(self): | def __len__(self): | ||||
| return len(list(self.walk())) | return len(list(self.walk(matchmod.always()))) | ||||
| def __nonzero__(self): | def __nonzero__(self): | ||||
| try: | try: | ||||
| next(iter(self)) | next(iter(self)) | ||||
| return True | return True | ||||
| except StopIteration: | except StopIteration: | ||||
| return False | return False | ||||
| def __bool__(self): | def __bool__(self): | ||||
| return self.__nonzero__(self) | return self.__nonzero__() | ||||
| def __contains__(self, path): | def __contains__(self, path): | ||||
| try: | try: | ||||
| self._resolve_entry(path) | self._resolve_entry(path) | ||||
| return True | return True | ||||
| except KeyError: | except KeyError: | ||||
| return False | return False | ||||
| assert False # TODO can this method move out of the manifest iface? | assert False # TODO can this method move out of the manifest iface? | ||||
| def _walkonetree(self, tree, match, subdir): | def _walkonetree(self, tree, match, subdir): | ||||
| for te in tree: | for te in tree: | ||||
| # TODO: can we prune dir walks with the matcher? | # TODO: can we prune dir walks with the matcher? | ||||
| realname = subdir + pycompat.fsencode(te.name) | realname = subdir + pycompat.fsencode(te.name) | ||||
| if te.type == r'tree': | if te.type == r'tree': | ||||
| for inner in self._walkonetree( | for inner in self._walkonetree( | ||||
| self.gitrepo[te.id], match, realname + b'/' | self._git_repo[te.id], match, realname + b'/' | ||||
| ): | ): | ||||
| yield inner | yield inner | ||||
| if not match(realname): | if not match(realname): | ||||
| continue | continue | ||||
| yield pycompat.fsencode(realname) | yield pycompat.fsencode(realname) | ||||
| def walk(self, match): | def walk(self, match): | ||||
| # TODO: this is a very lazy way to merge in the pending | # TODO: this is a very lazy way to merge in the pending | ||||