comparison hgext/git/dirstate.py @ 44492:eb061d272af4

git: correctly handle p1() on dirstate when underlying git repo is empty This shows up in my next change, which ends up making an empty git repo and then running hg. Differential Revision: https://phab.mercurial-scm.org/D8271
author Augie Fackler <raf@durin42.com>
date Tue, 10 Mar 2020 13:10:45 -0400
parents ec54b3d2af0b
children 7bbb83e4e8de
comparison
equal deleted inserted replaced
44491:fb16ad368606 44492:eb061d272af4
74 self._root = os.path.dirname(root) 74 self._root = os.path.dirname(root)
75 self.git = gitrepo 75 self.git = gitrepo
76 self._plchangecallbacks = {} 76 self._plchangecallbacks = {}
77 77
78 def p1(self): 78 def p1(self):
79 return self.git.head.peel().id.raw 79 try:
80 return self.git.head.peel().id.raw
81 except pygit2.GitError:
82 # Typically happens when peeling HEAD fails, as in an
83 # empty repository.
84 return nodemod.nullid
80 85
81 def p2(self): 86 def p2(self):
82 # TODO: MERGE_HEAD? something like that, right? 87 # TODO: MERGE_HEAD? something like that, right?
83 return nodemod.nullid 88 return nodemod.nullid
84 89