TeamwareToMercurial
From Genunix
Mercurial (hg) + Cadmium for TeamWare + WX users
Peter Dennis approached me, Stacey Marshall, as a local wx expert to put together a transition guide to help Revenue Product Engineering teams migrate from TeamWare and 'wx' to [Mercurial] and Cadmium. This is the accumulation of my ongoing investigations. Please feel free to contribute.
Introduction to Mercurial and Cadmium
- Mercurial is the replacement Distributed Source Code Management (DSCM) application for Teamware DSCM.
- Mercurial program is named hg (the chemical symbol for Mercury).
- It's pronounced like Mercury, but drop the 'y' and add 'e-all': Mer-cur-e-all.
- Cadmium (or cdm) is an extension to provide wx features to Mercurial.
- Its possible that Cadmium features may be made standard Mercurial features in the future.
Use within ON
Within ON we maintain a single, linear, uncluttered development branch in the gate.
Base----<change-1>----<change-2>----<change-n>----....
Mercurial like SCCS is more than happy to make multiple, non-linear, cluttered changesets.
Base---<change-1>----<change-2>----<change-3>-----------------------<change-4>
\ \ /
--<change-a>---<change-b>---<change-c=b+II>---<change-d=c+-3>
\ /
---<change-I>---<change-II>
Within Teamware we used wx redelget to flatten the file history. With Mercurial the Cadmium extension provides recommit to flatten the changsets.
Base---<change-1>----<change-2>----<change-3>---<change-4>
Setup for ON development - hgsetup
Use hgsetup to create/update users ~/.hgrc configuration file.
Refer to Mercurial Initial Setup for ON development for details.
Additional Utilities that maybe useful
which_scm
Reports the current Source Code Management (SCM) system in use and the top-level directory of the workspace.
$ which_scm mercurial /share/bld/u/sm26363/hg/myclone
$ which_scm cvs /net/tb3.uk/tank/src/misc/sm26363/BIND/bind_v9_5
$ which_scm teamware /net/tulasco.uk/gate/onnv-gates/onnv-clone
Typical usage might be:
which_scm | read SCM_TYPE CODEMGR_WS; [ $CODEMGR_WS != "/" ] && export CODEMGR_WS || unset CODEMGR_WS
wx2hg - Convert wx workspace to Mecurial workspace
wx2hg -t [path to mercurial workspace] [path to teamware workspace]
All files should be checked-in in the teamware workspace before running wx2hg.
Command line completion
Available from /usr/demo/mercurial, if you have SUNWmercurial installed on your system:
- bash_completion
- tcsh_complition
- zsh_completion
Editor modes / menus
Available if you have SUNWmercurial installed on your system:
- For Emacs users
- /usr/demo/mercurial/mercurial.el
- emacs-merge script script that invokes emacs ediff functionality.
- For Vim users
- /usr/demo/mercurial/vim/hg-menu.vim
Relevant Mercurial Extensions
Cadmium
Cadmium, or cdm, is a Mercurial extension developed at Sun to provide wx features to mercurial and is the main subject of this page.
- cdm provides the following features:
$ hg help cdm cdm extension - workspace extensions for mercurial This extension contains a number of commands to help you work within the OpenSolaris consolidations. Common uses: Show diffs relative to parent workspace - pdiffs Check source style rules - nits Run pre-putback checks - pbchk Collapse all your changes into a single changeset - recommit list of commands: apply apply cmd to all active files arcs show all ARC cases in checkin comments backup make backup copies of all workspace changes branchchk check if multiple heads (or branches) are present, or if bugs show all bug IDs in checkin comments cddlchk check for a valid CDDL block in active files comchk check checkin comments for active files comments show checkin comments for active files copyright check active files for valid copyrights cstyle check active C source files conform to the C Style Guide eval run cmd for each active file hdrchk check active header files conform to O/N rules jstyle check active Java source files for common stylistic errors keywords check source files do not contain SCCS keywords list list files changed relative to parent workspace nits check for stylistic nits in active files pbchk pre-putback check all active files pdiffs list workspace diffs relative to parent workspace permchk check active files permission - warn +x (execute) mode recommit compact outgoing deltas into a single, conglomerate delta renamed show renamed active files reparent reparent your workspace restore restore workspace from backup rtichk check active bug/RFEs for approved RTIs tagchk check if .hgtags is active and issue warning use "hg -v help cdm" to show aliases and global options
graphlog - graph log with ASCII characters
Print a revision history alongside a revision graph drawn with ASCII characters.
- Nodes printed as an @ character are parents of the working directory; the files you see are based on that/those changeset/changesets.
$ hg glog -l 3 @ changeset: 8014:5d0ee72e0ba1 |\ tag: tip | | parent: 8013:9406cd6ea18e | | parent: 7457:63e174bcec8e | | user: Stacey Marshall | | date: Wed Nov 05 14:45:55 2008 +0000 | | summary: Automated merge with ssh://onnv.sfbay.sun.com//export/onnv-clone | | | o changeset: 8013:9406cd6ea18e | | user: Chris Horne | | date: Wed Nov 05 06:47:46 2008 -0700 | | summary: PSARC/2008/674 nulldriver | | | o changeset: 8012:95c42a8a213e | | user: ying tian | | date: Wed Nov 05 12:39:50 2008 +0800 | | summary: 6703522 ahci driver needs to support SATA tape | |
hgk - view changes graphically
To view change sets graphically, similar to teamware's twversion, use the Hgk extension.
- For full details refer to http://www.selenic.com/mercurial/wiki/index.cgi/HgkExtension
- For configuration information refer to Suggested .hgrc configuration file changes below
fetch
Pull changes from a remote repository, merge new changes if needed.
$ hg fetch pulling from ssh://onnv.sfbay.sun.com//export/onnv-clone searching for changes adding changesets adding manifests adding file changes added 556 changesets with 5998 changes to 4949 files (+1 heads) updating to 8013:9406cd6ea18e 4925 files updated, 0 files merged, 135 files removed, 0 files unresolved merging with 7457:63e174bcec8e 2 files updated, 0 files merged, 0 files removed, 0 files unresolved new changeset 8014:5d0ee72e0ba1 merges remote changes with local
Workspace management
Create Workspace - workspace create <name> : hg init <name>
As with workspace create <name> the hg init <name> creates a suitable directory named <name>.
$ hg init master $ find master master master/.hg master/.hg/00changelog.i master/.hg/requires master/.hg/store $
Clone Workspace - bringover -p <parent> -w <name> . : hg clone <parent> <name>
The hg clone command is similar to the bringover command. Though Mercurial supports the use of HTTP and SSH URLs as the source of the repository. For example:
hg clone /share/bld/ONclones/onnv-hg-clone-eu hg clone ssh://anon@hg.opensolaris.org/hg/onnv/onnv-gate hg clone http://hg.genunix.org/onnv-gate.hg
Display Parent Workspace - workspace parent : hg paths default
Note that Mercurial workspace can have more than one parent.
$ hg paths default ssh://anon@hg.opensolaris.org/hg/onnv/onnv-gate
Display Workspace Name - workspace name : hg root
- hg root displays the current hg repository directory path.
Within an embeded path, such as usr/closed the 'closed' repository will be displayed, for example:
$ pwd /tank/project/onnv-clone/usr/src/cmd $ hg root /tank/project/onnv-clone/ $ cd ../../closed $ hg root /tank/project/onnv-clone/usr/closed
See also which_scm.
Check for changes in parent - bringover -n : hg incoming
- usage: hg incoming [OPTION] [SOURCE]
- Show new changesets found in source
- alias: in
$ hg incoming comparing with /home/sm26363/tmp/hg/master changeset: 0:d5b3d9c40628 tag: tip user: sm26363@estale date: Fri May 16 14:15:59 2008 +0100 summary: First test, multiple comment lines
Syncing with Parent - bringover : hg pull;hg update
- hg pull [options] [source]
- hg update
By default hg pull only collects the latest changesets, it does not update the working source files. To update the working source files following a pull use hg update.
$ hg pull pulling from /home/sm26363/tmp/hg/master requesting all changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (run 'hg update' to get a working copy) $ hg update 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
To pull and update in one there is a --update option.
Merging Changes - wx resolve : hg pull ; hg merge
If modified, uncommited, files exist in your workspace that are also modified in the parent a hg update will merge the files:
$ hg status
M x.txt
$ hg incoming
comparing with /home/sm26363/tmp/hg/master
searching for changes
changeset: 6:357312376bae
tag: tip
user: Stacey Marshall <stacey.marshall@sun.com>
date: Fri May 16 21:00:44 2008 +0100
summary: c4 commit
$ hg pull
pulling from /home/sm26363/tmp/hg/master
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
(run 'hg update' to get a working copy)
$ hg update
merging x.txt
warning: conflicts during merge.
merging x.txt failed!
0 files updated, 0 files merged, 0 files removed, 1 files unresolved
There are unresolved merges with locally modified files.
You can redo the full merge using:
hg update 3
hg update 6
$ cat -n x.txt
1 Hello World
2 c1
3 c2
4 <<<<<<< local
5 c2 more
6 =======
7 c3
8 c4
9 >>>>>>> other
The merge needs user intervention to continue, which you can apply
with your favourite editor. An alternative GUI merge tool can be used
as discussed below. Howver to complete this example I have edited the
file with ed (not my favourite editor):
$ $ ed x.txt 68 9d 6d 4d w 32 q $ cat x.txt Hello World c1 c2 c2 more c3 c4 $ $ hg diff diff -r 357312376bae x.txt --- a/x.txt Fri May 16 21:00:44 2008 +0100 +++ b/x.txt Fri May 16 22:09:19 2008 +0100 @@ -1,5 +1,6 @@ Hello World c1 c2 +c2 more c3 c4 $ hg commit -m "c2 more commit" $ hg push pushing to /home/sm26363/tmp/hg/master searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files
For *commited* files you will need to manually recommit the files.
cd ../c1 $ echo "Goodbye" >> x.txt $ cat x.txt Hello World c1 Goodbye $ hg commit -m "finished!" $ hg pul pulling from /home/sm26363/tmp/hg/master searching for changes adding changesets adding manifests adding file changes added 6 changesets with 6 changes to 1 files (+1 heads) (run 'hg heads' to see heads, 'hg merge' to merge) $
If your modified files have allready been comitted then hg pull
informs you that you need to merge the changes:
gpyfm example:
$ export HGMERGE=/opt/onbld/bin/gpyfm $ hg pull $ hg update $ hg -update -C <per-error-message> $ hg merge $ hg commit
An Example, using filemerge 'merge' tool
$ export HGMERGE= /share/onnv-tools/SUNWspro/SS11/bin/filemerge $ hg update -C 1 files updated, 0 files merged, 1 files removed, 0 files unresolved $ hg status ? usr/src/Makefile.orig
Merge tool
Mercurial does not provide its own file-merging GUI tool. You can continue to use teamware filemerge or use an alternative such as KDiff3, gpyfm, etc.
To configure Mercurial to use teamware modify your ~/.hgrc file accordingly:
# Merge tool [merge-patterns] ** = filemerge [merge-tools] filemerge.executable = /share/onnv-tools/teamware/bin/filemerge filemerge.args = -a $base $local $other $output filemerge.checkchanged = true filemerge.gui = true filemerge.premerge = false
- See merge-tools in hgrc(5) for explanation and further options.
- See also Disable automatic merge below. Ace 16:46, 27 August 2008 (BST)
Reverting a change - workspace undo : hg revert
TBD
- often paired with 'hg revert'
- alternative: 'hg backout'
File Management
List modified files - wx list : hg status or hg list
- hg status [OPTION]... [FILE]...
- show changed files in the working directory
- alias: st
The hg status command does not show *committed* files, for true wx list compatibility use the Cadmium hg list command.
In the following example 'x.txt' has been committed, 'y.txt' has been modified (not committed), 'z.txt' has been added and 'a.txt' has been created (not added):
$ hg status M y.txt A z.txt ? a.txt
The codes used to show the status of files are:
- M = modified
- A = added
- R = removed
- C = clean
- ! = deleted, but still tracked
- ? = not tracked
- I = ignored
- = the previous added file was copied from here
List committed files - putback -n : hg outgoing or hg list
- hg outgoing [OPTION]... [DEST]
- show changesets not found in destination
- alias: out
The hg outgoing command does not show *un-committed* files.
$ hg outgoing
Edit existing file - wx edit : NA
Just edit the file using your favourite editor. Mercurial automaticaly keeps track of edited files. See hg status
Add a new file - wx create : hg add
- hg add [OPTION]... [FILE]...
- add the specified files on the next commit
The file should exist to be added.
Files listed will be added to the repository on the next commit.
$ echo "Hello World" > x.txt $ hg status ? x.txt $ hg add x.txt $ hg status A x.txt
Reverting file changes - wx unedit : hg revert
- hg revert [OPTION]... [-r REV] [NAME]...
- restore individual files or dirs to an earlier state.
Modified files are saved with a .orig suffix before reverting.
$ hg status A usr/src/test.c ? usr/src/Makefile $ hg add Makefile $ hg status A usr/src/Makefile A usr/src/test.c $ hg revert Makefile $ hg status A usr/src/test.c ? usr/src/Makefile $ hg revert abort: no files or directories specified; use --all to revert the whole repo $ hg revert --all forgetting test.c $ hg status ? usr/src/Makefile ? usr/src/test.c
Deleting files - wx delete : hg remove
- hg remove [OPTION]... FILE...
- remove the specified files on the next commit.
- aliase: rm
Note that 'wx delete' command ran 'workspace filerm'.
Display differences - wx diffs : hg diff
- hg diff [OPTOIN]... [-r REV1[:REV2| -r REV2]] [FILE]...
- Provides unified diff output.
- As with 'wx diffs', if no file name is given then all active files (hg list) are implied.
Display History - wx prt : hg log
- hg log [OPTION].. [FILE]
- show revision history of entire repository or files
- Alias: history
A major change with Mercurial is that the log is for the entire change set, not per file. Thus the log is in some ways more similar to the wx putback commnents than the individual SCCS file comments.
$ hg log -v -l1 usr/src/cmd/rpcsvc/nis/rpc.nisd/resov_server/ngethostbyname.c changeset: 5942:f6814e9b7def user: sm26363 date: Wed Jan 30 09:01:17 2008 -0800 files: usr/src/cmd/rpcsvc/nis/rpc.nisd/resolv_common.c usr/src/cmd/rpcsvc/nis/rpc.nisd/resolv_common.h usr/src/cmd/rpcsvc/nis/rpc.nisd/resolv_server/main.c usr/src/cmd/rpcsvc/nis/rpc.nisd/resolv_server/nget_answer.c usr/src/cmd/rpcsvc/nis/rpc.nisd/resolv_server/ngethostbyname.c usr/src/cmd/rpcsvc/nis/rpc.nisd/resolv_server/nres.h usr/src/cmd/rpcsvc/nis/rpc.nisd/resolv_server/nres_rcv.c usr/src/cmd/rpcsvc/nis/rpc.nisd/resolv_server/nres_search.c usr/src/cmd/rpcsvc/nis/rpc.nisd/resolv_server/ypresolv_proc.c usr/src/cmd/ypcmd/ypserv_resolv_common.h description: 5074336 YP hosts cache should honor DNS TTL 6576955 rpc.nisd_resolv(1M) requires "ip6.int" support and update 6608309 rpc.nisd_resolv is adding the DNS search path wrongly 6655939 rpc.nisd_resolv(1M) lint warnings
Note that all the files are listed as are all of the original putback comments due to the -v (--verbose) option. See also the .hgrc configuration option 'logtemplate' below.
Additionally the log option can search for a keyword such as the CR number:
$ hg log -v -k 6633347 changeset: 6666:b61097837011 user: sm26363 date: Tue May 20 09:43:20 2008 -0700 files: usr/src/cmd/nscd/nscd<em>frontend.c usr/src/cmd/nscd/nscd</em>switch.c usr/src/lib/nsswitch/dns/common/dns_common.c description: 6633347 nscd (sparks) can give inconsistent name resolution if started without a resolv.conf file
Using the -p (--patch) option reports the log and changes in patch (diff -u) format.
To capture a previous comment, perhaps for use in another commit/recommit use hg log --template '{desc}' , for example:
hg log --template '{desc}' -r 8
or
hg log --template '{desc}' -l1
File Versioning - sccs print : hg annotate
- hg annotate [OPTION] FILE...
- show chageset information per file line
- alias: blame
By default files determind to be binary are not annotated, use -a option to override.
Apply_Changes_To_Workspace
Apply changes to workspace - wx delget : hg commit
- hg commit [OPTION]... [FILE]...
- Commit the specified files or all outstanding changes reported by hg status.
- aliases: ci
hg commit creates a changeset in the repository (workspace). The command runs your EDITOR (or HGEDITOR) for you to enter comments if you do not specify comments with --message "text" or --logfile <file>. Remember that comments are for the whole changeset, not per file.
$ hg status A x.txt $ hg commit $ hg log changeset: 0:ea2bea31aa54 tag: tip user: Stacey Marshall <stacey.marshall@sun.com> date: Fri May 16 17:02:12 2008 +0100 summary: First file: this is a multiple line comment $ hg log -v changeset: 0:ea2bea31aa54 tag: tip user: Stacey Marshall <stacey.marshall@sun.com> date: Fri May 16 17:02:12 2008 +0100 files: x.txt description: First file: this is a multiple line comment This second and subsequent lines are not shown by default. Last line.
Merging Changes - wx resolve : hg merge
- hg merge [-f] [[-r] REV]]
- Merge working directory with another revision
$ hg init master $ hg clone master c1 updating working directory 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg clone master c2 updating working directory 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd master $ echo "Hello World" > x.txt $ hg status ? x.txt $ hg add x.txt $ hg commit $ cd ../c1 $ hg pull pulling from /home/sm26363/tmp/hg/master requesting all changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (run 'hg update' to get a working copy) $ echo "c1" >>x.txt $ hg status ? x.txt $ pwd /home/sm26363/tmp/hg/c1 $ ls x.txt $ rm x.txt $ hg update 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ echo "c1" >>x.txt $ hg status M x.txt $ cd c1 c2 /home/sm26363/tmp/hg/c2 $ hg pull --update pulling from /home/sm26363/tmp/hg/master requesting all changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ pwd /home/sm26363/tmp/hg/c2 $ ls x.txt $ echo "c2" >>x.txt $ cd - /home/sm26363/tmp/hg/c1 $ hg commit $ hg push pushing to /home/sm26363/tmp/hg/master searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files $ cd - /home/sm26363/tmp/hg/c2 $ hg commit $ hg status $ hg pull pulling from /home/sm26363/tmp/hg/master searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) (run 'hg heads' to see heads, 'hg merge' to merge) $ $ hg heads changeset: 2:efcf1ca206b6 tag: tip parent: 0:17f4227fa5a2 user: Stacey Marshall <stacey.marshall@sun.com> date: Fri May 16 17:59:33 2008 +0100 summary: c1 commits changeset: 1:10918aacdf80 user: Stacey Marshall <stacey.marshall@sun.com> date: Fri May 16 18:00:01 2008 +0100 summary: c2 commits $ hg merge merging x.txt output file x.txt appears unchanged was merge successful (yn)? n merging x.txt failed! 0 files updated, 0 files merged, 0 files removed, 1 files unresolved There are unresolved merges, you can redo the full merge using: hg update -C 1 hg merge 2
At this point the mergetool appeared which I exited without saving my changes. Mercurial spoted that (checkchanged=true set in .hgrc), asks what I want to do and tells me how to re-execute the merge again:
$ hg status M x.txt ? x.txt.orig $ hg update -C 1 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg merge 2 merging x.txt 0 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $
As per the message we should now commit and most likely recommit:
$ hg commit -m "Merged parent changes" $ hg recommit
The hg recommit command is described in more detail below. Your now ready to push your changes or to continue editing.
Code review - wx webrev : webrev
Latest onbld webrev has been made Mercurial aware and will produce a webrev correctly.
View older version - wx get -p [-r] : hg cat [-r]
Because Mercurial works on changesets the -r revision makes more sense here than it did with 'wx' (its really an 'sccs get' under the hood).
Cadmium extensions
For the complete list of cadmium extensions run hg help cdm.
The following are the more commonly used.
Reparent for integration - workspace parent -p : hg reparent
- hg reparent path
- Updates the 'default' path.
Commonly used to change parent to the master source gate before push of changes.
List active files - wx list : hg list
- hg list [amrRu] [-p PARENT]
- list files changed relative to parent workspace
- alias: active
The parent tip is taken to be the latest revision shared between us and the parent workspace.
- options:
- -p --parent : parent workspace
- -r --removed : show removed files
- -a --added : show added files
- -m --modified : show modified files
The hg list extension will list modified-added files and commited files in the workspace. For example compare hg status to hg list:
$ hg status M y.txt A h1 ? h2 ? s1 ? s2 $ hg list added: h1 modified: x.txt y.txt $
Above x.txt has been committed and hence does not show up in the hg status ouput. While files h2, s1 and s2 are new files that have not been added to the workspace using hg add and so are not shown by hg list.
Note:
- hg list unlike hg status lists committed files.
- files which have not been added to the repository (a.txt) are not listed by hg list.
Search file contents - wx grep : ???
'hg grep' exists but it does a different thing. Use hg apply to grep active files.
Apply command to all active files - wx apply : hg apply
- hg apply [-p PARENT] [-r] command...
- apply cmd to all active files
options:
- -p --parent parent workspace
- -r --remain do not change directories
Apply complex commands to all active files - wx eval : hg eval
- hg eval [-p PARENT] [-r] command...
- run command for each active file where command can refer to:
- $file - active file basename.
- $dir - active file dirname.
- $filepath - path from workspace root to active file.
- $workspace - full path to workspace root.
- run command for each active file where command can refer to:
For example "hg eval 'echo $dir; hg log -l3 $file'" will show the last 3 log entries for each active file, preceded by its directory.
options:
- -p --parent parent workspace
- -r --remain do not change directories
Backup Changes - wx backup : hg backup
- hg backup [-t]
- make backup copies of all workspace changes
- alias: bu
Backups are stored in ~/cdm.backup/<basename of workspace> by default. you may specify an alternative location by setting backupdir in [cdm] section of .hgrc file, for example:
[cdm] backupdir=~/.cdm.backup
- options:
- -t --if-newer : only backup if workspace files are newer
Note that files need to have been added or modified to be backed up; use hg list to list files that would be backed up.
This feature is very useful when using workspaces in volatile areas. And or for taking snapshots of changes.
Restore Backup - wx restore : hg restore <name>
- hg restore [-g GENERATION] BACKUP
- restore workspace from backup
Restores a workspace from the specified backup directory and generation (which defaults to the latest).
- options:
- -g --generation : generation number
The *name* to restore is that of the workspace basename previously backed up to $HOME/cdm.backup.
Note: a restore will fail if the workspace has uncomitted changes. You must therefore commit those changes before a restore operation.
Collapsing Deltas - wx redelget : hg recommit
- hg recommit [-f] [-p PARENT]
- compact outgoing deltas into a single, conglomerate delta
- alias: reci
- options:
- -p --parent : parent workspace
- -f --force : force operation
- -m --message : use <text> as commit message
- -l --logfile : read commit message from file
- -u --user : record user as committer
When multiple commits have been made to a file you may collapse the multiple deltas to a single delta using the recommit command:
In the following example x.txt has *two commits:*
$ hg log -v -l3 x.txt | tee s1 changeset: 13:2dfdfdaf5ed2 tag: tip user: Stacey Jonathan Marshall <Stacey.Marshall@Sun.COM> date: Tue Jun 17 14:55:55 2008 +0100 files: x.txt description: 2nd commit after making some changes. changeset: 12:94fdd53745dd parent: 10:d9a3bd69e9ef user: Stacey Jonathan Marshall <Stacey.Marshall@Sun.COM> date: Tue Jun 17 14:52:47 2008 +0100 files: x.txt description: 1st commit changeset: 9:5ce9f262adf5 user: Stacey Marshall <stacey.marshall@sun.com> date: Fri May 16 22:52:06 2008 +0100 files: x.txt y.txt description: Test File
Now Use recommit to *merge the two:*
$ hg recommit -m "Merged deltas" Do you want to backup files first? [Y/n]: n saving bundle to /home/sm26363/tmp/hg/j2/.hg/strip-backup/5f06f03aea7b-temp saving bundle to /home/sm26363/tmp/hg/j2/.hg/strip-backup/94fdd53745dd-temp $ hg status ? s1 ? s2 $ hg list modified: x.txt $ hg log -v -l2 x.txt changeset: 11:2fa26302329c tag: tip user: Stacey Jonathan Marshall <Stacey.Marshall@Sun.COM> date: Tue Jun 17 15:12:57 2008 +0100 files: x.txt description: Merged deltas changeset: 9:5ce9f262adf5 user: Stacey Marshall <stacey.marshall@sun.com> date: Fri May 16 22:52:06 2008 +0100 files: x.txt y.txt description: 2nd update
ON Nits - wx nits : hg nits
- usage: hg nits [-p PARENT]
- Check for stylistic nits in active files
As with wx nits runs cddlchk, copyright, cstyle, hdrchk, jstyle, permchk, and keywords checks.
- options:
- -p --parent parent workspace
Note SCCS keywords are no longer permitted.
Preventing certain checks
To prevent a particular check add the pathname to a check-name.NOT file under the '.hg/cdm' directory where check-name is the name of the check to skip.
For example to exclude usr/src/lib/libresolv2/common/irs/dns_ho.c from csyle check:
$ mkdir -p `hg root`/.hg/cdm/ $ echo “usr/src/lib/libresolv2/common/irs/dns_ho.c” > `hg root`/.hg/cdm/cstyle.NOT $ hg cstyle Skipping usr/src/lib/libresolv2/common/irs/dns_ho.c... $
Putback Check - wx pbchk : hg pbchk
- hg pbchk [-N] [-p PARENT]
- pre-putback check all active files
Run cddlchk, comchk, copyright, cstyle, hdrchk, jstyle, permchk, tagchk, branchchk, keywords and rtichk checks. Additionally, warn about uncommitted changes.
- options:
- -p --parent : parent workspace
- -N --nocheck : skip RTI check
- Notes
- See also Preventing Certain checks
Source differences from child to parent - wx tpdiffs : hg pdiffs
- hg pdiffs [-p PARENT]
- List workspace diffs relative to parent workspace
The parent tip is taken to be the latest revision shared between us and the parent workspace.
- options:
- -p --parent : parent workspace
The hg pdiffs provides unified diff(1) output between the current hg list files and the parent workspace.
Putback - wx putback : hg push
- hg push [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]
- push changes to the specified destination
- As with teamware you may need to merge your changes with the gate before you can successfully integrate (push) your changes.
For details of integrating your changes to a Solaris ON gate refer to Mercurial ON Gate Putback Procedure.
New features
Of which I'm sure there are more but here is a handful from the KTD SCM migration PDF. It might be good to add some examples... Ace 19:10, 20 June 2008 (BST)
hg grep
- This command behaves differently than Unix grep.
- It only accepts Python/Perl regexps.
- It searches repository history, not the working directory.
- It always prints the revision number in which a match appears.
- By default only prints output for the first revision of a file in which it finds a match.
hg import/export
- generates/imports diffs that can be applied by Hg directly, or to non-Hg repositories with patch/gpatch
This might be useful for backports then... Provide an example that caters for renamed / deleted / created files.
hg bundle/unbundle
- generates/imports bundles of changesets
hg revert | hg update -C
- Revert to known/clean workspace or rev
hg rollback
- Can be used to undo a commit
- Can also undo changes pulled or pushed into a repo
- No way to undo a rollback
hg tag
- generates a tag nickname to call your revision (e.g. 'onnv_71' tag)
- normally resides in root dir/.hgtags
- tag -l creates a localtag which isn't revision controlled (lives in .hg dir)
hg tags
- show all tags in the repository
Suggested .hgrc configuration file changes
log file output with multiple comments by default.
Add to the [ui] (user interface) section the following:
[ui]
logtemplate = 'changeset: {rev}:{node|short}\nuser: {author}\ndate: {date|isodate}\nlog:\n{desc}\n--------------------------------------------------------------------\n'
Ignore filenames
Refer to the hgignore(5) manual page and add filenames to a file. For example to have hg ignore emacs backup files add the following:
$ cat ~/.hgignore
syntax: glob *~
Then add to the [ui] (user interface) section the following:
[ui] ignore=~/.hgignore
Configure mercurial to use teamware filemerge as merge tool
Modify the merge-tools section as follows:
[merge-tools] filemerge.executable = /share/onnv-tools/teamware/bin/filemerge filemerge.args = -a $base $local $other $output filemerge.checkchanged = true filemerge.gui = true
Disable automatic merge
By default mercurial will automatically merge changes that do not appear to overlap with your changes. To prevent this and thus avoid unexpected changes add the following to the merge-tools section as follows:
[merge-tools] filemerge.premerge = false
- See MercurialMergeExample for details. Ace 16:46, 27 August 2008 (BST)
Graphical interactive history viewer
View historical changesets graphically with hg view by adding the following to the [extensions] section of $HOME/.hgrc file:
hgk=/usr/lib/python2.4/vendor-packages/hgext/hgk.py
For further information refer to http://www.selenic.com/mercurial/wiki/index.cgi/HgkExtension
Pathname Aliases
Add aliases to your favorit hg master workspaces by appending pathnames to the [paths] section of $HOME/.hgrc:
[paths] onnv-gate=ssh://anon@hg.opensolaris.org/hg/onnv/onnv-gate uk-onnv-clone=/share/bld/ONclones/onnv-hg-clone-eu
Appendix I - Quick Reference Chart
| Description | teamware / wx | Mercurial / Cadmium |
|---|---|---|
| Create Workspace | workspace create <name> | hg init <name> |
| Clone workspace | bringover -p <parent> -w <name> . | hg clone <parent> <name> |
| Display parent workspace | workspace parent | hg paths default |
| Display workspace name | workspace name | hg root |
| Checking for changes in parent | bringover -n | hg incoming |
| Syncing with parent | bringover | hg pull;hg update |
| Listing modified files | wx list | hg status (or hg list) |
| Listing commited files | putback -n | hg outgoing (or hg list) |
| Edit existing file | wx edit | NA |
| Adding a file | wx create | hg add |
| Reverting file changes | wx unedit | hg revert |
| Deleteing files | wx delete | hg remove |
| Display differences | wx diffs | hg diff |
| Display History | wx prt | hg log |
| File Versioning | sccs print | hg annotate |
| Apply Changes To Workspace | wx delget | hg commit |
| Merging Changes | wx resolve | hg merge |
| List Active Files | wx list | hg list |
| Backup Changes | wx backup | hg backup |
| Restore Backup | wx restore | hg restore <name> |
| Collapsing Deltas | wx redelget | hg recommit |
| ON Nits | wx nits | hg nits |
| Putback Check | wx pbchk | hg pbchk |
| Source differences from Child to Parent | wx tpdiffs | hg pdiffs |
| Putback | wx putback | hg push |
What's missing?
Think somethings missing? list it here? wx putback -n equivalent for ON development is hg -v outgoing
Change of commit comment
How does one change the commit comment, Need to confirm that recommit takes care of that.
wx unedit
Question: To edit a file you just edit it, so how do you unedit it?
Answer: You do "hg revert <filename>", or "hg revert --all" to unedit everything.
workspace delete
Question. What is the Mercurial equivalent of Teamware workspace delete? Anaswer. rm -rf workspace-name
References
- hg help -v
- Manual pages
- hg(1)
- hgrc(5)
- OpenSolaris references
- Genunix WIKI
- stevel's KTD slides
- SCM Migration (pdf) - Only found this today! Ace 19:10, 20 June 2008 (BST)
- e-mail Aliases
- scm-migration-dev@opensolaris.org

