Merge lp:~parthm/bzr/181124-ls-short-opts into lp:bzr

Proposed by Parth Malwankar on 2010-04-29
Status: Merged
Approved by: Vincent Ladeuil on 2010-05-06
Approved revision: 5200
Merged at revision: 5216
Proposed branch: lp:~parthm/bzr/181124-ls-short-opts
Merge into: lp:bzr
Diff against target: 133 lines (+21/-16)
4 files modified
NEWS (+4/-0)
bzrlib/builtins.py (+8/-16)
bzrlib/option.py (+3/-0)
bzrlib/tests/test_help.py (+6/-0)
To merge this branch: bzr merge lp:~parthm/bzr/181124-ls-short-opts
Reviewer Review Type Date Requested Status
John A Meinel 2010-04-29 Approve on 2010-05-04
bzr-core 2010-05-04 Pending
Review via email: mp+24414@code.launchpad.net

Commit Message

(parthm, #181124) short options for commonly used ls long options.

Description of the Change

=== Fixes Bug #181124 ===
Trivial patch to add some short options for 'bzr ls'
I have skipped --from-root as I couldn't think of a good short option. -l as mentioned in the bug report was confusion as 'ls -l' is commonly used.

To post a comment you must log in.
Matthew Fuller (fullermd) wrote :

> + Option('null', short_name='Z',

-0 would be more fitting with similar options in oodles of other
programs.

Parth Malwankar (parthm) wrote :

> > + Option('null', short_name='Z',
>
> -0 would be more fitting with similar options in oodles of other
> programs.

I was actually trying to be consistent with GNU grep but I don't have a specific preference. We can go with -0 if thats preferred.

John A Meinel (jameinel) wrote :

So our general guidelines were to only give short options to things that actually were used often, and to try to keep them consistent across all commands.

However, since Martin was the one who originally asked for us to be cautious about short options, and he's the one who posted the bug, and said that it should be done, I guess this is ok.

I personally prefer -0 for --null to -Z, but there doesn't seem to be a huge consensus in GNU land. xargs uses -0, find uses -print0, grep uses -Z...

Do we have other tools to include, since so far my sample size has each version happening exactly 1 time... :)

If you're going to be changing this, I would probably pull 'null' out into bzrlib.option, since it is used by cmd_added, and cmd_ignored (IIRC). I would like us to be consistent as much as possible.

Of course, some people have asked for -# w/ bzr.log to mean --last #, which would possibly conflict, but I don't think we can trivially support -# anyway (the option infrastructure would want us to create N options to support N variants of -#, though I'm sure we could do better with some deep work.)

So this is probably "BB:tweak", though I'll mark it needs-fixing as the best approximation.

review: Needs Fixing
Matthew Fuller (fullermd) wrote :

On Thu, Apr 29, 2010 at 03:36:59PM -0000 I heard the voice of
Parth Malwankar, and lo! it spake thus:
>
> I was actually trying to be consistent with GNU grep but I don't
> have a specific preference. We can go with -0 if thats preferred.

That can vary by the age and divergence of grep.

% man grep
[...]
       --null Output a zero byte (the ASCII NUL character) instead of
[...]
       -Z, --decompress
              Decompress the input data before searching.

% grep -V
grep (GNU grep) 2.5.1-FreeBSD

Parth Malwankar (parthm) wrote :

> I personally prefer -0 for --null to -Z, but there doesn't seem to be a huge
> consensus in GNU land. xargs uses -0, find uses -print0, grep uses -Z...
>
> Do we have other tools to include, since so far my sample size has each
> version happening exactly 1 time... :)
>

bzr-grep uses -Z. It seems we are leaning towards standardizing -0/--null
for bzr. I can updated bzr-grep for this.

lp:~parthm/bzr/181124-ls-short-opts updated on 2010-04-30
5197. By Parth Malwankar on 2010-04-30

--null is now a _standard_option

5198. By Parth Malwankar on 2010-04-30

added NEWS entry.

Parth Malwankar (parthm) wrote :

Thanks for the review comments John, fullermd.

-0/--null is now a _standard_option.
Updated commands ls, modified, and added to used this.
Looks like ignored doesn't take a null option.
Added a NEWS entry to "Improvements" as this is a user visible change.

John A Meinel (jameinel) wrote :

A very small thing that we don't use:

takes_options = [ 'null' ]

As our formatting. It should just be:

takes_options = ['null']

However, it looks good, and can be cleaned up at merged time.

review: Approve
lp:~parthm/bzr/181124-ls-short-opts updated on 2010-05-05
5199. By Parth Malwankar on 2010-05-05

cosmetic fix as per coding practice.

5200. By Parth Malwankar on 2010-05-05

merged in changes from trunk and resolved conflict in builtins.py

Parth Malwankar (parthm) wrote :

> takes_options = ['null']
>

Done. I have also merged in trunk and resolved a conflict in builtins.py due to another mp being landed earlier.

Parth Malwankar (parthm) wrote :

Thanks Vincent.
I will land this patch.

lp:~parthm/bzr/181124-ls-short-opts updated on 2010-05-07
5201. By Parth Malwankar on 2010-05-06

merged in changes from trunk.

5202. By Parth Malwankar on 2010-05-07

updated test_help to have --null (which is a standard option now)

5203. By Parth Malwankar on 2010-05-07

merged in changes from trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-05-05 18:51:16 +0000
3+++ NEWS 2010-05-07 04:55:45 +0000
4@@ -112,6 +112,10 @@
5 (case-sensitive) as false.
6 (Brian de Alwis, Vincent Ladeuil)
7
8+* ``bzr ls`` now supports short options for existing long options.
9+ ``-k/--kind``, ``-i/--ignored``, ``-u/--unknown`` and ``-0/--null``.
10+ (Parth Malwankar, #181124)
11+
12 * ``Config.get_user_option_as_bool`` will now warn if a value cannot
13 be interpreted as a boolean.
14 (Vincent Ladeuil)
15
16=== modified file 'bzrlib/builtins.py'
17--- bzrlib/builtins.py 2010-05-05 14:11:13 +0000
18+++ bzrlib/builtins.py 2010-05-07 04:55:45 +0000
19@@ -2032,11 +2032,7 @@
20
21 hidden = True
22 _see_also = ['status', 'ls']
23- takes_options = ['directory',
24- Option('null',
25- help='Write an ascii NUL (\\0) separator '
26- 'between files rather than a newline.')
27- ]
28+ takes_options = ['directory', 'null']
29
30 @display_command
31 def run(self, null=False, directory=u'.'):
32@@ -2055,11 +2051,7 @@
33
34 hidden = True
35 _see_also = ['status', 'ls']
36- takes_options = ['directory',
37- Option('null',
38- help='Write an ascii NUL (\\0) separator '
39- 'between files rather than a newline.')
40- ]
41+ takes_options = ['directory', 'null']
42
43 @display_command
44 def run(self, null=False, directory=u'.'):
45@@ -2539,16 +2531,16 @@
46 help='Recurse into subdirectories.'),
47 Option('from-root',
48 help='Print paths relative to the root of the branch.'),
49- Option('unknown', help='Print unknown files.'),
50+ Option('unknown', short_name='u',
51+ help='Print unknown files.'),
52 Option('versioned', help='Print versioned files.',
53 short_name='V'),
54- Option('ignored', help='Print ignored files.'),
55- Option('null',
56- help='Write an ascii NUL (\\0) separator '
57- 'between files rather than a newline.'),
58- Option('kind',
59+ Option('ignored', short_name='i',
60+ help='Print ignored files.'),
61+ Option('kind', short_name='k',
62 help='List entries of a particular kind: file, directory, symlink.',
63 type=unicode),
64+ 'null',
65 'show-ids',
66 'directory',
67 ]
68
69=== modified file 'bzrlib/option.py'
70--- bzrlib/option.py 2010-05-03 09:19:15 +0000
71+++ bzrlib/option.py 2010-05-07 04:55:45 +0000
72@@ -506,6 +506,9 @@
73 # Declare the standard options
74 _standard_option('help', short_name='h',
75 help='Show help message.')
76+_standard_option('null', short_name='0',
77+ help='Use an ASCII NUL (\\0) separator rather than '
78+ 'a newline.')
79 _standard_option('usage',
80 help='Show usage message and options.')
81 _standard_option('verbose', short_name='v',
82
83=== modified file 'bzrlib/tests/test_help.py'
84--- bzrlib/tests/test_help.py 2010-04-23 08:51:52 +0000
85+++ bzrlib/tests/test_help.py 2010-05-07 04:55:45 +0000
86@@ -122,6 +122,7 @@
87 '\n'
88 'Options:\n'
89 ' --usage Show usage message and options.\n'
90+ ' -0, --null Use an ASCII NUL (\\0) separator rather than a newline.\n'
91 ' -v, --verbose Display more information.\n'
92 ' -q, --quiet Only display errors and warnings.\n'
93 ' -h, --help Show help message.\n'
94@@ -142,6 +143,7 @@
95 '\n'
96 ':Options:\n'
97 ' --usage Show usage message and options.\n'
98+ ' -0, --null Use an ASCII NUL (\\0) separator rather than a newline.\n'
99 ' -v, --verbose Display more information.\n'
100 ' -q, --quiet Only display errors and warnings.\n'
101 ' -h, --help Show help message.\n'
102@@ -177,6 +179,7 @@
103 '\n'
104 'Options:\n'
105 ' --usage Show usage message and options.\n'
106+ ' -0, --null Use an ASCII NUL (\\0) separator rather than a newline.\n'
107 ' -v, --verbose Display more information.\n'
108 ' -q, --quiet Only display errors and warnings.\n'
109 ' -h, --help Show help message.\n'
110@@ -196,6 +199,7 @@
111 '\n'
112 'Options:\n'
113 ' --usage Show usage message and options.\n'
114+ ' -0, --null Use an ASCII NUL (\\0) separator rather than a newline.\n'
115 ' -v, --verbose Display more information.\n'
116 ' -q, --quiet Only display errors and warnings.\n'
117 ' -h, --help Show help message.\n'
118@@ -230,6 +234,7 @@
119 '\n'
120 'Options:\n'
121 ' --usage Show usage message and options.\n'
122+ ' -0, --null Use an ASCII NUL (\\0) separator rather than a newline.\n'
123 ' -v, --verbose Display more information.\n'
124 ' -q, --quiet Only display errors and warnings.\n'
125 ' -h, --help Show help message.\n'
126@@ -273,6 +278,7 @@
127 '\n'
128 'Options:\n'
129 ' --usage Show usage message and options.\n'
130+ ' -0, --null Use an ASCII NUL (\\0) separator rather than a newline.\n'
131 ' -v, --verbose Display more information.\n'
132 ' -q, --quiet Only display errors and warnings.\n'
133 ' -h, --help Show help message.\n'