Show More
@@ -18,9 +18,8 b' import zlib' | |||
|
18 | 18 | from .i18n import _ |
|
19 | 19 | |
|
20 | 20 | from . import ( |
|
21 | cmdutil, | |
|
22 | encoding, | |
|
23 | 21 | error, |
|
22 | formatter, | |
|
24 | 23 | match as matchmod, |
|
25 | 24 | util, |
|
26 | 25 | vfs as vfsmod, |
@@ -80,30 +79,42 b' def _rootctx(repo):' | |||
|
80 | 79 | def buildmetadata(ctx): |
|
81 | 80 | '''build content of .hg_archival.txt''' |
|
82 | 81 | repo = ctx.repo() |
|
83 | hex = ctx.hex() | |
|
84 | if ctx.rev() is None: | |
|
85 | hex = ctx.p1().hex() | |
|
86 | if ctx.dirty(missing=True): | |
|
87 | hex += '+' | |
|
82 | ||
|
83 | default = ( | |
|
84 | r'repo: {root}\n' | |
|
85 | r'node: {ifcontains(rev, revset("wdir()"),' | |
|
86 | r'"{p1node}{dirty}", "{node}")}\n' | |
|
87 | r'branch: {branch|utf8}\n' | |
|
88 | 88 | |
|
89 | base = 'repo: %s\nnode: %s\nbranch: %s\n' % ( | |
|
90 | _rootctx(repo).hex(), hex, encoding.fromlocal(ctx.branch())) | |
|
89 | # {tags} on ctx includes local tags and 'tip', with no current way to | |
|
90 | # limit that to global tags. Therefore, use {latesttag} as a substitute | |
|
91 | # when the distance is 0, since that will be the list of global tags on | |
|
92 | # ctx. | |
|
93 | r'{ifeq(latesttagdistance, 0, latesttag % "tag: {tag}\n",' | |
|
94 | r'"{latesttag % "latesttag: {tag}\n"}' | |
|
95 | r'latesttagdistance: {latesttagdistance}\n' | |
|
96 | r'changessincelatesttag: {changessincelatesttag}\n")}' | |
|
97 | ) | |
|
91 | 98 | |
|
92 | tags = ''.join('tag: %s\n' % t for t in ctx.tags() | |
|
93 | if repo.tagtype(t) == 'global') | |
|
94 | if not tags: | |
|
95 | repo.ui.pushbuffer() | |
|
96 | opts = {'template': '{latesttag}\n{latesttagdistance}\n' | |
|
97 | '{changessincelatesttag}', | |
|
98 | 'style': '', 'patch': None, 'git': None} | |
|
99 | cmdutil.show_changeset(repo.ui, repo, opts).show(ctx) | |
|
100 | ltags, dist, changessince = repo.ui.popbuffer().split('\n') | |
|
101 | ltags = ltags.split(':') | |
|
102 | tags = ''.join('latesttag: %s\n' % t for t in ltags) | |
|
103 | tags += 'latesttagdistance: %s\n' % dist | |
|
104 | tags += 'changessincelatesttag: %s\n' % changessince | |
|
99 | opts = { | |
|
100 | 'template': default | |
|
101 | } | |
|
102 | ||
|
103 | out = util.stringio() | |
|
105 | 104 | |
|
106 | return base + tags | |
|
105 | fm = formatter.formatter(repo.ui, out, 'archive', opts) | |
|
106 | fm.startitem() | |
|
107 | fm.context(ctx=ctx) | |
|
108 | fm.data(root=_rootctx(repo).hex()) | |
|
109 | ||
|
110 | if ctx.rev() is None: | |
|
111 | dirty = '' | |
|
112 | if ctx.dirty(missing=True): | |
|
113 | dirty = '+' | |
|
114 | fm.data(dirty=dirty) | |
|
115 | fm.end() | |
|
116 | ||
|
117 | return out.getvalue() | |
|
107 | 118 | |
|
108 | 119 | class tarit(object): |
|
109 | 120 | '''write archive to tar file or stream. can write uncompressed, |
General Comments 0
You need to be logged in to leave comments.
Login now