changeset 24680:0974d3a0be29

largefiles: use common function to build content of .hg_archival.txt This fixes the missing "changessincelatesttag" field introduced by 242d11819c6c.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 08 Apr 2015 22:42:37 +0900
parents 422d3c0c7f33
children 33ab99a6ad9b
files hgext/largefiles/overrides.py tests/test-largefiles-misc.t
diffstat 2 files changed, 3 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Wed Apr 08 22:38:46 2015 +0900
+++ b/hgext/largefiles/overrides.py	Wed Apr 08 22:42:37 2015 +0900
@@ -14,7 +14,6 @@
 from mercurial import hg, util, cmdutil, scmutil, match as match_, \
         archival, pathutil, revset
 from mercurial.i18n import _
-from mercurial.node import hex
 
 import lfutil
 import lfcommands
@@ -900,24 +899,8 @@
     archiver = archival.archivers[kind](dest, mtime or ctx.date()[0])
 
     if repo.ui.configbool("ui", "archivemeta", True):
-        def metadata():
-            base = 'repo: %s\nnode: %s\nbranch: %s\n' % (
-                hex(repo.changelog.node(0)), hex(node), ctx.branch())
-
-            tags = ''.join('tag: %s\n' % t for t in ctx.tags()
-                           if repo.tagtype(t) == 'global')
-            if not tags:
-                repo.ui.pushbuffer()
-                opts = {'template': '{latesttag}\n{latesttagdistance}',
-                        'style': '', 'patch': None, 'git': None}
-                cmdutil.show_changeset(repo.ui, repo, opts).show(ctx)
-                ltags, dist = repo.ui.popbuffer().split('\n')
-                tags = ''.join('latesttag: %s\n' % t for t in ltags.split(':'))
-                tags += 'latesttagdistance: %s\n' % dist
-
-            return base + tags
-
-        write('.hg_archival.txt', 0644, False, metadata)
+        write('.hg_archival.txt', 0644, False,
+              lambda: archival.buildmetadata(ctx))
 
     for f in ctx:
         ff = ctx.flags(f)
--- a/tests/test-largefiles-misc.t	Wed Apr 08 22:38:46 2015 +0900
+++ b/tests/test-largefiles-misc.t	Wed Apr 08 22:42:37 2015 +0900
@@ -342,6 +342,7 @@
   branch: default
   latesttag: null
   latesttagdistance: 4
+  changessincelatesttag: 4
 
 Test update with subrepos.