archive: look for first visible revision to build repo identity (
issue4591)
No test for the case where all revisions are hidden because "archive" command
aborts if the target revision is null.
--- 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')
--- a/tests/test-obsolete.t Wed Apr 08 22:42:37 2015 +0900
+++ b/tests/test-obsolete.t Wed Apr 08 23:30:02 2015 +0900
@@ -250,6 +250,30 @@
o 0:1f0dee641bb7 (public) [ ] add a
+ $ cd ..
+
+Revision 0 is hidden
+--------------------
+
+ $ hg init rev0hidden
+ $ cd rev0hidden
+
+ $ mkcommit kill0
+ $ hg up -q null
+ $ hg debugobsolete `getid kill0`
+ $ mkcommit a
+ $ mkcommit b
+
+Should pick the first visible revision as "repo" node
+
+ $ hg archive ../archive-null
+ $ cat ../archive-null/.hg_archival.txt
+ repo: 1f0dee641bb7258c56bd60e93edfa2405381c41e
+ node: 7c3bad9141dcb46ff89abf5f61856facd56e476c
+ branch: default
+ latesttag: null
+ latesttagdistance: 2
+ changessincelatesttag: 2
$ cd ..