Patchwork [4,of,5] largefiles: use common function to build content of .hg_archival.txt

login
register
mail settings
Submitter Yuya Nishihara
Date April 9, 2015, 12:57 p.m.
Message ID <8837e54c611889f857f1.1428584236@mimosa>
Download mbox | patch
Permalink /patch/8573/
State Accepted
Commit 0974d3a0be294fb5327f9d8c228120258725097b
Headers show

Comments

Yuya Nishihara - April 9, 2015, 12:57 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1428500557 -32400
#      Wed Apr 08 22:42:37 2015 +0900
# Node ID 8837e54c611889f857f111dcec7720af63bb334a
# Parent  c6e25c1691f0dae2cac4fb5d930ebeab0f2b60c1
largefiles: use common function to build content of .hg_archival.txt

This fixes the missing "changessincelatesttag" field introduced by
242d11819c6c.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -14,7 +14,6 @@  import copy
 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 @@  def overridearchive(orig, repo, dest, no
     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)
diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t
--- a/tests/test-largefiles-misc.t
+++ b/tests/test-largefiles-misc.t
@@ -342,6 +342,7 @@  Lock in subrepo, otherwise the change is
   branch: default
   latesttag: null
   latesttagdistance: 4
+  changessincelatesttag: 4
 
 Test update with subrepos.