monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] "" is invalid file_path?


From: Nathaniel Smith
Subject: Re: [Monotone-devel] "" is invalid file_path?
Date: Mon, 8 Sep 2008 02:18:10 -0700

On Mon, Sep 8, 2008 at 12:59 AM, Stephen Leake
<address@hidden> wrote:
> Part of parsing this requires turning the file name string into a
> file_path object. However, the file_path_as_external constructor
> complains that "" is an invalid path. This is from this line in
> normalize_external_path:
>
>      N(!path.empty(), F("empty path '%s' is invalid") % path);
>
> However, fully_normalized_path has this:
>
>  // empty path is fine
>  if (path.empty())
>    return true;
>
> What is the rationale for normalize_external_path rejecting ""?
>
> One fix is to delete that line from normalize_external_path.

IIRC that would be wrong.  As paths.hh says:
//        file_path_internal: use this for strings that come from
//          "monotone-internal" places, e.g. parsing revisions.  this turns on
//          stricter checking -- the string must already be normalized -- and
//          is extremely fast.  such strings are interpreted as being relative
//          to the project root.
//        file_path_external: use this for strings that come from the user.
//          these strings are normalized before being checked, and if there is
//          a problem trigger N() invariants rather than I() invariants.  if in
//          a workspace, such strings are interpreted as being
//          _relative to the user's original directory_.
//          if not in a workspace, strings are treated as referring to some
//          database object directly.

_external vs. _internal basically denote different syntaxes for
writing paths as strings -- _external is the stuff that people type on
the command line.  "" is a valid path in _internal-ese, but not in
_external-ese.  So if you remove that check, "mtn add ''" will be
valid (well, or more likely will give a weird assertion failed error
instead of the useful error it gives now).

Why do you want to use the _external-handling functions for parsing
path strings generated programatically by mtn?

-- Nathaniel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]