mercurial/archival.py
changeset 24681 33ab99a6ad9b
parent 24678 fbcace19534f
child 24953 5115d03440f4
child 25665 dc05a10e1e45
--- a/mercurial/archival.py	Wed Apr 08 22:42:37 2015 +0900
+++ b/mercurial/archival.py	Wed Apr 08 23:30:02 2015 +0900
@@ -54,11 +54,17 @@
             return kind
     return None
 
+def _rootctx(repo):
+    # repo[0] may be hidden
+    for rev in repo:
+        return repo[rev]
+    return repo['null']
+
 def buildmetadata(ctx):
     '''build content of .hg_archival.txt'''
     repo = ctx.repo()
     base = 'repo: %s\nnode: %s\nbranch: %s\n' % (
-        repo[0].hex(), ctx.hex(), encoding.fromlocal(ctx.branch()))
+        _rootctx(repo).hex(), ctx.hex(), encoding.fromlocal(ctx.branch()))
 
     tags = ''.join('tag: %s\n' % t for t in ctx.tags()
                    if repo.tagtype(t) == 'global')