Patchwork [4,of,6,stable] largefiles: in overridelog, use non-lf matcher for patch generation (issue4334)

login
register
mail settings
Submitter Siddharth Agarwal
Date Aug. 13, 2014, 11:05 p.m.
Message ID <d2de7533ff9f945ef7a2.1407971123@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/5385/
State Accepted
Headers show

Comments

Siddharth Agarwal - Aug. 13, 2014, 11:05 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1407968321 25200
#      Wed Aug 13 15:18:41 2014 -0700
# Branch stable
# Node ID d2de7533ff9f945ef7a26080d9ff8d15fdddde89
# Parent  f8b7102e2de614132fd1ff5291cd2b33a795b9c7
largefiles: in overridelog, use non-lf matcher for patch generation (issue4334)

This has actually been broken since at least Mercurial 2.8 -- hg log --patch
with largefiles only used to work when no largefiles existed. Rev 5809d62e7106
exposed this bug for all cases.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -299,11 +299,25 @@ 
 
         return m, pats
 
+    # For hg log --patch, the match object is used in two different senses:
+    # (1) to determine what revisions should be printed out, and
+    # (2) to determine what files to print out diffs for.
+    # The magic matchandpats override should be used for case (1) but not for
+    # case (2).
+    def overridemakelogfilematcher(repo, pats, opts):
+        pctx = repo[None]
+        match, pats = oldmatchandpats(pctx, pats, opts)
+        return lambda rev: match
+
     oldmatchandpats = installmatchandpatsfn(overridematchandpats)
+    oldmakelogfilematcher = cmdutil._makenofollowlogfilematcher
+    setattr(cmdutil, '_makenofollowlogfilematcher', overridemakelogfilematcher)
+
     try:
         return orig(ui, repo, *pats, **opts)
     finally:
         restorematchandpatsfn()
+        setattr(cmdutil, '_makenofollowlogfilematcher', oldmakelogfilematcher)
 
 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
@@ -724,6 +724,81 @@ 
   |
   o  0:30d30fe6a5be  add files
   
+
+Test log with --patch
+  $ hg log --patch -r 6::7
+  changeset:   6:4355d653f84f
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     edit files yet again
+  
+  diff -r 9d5af5072dbd -r 4355d653f84f .hglf/large3
+  --- a/.hglf/large3	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/.hglf/large3	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,1 @@
+  -baaf12afde9d8d67f25dab6dced0d2bf77dba47c
+  +7838695e10da2bb75ac1156565f40a2595fa2fa0
+  diff -r 9d5af5072dbd -r 4355d653f84f .hglf/sub/large4
+  --- a/.hglf/sub/large4	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/.hglf/sub/large4	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,1 @@
+  -aeb2210d19f02886dde00dac279729a48471e2f9
+  +971fb41e78fea4f8e0ba5244784239371cb00591
+  diff -r 9d5af5072dbd -r 4355d653f84f normal3
+  --- a/normal3	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/normal3	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,1 @@
+  -normal3
+  +normal33
+  diff -r 9d5af5072dbd -r 4355d653f84f sub/normal4
+  --- a/sub/normal4	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/sub/normal4	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,1 @@
+  -normal4
+  +normal44
+  
+  changeset:   7:daea875e9014
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add/edit more largefiles
+  
+  diff -r 4355d653f84f -r daea875e9014 .hglf/large3
+  --- a/.hglf/large3	Thu Jan 01 00:00:00 1970 +0000
+  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +0,0 @@
+  -7838695e10da2bb75ac1156565f40a2595fa2fa0
+  diff -r 4355d653f84f -r daea875e9014 .hglf/sub2/large6
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/.hglf/sub2/large6	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +0d6d75887db61b2c7e6c74b5dd8fc6ad50c0cc30
+  diff -r 4355d653f84f -r daea875e9014 .hglf/sub2/large7
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/.hglf/sub2/large7	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +bb3151689acb10f0c3125c560d5e63df914bc1af
+  
+
+  $ hg log --patch -r 6::7 sub/
+  changeset:   6:4355d653f84f
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     edit files yet again
+  
+  diff -r 9d5af5072dbd -r 4355d653f84f .hglf/sub/large4
+  --- a/.hglf/sub/large4	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/.hglf/sub/large4	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,1 @@
+  -aeb2210d19f02886dde00dac279729a48471e2f9
+  +971fb41e78fea4f8e0ba5244784239371cb00591
+  diff -r 9d5af5072dbd -r 4355d653f84f sub/normal4
+  --- a/sub/normal4	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/sub/normal4	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,1 @@
+  -normal4
+  +normal44
+  
   $ cat sub/normal4
   normal44
   $ cat sub/large4