From patchwork Sat Feb 3 08:36:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [9, of, 9] archive: rewrite default metadata template as a multi-line bytes literal From: Yuya Nishihara X-Patchwork-Id: 27268 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sat, 03 Feb 2018 17:36:20 +0900 # HG changeset patch # User Yuya Nishihara # Date 1517639173 -32400 # Sat Feb 03 15:26:13 2018 +0900 # Node ID d04fb3e17bb06003d0e16cb1a4be782cb7820f79 # Parent c1752bc1026f6388a83793b2fcf2eb6cddae53e1 archive: rewrite default metadata template as a multi-line bytes literal This fixes test-directaccess.t on Python 3. diff --git a/mercurial/archival.py b/mercurial/archival.py --- a/mercurial/archival.py +++ b/mercurial/archival.py @@ -76,29 +76,27 @@ def _rootctx(repo): return repo[rev] return repo['null'] +# {tags} on ctx includes local tags and 'tip', with no current way to limit +# that to global tags. Therefore, use {latesttag} as a substitute when +# the distance is 0, since that will be the list of global tags on ctx. +_defaultmetatemplate = br''' +repo: {root} +node: {ifcontains(rev, revset("wdir()"), "{p1node}{dirty}", "{node}")} +branch: {branch|utf8} +{ifeq(latesttagdistance, 0, join(latesttag % "tag: {tag}", "\n"), + separate("\n", + join(latesttag % "latesttag: {tag}", "\n"), + "latesttagdistance: {latesttagdistance}", + "changessincelatesttag: {changessincelatesttag}"))} +'''[1:] # drop leading '\n' + def buildmetadata(ctx): '''build content of .hg_archival.txt''' repo = ctx.repo() - default = ( - r'repo: {root}\n' - r'node: {ifcontains(rev, revset("wdir()"),' - r'"{p1node}{dirty}", "{node}")}\n' - r'branch: {branch|utf8}\n' - - # {tags} on ctx includes local tags and 'tip', with no current way to - # limit that to global tags. Therefore, use {latesttag} as a substitute - # when the distance is 0, since that will be the list of global tags on - # ctx. - r'{ifeq(latesttagdistance, 0, latesttag % "tag: {tag}\n",' - r'"{latesttag % "latesttag: {tag}\n"}' - r'latesttagdistance: {latesttagdistance}\n' - r'changessincelatesttag: {changessincelatesttag}\n")}' - ) - opts = { 'template': repo.ui.config('experimental', 'archivemetatemplate', - default) + _defaultmetatemplate) } out = util.stringio()