Rev 2788: (Daniel Watkins) Warn when a given ignore pattern matches existing versioned files in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Sep 3 11:17:37 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2788
revision-id: pqm at pqm.ubuntu.com-20070903101735-al3ficqurndkv49i
parent: pqm at pqm.ubuntu.com-20070903094621-g97i8i5qwal4x0er
parent: ian.clatworthy at internode.on.net-20070903082334-yqbzwb83q0jbdb62
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2007-09-03 11:17:35 +0100
message:
  (Daniel Watkins) Warn when a given ignore pattern matches existing versioned files
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_ignore.py test_ignore.py-20060703063225-4tm8dc2pa7wwg2t3-1
    ------------------------------------------------------------
    revno: 2784.1.1
    merged: ian.clatworthy at internode.on.net-20070903082334-yqbzwb83q0jbdb62
    parent: pqm at pqm.ubuntu.com-20070903080656-1sn8ea2d3ohx75ek
    parent: d.m.watkins at warwick.ac.uk-20070829094837-xunde9qmpsz8btru
    committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
    branch nick: ianc-integration
    timestamp: Mon 2007-09-03 18:23:34 +1000
    message:
      (Daniel Watkins) Warn when a given ignore pattern matches existing versioned files
    ------------------------------------------------------------
    revno: 2747.5.4
    merged: d.m.watkins at warwick.ac.uk-20070829094837-xunde9qmpsz8btru
    parent: d.m.watkins at warwick.ac.uk-20070828111427-pvr0d9bgjl515w1u
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: 48623
    timestamp: Wed 2007-08-29 11:48:37 +0200
    message:
      Added test showing that the warning lists only files matching the new glob, as per abentley's request.
    ------------------------------------------------------------
    revno: 2747.5.3
    merged: d.m.watkins at warwick.ac.uk-20070828111427-pvr0d9bgjl515w1u
    parent: d.m.watkins at warwick.ac.uk-20070825124224-akgvn9cia1xkjac7
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: 48623
    timestamp: Tue 2007-08-28 13:14:27 +0200
    message:
      Modified to avoid encoding issues.
    ------------------------------------------------------------
    revno: 2747.5.2
    merged: d.m.watkins at warwick.ac.uk-20070825124224-akgvn9cia1xkjac7
    parent: d.m.watkins at warwick.ac.uk-20070825124159-mwkmk95iqc64vmyh
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: 48623
    timestamp: Sat 2007-08-25 14:42:24 +0200
    message:
      Added tests for new functionality.
    ------------------------------------------------------------
    revno: 2747.5.1
    merged: d.m.watkins at warwick.ac.uk-20070825124159-mwkmk95iqc64vmyh
    parent: pqm at pqm.ubuntu.com-20070824133750-r25v5g25g1flggy6
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: 48623
    timestamp: Sat 2007-08-25 14:41:59 +0200
    message:
      'ignore' now outputs a list of versioned files that match the given pattern.
=== modified file 'NEWS'
--- a/NEWS	2007-09-03 09:46:21 +0000
+++ b/NEWS	2007-09-03 10:17:35 +0000
@@ -150,6 +150,9 @@
    * New option ``-c``/``--change`` for ``diff`` and ``status`` to show
      changes in one revision.  (Lukáš Lalinský)
 
+   * If versioned files match a given ignore pattern, a warning is now
+     given. (Daniel Watkins, #48623)
+
   API BREAKS:
 
    * ``Branch.append_revision`` is removed altogether; please use 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2007-09-03 07:34:25 +0000
+++ b/bzrlib/builtins.py	2007-09-03 08:23:34 +0000
@@ -1966,6 +1966,19 @@
         if not tree.path2id('.bzrignore'):
             tree.add(['.bzrignore'])
 
+        ignored = globbing.Globster(name_pattern_list)
+        matches = []
+        tree.lock_read()
+        for entry in tree.list_files():
+            id = entry[3]
+            if id is not None:
+                filename = entry[0]
+                if ignored.match(filename):
+                    matches.append(filename.encode('utf-8'))
+        tree.unlock()
+        if len(matches) > 0:
+            print "Warning: the following files are version controlled and" \
+                  " match your ignore pattern:\n%s" % ("\n".join(matches),)
 
 class cmd_ignored(Command):
     """List ignored files and the patterns that matched them.

=== modified file 'bzrlib/tests/blackbox/test_ignore.py'
--- a/bzrlib/tests/blackbox/test_ignore.py	2007-06-27 19:13:50 +0000
+++ b/bzrlib/tests/blackbox/test_ignore.py	2007-08-29 09:48:37 +0000
@@ -117,3 +117,37 @@
         self.assertContainsRe(out, 'CVS')
         self.assertEqual('', err)
 
+    def test_ignore_versioned_file(self):
+        tree = self.make_branch_and_tree('.')
+        self.build_tree(['a','b'])
+        tree.add('a')
+
+        # test a single versioned file
+        out, err = self.run_bzr('ignore a')
+        self.assertEqual(out, 
+                         "Warning: the following files are version controlled"\
+                         " and match your ignore pattern:\na\n")
+
+        # test a single unversioned file
+        out, err = self.run_bzr('ignore b')
+        self.assertEqual(out, '')
+
+        # test wildcards
+        tree.add('b')
+        out, err = self.run_bzr('ignore *')
+        self.assertEqual(out, 
+                         "Warning: the following files are version controlled"\
+                         " and match your ignore pattern:\n.bzrignore\na\nb\n")
+
+    def test_ignored_versioned_file_matching_new_pattern(self):
+        tree = self.make_branch_and_tree('.')
+        self.build_tree(['a', 'b'])
+        tree.add(['a', 'b'])
+        self.run_bzr('ignore *')
+
+        # If only the given pattern is used then only 'b' should match in
+        # this case.
+        out, err = self.run_bzr('ignore b')
+        self.assertEqual(out, 
+                         "Warning: the following files are version controlled"\
+                         " and match your ignore pattern:\nb\n")




More information about the bazaar-commits mailing list