Patchwork [2,of,2,stable] largefiles: fix cat when using relative paths from subdirectory

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 25, 2013, 5:34 p.m.
Message ID <235c36b2fa6887b601f7.1359135246@mk-desktop>
Download mbox | patch
Permalink /patch/736/
State Accepted
Commit b7da9c042b9e640cedb73d283cf0ca8f41459315
Headers show

Comments

Mads Kiilerich - Jan. 25, 2013, 5:34 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1359134413 -3600
# Branch stable
# Node ID 235c36b2fa6887b601f729b409a7f6673203772a
# Parent  1fa7dfd609ffd5464d2aef473cb1191758b0e073
largefiles: fix cat when using relative paths from subdirectory
Mads Kiilerich - Jan. 28, 2013, 2:31 p.m.
On 01/27/2013 04:52 PM, Kevin Bullock wrote:
> On 25 Jan 2013, at 11:34 AM, Mads Kiilerich wrote:
>
>> # HG changeset patch
>> # User Mads Kiilerich <madski@unity3d.com>
>> # Date 1359134413 -3600
>> # Branch stable
>> # Node ID 235c36b2fa6887b601f729b409a7f6673203772a
>> # Parent  1fa7dfd609ffd5464d2aef473cb1191758b0e073
>> largefiles: fix cat when using relative paths from subdirectory
> This series looks good (and pretty straightforward), crew it.
>

Thanks, pushed

/Mads

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -1149,10 +1149,25 @@ 
 
 def overridecat(orig, ui, repo, file1, *pats, **opts):
     ctx = scmutil.revsingle(repo, opts.get('rev'))
-    if not lfutil.standin(file1) in ctx:
-        result = orig(ui, repo, file1, *pats, **opts)
-        return result
-    return lfcommands.catlfile(repo, file1, ctx.rev(), opts.get('output'))
+    err = 1
+    notbad = set()
+    m = scmutil.match(ctx, (file1,) + pats, opts)
+    origmatchfn = m.matchfn
+    def lfmatchfn(f):
+        lf = lfutil.splitstandin(f)
+        if lf is None:
+            return origmatchfn(f)
+        notbad.add(lf)
+        return origmatchfn(lf)
+    m.matchfn = lfmatchfn
+    m.bad = lambda f, msg: f not in notbad
+    for f in ctx.walk(m):
+        lf = lfutil.splitstandin(f)
+        if lf is None:
+            err = orig(ui, repo, f, **opts)
+        else:
+            err = lfcommands.catlfile(repo, lf, ctx.rev(), opts.get('output'))
+    return err
 
 def mercurialsinkbefore(orig, sink):
     sink.repo._isconverting = True
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -1338,8 +1338,10 @@ 
   normal3-modified
   $ hg cat -r '.^' normal3
   normal3-modified
-  $ hg cat -r '.^' sub/large4
+  $ hg cat -r '.^' sub/large4 doesntexist
   large4-modified
+  doesntexist: no such file in rev a381d2c8c80e
+  [1]
 
 Test that renaming a largefile results in correct output for status
 
@@ -1865,6 +1867,8 @@ 
   $ echo more >> anotherlarge
   $ hg st .
   M anotherlarge
+  $ hg cat anotherlarge
+  anotherlarge
   $ hg revert anotherlarge
   $ hg st
   ? sub/anotherlarge.orig