Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Issue 11475046: Add Bob's path library to pub. (Closed)

Created:
8 years ago by nweiz
Modified:
8 years ago
Reviewers:
Bob Nystrom
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add Bob's path library to pub. BUG=7215 Committed: https://code.google.com/p/dart/source/detail?r=15881

Patch Set 1 #

Total comments: 63

Patch Set 2 : Code review changes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1234 lines, -110 lines) Patch
M utils/pub/command_lish.dart View 1 1 chunk +2 lines, -2 lines 0 comments Download
M utils/pub/curl_client.dart View 1 chunk +1 line, -1 line 0 comments Download
M utils/pub/entrypoint.dart View 1 chunk +1 line, -1 line 0 comments Download
M utils/pub/io.dart View 1 8 chunks +67 lines, -91 lines 0 comments Download
A utils/pub/path.dart View 1 chunk +514 lines, -0 lines 0 comments Download
M utils/pub/pub.dart View 3 chunks +4 lines, -3 lines 0 comments Download
M utils/pub/validator/name.dart View 2 chunks +4 lines, -4 lines 0 comments Download
A utils/tests/pub/path/path_posix_test.dart View 1 1 chunk +278 lines, -0 lines 0 comments Download
A utils/tests/pub/path/path_test.dart View 1 chunk +59 lines, -0 lines 0 comments Download
A utils/tests/pub/path/path_windows_test.dart View 1 1 chunk +295 lines, -0 lines 0 comments Download
M utils/tests/pub/test_pub.dart View 3 chunks +9 lines, -8 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
nweiz
https://codereview.chromium.org/11475046/diff/1/utils/pub/path.dart File utils/pub/path.dart (right): https://codereview.chromium.org/11475046/diff/1/utils/pub/path.dart#newcode27 utils/pub/path.dart:27: /// Gets the file extension of [path]; the portion ...
8 years ago (2012-12-08 01:46:31 UTC) #1
Bob Nystrom
Some nits, otherwise LGTM. https://codereview.chromium.org/11475046/diff/1/utils/pub/command_lish.dart File utils/pub/command_lish.dart (right): https://codereview.chromium.org/11475046/diff/1/utils/pub/command_lish.dart#newcode16 utils/pub/command_lish.dart:16: import 'path.dart' as path; Do ...
8 years ago (2012-12-08 03:36:53 UTC) #2
nweiz
https://codereview.chromium.org/11475046/diff/1/utils/pub/command_lish.dart File utils/pub/command_lish.dart (right): https://codereview.chromium.org/11475046/diff/1/utils/pub/command_lish.dart#newcode16 utils/pub/command_lish.dart:16: import 'path.dart' as path; On 2012/12/08 03:36:53, Bob Nystrom ...
8 years ago (2012-12-08 03:43:45 UTC) #3
Bob Nystrom
https://codereview.chromium.org/11475046/diff/1/utils/pub/path.dart File utils/pub/path.dart (right): https://codereview.chromium.org/11475046/diff/1/utils/pub/path.dart#newcode27 utils/pub/path.dart:27: /// Gets the file extension of [path]; the portion ...
8 years ago (2012-12-08 05:12:33 UTC) #4
nweiz
8 years ago (2012-12-10 21:30:59 UTC) #5
Message was sent while issue was closed.
https://codereview.chromium.org/11475046/diff/1/utils/pub/path.dart
File utils/pub/path.dart (right):

https://codereview.chromium.org/11475046/diff/1/utils/pub/path.dart#newcode241
utils/pub/path.dart:241: if (path == '') return path;
On 2012/12/08 05:12:33, Bob Nystrom wrote:
> On 2012/12/08 01:46:31, nweiz wrote:
> > An empty string is never a valid path. Why is there special handling for it
> > here?
> 
> It's following python. It feels a bit weird, but I think it might be
marginally
> helpful if you're normalizing a pile of strings and some of them happen to be
> empty strings. In that case, I think yielding an empty string in return is
> fairly innocuous.

Even if it works, it's a little weird that you're explicitly checking for it
here and nowhere else. Why not just let it fall through the logic naturally?

https://codereview.chromium.org/11475046/diff/1/utils/pub/path.dart#newcode338
utils/pub/path.dart:338: separators.add(match[0]);
On 2012/12/08 05:12:33, Bob Nystrom wrote:
> On 2012/12/08 01:46:31, nweiz wrote:
> > Why is it useful to keep track of separators? It just seems to make the
> > manipulation code more complicated.
> 
> As much as possible, path retains the information you give it. It doesn't try
to
> clean up or normalize your path unless you ask it to. So, if you give it:
> 
> a/b\c/d.txt
> 
> and call path.withoutExtension(), I want you to get: a/b\c/d and not a\b\c\d
> 
> That means keeping track of which separators were used. Nit-picky, but I'm
> trying to keep as much user-given information as I can.

I think this will end up causing more pain than it's worth down the line if
_parse ever becomes exposed. It's a nice idea to do no normalization, but in
this case I think it's worth it to make the manipulation easier, especially
since there's no semantic difference at all between the two forms.

https://codereview.chromium.org/11475046/diff/1/utils/pub/path.dart#newcode381
utils/pub/path.dart:381: _rootPattern = new RegExp('^$rootPattern');
On 2012/12/08 05:12:33, Bob Nystrom wrote:
> On 2012/12/08 01:46:31, nweiz wrote:
> > This RegExp should be '^($rootPattern)'.
> 
> How come?

Otherwise on Windows it ends up as r'^\\\\|[a-zA-Z]:[/\\]'; the
beginning-of-string character is only required for "\\", not for "C:\".

Powered by Google App Engine
This is Rietveld 408576698