--- wikisrc/users/dholland/hgnb.mdwn 2014/12/14 03:01:20 1.6 +++ wikisrc/users/dholland/hgnb.mdwn 2014/12/14 09:52:59 1.12 @@ -26,22 +26,22 @@ somewhere that constitutes the master co Therefore, the basic usage is almost entirely unchanged: - CVS Mercurial + CVS Mercurial - cvs checkout hg clone - cvs update -dP hg pull && hg update - cvs -n update hg status - cvs log file hg log file [or just hg log] - - cvs update -p file hg cat file - cvs annotate hg annotate - cvs diff -u hg diff - cvs add hg add - cvs rm hg rm - [no can do] hg cp - [no can do] hg mv - cvs commit hg commit && hg push - cvs tag hg tag + cvs checkout hg clone + cvs update -dP hg pull && hg update + cvs -n update hg status + cvs log file hg log file [or just hg log] + + cvs update -p file hg cat file + cvs annotate hg annotate + cvs diff -u hg diff + cvs add hg add + cvs rm hg rm + [no can do] hg cp + [no can do] hg mv + cvs commit hg commit && hg push + cvs tag hg tag You will notice that CVS's update and commit have been divided into two now-separable actions: in Mercurial, pull fetches changes from a @@ -65,17 +65,20 @@ committed, you need to do an explicit me push. In the simple case, you do an explicit merge as follows: - hg pull - hg merge - hg commit + + hg pull + hg merge + hg commit When you get a merge conflict, you first need to resolve it (in the usual way by editing) and then you must tag it resolved in hg before hg will let you commit, like this: - hg resolve -m file + + hg resolve -m file You can list unresolved conflicts thus: - hg resolve -l + + hg resolve -l Note that even with the explicit merge this is almost exactly equivalent to the CVS behavior when someone commits ahead of you. @@ -86,10 +89,11 @@ that touches the same files you've edite There is one gotcha, which is that you can't do explicit merges in a tree with uncommitted changes. The best way around this is to stash your changes: - hg stash - hg merge - ...whatever merge stuff... - hg unstash + + hg stash + hg merge + ...whatever merge stuff... + hg unstash You can also do the merge in another tree; because Mercurial is a distributed tool, you can create a temporary copy of your tree, or @@ -99,14 +103,14 @@ trees, "src" and "scratch", where you ne in "scratch" so it can be used for this kind of thing. Then you can do the following (starting at the top of src): - hg push ../scratch - cd ../scratch - hg update - hg merge - ...whatever merge stuff, including commit... - cd ../src - hg pull ../scratch - hg update + hg push ../scratch + cd ../scratch + hg update + hg merge + ...whatever merge stuff, including commit... + cd ../src + hg pull ../scratch + hg update ### Disconnected operation @@ -122,7 +126,8 @@ push, pull, incoming, and outgoing. A commit with no descendents (that is, the most recent commit on any line of development) is called a "head". You can list these as follows: - hg heads + + hg heads This will include commits that have descendents only on other branches, e.g. the last commit on a development branch that's been @@ -134,11 +139,13 @@ incoming" and "hg outgoing" respectively If you interrupt Mercurial (or Mercurial gets interrupted, e.g. by a system crash) you want to do this afterwards: - hg recover + + hg recover and if you have reason to think the repository might be corrupt you can check it like this: - hg verify + + hg verify ### Development branches @@ -159,43 +166,47 @@ changes before they're done, go ahead an Create a new branch: - cvs update -dP hg pull && hg update (if needed) - update doc/BRANCHES update doc/BRANCHES (if appropriate) - cvs commit doc/BRANCHES hg commit doc/BRANCHES (if needed) - cvs tag libc13-base hg tag libc13-base - cvs ph'tagn hg branch libc13 - [make first change] [make first change] - cvs commit hg commit - hg push + cvs update -dP hg pull && hg update (if needed) + update doc/BRANCHES update doc/BRANCHES (if appropriate) + cvs commit doc/BRANCHES hg commit doc/BRANCHES (if needed) + cvs tag libc13-base hg tag libc13-base + cvs ph'tagn hg branch libc13 + [make first change] [make first change] + cvs commit hg commit + hg push Mercurial warns you that branches are permanent and expensive; this warning is aimed at git users who ought to be creating bookmarks instead and not something you need to be concerned about. Check out a new tree on a branch: - cvs co -P -rlibc13 hg clone [url] - cd src - hg update -r libc13 + + cvs co -P -rlibc13 hg clone [url] + cd src + hg update -r libc13 Switch to a new tree on a branch: - cvs up -dP -A -rlibc13 hg pull (if needed) - hg update -r libc13 + + cvs up -dP -A -rlibc13 hg pull (if needed) + hg update -r libc13 Note that if you have uncommitted changes, Mercurial will balk at crossing from one branch to another because it doesn't know how to merge them. In that case do this: - hg update -r libc13-base - [resolve conflicts if needed] - hg update -r libc13 - [resolve conflicts if needed] + + hg update -r libc13-base + [resolve conflicts if needed] + hg update -r libc13 + [resolve conflicts if needed] Check which branch you're currently on: - cat CVS/Tag hg branch + cat CVS/Tag hg branch See list of branches: - [no can do reliably] hg branches + + [no can do reliably] hg branches Note that unlike with CVS there's no version-control-related reason to get a new tree just to work on a branch. @@ -206,17 +217,17 @@ administrative reasons. Sync your branch with the trunk ("HEAD" in CVS): - cvs ph'tagn hg merge default - [resolve conflicts] [resolve conflicts] - cvs commit hg commit - hg push + cvs ph'tagn hg merge default + [resolve conflicts] [resolve conflicts] + cvs commit hg commit + hg push When you're done with your branch, in Mercurial you can "close" it so it's no longer active. This causes it to disappear from some reports, reduces some internal management overheads, and prevents accidental commits on it. - [no can do] hg commit --close-branch + [no can do] hg commit --close-branch Don't forget to update doc/BRANCHES too. @@ -232,34 +243,32 @@ empty revision so it doesn't contain any To start a new vendor branch for the upstream package "frobozz", assuming you've already written frobozz2netbsd if one's needed: - mkdir tmp - cd tmp - hg update -r0000 - mkdir external && cd external - mkdir bsd && cd bsd - mkdir frobozz && cd frobozz - tar -xvzf \ tar -xvzf \ - frobozz-1.0.tgz frobozz-1.0.tgz - mv frobozz-1.0 dist mv frobozz-1.0 dist - cp .../frobozz2netbsd . cp .../frobozz2netbsd . - ./frobozz2netbsd ./frobozz2netbsd (if needed) - cvs import \ - src/distrib/bsd/frobozz \ - FROBOZZ frobozz-1-0 - hg add - hg branch FROBOZZ - hg commit - hg tag frobozz-1-0 - cd ../src - cvs update -dP - hg update -r default - hg merge FROBOZZ - hg commit - [hack as needed] [hack as needed] - cvs commit hg commit - hg push - cd .. - rm -r tmp + mkdir tmp + cd tmp + hg update -r0000 + mkdir external && cd external + mkdir bsd && cd bsd + mkdir frobozz && cd frobozz + tar -xvzf frobozz-1.0.tgz tar -xvzf frobozz-1.0.tgz + mv frobozz-1.0 dist mv frobozz-1.0 dist + cp .../frobozz2netbsd . cp .../frobozz2netbsd . + ./frobozz2netbsd ./frobozz2netbsd (if needed) + cvs import src/distrib/bsd/frobozz \ + FROBOZZ frobozz-1-0 + hg add + hg branch FROBOZZ + hg commit + hg tag frobozz-1-0 + cd ../src + cvs update -dP + hg update -r default + hg merge FROBOZZ + hg commit + [hack as needed] [hack as needed] + cvs commit hg commit + hg push + cd .. + rm -r tmp Note that in both cases this imports frobozz2netbsd on the branch; this seems the most convenient but I'm not sure if it's been our @@ -267,35 +276,33 @@ standard procedure. To update "frobozz" to 1.1: - mkdir tmp - cd tmp - hg update -rFROBOZZ - cd external/bsd/frobozz - tar -xvzf \ tar -xvzf \ - frobozz-1.1.tgz frobozz-1.1.tgz - rm -r dist - mv frobozz-1.1 dist mv frobozz-1.1 dist - ./frobozz2netbsd ./frobozz2netbsd - cvs import \ - src/distrib/bsd/frobozz \ - FROBOZZ frobozz-1-0 - hg addremove - hg commit - hg tag frobozz-1-1 - cd .. - mkdir tmp2 && cd tmp2 - cvs ph'tagn - hg update -r default - hg merge FROBOZZ - [resolve conflicts] [resolve conflicts] - cvs commit hg commit - cd ../src - cvs update -dP - [hack as needed] [hack as needed] - cvs commit hg commit - hg push - cd .. - rm -r tmp tmp2 + mkdir tmp + cd tmp + hg update -rFROBOZZ + cd external/bsd/frobozz + tar -xvzf frobozz-1.1.tgz tar -xvzf frobozz-1.1.tgz + rm -r dist + mv frobozz-1.1 dist mv frobozz-1.1 dist + ./frobozz2netbsd ./frobozz2netbsd + cvs import src/distrib/bsd/frobozz \ + FROBOZZ frobozz-1-0 + hg addremove + hg commit + hg tag frobozz-1-1 + cd .. + mkdir tmp2 && cd tmp2 + cvs ph'tagn + hg update -r default + hg merge FROBOZZ + [resolve conflicts] [resolve conflicts] + cvs commit hg commit + cd ../src + cvs update -dP + [hack as needed] [hack as needed] + cvs commit hg commit + hg push + cd .. + rm -r tmp tmp2 ### Release branches @@ -316,24 +323,26 @@ without looking it up. Tagging a release: - cvs rtag -r netbsd-7 \ hg tag -r netbsd-7 \ - netbsd-7-0-RELEASE netbsd-7-0-RELEASE + cvs rtag -r netbsd-7 \ hg tag -r netbsd-7 \ + netbsd-7-0-RELEASE netbsd-7-0-RELEASE Viewing the changes on a branch: - cvs log > file hg log -b netbsd-7 - [page through & curse] + cvs log > file hg log -b netbsd-7 + [page through and curse] Extracting tarballs: - cd src - hg export -r \ hg archive -r \ - netbsd-7-0-RELEASE \ netbsd-7-0-RELEASE \ - src .../netbsd-7.0.tar.gz - mv src netbsd-7.0 - tar -cvzf \ - netbsd-7.0.tar.gz \ - netbsd-7.0 + mkdir tmp + cd tmp + cvs export -r netbsd-7-0-RELEASE \ hg archive -r netbsd-7-0-RELEASE \ + src ../netbsd-7.0.tar.gz + mv src netbsd-7.0 + tar -cvzf ../netbsd-7.0.tar.gz \ + netbsd-7.0 + cd .. + rm -r tmp + ### Reverting a bad commit @@ -343,13 +352,13 @@ separately, then commit them all. In Mercurial, because Mercurial has whole-tree commits, you can do it with a single command. - cvs update -j1.6 -j1.5 foo.c - cvs update -j1.9 -j1.8 bar.c - cvs update -j1.15 -j1.14 baz.c - hg backout -r 101abcde - [resolve conflicts] [resolve conflicts] - cvs commit hg commit - hg push + cvs update -j1.6 -j1.5 foo.c + cvs update -j1.9 -j1.8 bar.c + cvs update -j1.15 -j1.14 baz.c + hg backout -r 101abcde + [resolve conflicts] [resolve conflicts] + cvs commit hg commit + hg push Note that apparently if you use hg backout to back out the most recent commit, it auto-commits. @@ -404,9 +413,11 @@ local modification until whatever issue sorted out. To revert to a specific version: - hg revert -r rev subtree + + hg revert -r rev subtree To revert to a specific date: - hg revert -d date subtree + + hg revert -d date subtree ### Other stuff