D8271: git: correctly handle p1() on dirstate when underlying git repo is empty
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Tue Mar 10 17:26:19 UTC 2020
Closed by commit rHGeb061d272af4: git: correctly handle p1() on dirstate when underlying git repo is empty (authored by durin42).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D8271?vs=20668&id=20670
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8271/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8271
AFFECTED FILES
hgext/git/dirstate.py
CHANGE DETAILS
diff --git a/hgext/git/dirstate.py b/hgext/git/dirstate.py
--- a/hgext/git/dirstate.py
+++ b/hgext/git/dirstate.py
@@ -76,7 +76,12 @@
self._plchangecallbacks = {}
def p1(self):
- return self.git.head.peel().id.raw
+ try:
+ return self.git.head.peel().id.raw
+ except pygit2.GitError:
+ # Typically happens when peeling HEAD fails, as in an
+ # empty repository.
+ return nodemod.nullid
def p2(self):
# TODO: MERGE_HEAD? something like that, right?
To: durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list