Re: How I repaired my repository

From:

Eric Siegerman

Subject:

Re: How I repaired my repository

Date:

Tue, 30 Jul 2002 14:44:04 -0400

User-agent:

Mutt/1.2.5i

Glad to hear you've recovered!
On Tue, Jul 30, 2002 at 11:11:37AM -0700, Mike Ayers wrote:
> That's it. This is basically the method suggested by Eric Siegerman
> with a few modifications.
Yup, pretty much the same modifications I'd have made :-)
> $ find . -type f | grep -v '/CVS/' | sed 's/^/\"/' | sed 's/$/\"/' |
> xargs rm
>
> (the sed scripts enclose the filename in quotes to handle paths with
> spaces in them, which I had)
You can do both of those in one sed script with:
... | sed 's/.*/"&"/' | ...
Though I'd use single quotes instead:
... | sed "s/.*/'&'/" | ...
to protect against other shell-sensitive characters that aren't
disabled by double quotes -- '$' for example.
Even better is to use GNU find and xargs, both of which are parts
of their findutils package, since those provide a way to
completely avoid the problem:
find DIRS -CRITERIA -print0 | xargs -0 COMMAND
That separates the pathnames with '\0's instead of newlines, and
causes xargs to look for same.
> 6. Do a `cvs update` on the restored sandbox. This should reduce the
> differences to the files which are actually different,
> and mark those files commitable.
Hmm, I'd have done a "cvs -n update" first, looking for anything
unusual, i.e. other than "M" and "?" lines, before trusting a
"real" update not to make a mess:
- If there are files reported as "lost", you need to
"cvs remove" them
- There shouldn't be any conflicts, given the situation, but if
there are, this is a case where CVS's automatic merge will
NOT do the right thing.
- Likewise any files reported as "U" but not as "lost". Again,
this shouldn't occur -- which is why I *really* want to know
if it does!
Think of this sanity checking as the manual equivalent of
assert()'s :-)
> 8. Now step through your archives and find all the directories which
> do not exist in the restored repository and should.
> I do not know how to do this on the command line, as I am using
> WinCVS, which makes this step quite easy.
You can do this iteratively using CVS:
- do "cvs -nq update" and look for the "?" lines
- "cvs add" those
- repeat until there aren't any more "?"s
You can't reduce it to a single pipeline per pass:
cvs -nq update | sed 'some magic or other' | xargs cvs add
That doesn't work, especially in client/server mode, if the files
being added are in multiple directories. (Rather, it used not to
work; maybe it does now...)
The multiple passes are because, if a directory is new, its
contents won't show up as "?" lines until you've "cvs add"ed the
directory itself.
> Optionally, tag them as well.
I wouldn't consider this optional, but that's personal preference
of course :-)
--
| | /\
|-_|/ > Eric Siegerman, Toronto, Ont. address@hidden
| | /
Anyone who swims with the current will reach the big music steamship;
whoever swims against the current will perhaps reach the source.
- Paul Schneider-Esleben