# HG changeset patch # User Siddharth Agarwal <sid0@fb.com> # Date 1393316592 28800 # Tue Feb 25 00:23:12 2014 -0800 # Node ID c99941ff2d287d2b1d76ceab4b3881974ede5f7c # Parent aa8519daf037d63cb6fb8b9a7387dea4c6f08973 overlayrevlog: handle root commits correctly Previously, we'd try to access commit.parents[0] and fail. Now, check for commit.parents being empty and return what Mercurial thinks is a repository root in that case. diff --git a/hggit/overlay.py b/hggit/overlay.py --- a/hggit/overlay.py +++ b/hggit/overlay.py @@ -192,6 +192,9 @@ return self.base.parents(n) commit = self.repo.handler.git.get_object(_maybehex(n)) + if not commit.parents: + return [nullid, nullid] + def gitorhg(n): hn = self.repo.handler.map_hg_get(hex(n)) if hn is not None: diff --git a/tests/test-incoming.t b/tests/test-incoming.t old mode 100755 new mode 100644 --- a/tests/test-incoming.t +++ b/tests/test-incoming.t @@ -9,6 +9,15 @@ $ fn_git_commit -m "add alpha" $ cd .. + $ hg init hgrepo-empty + $ hg -R hgrepo-empty incoming gitrepo | grep -v 'no changes found' | grep -v 'bookmark:' + comparing with gitrepo + changeset: 0:7eeab2ea75ec + user: test <test@example.org> + date: Mon Jan 01 00:00:10 2007 +0000 + summary: add alpha + + $ hg clone gitrepo hgrepo | grep -v '^updating' importing git objects into hg 1 files updated, 0 files merged, 0 files removed, 0 files unresolved