9927
Comment: Add tip about emulating `hg incoming` for merges of heads
|
237
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
#pragma section-numbers 3 = Tips and Tricks = ''(see also [:FAQ], [:HOWTOs], [wiki:Self:CategoryTipsAndTricks CategoryTipsAndTricks])'' || [[TableOfContents]] || [[Include(/Index)]] || === Undo an "hg add" === {{{ hg revert # take out of source control hg rm -f # remove it }}} On Unix, to revert just the pending adds, you can use {{{ hg status -an0 | xargs -r0 hg revert }}} === Save a push URL so that you don't need to enter it each time === It is possible to store a default [:Push:push] URL that will be used when you type just "hg push". Edit [:.hgrc:hgrc] and add something like: {{{ [paths] default-push = ssh://hg@example.com/path }}} === Track changes to a repository with RSS === You can track changes to projects and individual files with RSS feeds from hgweb. Here are some examples: * http://selenic.com/hg/rss-log/ * http://selenic.com/hg/rss-log/tip/mercurial/hgweb/hgweb_mod.py === Create links to snapshots of files and tarballs === If you want to create web links to [:Tag:tagged] or [:Tip:tip] versions of a [:Repository:repository] or a file, you can do so like this: * http://selenic.com/hg/archive/tip.tar.gz * http://selenic.com/hg/archive/0.9.3.zip * http://selenic.com/hg/raw-file/tip/COPYING * http://selenic.com/hg/raw-file/0.9.3/COPYING === Configuring Mercurial === See in [:.hgrc]. === Abbreviate command options === It is possible to abbreviate command options: {{{ hg revert --no-b hg revert --no-backup }}} === Ignore files from Emacs/XEmacs === Add the following to [:.hgignore]: {{{ syntax: glob *~ syntax: regexp (.*/)?\#[^/]*\#$ }}} === Ignore files in local working copy only === Add the following to the repo's `.hg/hgrc`: {{{ [ui] ignore = /path/to/repo/.hg/hgignore }}} and create a new file `.hg/hgignore` beside it. This new file will be untracked, but work the same as the versioned [:.hgignore] file for this specific working copy. (The `/path/to/repo` bit is unfortunate but necessary to make it work when invoking `hg` from within a subdir of the repo.) === Make a clean copy of a source tree, like CVS export === {{{ hg clone source export rm -rf export/.hg }}} or using the archive command {{{ cd source hg archive ../export }}} The same thing, but for a [:Tag:tagged] release: {{{ hg clone --noupdate source export-tagged cd export-tagged hg update mytag rm -rf .hg }}} or using the archive command {{{ cd source hg archive -r mytag ../export-tagged }}} === One liner to remove unknown files with a pattern === To make these work, replace the {{{ls -l}}} with the command you wish to execute (ie. {{{rm}}}). You can also tweak the parameters passed to {{{hg status}}} to filter by something other than unknown files (see {{{hg help status}}}). {{{ hg status -nu0 | grep -z pattern | xargs -0r ls -l }}} The above command requires a current version of GNU grep. If you don't have one, you can use the following: {{{ hg status -nu | grep pattern | tr '\n' '\0' | xargs -0r ls -l }}} === Generating color diff output with extdiff and colordiff === You can use the [:ExtdiffExtension:extdiff extension] to get colorized diff output. If you've enabled the extension and have colordiff installed, the following [:.hgrc:hgrc] snippet will create a new {{{cdiff}}} command: {{{ [defaults] # suppress noisy extdiff header message cdiff = -q [extdiff] cmd.cdiff = colordiff opts.cdiff = -uprN }}} === Using config substitution and the [DEFAULT] section of hgrc === The `hgrc` manpage gives a passing description of the `[DEFAULT]` section header but gives no notion of how one might use this (or the possible caveats). Here's an example: * `%(NAME)s` is substituted in configuration values if `NAME` is defined in the current section * Names defined in the `[DEFAULT]` section appear in all other configuration sections (unless overridden in a particular section) * In most sections, names not specifically used are ignored however... * The `[extensions]` will attempt to load any names in it has extensions * Putting a name in `[DEFAULT]` usually breaks the configuration as the name is likely not a valid extension * Placing a name under `[DEFAULT]` requires that you keep the `[extensions]` section from trying to load it. Here's an example of the usage: {{{ [DEFAULT] HOME = /home/myuser [ui] ignore.mine = %(HOME)s/.hgignore.mine style = %(HOME)s/.hg-styles/hg-map-cmdline.color [paths] dotfiles = %(HOME)s/ [extensions] # Avoid the [DEFAULT] extension bug HOME = ! }}} === Using FileMerge.app/opendiff as the diff program (OS X) === The Developer Tools for OS X provide the excellent graphical diff program "File``Merge.app". The provided command-line wrapper "opendiff" for "File``Merge.app" will not work with ExtdiffExtension. Instead, use the script [http://ssel.vub.ac.be/ssel/internal:fmdiff fmdiff] which wraps "File``Merge.app" so that it responds like the usual diff program. Once fmdiff is in your path, just add the below to your .hgrc file {{{ [extensions] hgext.extdiff = [extdiff] cmd.opendiff = fmdiff }}} and use {{{ $ hg opendiff ... }}} === hg diff does not support -foo option like gnu diff does === I use the following bash function to put the diff options I like most {{{ hgdi () { for i in `hg status -marn "$@"` do diff -ubwd <(hg cat "$i") "$i" done } }}} You can also use the extdiff extension to call GNU diff from Mercurial. === Handling binary files === as stated in BinaryFiles, you need to have a tool which manages binary merge. Joachim Eibl's new kdiff3 version ships a version qt4 version (on windows called "kdiff3-QT4.exe") which recognizes binary files. Pressing "cancel" and "do not save" leaves you with the version of the file you have currently in the filesystem. See also on CvsConcepts. === Diagnose "abort: Error" messages === I get a cryptic "abort: Error" message while pushing to my server. This is not enough info to figure out the problem. I tried `hg -v --debug push` but I still don't get anything more informative. What can I do? * disable cgitb in hgweb on the server * run with `--debug --traceback` on the client * check the error logs on the server === Removing the working directory of a repository === If you forgot to specify {{{-U}}} on "hg [:Clone:clone]", doing {{{ hg update null }}} will remove everything from the [:WorkingDirectory:working directory] of the [:Repository:repository]. See also [:Update:update]. ~-([http://selenic.com/pipermail/mercurial/2008-March/018332.html reference])-~ === Setting the default context for diff to something larger === hg diff outputs 3 lines of context per default (see "hg help diff"). To change the default to for example 8 lines, add {{{ [defaults] diff = --unified 8 }}} to the defaults section of your [:.hgrc]. However, this only affects the diff command itself. ~-([http://www.selenic.com/mercurial/bts/issue1076 reference])-~ === Find repositories with GNU find === Users with access to GNU find may find these one-liners useful for managing all their repositories at once. They can of course be added to shell scripts to do more interesting things. Print a list of directories which have repositories (a directory called ".hg" exists): {{{ find ~/ -name ".hg" -type d -execdir pwd \; }}} Print a list of tracked files too: {{{ find ~/ -name ".hg" -type d -printf "\t" -execdir pwd \; -execdir hg status -c -m -a -d \; -printf "\n" }}} === Change temporary directory used on remote when pushing === See description of a [:Hook#tmpdirhook:hook for changing tmp directory] on remote when pushing. === Keep "My" or "Their" files when doing a merge === [[Anchor(mergemineortheir)]] Occasionally you want to merge two heads, but you want to force the files that are kept as the result of a merge. Since mercurial 0.9.5, you can override the internal merge.ui settings by doing: {{{ HGMERGE=internal:local hg merge #keep my files HGMERGE=internal:other hg merge #keep their files }}} Using {{{internal:fail}}} will fail the merge (I can not imagine why one would want that behaviour !) According to Matt it is used prevent Mercurial from starting a merge tool after a merge with conflicts. See: http://marc.info/?l=mercurial&m=121476472203779&w=2 === Split a subdirectory into a separate project === Use ConvertExtension with --filemap option. === Use an extension only for one call (without editing hgrc) === You can enable an [:UsingExtensions:extension] only for this call of {{{hg}}} by setting {{{--config}}}. This enables the [:MqExtension:mq extension] and calls its strip command to remove revision 111: {{{ hg --config extensions.hgext.mq= strip 111 }}} === Convert a repo with mixed line endings to LF only === Enable the Win32TextExtension with encoding only. Snippet of hgrc: {{{ [extensions] hgext.win32text= #encode only => only LF in repo [encode] ** = cleverencode: [decode] #** = cleverdecode: }}} Update the working directory. To force the update to all files do {{{hg update null}}} first and then {{{hg update [rev]}}}. The line endings in the working directory are still the same as in the repo. Commit the changes. All the line endings are converted to LF before committing. To see the changes in the working dir do {{{hg update null}}} and {{{hg update [tip]}}} again. (To convert all the line endings to CRLF, enable decode only). === Log all csets that would be merged (emulate `hg incoming` for merges) === To see which changesets would be merged into head `tgt` from `src` by {{{ hg update tgt hg merge src }}} you can do {{{ hg log --follow --rev src:null --prune tgt }}} or, shorter, {{{ hg log -fr src:null -P tgt }}} To omit merge csets, add `-M`. |
Author Devis Reimers prefers [[http://www.HairAgainReviews.org|Hair Again]], yoga, hula hooping. Last of all he's catches his encouragement through [[http://Www.Ehow.com/search.html?s=loosening|loosening]] up together with his friends. |
Author Devis Reimers prefers Hair Again, yoga, hula hooping. Last of all he's catches his encouragement through loosening up together with his friends.