D5176: archive: change "matcnfn" argument to a real matcher

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Mon Oct 22 15:16:26 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG3d76a8e627a6: archive: change "matcnfn" argument to a real matcher (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5176?vs=12290&id=12311

REVISION DETAIL
  https://phab.mercurial-scm.org/D5176

AFFECTED FILES
  hgext/extdiff.py
  hgext/largefiles/overrides.py
  mercurial/archival.py
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1216,8 +1216,7 @@
 
     bodyfh = web.res.getbodyfile()
 
-    archival.archive(web.repo, bodyfh, cnode, artype, prefix=name,
-                     matchfn=match,
+    archival.archive(web.repo, bodyfh, cnode, artype, prefix=name, match=match,
                      subrepos=web.configbool("web", "archivesubrepos"))
 
     return []
diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -274,7 +274,7 @@
     'zip': zipit,
     }
 
-def archive(repo, dest, node, kind, decode=True, matchfn=None,
+def archive(repo, dest, node, kind, decode=True, match=None,
             prefix='', mtime=None, subrepos=False):
     '''create archive of repo as it was at node.
 
@@ -286,7 +286,7 @@
     decode tells whether to put files through decode filters from
     hgrc.
 
-    matchfn is function to filter names of files to write to archive.
+    match is a matcher to filter names of files to write to archive.
 
     prefix is name of path to put before every archive member.
 
@@ -315,11 +315,11 @@
 
     if repo.ui.configbool("ui", "archivemeta"):
         name = '.hg_archival.txt'
-        if not matchfn or matchfn(name):
+        if not match or match(name):
             write(name, 0o644, False, lambda: buildmetadata(ctx))
 
-    if matchfn:
-        files = [f for f in ctx.manifest().keys() if matchfn(f)]
+    if match:
+        files = [f for f in ctx.manifest().keys() if match(f)]
     else:
         files = ctx.manifest().keys()
     total = len(files)
@@ -339,7 +339,7 @@
     if subrepos:
         for subpath in sorted(ctx.substate):
             sub = ctx.workingsub(subpath)
-            submatch = matchmod.subdirmatcher(subpath, matchfn)
+            submatch = matchmod.subdirmatcher(subpath, match)
             total += sub.archive(archiver, prefix, submatch, decode)
 
     if total == 0:
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -929,12 +929,12 @@
     finally:
         web.repo.lfstatus = False
 
-def overridearchive(orig, repo, dest, node, kind, decode=True, matchfn=None,
+def overridearchive(orig, repo, dest, node, kind, decode=True, match=None,
             prefix='', mtime=None, subrepos=None):
     # For some reason setting repo.lfstatus in hgwebarchive only changes the
     # unfiltered repo's attr, so check that as well.
     if not repo.lfstatus and not repo.unfiltered().lfstatus:
-        return orig(repo, dest, node, kind, decode, matchfn, prefix, mtime,
+        return orig(repo, dest, node, kind, decode, match, prefix, mtime,
                     subrepos)
 
     # No need to lock because we are only reading history and
@@ -955,7 +955,7 @@
         prefix = archival.tidyprefix(dest, kind, prefix)
 
     def write(name, mode, islink, getdata):
-        if matchfn and not matchfn(name):
+        if match and not match(name):
             return
         data = getdata()
         if decode:
@@ -991,7 +991,7 @@
     if subrepos:
         for subpath in sorted(ctx.substate):
             sub = ctx.workingsub(subpath)
-            submatch = matchmod.subdirmatcher(subpath, matchfn)
+            submatch = matchmod.subdirmatcher(subpath, match)
             sub._repo.lfstatus = True
             sub.archive(archiver, prefix, submatch)
 
diff --git a/hgext/extdiff.py b/hgext/extdiff.py
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -139,7 +139,7 @@
         repo.ui.setconfig("ui", "archivemeta", False)
 
         archival.archive(repo, base, node, 'files',
-                         matchfn=scmutil.matchfiles(repo, files),
+                         match=scmutil.matchfiles(repo, files),
                          subrepos=listsubrepos)
 
         for fn in sorted(files):



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list