changeset 18341:ed23d6100dd3

largefiles: make log match largefiles in the non-standin location too Yet another match hack.
author Mads Kiilerich <mads@kiilerich.com>
date Tue, 15 Jan 2013 01:05:12 +0100
parents 8802277c40ee
children de99de39ba28
files hgext/largefiles/overrides.py tests/test-largefiles.t
diffstat 2 files changed, 64 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Tue Jan 15 01:05:12 2013 +0100
+++ b/hgext/largefiles/overrides.py	Tue Jan 15 01:05:12 2013 +0100
@@ -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)
--- a/tests/test-largefiles.t	Tue Jan 15 01:05:12 2013 +0100
+++ b/tests/test-largefiles.t	Tue Jan 15 01:05:12 2013 +0100
@@ -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