[PATCH 2 of 2] largefiles: make log match largefiles in the non-standin location too

Mads Kiilerich mads at kiilerich.com
Mon Jan 14 09:42:14 CST 2013


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1358178089 -3600
# Node ID b0d481f8485dfcdf9a42ef282c4a4f09c5746448
# Parent  0002bbd903171aa20826c5795419a75ead646e1f
largefiles: make log match largefiles in the non-standin location too

Yet another match hack.

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -240,11 +240,34 @@
         repo._repo.lfstatus = False
 
 def overridelog(orig, ui, repo, *pats, **opts):
+    def overridematch(ctx, pats=[], opts={}, globbed=False,
+            default='relpath'):
+        """Matcher that merges root directory with .hglf, suitable for log.
+        It is still possible to match .hglf directly.
+        For any listed files run log on the standin too.
+        matchfn tries both the given filename and with .hglf stripped.
+        """
+        match = oldmatch(ctx, pats, opts, globbed, default)
+        m = copy.copy(match)
+        standins = [lfutil.standin(f) for f in m._files]
+        m._files.extend(standins)
+        m._fmap = set(m._files)
+        origmatchfn = m.matchfn
+        def lfmatchfn(f):
+            lf = lfutil.splitstandin(f)
+            if lf is not None and origmatchfn(lf):
+                return True
+            r = origmatchfn(f)
+            return r
+        m.matchfn = lfmatchfn
+        return m
+    oldmatch = installmatchfn(overridematch)
     try:
         repo.lfstatus = True
         return orig(ui, repo, *pats, **opts)
     finally:
         repo.lfstatus = False
+        restorematchfn()
 
 def overrideverify(orig, ui, repo, *pats, **opts):
     large = opts.pop('large', False)
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -987,6 +987,47 @@
   $ cat sub2/large7
   large7
 
+Log on largefiles
+
+- same output
+  $ hg log --template '{rev}:{node|short}  {desc|firstline}\n' .hglf/sub/large4
+  8:a381d2c8c80e  modify normal file and largefile in repo b
+  6:4355d653f84f  edit files yet again
+  5:9d5af5072dbd  edit files again
+  4:74c02385b94c  move files
+  $ hg log --template '{rev}:{node|short}  {desc|firstline}\n' sub/large4
+  8:a381d2c8c80e  modify normal file and largefile in repo b
+  6:4355d653f84f  edit files yet again
+  5:9d5af5072dbd  edit files again
+  4:74c02385b94c  move files
+
+- .hglf only matches largefiles, without .hglf it matches 9 bco sub/normal
+  $ hg log --template '{rev}:{node|short}  {desc|firstline}\n' .hglf/sub
+  8:a381d2c8c80e  modify normal file and largefile in repo b
+  6:4355d653f84f  edit files yet again
+  5:9d5af5072dbd  edit files again
+  4:74c02385b94c  move files
+  1:ce8896473775  edit files
+  0:30d30fe6a5be  add files
+  $ hg log --template '{rev}:{node|short}  {desc|firstline}\n' sub
+  9:598410d3eb9a  modify normal file largefile in repo d
+  8:a381d2c8c80e  modify normal file and largefile in repo b
+  6:4355d653f84f  edit files yet again
+  5:9d5af5072dbd  edit files again
+  4:74c02385b94c  move files
+  1:ce8896473775  edit files
+  0:30d30fe6a5be  add files
+
+- globbing gives same result
+  $ hg log --template '{rev}:{node|short}  {desc|firstline}\n' 'glob:sub/*'
+  9:598410d3eb9a  modify normal file largefile in repo d
+  8:a381d2c8c80e  modify normal file and largefile in repo b
+  6:4355d653f84f  edit files yet again
+  5:9d5af5072dbd  edit files again
+  4:74c02385b94c  move files
+  1:ce8896473775  edit files
+  0:30d30fe6a5be  add files
+
 Rollback on largefiles.
 
   $ echo large4-modified-again > sub/large4


More information about the Mercurial-devel mailing list