Mercurial > hg
comparison hgext/git/dirstate.py @ 47012:d55b71393907
node: replace nullid and friends with nodeconstants class
The introduction of 256bit hashes require changes to nullid and other
constant magic values. Start pushing them down from repository and
revlog where sensible.
Differential Revision: https://phab.mercurial-scm.org/D9465
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Mon, 29 Mar 2021 01:52:06 +0200 |
parents | 59fa3890d40a |
children | 7431f5ab0d2a |
comparison
equal
deleted
inserted
replaced
46992:5fa019ceb499 | 47012:d55b71393907 |
---|---|
2 | 2 |
3 import contextlib | 3 import contextlib |
4 import errno | 4 import errno |
5 import os | 5 import os |
6 | 6 |
7 from mercurial.node import nullid | 7 from mercurial.node import sha1nodeconstants |
8 from mercurial import ( | 8 from mercurial import ( |
9 error, | 9 error, |
10 extensions, | 10 extensions, |
11 match as matchmod, | 11 match as matchmod, |
12 pycompat, | 12 pycompat, |
79 try: | 79 try: |
80 return self.git.head.peel().id.raw | 80 return self.git.head.peel().id.raw |
81 except pygit2.GitError: | 81 except pygit2.GitError: |
82 # Typically happens when peeling HEAD fails, as in an | 82 # Typically happens when peeling HEAD fails, as in an |
83 # empty repository. | 83 # empty repository. |
84 return nullid | 84 return sha1nodeconstants.nullid |
85 | 85 |
86 def p2(self): | 86 def p2(self): |
87 # TODO: MERGE_HEAD? something like that, right? | 87 # TODO: MERGE_HEAD? something like that, right? |
88 return nullid | 88 return sha1nodeconstants.nullid |
89 | 89 |
90 def setparents(self, p1, p2=nullid): | 90 def setparents(self, p1, p2=None): |
91 assert p2 == nullid, b'TODO merging support' | 91 if p2 is None: |
92 p2 = sha1nodeconstants.nullid | |
93 assert p2 == sha1nodeconstants.nullid, b'TODO merging support' | |
92 self.git.head.set_target(gitutil.togitnode(p1)) | 94 self.git.head.set_target(gitutil.togitnode(p1)) |
93 | 95 |
94 @util.propertycache | 96 @util.propertycache |
95 def identity(self): | 97 def identity(self): |
96 return util.filestat.frompath( | 98 return util.filestat.frompath( |
100 def branch(self): | 102 def branch(self): |
101 return b'default' | 103 return b'default' |
102 | 104 |
103 def parents(self): | 105 def parents(self): |
104 # TODO how on earth do we find p2 if a merge is in flight? | 106 # TODO how on earth do we find p2 if a merge is in flight? |
105 return self.p1(), nullid | 107 return self.p1(), sha1nodeconstants.nullid |
106 | 108 |
107 def __iter__(self): | 109 def __iter__(self): |
108 return (pycompat.fsencode(f.path) for f in self.git.index) | 110 return (pycompat.fsencode(f.path) for f in self.git.index) |
109 | 111 |
110 def items(self): | 112 def items(self): |