[Top][All Lists]

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

Re: loginfo and filenames with spaces

From: Dan Peterson
Subject: Re: loginfo and filenames with spaces
Date: Fri, 25 Apr 2003 10:01:18 -0700 (Pacific Daylight Time)

On Thu, 24 Apr 2003 Larry Jones wrote:

> BackLoop writes:
> >
> > But there is problem with folders and filenames containing spaces -
> > the loginfo substitute parameter %s returns the folder and filelist
> > separated by space. Also I tried to capture stdout but there is the
> > same- filelist separated by space.
> > Any ideas how to resolve this? Maybe there is some patch for CVS which
> > adresses the problem?
> The best solution is to not use spaces in file and directory names.
> Failing that, a workaround is to use an upsupported character (space is
> traditional) in the format string to give you an empty field that you
> can key off of.  For example, using %{ s } instead of %s would result in
> something like:
>     "my directory ,my first file, ,my second file,"
> Of course, if you also have commas in your file/directory names, that
> makes life a bit more interesting.

Our users seem to create filenames with every possible character, so I use
multiple "unsupported characters" just to lessen the likelihood that a
comma in the filename will cause problems.  I use a ',' as the unsupported
character simply because multiple spaces is harder to see.

eg. %{,,,sVv} would send the script something like:

  baz/foo bar ,,,file 1,1,2,1.3 ,,,file 2,1.1,1.2 ,,,file 3,1.7,1.8

then in perl:

  ($dir, @files) = split(' ,,,', $filelist);

  for (@files) {
    # Don't use split here because filename may contain commas
    ($filename, $oldrev, $newrev) = (m/(.*),(.*),(.*)/);

If your script needs to determine which files were Added, Modified or
Removed, then you probably need to use the oldrev %{V} and newrev %{v}
format strings as I did above.  The reason is because you can't reliably
determine if a file was Added/Modified/Removed by looking at STDIN.

For example commit 4 files; the first named "file has space" which is a
"Modified" file and the next 3 named "file", "has" and "space" which are
"Added" files.  STDIN to the loginfo script will show something like:

  Modified Files:
          file has space
  Added Files:
          file has space

If you only look at STDIN you can't tell which files were Added and which
were Modified.  Is "Modified Files" showing "file", "has" and "space" or is
it showing "file has space"?

To get around this, you can use the %{,,,sVv} format string.  The $oldrev
for an "Added" file will be "NONE" and the $newrev for a "Removed" file
will be "NONE", so:

  $state = ($oldrev =~ /NONE/i) ? 'A' : (($newrev =~ /NONE/i) ? 'R' : 'M');

reply via email to

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