顯示具有 Linux Development 標籤的文章。 顯示所有文章
顯示具有 Linux Development 標籤的文章。 顯示所有文章

2011年1月12日 星期三

CVS to SVN Crossover Guide, command comparison

CVS to SVN Crossover Guide

link from http://svn.apache.org/repos/asf/subversion/trunk/doc/user/cvs-crossover-guide.html

Purpose
This document provides an alternate method of learning Subversion. Many users dislike learning new technology via a theoretical "top down" approach, as provided by the Subversion Book. Instead, this document presents Subversion from the "bottom up": it shows a CVS command or task, and then shows the equivalent task in Subversion (along with relevant book links.) It's essentially a re-indexing of topics covered by the book, keyed on CVS tasks.

Table of Contents
Setup
Repository creation
Importing data
Installing a server
Authenticating to a server
Browsing a repository
Checking out a working copy
Basic Work Cycle
Seeing locally changed items
Seeing out-of-date items
Scheduling additions or deletions
Copying and moving
Undoing local changes
Updating and committing
Resolving conflicts
Adding a binary file
Using native line-endings
Examining history
Seeing history of an item
Comparing two versions of an item
Branching/Tagging/Merging
Creating a branch
Moving a working copy to a branch
Finding the beginning of a branch
Porting a single change
Merging a whole branch
Reverting a committed change
Resurrecting deleted items
Creating a tag
Tweaking a tag
Seeing all tags
Comparing two tags
Seeing logs between two tags
Other tasks
Using modules
Line endings and keywords
Repository creation
Create a new repository for holding versioned data.

CVS Subversion
Commands:
$ cvs -d /usr/local/repos init
Explanation:
Creates a new directory repos ready to hold RCS files and config scripts. Commands:
$ svnadmin create /usr/local/repos
Explanation:
Creates a new directory repos containing BerkeleyDB files and config scripts.

Book References:
Repository Creation and Configuration
Importing data
Populate a new repository with initial data. Assuming that you have a tree of code in the local directory myproj/, and you want to move this tree into the repository.

CVS Subversion
Commands:
$ cd myproj
$ cvs -d /usr/local/repos import myproj/ none start
Explanation:
This copies the contents of the current working directory to a new directory (myproj) in the CVS repository. The CVS repository now contains a directory /myproj/ at the top level. Commands:
$ svn mkdir file:///usr/local/repos/tags
$ svn mkdir file:///usr/local/repos/branches
$ svn import myproj/ file:///usr/local/repos/trunk
Explanation:
Though not strictly required, we deliberately create /tags and /branches top-level directories in the repository, to hold tags and branches later on. Then we import the contents of the local myproj/ directory into a newly created /trunk directory in the repository.

Book References:
Choosing a repository layout
svn import
Installing a server
Make the repository available to clients via a network.

CVS Subversion
Commands:
(too complex to demonstrate here)
Explanation:
Export the repository via the cvs pserver program. It can be launched by either inetd or a client's ssh remote request. Commands:
(too complex to demonstrate here)
Explanation:
Export the repository with the Apache 2.0.x server, or via the svnserve program. The latter can run as a standalone daemon, can be launched by inetd, or invoked by a client's ssh remote request.

Book References:
Server configuration
Authenticating to a server
Have a network client prove its identity to a version control server.

CVS Subversion
Commands:
$ cvs -d :pserver:user@host:/repos command…
Explanation:
When contacting a repository, the client pre-emptively "pushes" its authentication credentials at the server. Commands:
$ svn command URL…
Password for 'user': XXXXXXX
Explanation:
The client's authentication credentials are "pulled" from the user interactively, and only when the server deems that a challenge needs to be made. (And contrary to popular belief, the --username and --password options are merely values to be used if the server issues a challenge; they do not "push" the credentials at the server.)

Book References:
Network Model
Browsing a repository
Browse the repository as a filesystem, perusing file contents and history as well (older versions of files or trees.)

CVS Subversion
Commands:
(not possible with commandline client)
Explanation:
Not possible with commandline client. A third-party web server tool such as ViewCVS must be used. Commands:
$ svn list URL [-r rev] [-v]
$ svn cat URL [-r rev]
Explanation:
The svn list and svn cat commands allow interactive browsing of a repository (and all previous states of a repository) from the commandline. (The --verbose [-v] switch displays full listing information.) If Apache is being used as a Subversion server process (i.e. clients access via http://), then the latest version of the repository can be directly browsed by entering URL into any web browser. Additionally, a third-party web server tool (such as ViewCVS) can be used with Subversion.

Book References:
svn list
Checking out a working copy
Create a workspace on local disk which mirrors a directory in the repository.

CVS Subversion
Commands:
$ cvs -d /usr/local/repos checkout myproj
U myproj/foo.c
U myproj/bar.c
…
Explanation:
Creates a local directory myproj which is a mirror of the repository directory /myproj. Commands:
$ svn checkout file:///usr/local/repos/trunk myproj
A myproj/foo.c
A myproj/bar.c
…
Explanation:
Assuming that the original project data was imported into the repository /trunk directory, this creates a local directory myproj which is a mirror of the repository directory /trunk. Standard Subversion convention is to do "mainline" development in /trunk. See branching and tagging sections for more details.

Book References:
Initial Checkout
svn checkout
Seeing locally changed items
Discover which items in the working copy have local modifications or are scheduled for addition/deletion.

CVS Subversion
Commands:
$ cvs status
…
File: baz.c Status: Up-to-date
…
$ cvs update
M foo.c
U bar.c
…
Explanation:
The cvs status command shows whether a file is locally modified or out of date, including information about working revision and branch info. Unfortunately, because the output is so verbose and hard to read, many users run cvs update instead, which shows a more compact listing of modified files (and of course, it also causes the server to merge changes into your working copy.) Commands:
$ svn status
M foo.c
…
Explanation:
Shows modified files only. Very fast, as it does not use the network. Does not update your working copy, yet still shows a single-line display, much like svn update. To see working revision and branch information, run svn info.

Book References:
Examine Your Changes
svn status
Seeing out-of-date items
Discover which items in the working copy are out-of-date (i.e. newer versions exist in the repository.)

CVS Subversion
Commands:
$ cvs status
…
File: baz.c Status: Needs Patch
…
$ cvs -n update
M foo.c
U bar.c
…
Explanation:
The cvs status command shows whether a file is locally modified or out of date, including information about working revision and branch info. A less verbose option is to run cvs -n update instead, which shows a compact listing of both out-of-date and locally modified files, without actually updating the working copy. Commands:
$ svn status -u
M 46 foo.c
M * 46 bar.c
* 46 baz.c
…
Explanation:
Shows modified files (M) as well as out-of-date files (*). Contacts repository, but doesn't modify the working copy. To see working revision and branch information, run svn info.

Book References:
Examine Your Changes
svn status
Scheduling additions or deletions
Schedule a working-copy file or directory to be added or removed from the repository.

CVS Subversion
Commands:
$ touch foo.c
$ cvs add foo.c
cvs server: scheduling file `blah' for addition
cvs server: use 'cvs commit' to add this file permanently

$ mkdir new-dir
$ cvs add new-dir
Directory new-dir added to the repository

$ rm bar.c
$ cvs rm bar.c
cvs remove: scheduling `bar.c' for removal
cvs remove: use 'cvs commit' to remove this file permanently

$ rm -rf old-dir/*
$ cvs rm old-dir
cvs remove: Removing 3bits
…
Explanation:
Schedules a file or directory for addition or removal to/from the repository. The repository will not be changed until the user runs cvs commit, except for the case of adding a directory, which immediately changes the repository. Also, directories cannot be truly removed from the repository, just emptied out. (cvs update -P will prune empty directories from your working copy.) Commands:
$ touch foo.c
$ svn add foo.c
A foo.c

$ mkdir new-dir
$ svn add new-dir
A new-dir

$ svn rm bar.c
D bar.c

$ svn rm old-dir
D old-dir/file1
D old-dir/file2
…
Explanation:
Schedules a file or directory for addition or removal to/from the repository. The repository will not be changed until the user runs svn commit. The scheduled operations are shown as A or D by svn status, and svn revert can un-do the scheduling. Directories really can be deleted (though as with all deleted items, continues to exist in history.)

Book References:
Make Changes to Your Working Copy
svn add
svn delete
Copying and moving
Copy or move/rename a file or directory.

CVS Subversion
Commands:
(not possible.)
Explanation:
Not possible, unless an administrator directly mucks with RCS files in the repository. (And in that case, no history records the act of copying or renaming.) Commands:
$ svn copy foo.c foo2.c
A foo2.c

$ svn copy dir dir2
A dir2

$ svn move bar.c baz.c
A baz.c
D bar.c

$ svn move dirA dirB
A dirB
D dirA/file1
D dirA/file2
…
Explanation:
The svn copy command schedules a file or directory for addition to the repository, recording the "source" of the copy. After committing, svn log on the copied item will trace history back through the original copy-source. The svn move command is exactly equivalent to running svn copy, followed by an svn delete on the copy-source: the result is a new item scheduled for addition (with copy-history attached) and the original item scheduled for deletion.

Book References:
Make Changes to Your Working Copy
svn copy
svn move
Finding the beginning of a branch
If you're attempting to merge an entire branch into another, you need to compare the "root" and "tip" of the source branch, and then merge those differences into a working copy of the target branch. Obviously the "tip" of the branch can be represented by using the HEAD keyword. But how do you find the "birth" revision of the source branch?

The easiest solution is to run

$ svn log -v --stop-on-copy source-branch-URL
…

This command will display every change ever made to the branch, but --stop-on-copy option will cause the output to stop as soon as detects a copy operation in the branch's history. By definition, then, the very last log entry printed will show the copy being made. It will look something like:

r9189 | joe | 2004-03-22 10:10:47 -0600 (Mon, 22 Mar 2004) | 1 line
Changed paths:
A /branches/mybranch (from /trunk:9188)

In this case, you would then know to compare revisions 9189 and HEAD of the branch in order to perform the merge:

$ svn merge -r9189:HEAD source-branch-URL target-branch-WC
…

Seeing all of a project's tags
Assuming you've been following a consistent policy for creating tag-copies, then this is just a matter of running svn ls on a directory containing your tags. Typically you would run it on the /tags directory in your repository, although you're certainly free to organize this directory in a more complex way, or invent a different convention altogether.

As an example, you can see all of Subversion's tags by running:

$ svn ls --verbose http://svn.apache.org/repos/asf/subversion/tags
…
7739 kfogel Nov 13 22:05 0.33.0/
7796 josander Nov 18 12:15 0.33.1/
7932 josander Dec 03 17:54 0.34.0/
8045 josander Dec 19 15:13 0.35.0/
8063 josander Dec 20 11:20 0.35.1/
8282 josander Jan 13 14:15 0.36.0/
8512 josander Jan 24 17:31 0.37.0/
8810 kfogel Feb 23 03:44 1.0.0/
…

Seeing the differences between two tags
Just use svn diff in its fully expanded form, which compares any two URLs:

$ svn diff tagURL1 tagURL2
…

Seeing logs between two tags
This is a somewhat common practice in CVS, and is doable in Subversion, but requires a little bit more work. Assuming that you've made two tags of /trunk at different points in time, the ultimate goal here is to run

$ svn log -rX:Y trunkURL

…where X and Y are the revisions from which the two tags were copied. To discover X and Y, you can use the same technique described in the previous section ("finding the beginning of a branch".) Just use the --stop-on-copy option when logging the history of each tag. No commits happen on tag directories, so the following commands should each produce exactly one log entry:

$ svn log -v --stop-on-copy tag1-URL

r3520 | joe | 2004-03-12 15:28:43 -0600 (Fri, 12 Mar 2004) | 1 line
…

$ svn log -v --stop-on-copy tag2-URL
a
r4177 | joe | 2004-03-12 15:28:43 -0600 (Fri, 12 Mar 2004) | 1 line
…

So in this example, the values of X and Y are 3520 and 4177. Now you can view all /trunk changes between those two points in time:

$ svn log -r3520:4177 trunkURL
…

Fixing an incorrect tag
If your tag is a bit off, you can "adjust" it just as people often do in CVS. Simply check out a working copy of the tag directory, make any changes you wish, and commit.

Remember, because branches and tags are directories, they can also be deleted when they're no longer of any use to your project. They'll continue to exist in the repository's history.

Creating/using "modules"
Compare CVS Modules vs. svn:externals.

2010年5月26日 星期三

Linux Development - svn

Windows SVN software
TortoiseSVN
http://tortoisesvn.tigris.org/


svn command option -r can set the following values. I will diagnose these values when I am free.
-r [--revision] ARG : ARG (some commands also take ARG1:ARG2 range)
A revision argument can be one of:
NUMBER revision number
'{' DATE '}' revision at start of the date
'HEAD' latest in repository
'BASE' base rev of item's working copy
'COMMITTED' last commit at or before BASE
'PREV' revision just before COMMITTED

Q. HEAD, BASE, COMMITTED, PREV means what in svn?


Commit code to svn
# svn commit -m "message" commited-file

Update codes commited by other one
# svn update

Get the current working directory file status
# svn status

See the file difference
# svn log filename
# svn diff -r r669:676 filename

See the diff summary in a revision comparison
$ svn diff -r1302:1303 --summarize
M XXXX/abcd.h
M YYYY/zxcv.c


check out the specified revision from the svn source trunk
# svn co svn://ipaddress/pathTotheTrunk/trunk -r1232
# svn co svn://ipaddress/pathTotheTrunk/trunk@1232 PATH
PATH is the local-folder name which will store the check-out files

update the file to the latest version of the source trunk
# svn up -rHEAD path-to-the-source-file

update the file to the revision 1232 of the source trunk
# svn up -r1234 path-to-the-source-file


update the code in a specified date
# find . -name .svn -execdir svn update -r {2011-04-04} \;

import project to the svn repository, the below "myproject" is the imported folder
# svn import --no-ignore myproject svn://repository-address/path/to/newproject

After this command, all the files contained in the myproject will upload to the newproject folder of svn repository.
And we can use the following svn-address to check out this new project, like following command
# svn co svn://repository-address/path/to/newproject

we can use the option --no-ignore to avoid svn ignore the default ignored files (include .so ...)
Under version-controlled status
# svn st --no-ignore
# svn add --no-ignore local-folder
Import a directory of non-version-controlled
# svn import --no-ignore localFolder URL

Export the SVN repository files without the version-control tags (clean directory tree) to the local-folder
# svn export URL local-folder

change to the working directory
svn merge source-branch-URL -cSource-Revision
or
svn merge -r9189:HEAD source-branch-URL target-branch-WC


This will be useful when you create a branch for new feature implement,
and you want to reintegrate the implemented new feature back to trunk. The merging process will include 2 phases.


1st,
Keeping a Branch in Sync with trunk
$ pwd
.../your-branch
$ svn merge [--dry-run] ^/trunk
After Sync,
$ # build, test, verify, ...
$ svn commit -m "......"


second,
Reintegrating a Branch back to trunk
you need a clean working copy of the trunk first,
$ pwd
.../your-trunk
$ svn update # (make sure the working copy is up to date)
$ svn merge [--dry-run] --reintegrate ^/branches/your-branch
$ # build, test, verify, ...
$ svn commit -m "......"


How to use the TortoiseSVN to create the new branch or tag?
1. Use the "Log Message" to browase the specified source trunk
Note: remember to enable the "Show All" button in the most bottom screen.
2. type the search string in the "searching-field"
3. The "Log Message" will list all the comformed revision in the screen.
4. Click right button on the spevified revision. Select the "Create branch/tag from revision" from the pop-up menu. Then there will appear a sub window with title "COPY (Branch /Tag)". See the following figure for example.




















5. Select the right path in the "To URL" field. Note that svn-branch will under "branch" folder and svn-tag will under "release" folder.
6. Finally click "OK" will finish the processing.

2009年12月10日 星期四

Linux Development - Makefile, gcc

Makefile tips

-include $(TARGET_HOME)/.config
-include $(TARGET_HOME)/release.mak
==> while we add the prefix sign "--" in front of include statement, it means that if the include file is not exist, this statement is still ok without any error



Sample Makefile:
all: testLibiptcless1

testLibiptcless1: testLibiptcless1.c
gcc -Wall -Wunused -DNETFILTER_VERSION=\"1.2.6\" -rdynamic -o $@ $< \
/usr/local/lib/iptables.o /usr/local/lib/libiptc.a -ldl ==> We can link the other object file directly in the gcc command, remember be aware put all the linked libraries after the source code/output executed files

Sometimes we need some parameters inside the function (maybe for further usage). But that parameter is currently not used. So we can declare the attribute after the unused parameter. The attribute is declared as following usage.

#if defined(__GNUC__)
# define dlna_unused __attribute__((unused)) ==> define the dlna_unused
#else
# define dlna_unused
#endif

void
soap_device_callback( IN http_parser_t * parser dlna_unused, // we tag the dlna_unused here to quiet the gcc produce the Warning messages
IN http_message_t * request,
INOUT SOCKINFO * info )



-Wunused causes gcc to complain about unused parameters. This is often a good thing, if it makes you check twice whether you mistyped a variable name or forgot to implement something. But sometimes you really need to have a parameter which is not used, perhaps because the function needs to match a particular prototype.

gcc has a __attribute__((unused)) thing you can apply to paramters to quieten the warning. This actually means possibly unused: if you do use the parameter, gcc doesn't complain. So with unused alone, you can make errors in the opposite direction.

Linux Development - ccache

Use the following method to show the gcc
# readlink -f $(which gcc)
/usr/bin/ccache

# which gcc
/usr/lib/ccache/gcc
# ls -la /usr/lib/ccache/gcc
lrwxrwxrwx 1 root root 16 2008-02-27 01:05 /usr/lib/ccache/gcc -> ../../bin/ccache ==> Actually the gcc was link as a ccache

ccache
ccache is a compiler cache. It acts as a caching pre-processor to C/C++ compilers, using the -E compiler switch and a hash to detect when a compilation can be satisfied from cache. This often results in a 5 to 10 times speedup in common compilations.

The idea came from Erik Thiele wrote the original compilercache program as a bourne shell script. ccache is a re-implementation of Erik's idea in C with more features and better performance.

2009年12月3日 星期四

Linux Development - Cross Compilation

Q. How to compile the libpcap in the linux x86 enviroment for the ARM target?

>> Before compile the package. We need to setup the related tools as the cross compiler toolchain tools as following.
# set | grep arm
AR=arm-linux-uclibc-ar
AS=arm-linux-uclibc-as
BUILD='-Os -mtune=arm9e -march=armv5te'
CC=arm-linux-uclibc-gcc
CROSS_TARGET=arm-linux-uclibc
CXX=arm-linux-uclibc-g++
LD=arm-linux-uclibc-ld
RANLIB=arm-linux-uclibc-ranlib
READELF=arm-linux-uclibc-readelf
STRIP=arm-linux-uclibc-strip


# ac_cv_linux_vers=2 ./configure --host=arm --build=arm-linux --prefix=/usr/local/libpcap

How to instruct the configure to build the crosscompile code version of iperf
For example of ARM device target
# ./configure --host="armeb-linux" --enable-debuginfo --prefix=/pat/prefix

2008年5月12日 星期一

Linux Development - Make

.SECONDEXPANSION:
AVAR = top
onefile: $(AVAR)
echo "make onefile";
twofile: $$(AVAR)
echo "make twofile";
AVAR = bottom

# make onefile
make: *** No rule to make target `top', needed by `onefile'. Stop.
==> $(AVAR) is expanded to "top"
# make twofile
make: *** No rule to make target `bottom', needed by `twofile'. Stop.
==> because of second expansion, the $$(AVAR) is expanded to "bottom"

make debug tips
we can use the following parameters added after make to verbose the debugging messages
-w Option: How the ‘-w’ or ‘--print-directory’ option helps debug use of recursive make commands.