[PATCH 2 of 8 STABLE RFC] largefiles: adjust matching function to match appropriate files
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Fri Feb 17 16:07:28 UTC 2012
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1329494572 -32400
# Branch stable
# Node ID 7a58a75274f8356ea503f207a321033023daf371
# Parent be820a2353e7b3e9af8a59b050cd7bf8b1e38490
largefiles: adjust matching function to match appropriate files
current implementation can not show correct statuses, if "hg status"
is invoked with:
- two target revisions, and
- any file or directory patterns for largefiles
this problem occures in steps shown below:
1. specified "match" is used to pick files up from manifest of
each context in "localrepository.status()"
2. "match.matchfn" only accepts non-STANDIN files, so
3. any STANDIN files corresponded to specified patterns are not
choosen
this patch adjust matching function to match against corresponded
STANDIN files.
this patch also does "m._fmap = set(m._files)" to keep internal
consistency in "match", even though this is required only in cases
using "match.exact(f)".
diff -r be820a2353e7 -r 7a58a75274f8 hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py Sat Feb 18 01:02:52 2012 +0900
+++ b/hgext/largefiles/reposetup.py Sat Feb 18 01:02:52 2012 +0900
@@ -146,6 +146,16 @@
m = copy.copy(match)
m._files = [tostandin(f) for f in m._files]
+ m._fmap = set(m._files)
+ orig_matchfn = m.matchfn
+ def matchfn(f):
+ # at first, try original matching for patterns
+ # specifying STANDIN directly
+ if orig_matchfn(f):
+ return True
+ wf = lfutil.splitstandin(f)
+ return (wf and orig_matchfn(wf))
+ m.matchfn = matchfn
# Get ignored files here even if we weren't asked for them; we
# must use the result here for filtering later
diff -r be820a2353e7 -r 7a58a75274f8 tests/test-largefiles.t
--- a/tests/test-largefiles.t Sat Feb 18 01:02:52 2012 +0900
+++ b/tests/test-largefiles.t Sat Feb 18 01:02:52 2012 +0900
@@ -995,3 +995,52 @@
C a/b/c/x/y.normal.txt
$ cd ..
+
+tests for pattern matching on "hg status" with target reivisions:
+
+ $ hg init statusrev
+ $ cd statusrev
+
+ $ mkdir -p sub/
+ $ echo a > sub/a.txt
+ $ hg add --large sub/a.txt
+ $ hg commit -m '#0'
+ Invoking status precommit hook
+ A sub/a.txt
+ $ echo b > sub/b.txt
+ $ hg add --large sub/b.txt
+ $ hg commit -m '#1'
+ Invoking status precommit hook
+ A sub/b.txt
+ $ echo c > sub/c.txt
+ $ hg add --large sub/c.txt
+ $ hg commit -m '#2'
+ Invoking status precommit hook
+ A sub/c.txt
+
+ $ hg status -A sub/b.txt
+ C sub/b.txt
+ $ hg status -A --rev 0 sub/b.txt
+ A sub/b.txt
+ $ hg status -A --rev . --rev 0 sub/b.txt
+ R sub/b.txt
+ $ hg status -A --rev 0 --rev 1 sub/b.txt
+ A sub/b.txt
+
+ $ hg status -A sub
+ C sub/a.txt
+ C sub/b.txt
+ C sub/c.txt
+ $ hg status -A --rev 0 sub
+ A sub/b.txt
+ A sub/c.txt
+ C sub/a.txt
+ $ hg status -A --rev . --rev 0 sub
+ R sub/b.txt
+ R sub/c.txt
+ C sub/a.txt
+ $ hg status -A --rev 0 --rev 1 sub
+ A sub/b.txt
+ C sub/a.txt
+
+ $ cd ..
More information about the Mercurial-devel
mailing list