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

Proposed by Parth Malwankar
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
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 Approve
bzr-core 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.
Revision history for this message
Matthew Fuller (fullermd) wrote :

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

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

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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.

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

Thanks Vincent.
I will land this patch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2010-05-05 18:51:16 +0000
+++ NEWS 2010-05-07 04:55:45 +0000
@@ -112,6 +112,10 @@
112 (case-sensitive) as false.112 (case-sensitive) as false.
113 (Brian de Alwis, Vincent Ladeuil)113 (Brian de Alwis, Vincent Ladeuil)
114114
115* ``bzr ls`` now supports short options for existing long options.
116 ``-k/--kind``, ``-i/--ignored``, ``-u/--unknown`` and ``-0/--null``.
117 (Parth Malwankar, #181124)
118
115* ``Config.get_user_option_as_bool`` will now warn if a value cannot119* ``Config.get_user_option_as_bool`` will now warn if a value cannot
116 be interpreted as a boolean.120 be interpreted as a boolean.
117 (Vincent Ladeuil)121 (Vincent Ladeuil)
118122
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 2010-05-05 14:11:13 +0000
+++ bzrlib/builtins.py 2010-05-07 04:55:45 +0000
@@ -2032,11 +2032,7 @@
20322032
2033 hidden = True2033 hidden = True
2034 _see_also = ['status', 'ls']2034 _see_also = ['status', 'ls']
2035 takes_options = ['directory',2035 takes_options = ['directory', 'null']
2036 Option('null',
2037 help='Write an ascii NUL (\\0) separator '
2038 'between files rather than a newline.')
2039 ]
20402036
2041 @display_command2037 @display_command
2042 def run(self, null=False, directory=u'.'):2038 def run(self, null=False, directory=u'.'):
@@ -2055,11 +2051,7 @@
20552051
2056 hidden = True2052 hidden = True
2057 _see_also = ['status', 'ls']2053 _see_also = ['status', 'ls']
2058 takes_options = ['directory',2054 takes_options = ['directory', 'null']
2059 Option('null',
2060 help='Write an ascii NUL (\\0) separator '
2061 'between files rather than a newline.')
2062 ]
20632055
2064 @display_command2056 @display_command
2065 def run(self, null=False, directory=u'.'):2057 def run(self, null=False, directory=u'.'):
@@ -2539,16 +2531,16 @@
2539 help='Recurse into subdirectories.'),2531 help='Recurse into subdirectories.'),
2540 Option('from-root',2532 Option('from-root',
2541 help='Print paths relative to the root of the branch.'),2533 help='Print paths relative to the root of the branch.'),
2542 Option('unknown', help='Print unknown files.'),2534 Option('unknown', short_name='u',
2535 help='Print unknown files.'),
2543 Option('versioned', help='Print versioned files.',2536 Option('versioned', help='Print versioned files.',
2544 short_name='V'),2537 short_name='V'),
2545 Option('ignored', help='Print ignored files.'),2538 Option('ignored', short_name='i',
2546 Option('null',2539 help='Print ignored files.'),
2547 help='Write an ascii NUL (\\0) separator '2540 Option('kind', short_name='k',
2548 'between files rather than a newline.'),
2549 Option('kind',
2550 help='List entries of a particular kind: file, directory, symlink.',2541 help='List entries of a particular kind: file, directory, symlink.',
2551 type=unicode),2542 type=unicode),
2543 'null',
2552 'show-ids',2544 'show-ids',
2553 'directory',2545 'directory',
2554 ]2546 ]
25552547
=== modified file 'bzrlib/option.py'
--- bzrlib/option.py 2010-05-03 09:19:15 +0000
+++ bzrlib/option.py 2010-05-07 04:55:45 +0000
@@ -506,6 +506,9 @@
506# Declare the standard options506# Declare the standard options
507_standard_option('help', short_name='h',507_standard_option('help', short_name='h',
508 help='Show help message.')508 help='Show help message.')
509_standard_option('null', short_name='0',
510 help='Use an ASCII NUL (\\0) separator rather than '
511 'a newline.')
509_standard_option('usage',512_standard_option('usage',
510 help='Show usage message and options.')513 help='Show usage message and options.')
511_standard_option('verbose', short_name='v',514_standard_option('verbose', short_name='v',
512515
=== modified file 'bzrlib/tests/test_help.py'
--- bzrlib/tests/test_help.py 2010-04-23 08:51:52 +0000
+++ bzrlib/tests/test_help.py 2010-05-07 04:55:45 +0000
@@ -122,6 +122,7 @@
122 '\n'122 '\n'
123 'Options:\n'123 'Options:\n'
124 ' --usage Show usage message and options.\n'124 ' --usage Show usage message and options.\n'
125 ' -0, --null Use an ASCII NUL (\\0) separator rather than a newline.\n'
125 ' -v, --verbose Display more information.\n'126 ' -v, --verbose Display more information.\n'
126 ' -q, --quiet Only display errors and warnings.\n'127 ' -q, --quiet Only display errors and warnings.\n'
127 ' -h, --help Show help message.\n'128 ' -h, --help Show help message.\n'
@@ -142,6 +143,7 @@
142 '\n'143 '\n'
143 ':Options:\n'144 ':Options:\n'
144 ' --usage Show usage message and options.\n'145 ' --usage Show usage message and options.\n'
146 ' -0, --null Use an ASCII NUL (\\0) separator rather than a newline.\n'
145 ' -v, --verbose Display more information.\n'147 ' -v, --verbose Display more information.\n'
146 ' -q, --quiet Only display errors and warnings.\n'148 ' -q, --quiet Only display errors and warnings.\n'
147 ' -h, --help Show help message.\n'149 ' -h, --help Show help message.\n'
@@ -177,6 +179,7 @@
177 '\n'179 '\n'
178 'Options:\n'180 'Options:\n'
179 ' --usage Show usage message and options.\n'181 ' --usage Show usage message and options.\n'
182 ' -0, --null Use an ASCII NUL (\\0) separator rather than a newline.\n'
180 ' -v, --verbose Display more information.\n'183 ' -v, --verbose Display more information.\n'
181 ' -q, --quiet Only display errors and warnings.\n'184 ' -q, --quiet Only display errors and warnings.\n'
182 ' -h, --help Show help message.\n'185 ' -h, --help Show help message.\n'
@@ -196,6 +199,7 @@
196 '\n'199 '\n'
197 'Options:\n'200 'Options:\n'
198 ' --usage Show usage message and options.\n'201 ' --usage Show usage message and options.\n'
202 ' -0, --null Use an ASCII NUL (\\0) separator rather than a newline.\n'
199 ' -v, --verbose Display more information.\n'203 ' -v, --verbose Display more information.\n'
200 ' -q, --quiet Only display errors and warnings.\n'204 ' -q, --quiet Only display errors and warnings.\n'
201 ' -h, --help Show help message.\n'205 ' -h, --help Show help message.\n'
@@ -230,6 +234,7 @@
230 '\n'234 '\n'
231 'Options:\n'235 'Options:\n'
232 ' --usage Show usage message and options.\n'236 ' --usage Show usage message and options.\n'
237 ' -0, --null Use an ASCII NUL (\\0) separator rather than a newline.\n'
233 ' -v, --verbose Display more information.\n'238 ' -v, --verbose Display more information.\n'
234 ' -q, --quiet Only display errors and warnings.\n'239 ' -q, --quiet Only display errors and warnings.\n'
235 ' -h, --help Show help message.\n'240 ' -h, --help Show help message.\n'
@@ -273,6 +278,7 @@
273 '\n'278 '\n'
274 'Options:\n'279 'Options:\n'
275 ' --usage Show usage message and options.\n'280 ' --usage Show usage message and options.\n'
281 ' -0, --null Use an ASCII NUL (\\0) separator rather than a newline.\n'
276 ' -v, --verbose Display more information.\n'282 ' -v, --verbose Display more information.\n'
277 ' -q, --quiet Only display errors and warnings.\n'283 ' -q, --quiet Only display errors and warnings.\n'
278 ' -h, --help Show help message.\n'284 ' -h, --help Show help message.\n'