Merge lp:~parthm/bzr/538703-default-ignore-rules into lp:bzr

Proposed by Parth Malwankar
Status: Merged
Approved by: Ian Clatworthy
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~parthm/bzr/538703-default-ignore-rules
Merge into: lp:bzr
Diff against target: 154 lines (+24/-71)
4 files modified
NEWS (+5/-0)
bzrlib/builtins.py (+13/-7)
bzrlib/ignores.py (+0/-60)
bzrlib/tests/blackbox/test_ignore.py (+6/-4)
To merge this branch: bzr merge lp:~parthm/bzr/538703-default-ignore-rules
Reviewer Review Type Date Requested Status
Ian Clatworthy Approve
Vincent Ladeuil Approve
Review via email: mp+23757@code.launchpad.net

Commit message

Implement 'ignore --default-rules', remove 'ignore --old-default-rules'

Description of the change

=== Fixed Bug #538703 ===
This merge proposal adds the --default-rules option to 'bzr ignore' which prints out the default ignores used by bzr.

The test case uses the python2.4+ builtin 'set' to test this option. I am assuming bzr is supported only on python2.4+. If this is not the case please let me know and I can conditionally use the sets module.

[538703-default-ignore-rules]% ./bzr --no-plugins ignore --default-rules
*.a
*.o
*.py[co]
*.so
*.sw[nop]
*~
.#*
[#]*#
[538703-default-ignore-rules]%

IMO --old-default-rules can be removed as it is for bzr < 0.9 but that can be a separate patch so that functionality is untouched.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

This doesn't entirely make sense to me; we write the ignores out to
~/.bazaar/ignores - showing the defaults isn't all that useful, because of
that.

Revision history for this message
Parth Malwankar (parthm) wrote :

On Wed, Apr 21, 2010 at 7:24 AM, Robert Collins
<email address hidden> wrote:
> This doesn't entirely make sense to me; we write the ignores out to
> ~/.bazaar/ignores - showing the defaults isn't all that useful, because of
> that.
>

The intent is avoid confusion caused by not knowing what
files are ignored by default. The bug #538703 entry captures
this confusion well :)

It was originally filed by me as a bug that bzr is not
adding *.a files by default and then the confusion cleared a
little but I couldn't really find a list of default ignores. Granted
that I could have 'cat ~/.bazaar/ignores' but I wasn't aware
of the file (maybe I could have read the docs better but I
think an the average user may not do that). I became aware
of the ignores file and its implicit creation only after looking
at the code.

IMO this option would make default ignores discoverable.
Also, the ~/.bazaar/ignores files may be edited over time
so the user will then be left with no way of know what
files bzr ignores by default.

Revision history for this message
Vincent Ladeuil (vila) wrote :

Having both --default-rules and --old-default-rules sounds messy, let's delete the later entirely.

As mentioned in the bug report, I think it's good to have the option to display
the *default* so that users can compare it to their ~/.bazaar/ignores.

review: Needs Fixing
Revision history for this message
Parth Malwankar (parthm) wrote :

> Having both --default-rules and --old-default-rules sounds messy, let's delete
> the later entirely.
>

Sounds fine to me. I can do that either in this patch or separately.
Is there a deprecation policy we need to follow for deletion of
--old-default-rules or is it reasonable to just remove it?

> As mentioned in the bug report, I think it's good to have the option to
> display
> the *default* so that users can compare it to their ~/.bazaar/ignores.

Revision history for this message
Vincent Ladeuil (vila) wrote :

I can't imagine anyone relying on --old-default-rules, so let's just delete it.

Revision history for this message
Parth Malwankar (parthm) wrote :

> I can't imagine anyone relying on --old-default-rules, so let's just delete
> it.

Thanks Vincent. I have removed --old-default-rules.
I have also updated 'bzr help ignore' to mention ~/.bazaar/ignore' because that was missing.

Revision history for this message
Vincent Ladeuil (vila) wrote :

Thanks, we just need a second review now.

review: Approve
Revision history for this message
Ian Clatworthy (ian-clatworthy) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-04-21 05:05:02 +0000
3+++ NEWS 2010-04-22 14:18:26 +0000
4@@ -19,6 +19,11 @@
5 * ``bzr diff`` now supports a --format option, which can be used to
6 select alternative diff formats. (Jelmer Vernooij, #555994)
7
8+* ``bzr ignore`` now supports a ``--default-rules`` option that displays
9+ the default ignore rules used by bzr. The flag ``--old-default-rules``
10+ is no longer supported by ``ignore``.
11+ (Parth Malwankar, #538703)
12+
13 * ``bzr pack`` now supports a ``--clean-obsolete-packs`` option that
14 can save disk space by deleting obsolete pack files created during the
15 pack operation.
16
17=== modified file 'bzrlib/builtins.py'
18--- bzrlib/builtins.py 2010-04-19 13:04:30 +0000
19+++ bzrlib/builtins.py 2010-04-22 14:18:26 +0000
20@@ -2649,6 +2649,12 @@
21 using this command or directly by using an editor, be sure to commit
22 it.
23
24+ Bazaar also supports a global ignore file ~/.bazaar/ignore. On Windows
25+ the global ignore file can be found in the application data directory as
26+ C:\\Documents and Settings\\<user>\\Application Data\\Bazaar\\2.0\\ignore.
27+ Global ignores are not touched by this command. The global ignore file
28+ can be edited directly using an editor.
29+
30 Patterns prefixed with '!' are exceptions to ignore patterns and take
31 precedence over regular ignores. Such exceptions are used to specify
32 files that should be versioned which would otherwise be ignored.
33@@ -2695,20 +2701,20 @@
34 _see_also = ['status', 'ignored', 'patterns']
35 takes_args = ['name_pattern*']
36 takes_options = [
37- Option('old-default-rules',
38- help='Write out the ignore rules bzr < 0.9 always used.')
39+ Option('default-rules',
40+ help='Display the default ignore rules that bzr uses.')
41 ]
42
43- def run(self, name_pattern_list=None, old_default_rules=None):
44+ def run(self, name_pattern_list=None, default_rules=None):
45 from bzrlib import ignores
46- if old_default_rules is not None:
47- # dump the rules and exit
48- for pattern in ignores.OLD_DEFAULTS:
49+ if default_rules is not None:
50+ # dump the default rules and exit
51+ for pattern in ignores.USER_DEFAULTS:
52 self.outf.write("%s\n" % pattern)
53 return
54 if not name_pattern_list:
55 raise errors.BzrCommandError("ignore requires at least one "
56- "NAME_PATTERN or --old-default-rules")
57+ "NAME_PATTERN or --default-rules.")
58 name_pattern_list = [globbing.normalize_pattern(p)
59 for p in name_pattern_list]
60 for name_pattern in name_pattern_list:
61
62=== modified file 'bzrlib/ignores.py'
63--- bzrlib/ignores.py 2010-03-29 00:54:27 +0000
64+++ bzrlib/ignores.py 2010-04-22 14:18:26 +0000
65@@ -27,66 +27,6 @@
66
67 from trace import warning
68
69-# This was the full ignore list for bzr 0.8
70-# please keep these sorted (in C locale order) to aid merging
71-OLD_DEFAULTS = [
72- '#*#',
73- '*$',
74- '*,v',
75- '*.BAK',
76- '*.a',
77- '*.bak',
78- '*.elc',
79- '*.exe',
80- '*.la',
81- '*.lo',
82- '*.o',
83- '*.obj',
84- '*.orig',
85- '*.py[oc]',
86- '*.so',
87- '*.tmp',
88- '*~',
89- '.#*',
90- '.*.sw[nop]',
91- '.*.tmp',
92- # Our setup tests dump .python-eggs in the bzr source tree root
93- './.python-eggs',
94- '.DS_Store',
95- '.arch-ids',
96- '.arch-inventory',
97- '.bzr.log',
98- '.del-*',
99- '.git',
100- '.hg',
101- '.jamdeps'
102- '.libs',
103- '.make.state',
104- '.sconsign*',
105- '.svn',
106- '.sw[nop]', # vim editing nameless file
107- '.tmp*',
108- 'BitKeeper',
109- 'CVS',
110- 'CVS.adm',
111- 'RCS',
112- 'SCCS',
113- 'TAGS',
114- '_darcs',
115- 'aclocal.m4',
116- 'autom4te*',
117- 'config.h',
118- 'config.h.in',
119- 'config.log',
120- 'config.status',
121- 'config.sub',
122- 'stamp-h',
123- 'stamp-h.in',
124- 'stamp-h1',
125- '{arch}',
126-]
127-
128-
129 # ~/.bazaar/ignore will be filled out using
130 # this ignore list, if it does not exist
131 # please keep these sorted (in C locale order) to aid merging
132
133=== modified file 'bzrlib/tests/blackbox/test_ignore.py'
134--- bzrlib/tests/blackbox/test_ignore.py 2010-02-17 17:11:16 +0000
135+++ bzrlib/tests/blackbox/test_ignore.py 2010-04-22 14:18:26 +0000
136@@ -106,12 +106,14 @@
137 """'ignore' with no arguments returns an error"""
138 self.make_branch_and_tree('.')
139 self.run_bzr_error(('bzr: ERROR: ignore requires at least one '
140- 'NAME_PATTERN or --old-default-rules\n',),
141+ 'NAME_PATTERN or --default-rules.\n',),
142 'ignore')
143
144- def test_ignore_old_defaults(self):
145- out, err = self.run_bzr('ignore --old-default-rules')
146- self.assertContainsRe(out, 'CVS')
147+ def test_ignore_default_rules(self):
148+ out, err = self.run_bzr(['ignore', '--default-rules'])
149+ reference_set = set(ignores.USER_DEFAULTS)
150+ output_set = set(out.rstrip().split('\n'))
151+ self.assertEqual(reference_set, output_set)
152 self.assertEqual('', err)
153
154 def test_ignore_versioned_file(self):