zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Quick local CVS change scan, and bug in read?
Date: Sat, 18 May 2013 16:24:29 -0700	[thread overview]
Message-ID: <CAH+w=7YQLJZGxjdA=ZwA_u+JJg=LcGPRkPExj5bNcXRhX6hZUg@mail.gmail.com> (raw)

I found a couple of hosts where I had CVS checkouts of zsh, where it
is now impossible to use e.g. "cvs diff" or "cvs status" to discover
whether there are any local changes.  So I whipped up the function
below to compare the date stamps on the individual files to the date
recorded for each in CVS/Entries.  I thought some of you might find it
useful.  (One of the few things I'm finding annoying about git is that
a cloned repository doesn't preserve file timestamps.)

In the course of testing/refining this, I discovered that some
CVS/Entries files end with the line "D" with none of the usual
field-separator slashes.  When the "while IFS=/ read ..." loop
encounters such a line, it assigns type=D but leaves name, version,
date, flags, and branch set to their existing values from the previous
loop pass.  I'm pretty sure this is wrong; bash read assigns empty
string to all the "unused" variables in the list.  I had to change
from testing for an empty $date to testing for $type not "D".

Another problem is that the %e format in strftime is supposed to
prefix single-digit dates with a space, but zstat doesn't consistently
do that, which makes the date comparison more difficult than
necessary.  For example, the leading space is present on CentOS 5 for
zsh 4.2.6 and MacOS Lion zsh version 4.3.11, but is missing on Ubuntu
10.04 zsh 4.3.10.  It's also present in a fresh build of
zsh-5.0.2-88-gaa7467b on Unbutu, so I presume this to be some kind of
strange build-specific issue.

compareCVS () {
  emulate -L zsh
  setopt extendedglob
  zmodload -i zsh/stat
  for directory in **/*~(*/)#CVS*(D/)
  do
    (
      cd $directory && if [[ -r CVS/Entries ]]
      then
        while IFS=/ read type name version date flags branch
        do
          if [[ $type != D ]]
          then
            builtin stat -A argv -gF '%a %b %e %T %Y' +mtime $name
            [[ "${date/  / }" != "${1/  / }" ]] && print
$directory/$name ${branch:+"on branch"} ${branch#T} differs
          fi
        done < CVS/Entries
      else
        print $directory NOT IN CVS
      fi
    )
  done
}


             reply	other threads:[~2013-05-18 23:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-18 23:24 Bart Schaefer [this message]
2013-05-19  1:29 ` Phil Pennock
2013-05-19  4:26   ` Bart Schaefer
2013-05-19  5:36     ` Phil Pennock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7YQLJZGxjdA=ZwA_u+JJg=LcGPRkPExj5bNcXRhX6hZUg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).