[PATCH 2 of 3] largefiles: don't prefix standin patterns with '.hglf' when logging

Matt Harbison mharbison72 at gmail.com
Tue Mar 3 22:57:00 CST 2015


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1425237714 18000
#      Sun Mar 01 14:21:54 2015 -0500
# Node ID 4deaf73138da53d72506cc439f256cb5418bf548
# Parent  a3c200d0caa9bbada74452db54bed0580ec83447
largefiles: don't prefix standin patterns with '.hglf' when logging

When logging '.hglf/foo', the pattern list was being transformed from
['.hglf/foo'] into ['.hglf/foo', '.hglf/.hglf/foo'].  Aside from the
pathological case of somebody getting a directory named '.hglf' created inside
the standing directory, the old code shouldn't have had any bad effects.

MinGW gets in the way when logging standins from a non root directory, changing
'glob:../.hglf/sub/another*' into ['glob;..\\.hglf\\sub\\another*'] before
Mercurial even gets a shot at it.  It's conditionalized for test stability, but
I don't see a way around the check-code warning.  Maybe hiding it (or the path
part anyway) in a shell variable.

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -319,11 +319,21 @@
             back = (m._cwd.count('/') + 1) * '../'
 
             def tostandin(f):
+                # The file may already be a standin, so trucate the back
+                # escaping and test before mangling it.  This avoids turning
+                # 'glob:../.hglf/foo*' into 'glob:../.hglf/../.hglf/foo*'.
+                if f.startswith(back) and lfutil.splitstandin(f[len(back):]):
+                    return f
+
                 return back + lfutil.standin(m._cwd + '/' + f)
 
             pats.update(fixpats(f, tostandin) for f in p)
         else:
-            pats.update(fixpats(f) for f in p)
+            def tostandin(f):
+                if lfutil.splitstandin(f):
+                    return f
+                return lfutil.standin(f)
+            pats.update(fixpats(f, tostandin) for f in p)
 
         for i in range(0, len(m._files)):
             # Don't add '.hglf' to m.files, since that is already covered by '.'
@@ -351,6 +361,7 @@
             return r
         m.matchfn = lfmatchfn
 
+        ui.debug('updated patterns: %s\n' % pats)
         return m, pats
 
     # For hg log --patch, the match object is used in two different senses:
diff --git a/tests/test-check-code-hg.t b/tests/test-check-code-hg.t
--- a/tests/test-check-code-hg.t
+++ b/tests/test-check-code-hg.t
@@ -13,3 +13,10 @@
   Skipping mercurial/httpclient/__init__.py it has no-che?k-code (glob)
   Skipping mercurial/httpclient/_readers.py it has no-che?k-code (glob)
   Skipping mercurial/httpclient/socketutil.py it has no-che?k-code (glob)
+  tests/test-largefiles-misc.t:*: (glob)
+   >   $ hg --debug log -T '{rev}: {desc}\n' 'glob:../.hglf/sub/another*'
+   x:.y in a path does not work on msys, rewrite as x://.y, or see `hg log -k msys` for alternatives
+  tests/test-largefiles-misc.t:*: (glob)
+   >   $ hg --debug log -G -T '{rev}: {desc}\n' 'glob:../.hglf/sub/another*'
+   x:.y in a path does not work on msys, rewrite as x://.y, or see `hg log -k msys` for alternatives
+  [1]
diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t
--- a/tests/test-largefiles-misc.t
+++ b/tests/test-largefiles-misc.t
@@ -466,14 +466,22 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     anotherlarge
   
-  $ hg log -G glob:another*
-  @  changeset:   1:9627a577c5e9
-  |  tag:         tip
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     anotherlarge
+  $ hg --debug log -T '{rev}: {desc}\n' -G glob:another*
+  updated patterns: set(['glob:../.hglf/sub/another*', 'glob:another*'])
+  @  1: anotherlarge
   |
 
+#if no-msys
+  $ hg --debug log -T '{rev}: {desc}\n' 'glob:../.hglf/sub/another*'
+  updated patterns: set(['glob:../.hglf/sub/another*'])
+  1: anotherlarge
+
+  $ hg --debug log -G -T '{rev}: {desc}\n' 'glob:../.hglf/sub/another*'
+  updated patterns: set(['glob:../.hglf/sub/another*'])
+  @  1: anotherlarge
+  |
+#endif
+
   $ echo more >> anotherlarge
   $ hg st .
   M anotherlarge
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -46,12 +46,9 @@
   $ hg ci -me -d '5 0'
 
 Make sure largefiles doesn't interfere with logging a regular file
-  $ hg log a --config extensions.largefiles=
-  changeset:   0:9161b9aeaf16
-  user:        test
-  date:        Thu Jan 01 00:00:01 1970 +0000
-  summary:     a
-  
+  $ hg --debug log a -T '{rev}: {desc}\n' --config extensions.largefiles=
+  updated patterns: set(['a', '.hglf/a'])
+  0: a
   $ hg log a
   changeset:   0:9161b9aeaf16
   user:        test
@@ -69,17 +66,11 @@
   date:        Thu Jan 01 00:00:01 1970 +0000
   summary:     a
   
-  $ hg log glob:a* --config extensions.largefiles=
-  changeset:   3:2ca5ba701980
-  user:        test
-  date:        Thu Jan 01 00:00:04 1970 +0000
-  summary:     d
-  
-  changeset:   0:9161b9aeaf16
-  user:        test
-  date:        Thu Jan 01 00:00:01 1970 +0000
-  summary:     a
-  
+  $ hg --debug log glob:a* -T '{rev}: {desc}\n' --config extensions.largefiles=
+  updated patterns: set(['glob:.hglf/a*', 'glob:a*'])
+  3: d
+  0: a
+
 log on directory
 
   $ hg log dir


More information about the Mercurial-devel mailing list