Archive for the ‘CVS’ Category

Diff and Patch Notes

February 28th, 2007

Useful diff and patch commands:

Create a patch with 3 lines of context and amount of blank lines. I want to see other whitespace difference – it might expose a typo.

diff -u 3 oldfile newfile > patchfile

Use CVS diff to create a patch comparing the local file (newer) with the repository version.

cvs diff -up file > patchfile


Patch a file and create an orig copy (from http://gentoo-wiki.com/MAN_patch_1 ). The -B option allows the prefix for a file – in this case I’ll save it somewhere else as a patched file.

patch -b < patchfile
patch -B /home/user/patched < patchfile

Patch a file you specify

patch file_to_be_patched patchfile

Diff notes
<

# diff -h
usage: man [-c|-f|-k|-w|-tZT device] [-i|-I] [-adlhu7V] [-Mpath] [-Ppager]
           [-Cfile] [-Slist] [-msystem] [-pstring] [-Llocale] [-eextension]
           [section] page ...
-a, --all                   find all matching manual pages.
-d, --debug                 emit debugging messages.
-e, --extension             limit search to extension type `extension'.
-f, --whatis                equivalent to whatis.
-k, --apropos               equivalent to apropos.
-w, --where, --location     print physical location of man page(s).
-W, --where-cat,
    --location-cat          print physical location of cat file(s).
-l, --local-file            interpret `page' argument(s) as local filename(s).
-u, --update                force a cache consistency check.
-i, --ignore-case           look for pages case-insensitively (default).
-I, --match-case            look for pages case-sensitively.
-r, --prompt string         provide the `less' pager with a prompt
-c, --catman                used by catman to reformat out of date cat pages.
-7, --ascii                 display ASCII translation of certain latin1 chars.
-E, --encoding encoding     use the selected nroff device and display in pager.
-t, --troff                 use groff to format pages.
-T, --troff-device device   use groff with selected device.
-H, --html                  use lynx or argument to display html output.
-Z, --ditroff               use groff and force it to produce ditroff.
-X, --gxditview             use groff and display through gditview (X11):
                            -X = -TX75, -X100 = -TX100, -X100-12 = -TX100-12.
-D, --default               reset all options to their default values.
-C, --config-file file      use this user configuration file.
-M, --manpath path          set search path for manual pages to `path'.
-P, --pager pager           use program 'pager' to display output.
-S, --sections list         use colon separated section list.
-m, --systems system        search for man pages from other unix system(s).
-L, --locale locale         define the locale for this particular man search.
-p, --preprocessor string   string indicates which preprocessors to run.
                             e - [n]eqn   p - pic    t - tbl
                             g - grap     r - refer  v - vgrind
-V, --version               show version.
-h, --help                  show this usage message.
  • del.icio.us
  • Digg
  • Slashdot
  • Technorati
  • MisterWong
  • Reddit

CVS – set up and patching

December 26th, 2006

I recently started using cvs for my web design work – because its the most popular and though subversion is improved, I’ll gain to learn CVS.

References:

http://cvsbook.red-bean.com/ – online CVS manual – excellent

http://developer.gnome.org/tools/cvs.html – more notes

http://durak.org/cvswebsites/howto-cvs/node38.html – cvswrappers file

http://www-bcl.cs.unm.edu/computers/cvs.html – notes

#####Starting things up

add this to .bashrc

export CVSROOT=/home/cvsuser/cvsroot

add this to .cshrc

setenv CVSROOT /home/cvsuser/cvsroot

Initialize cvs – in the directory specified by $CVSROOT

# cvs init

Import projects

# cvs import -m "vtiger codebase import" websitecom_CRM Inspiriat start

Checkout a project for editing

# cvs checkout websitecom_CRM

#####Connect to a remote CVS repository

set CVSROOT and remote shell

# export CVSROOT=":ext:user@some.remote.host.tld:/home/user/cvsrepo"
# export CVS_RSH="ssh"

#####Status commands

Log for a file – see who and related code

# cvs log foo.php

Get status of every file – quite long….

# cvs status

Show status of foo.php

# cvs status foo.php

#####Add/remove/rename files and directories

Add a file

# cvs add newfoo.php
# cvs ci -m "added newfoo.php to project" newfoo.php

Add a binary file

# cvs add -kb binary.exe
# cvs ci -m "added a binary.exe file" binary.exe

Add a directory

# cvs add subdir

Remove file

# rm file.php
# cvs remove file.php

Remove a directory

# cd dir
# rm file1 file2 file3
# cvs ci -m "removed file1 file2 file3"
# cd ..
# cvs update -P    (prune empty directories from the working copy, not the repository)  

Move a file

# mv oldname newname
# cvs remove oldname
# cvs add newname
# cvs ci -m "renamed oldname to newname" oldname newname

#####Before commit

Look at differences between checked-out and repository copy

# cvs -Q diff -c foo.php

Create a patch of these differences

# cvs -Q diff -c -u -p > newpatchfile.diff

Replace the local copy with one from the repository

# rm file.php ; cvs update file.php

#####Commit / Updates

Commit a specific file

# cvs commit -m "Added sorting by other columns" foo.php

Update your code with others contributions

# cvs update foo.php

#####After Commit

Show difference in revisions 1.1 and 1.2

# cvs diff -c -r 1.1 -r 1.2 foo.php

This command will now show little or nothing – working and repo has same copy

# cvs diff -u -p foo.php

#####Creating patches

Create a patch

# cvs diff -u -p -r 1.1 -r 1.2 foo.php > foo.php.patch

Create patch for using files not in CVS – (the -u -p outputs diff in patch format)
format: `diff -u -p oldfile newfile > patchfile`

# diff -u -p development/foo/fighter.php production/foo/fighter.php > fighter.php.patch

Apply patch to a file

# patch < patchfile

#####Binary files

CVS works fine with binary files and preserving permissions.
Format for binary files and permissions::
* Binary file: `*.jpg -k 'b'` (for a jpg file)
* Preserve permissions: `*.php -ko` (for a php file)

This is part of my cvswrappers file (in CVSROOT).

*.CLASS   -k 'b'
*.DOC   -k 'b'
*.AVI   -k 'b'
*.EAR   -k 'b
*.GIF   -k 'b'
*.PNG   -k 'b'
*.JPG   -k 'b'
*.PDF   -k 'b'
*.TAR   -k 'b'
*.WAR   -k 'b'
*.ZIP   -k 'b'
*.avi   -k 'b'
*.bin   -k 'b'
*.bz    -k 'b'
*.db    -k 'b'
*.bz2   -k 'b'
*.class   -k 'b'
*.doc   -k 'b'
*.ear   -k 'b'
*.exe   -k 'b'
*.gif   -k 'b'
*.gz    -k 'b'
*.hqx   -k 'b'
*.ico   -k 'b'
*.jar   -k 'b'
*.jpeg  -k 'b'
*.jpg   -k 'b'
*.msi   -k 'b'
*.mov   -k 'b'
*.mp3   -k 'b'
*.mpg   -k 'b'
*.pdf   -k 'b'
*.png   -k 'b'
*.ppt   -k 'b'
*.rpm   -k 'b'
*.sit   -k 'b'
*.srpm  -k 'b'
*.swf   -k 'b'
*.tar   -k 'b'
*.tbz   -k 'b'
*.tgz   -k 'b'
*.tif   -k 'b'
*.tiff  -k 'b'
*.war   -k 'b'
*.xbm   -k 'b'
*.xls   -k 'b'
*.zip   -k 'b'
*.sh      -ko
*.php      -ko
*.ini      -ko
*.txt   -ko
*.log     -ko
*.properties  -ko
*.html     -ko
*.htaccess    -ko
*.js    -ko   

Anything to add - please leave a comment. This is a work in progress.

  • del.icio.us
  • Digg
  • Slashdot
  • Technorati
  • MisterWong
  • Reddit

Mochabomb is Digg proof thanks to caching by WP Super Cache