How I repaired my repository

2002-07-30 Thread Mike Ayers


[Note: this is an update.  There were two steps I forgot]

Okay, here's how I restored my repository from a recent archive of the 
repository itself and a good working tree
(sandbox).  Thanks to all who responded - I couldn't have done
it without you.

First, all work is done on copies of the archive and the sandbox. 
Whenever I made a mistake, I just erased my working
copies and started over.

1.  Copy the archive to the new[1] location.  Call this the restored 
archive.

2.  Copy the sandbox to a new location.  Call this the preserved sandbox.

2.  In a new location, check out a sandbox from the archive.  Call this 
the restored sandbox.

3.  Delete everything from the restored sandbox that isn't a CVS admin 
file:

$ 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)

4.  Delete everything from the preserved sandbox that is a CVS admin file:

$ find . -type d -name CVS | sed 's/^/\/' | sed 's/$/\/' | xargs rm -rf

5.  Copy the preserved sandbox onto the restored sandbox:

$ cd /restored/sandbox
$ cp -R /preserved/sandbox/* .

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.

7.  Check the commitable files to ensure that they look like the ones 
in the preserved sandbox.

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.

9.  Add any files in the directories discovered in Step 8 to
the restored repository.

10.  Commit all the commitable files, using a comment which is the same 
for all of them, and which can be used to find them.
Optionally, tag them as well.

11.  Check out a new sandbox.  Other than the loss of some tags and 
commit comments, you should have your original archive back.
(Note: I put this step in because I found that the read-only bits on
the files in the restored sandbox were inconsistent after the
restoration).


That's it.  This is basically the method suggested by Eric Siegerman 
with a few modifications.  Hope it helps.


/|/|ike


[1] - Due to the nature of my archive failure, I could not restore my
archive to its old location.  It makes no difference, though.



___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs



Re: How I repaired my repository

2002-07-30 Thread Eric Siegerman

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 added 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.[EMAIL PROTECTED]
|  |  /
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

___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs