merge with stable
authorMatt Mackall <mpm@selenic.com>
Wed, 22 Feb 2012 17:36:33 -0600
changeset 16151 a01d2fb5ba65
parent 16150 0424f3c7d7ac (current diff)
parent 16145 616c2e278f18 (diff)
child 16152 816211dfa3a5
merge with stable
mercurial/context.py
mercurial/localrepo.py
--- a/hgext/largefiles/reposetup.py	Wed Feb 22 12:30:15 2012 +0100
+++ b/hgext/largefiles/reposetup.py	Wed Feb 22 17:36:33 2012 -0600
@@ -63,13 +63,21 @@
                         return man1
                     def filectx(self, path, fileid=None, filelog=None):
                         try:
-                            result = super(lfiles_ctx, self).filectx(path,
-                                fileid, filelog)
+                            if filelog is not None:
+                                result = super(lfiles_ctx, self).filectx(
+                                    path, fileid, filelog)
+                            else:
+                                result = super(lfiles_ctx, self).filectx(
+                                    path, fileid)
                         except error.LookupError:
                             # Adding a null character will cause Mercurial to
                             # identify this as a binary file.
-                            result = super(lfiles_ctx, self).filectx(
-                                lfutil.standin(path), fileid, filelog)
+                            if filelog is not None:
+                                result = super(lfiles_ctx, self).filectx(
+                                    lfutil.standin(path), fileid, filelog)
+                            else:
+                                result = super(lfiles_ctx, self).filectx(
+                                    lfutil.standin(path), fileid)
                             olddata = result.data
                             result.data = lambda: olddata() + '\0'
                         return result
--- a/mercurial/context.py	Wed Feb 22 12:30:15 2012 +0100
+++ b/mercurial/context.py	Wed Feb 22 17:36:33 2012 -0600
@@ -206,14 +206,15 @@
         # follow that here, too
         fset.discard('.')
         for fn in self:
-            for ffn in fset:
-                # match if the file is the exact name or a directory
-                if ffn == fn or fn.startswith("%s/" % ffn):
-                    fset.remove(ffn)
-                    break
+            if fn in fset:
+                # specified pattern is the exact name
+                fset.remove(fn)
             if match(fn):
                 yield fn
         for fn in sorted(fset):
+            if fn in self._dirs:
+                # specified pattern is a directory
+                continue
             if match.bad(fn, _('no such file in rev %s') % self) and match(fn):
                 yield fn
 
@@ -236,6 +237,22 @@
         return patch.diff(self._repo, ctx2.node(), self.node(),
                           match=match, opts=diffopts)
 
+    @propertycache
+    def _dirs(self):
+        dirs = set()
+        for f in self._manifest:
+            pos = f.rfind('/')
+            while pos != -1:
+                f = f[:pos]
+                if f in dirs:
+                    break # dirs already contains this and above
+                dirs.add(f)
+                pos = f.rfind('/')
+        return dirs
+
+    def dirs(self):
+        return self._dirs
+
 class filectx(object):
     """A filecontext object makes access to data related to a particular
        filerevision convenient."""
@@ -949,6 +966,9 @@
             finally:
                 wlock.release()
 
+    def dirs(self):
+        return self._repo.dirstate.dirs()
+
 class workingfilectx(filectx):
     """A workingfilectx object makes access to data related to a particular
        file in the working directory convenient."""
--- a/mercurial/dirstate.py	Wed Feb 22 12:30:15 2012 +0100
+++ b/mercurial/dirstate.py	Wed Feb 22 17:36:33 2012 -0600
@@ -110,6 +110,9 @@
                 _incdirs(dirs, f)
         return dirs
 
+    def dirs(self):
+        return self._dirs
+
     @propertycache
     def _ignore(self):
         files = [self._join('.hgignore')]
--- a/mercurial/localrepo.py	Wed Feb 22 12:30:15 2012 +0100
+++ b/mercurial/localrepo.py	Wed Feb 22 17:36:33 2012 -0600
@@ -1371,7 +1371,9 @@
 
         if not parentworking:
             def bad(f, msg):
-                if f not in ctx1:
+                # 'f' may be a directory pattern from 'match.files()',
+                # so 'f not in ctx1' is not enough
+                if f not in ctx1 and f not in ctx1.dirs():
                     self.ui.warn('%s: %s\n' % (self.dirstate.pathto(f), msg))
             match.bad = bad
 
--- a/tests/test-largefiles.t	Wed Feb 22 12:30:15 2012 +0100
+++ b/tests/test-largefiles.t	Wed Feb 22 17:36:33 2012 -0600
@@ -994,4 +994,14 @@
   C a/b/c/d/e.normal.txt
   C a/b/c/x/y.normal.txt
 
+verify that largefiles doesn't break filesets
+
+  $ hg log --rev . --exclude "set:binary()"
+  changeset:   0:41bd42f10efa
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add files
+  
+
   $ cd ..
--- a/tests/test-status.t	Wed Feb 22 12:30:15 2012 +0100
+++ b/tests/test-status.t	Wed Feb 22 17:36:33 2012 -0600
@@ -295,3 +295,39 @@
   $ hg ci -q -A -m 'add another file'
   $ hg status -A --rev 1:2 010a
   C 010a
+
+  $ cd ..
+
+test "hg status" with "directory pattern" which matches against files
+only known on target revision.
+
+  $ hg init repo6
+  $ cd repo6
+
+  $ echo a > a.txt
+  $ hg add a.txt
+  $ hg commit -m '#0'
+  $ mkdir -p 1/2/3/4/5
+  $ echo b > 1/2/3/4/5/b.txt
+  $ hg add 1/2/3/4/5/b.txt
+  $ hg commit -m '#1'
+
+  $ hg update -C 0 > /dev/null
+  $ hg status -A
+  C a.txt
+
+the directory matching against specified pattern should be removed,
+because directory existence prevents 'dirstate.walk()' from showing
+warning message about such pattern.
+
+  $ test ! -d 1
+  $ hg status -A --rev 1 1/2/3/4/5/b.txt
+  R 1/2/3/4/5/b.txt
+  $ hg status -A --rev 1 1/2/3/4/5
+  R 1/2/3/4/5/b.txt
+  $ hg status -A --rev 1 1/2/3
+  R 1/2/3/4/5/b.txt
+  $ hg status -A --rev 1 1
+  R 1/2/3/4/5/b.txt
+
+  $ cd ..