Ever been disgruntled by the fact that you can't do a cvs diff with new files, because you haven't got write access on a Drupal contrib module's CVS repository and thus can't cvs add those new files? There's a solution though: edit CVS's Entries file. But who likes manually modifying files over and over again?
The solution: fakeadd! (I've attached the file to this post in case this site ever goes down.) This nice shellscript allows you to update the Entries file using a simple syntax: fakeadd newfile.php.
A quick install how-to:
~/scripts.~/.bash_profile file (if you're using the bash shell, this is the default shell on OS X) and add the following:
# Add custom scripts, such as the CVS fakeadd script. export PATH=$PATH:~/scripts
chmod +x ~/scripts/fakeadd.-N flag. So your eventual command will look like this: cvs diff -N -up > foo.patch.Updated on November 30, 2008. The above blog post was improved based on the feedback I got in the comments:
-N parameter for cvs diff to pick up new files.| Attachment | Size |
|---|---|
| fakeadd | 770 bytes |
Comments
It works. A couple extra pointers...
First, run the fakeadd script from the directory where the new file lives. If you're adding some new unit tests to D7, for example, they might be in ./includes/tests. fakeadd changes the CVS/Entries file in the current directory, so to add ./includes/tests/foo.test, you need to cd to includes/tests first.
Second, when making the patch, you need the -N flag:
cvs diff -N -up > foo.patch
Very handy!
Thanks very much for this script! Had troubles patching with a new file and this worked perfectly!
humm....
i was trying to use this as "fakeadd modules/*/*.api.php" and it failed miserably. i'm trying to decide if it'd be worth hacking it to get this to work correctly or if i should just add them by hand...
there fixed that for you ;)
Thanks, I updated the blog
Thanks, I updated the blog post!
Alternative approach: cvsdo
Just thought I'd throw out there that I stumbled across this post (and it didn't /quite/ work for me, though I appreciated that other Drupalers were attempting to solve this) slightly before this one.
Down in the section titled "Including new files in a patch", it mentions a nice utility called cvsdo (source is here, but see below if you're a Debianite), which accomplished this task quite nicely, and comes with other useful cvs utilities such as cvschroot which lets you change the Root entry (recursively!) for a working copy (ie. from an anonymous checkout to a logged-in one, for instance).
Even better was the fact that, on my debian-based system, all I had to do was apt-get install cvsutils and kapow! I had 'cvsdo' at my service :)
Thanks, great tip!
Thanks, great tip!
Added to drupal.org
Added to drupal.org documentation page. both this script and cvsdo, cvsutils.
http://drupal.org/node/323
Cheers
Frank Carey
Pingback
[...] command fails without write access to the repository. Luckely there is a handy little tool called fakeadd which you can use to edit the CVS entries file and let it look like the new files have been [...]
This is awesome!
You should get this into the official patch docs. The current setup is really a pain for a big patches with multiple dirs.
Post new comment