5378
Comment:
|
6129
+Removing the working directory of a repository
|
Deletions are marked like this. | Additions are marked like this. |
Line 165: | Line 165: |
=== 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])-~ |
Tips and Tricks
(see also [:FAQ], [:HOWTOs], [wiki:CategoryTipsAndTricks CategoryTipsAndTricks])
1. Undo an "hg add"
hg revert # take out of source control hg rm -f # remove it
2. 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 .hg/hgrc and add something like:
[paths] default-push = ssh://hg@example.com/path
3. 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:
4. 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:
5. Configuring Mercurial
See in [wiki:mercurial.ini].
6. Abbreviate command options
It is possible to abbreviate command options:
hg revert --no-b hg revert --no-backup
7. Ignore files from Emacs/XEmacs
Add the following to [:.hgignore]:
syntax: glob *~ syntax: regexp (.*/)?\#[^/]*\#$
8. 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
9. 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
10. 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
11. 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 = !
12. Using FileMerge.app/opendiff as the diff program (OS X)
The Developer Tools for OS X provide the excellent graphical diff program "FileMerge.app". The provided command-line wrapper "opendiff" for "FileMerge.app" will not work with ExtdiffExtension. Instead, use the script [http://ssel.vub.ac.be/ssel/internal:fmdiff fmdiff] which wraps "FileMerge.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 ...
13. 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.
14. 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.
15. 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
16. 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])