English 中文(简体)
Using CVS to #ifdef my changes
原标题:
  • 时间:2009-11-24 22:12:55
  •  标签:
  • diff
  • cvs

I have a large project that has many changes not yet checked in. I want to check them in but have them only take effect when a certain symbol is #define d

CVS does have the ability to format diffs with #ifdef s inserted using the --ifdef argument. However, this does not merge the #ifdef s back into my working file. Even worse, the output includes some ugly header stuff that would need to be removed.

Index: path/to/my/file.h,v
===================================================================
RCS file: /path/to/my/file.h,v
retrieving revision 1.17
diff --ifdef=TEST -r1.17 file.h

Does anyone have a script that would automate the process of doing the CVS diff, removing the header stuff and copying the result back over the working file?

Great thanks if anyone can help.

问题回答

I m not sure I understand what you are wanting to do, so I will answer a slightly modified question in case it makes your current problem obsolete.

Generally, #ifdef are only enabled if set at compile time. Even if they are checked out or checked in, the code within the macro will not be included unless a compile time symbol is available. For example:

#ifdef DEBUG
cerr << "Some debug statement" << endl;
#endif

Unless you set a -DDEBUG option (in GCC, see your compiler s documenation) or #define DEBUG 1 somewhere else in your code (that is available to the #ifdef), the debug statement above will not be compiled into the resulting binary.

That being said, heavy use of #ifdef can quickly become a maintanence blackhole and make it more difficult for your code to be portable. I would recommend against such a strategy.





相关问题
Use the commit message in a CVS pre-commit hook

Is it possible to use the commit message in a pre-commit hook in CVS? The CVS server is running remotely, and I access it using pserver. Ideally, I want to allow the commit if the files pass the ...

Using CVS to #ifdef my changes

I have a large project that has many changes not yet checked in. I want to check them in but have them only take effect when a certain symbol is #define d CVS does have the ability to format diffs ...

Netbeans CVS - existing repo - existing working copy

I m using Netbeans to develop with Drupal. I m trying to let Netbeans get drupal core and modules from the repository on drupal.org to my local working copy. Problem is: I already have a working ...

Does an Eclipse CVS merge appear in the log view of a file?

I m not new to the Branch/Merge idea, but I m new to CVS. I have a sample file that I have brached off of the main trunk, and have made non-conflicting edits to both the branch and the main. When I ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Get local cvs comment history when committing file/s in emacs

I often commit files with similar cvs comment but not in a single operation. I would like to able to bring up previous comments I ve used in a previous commit when I am in the process of writing a ...

热门标签