Discussion:
[Newbie] Committing .. and then?
Don Bruder
2009-07-26 14:44:33 UTC
Permalink
Hi,
Sorry for the newbie question; I'm reading through some online tutorials
to try to work this out, but I can't find anything to explain what must be
a really simple problem.
I have a directory of files imported into CVS. I then delete the
originals, and 'checkout' the same files back into the working directory,
where I proceed to edit them. So far, so good?
When I've changed the file, I save it and 'commit'. OK, it tells me that
the changes have been recorded, and if I do cvs log <filename>, the
comments I added are all there. Good.
But, here's what I can't answer: if I want to edit that file again, do I
have to check it back _out_, before editing it? When I do 'cvs checkout
<filename>', I get a message that the module can't be found. Two
The "module not found" result is to be expected - with a basic
"checkout", you grab everything needed to build a tagged version of the
project (denoted by the various version tags in the repository) not
individual files. A "module" generally means "everything needed to build
a specific version of the project" - source and header files, perhaps
datasets, a makefile (or equivalent) possibly documentation in the form
of web pages, PDF files, man pages, or even just plain text files -
*EVERYTHING* needed to build the project. In practically every case,
there is more than one file in a module, and all of them "come along"
with a checkout.

So long as you haven't wiped out the copy you "checked out", you should
be good to go to edit it forever. "Checking out" simply means that
you've grabbed a copy of the "stuff" that's in the repository. Doing so
does nothing to the repository (or any of the files in it) except copy
stuff into your working directory, and perhaps note somewhere that
you've done so. When you "commit", any changes you may have made get put
in the repository, but unless you take steps to remove it, your "checked
out" copy (including any changes you "commit"ed) is still sitting in
your working directory, waiting for you to continue working with it.
1. does this mean that I no longer need to checkout the same file? Even
if I walk away from my computer and don't touch the file for another week?
Is it still 'checked in'? If so, how do I get it back out when I _am_
ready to edit it again?
Pretty much. It's already sitting there in your working directory. See
above paragraph. If you *KNOW, BEYOND A DOUBT* that you're the only
person working on the code, you don't need to do anything special before
starting to edit. On the other hand, if there's any realistic
possibility that someone else may have made changes to the repository
since the last time you did a commit, and you want to stay in sync with
what's actually in the repository, you're going to need to at least
update your working directory so that the files you have include their
changes. Depending on the project/amount of activity it sees, it might
be better to actually do a full checkout from scratch.
2. how do I tell the system 'OK, all done', and that my editing session is
over, and that I'm off to watch a film, smoke a reefer or go out for a jog?
The simple answer: You don't. A fundamental concept of software projects
is "It's never *DONE*, but we have to pay the bills somehow, so we're
gonna slap a "version 2.1.1.3.199.4A" sticker on it, and ship tomorrow
afternoon." CVS "understands" this concept, and is open-ended. Using the
right commands, you can build every version of a project from the first
time it was committed. And nothing ever "goes away" once you "commit"
it, even if it does eventually get lopped out of the shipping build -
Look in the repository's "attic", and you'll find any files that were
removed from the project at any point

When you're done working for a while, commit all your changes, then walk
away. That's it, that's all. You've fulfilled your duties under the CVS
"contract".

If/when you come back, update your working directory (or check out a new
copy) to get current with the version on the repository before you start
editing, and you're "caught up to" whatever changes may have been made
while you were away.

Something to keep in mind:
To paraphrase the old saying, "What happens in your working directory
stays in your working directory - at least until you commit". Until you
"commit", the CVS system (and the repository it's talking to, and
therefore anyone else who might be accessing that repository) knows
*NOTHING* about what you're doing in the "Las Vegas" of your working
directory. Once you "talk about it" with a "commit", everything you've
done to the codebase is public knowledge to everybody who has access to
that repository, but the stuff you do in your working directory AFTER
you "commit" remains invisible to the rest of the world - until the next
time you "commit".

Which means that you COULD "checkout" exactly once, make so many changes
that the original code isn't recognizable, never "commit", and still be
good to go - at least in your working directory. The Repository codebase
might go off in some other direction completely, but until/unless you
update from the repository, or commit your changes, you can behave as if
you're the only person working on the code. (Which is one of the major
ideas that drove the creation of the CVS system to begin with...)
--
Email shown is deceased. If you would like to contact me by email, please
post something that makes it obvious in this or another group you see me
posting in with a "how to contact you" address, and I'll get back to you.
Jim Hyslop
2009-07-26 17:51:39 UTC
Permalink
May I ask another question? I have a load of shell scripts in $HOME/bin...
nothing fancy, just some shit that I've knocked together over the years to
do various menial crap that I can't be bothered remembering the various
switches to. Now I want to add them to cvs, but what do I do with the
files in $HOME/bin ? They need to stay there, as my $PATH points there.
When an 'import' is done, are the files in $HOME/bin copied to $CVSROOT, a
la 'ln -s'? In short, do I need to do..
$ cd $HOME/bin
$ cvs import -m "my shell scripts" me bin *
$ rm -rfv $HOME/bin
$ cvs checkout bin
..?
Wouldn't that recreate the appropriate files in $HOME/bin, and I could
edit, commit and update at will? Do I *need* to delete them at all?
Can't I just ..
$ cd $HOME/bin
$ cvs import -m "my shell scripts" me bin *
$ cvs checkout bin
No, because the checkout command not only retrieves the files from the
repository, it creates a CVS subdirectory containing its administrative
files. If you tried checking out with the files present, you would get a
lot of confusing error messages.

What I often do for scripts like that is to import the scripts, then set
up a commit script that will copy the files from the repository into the
target directory (in your case, $HOME/bin). I do that because sometimes
the modifications and fine-tuning take longer than expected, and I have
to switch to other tasks before the modifications are complete. In that
case, I don't want to use the half-baked scripts.

See the Cederquist section "Keeping a checked out copy"
(http://ximbiot.com/cvs/manual/cvs-1.11.23/cvs_18.html#SEC188) for
details on how to do that.


- --
Jim Hyslop
Dreampossible: Better software. Simply. http://www.dreampossible.ca
Consulting * Mentoring * Training in
C/C++ * OOD * SW Development & Practices * Version Management

Loading...