Differences between revisions 16 and 72 (spanning 56 versions)
Revision 16 as of 2006-04-29 11:07:58
Size: 4675
Comment: add hgdi shell function
Revision 72 as of 2007-04-06 12:47:45
Size: 13270
Editor: 59
Comment: None
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Available tips:
[[TableOfContents]]

=== Make a clean copy of a source tree, like CVS export ===

{{{
hg clone source export
rm -rf export/.hg
}}}

=== The same thing, but for a tagged release ===

{{{
hg clone --noupdate source export-tagged
cd export-tagged
hg update mytag
rm -rf .hg
}}}

=== See diffs when editing commit message with VIM ===

Make a private copy of the 'hgeditor' script provided with mercurial and replace the call to the editor with following command:

{{{
vim "+e $HGTMP/diff" '+set buftype=help filetype=diff' "+vsplit $HGTMP/msg" || exit $?
}}}

This will start up VIM in vertical split mode with commit message in the left pane and diff in the right pane. The {{{buftype=help}}} setting for diff window tells vim to exit when all other windows are closed, so when you write and quit the log with {{{:x}}} ({{{:wq}}} - they are equivalent), vim exits. If you have syntax highlight set up, the diff will be properly highlighted.

This setting is suitable for wide terminals. If you have a narrow terminal, you may want to replace the {{{+vsplit}}} above with {{{+split}}} or add {{{nowrap}}} to the {{{+set}}}.

=== See diffstat of pulled changes ===

Place the following script (named "pull-diffstat" here) somewhere in your $PATH:

{{{
#!/bin/sh
test -n "$NODE" || exit 0
PARENT=`hg parents $NODE | head -1 | awk -F':' '{print $3}'`
TIP=`hg tip | head -1 | awk -F':' '{print $3}'`
echo "diffstat for $PARENT to $TIP"
hg diff -r $PARENT -r tip | diffstat
}}}

Add a changegroup entry to the [hooks] section of hgrc:

{{{
[hooks]
changegroup = pull-diffstat
}}}

Now you will see a diffstat of the new changes to your repo every time you do "hg pull".

=== 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
}}}

=== Keyword expansion according to file revision ===

This is an example on how you can achieve filewise keyword expansion (similar
to CVS) with an [encode] filter and the pretxncommit-hook. Comes in handy
when you want to keep track of different file revisions in the same
repository.

For demonstration we use just one keyword: "Hg".

 * {{{$Hg$}}}

It will be expanded by the script "hgpretxncommit.sh" (see below) to:

 * {{{$Hg: <basename of file>,v <short hash> <date> $}}}

You have the choice between two date output formats:

 * Generic Mercurial output
 * YYYY/mm/dd

You need an [encode] filter that "reverts" the expansion in your hgrc (unless
you don't care about the expanded keyword showing up in every "hg diff").

Simple example hgrc for a repository containing python files:

{{{
[encode]
*.py = sed 's/[$]Hg[^$]*[$]/\$Hg\$/'
[hooks]
pretxncommit = hgpretxncommit.sh
}}}

In "hgpretxncommit.sh" you have to tweak the 'excl' and 'slash' variables
according to your needs. The script doesn't look at files matching $excl.
Whereas files not matching $excl but matching $slash will have the commit
date expanded as YYYY/mm/dd (like the python files in this example).

{{{
#!/bin/sh
set -e
test $? -eq 0 || exit 1
excl='^\.hg\|\.\(p\(df\|ng\)\|jpg\)$'
slash='\.\(\(te\|dt\)x\|s\(ty\|h\)\|c\(fg\|ls\)\|bib\|py\|awk\)$'
cset="${HG_NODE:0:12}"
tipv=`hg tip --verbose`
manifest=`hg manifest | cut -d ' ' -f 3`
dateformat() {
 local m M
 if echo "$f" | grep -q "$slash"; then
  hgdate=`echo "$tipv" |
  awk '/^date: +/ { printf "%d/%s/%0.2d %s %s", $6, $3, $4, $5, $7 }'`
  m=0
  for M in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
  do
   let $((++m))
   hgdate=${hgdate/$M/`printf %0.2d $m`}
  done
 else
  hgdate=`echo "$tipv" | awk -F ': +' '/^date: +/ { print $2 }'`
 fi
}
for f in `echo "$tipv" | awk -F ': +' '/^files: +/ { print $2 }'`
do
 if echo "$f" | grep -v -q "$excl" && echo "$manifest" | grep -x -q "$f"
 then
  bn="${f##*/}"
  dateformat
  hg cat "$f" |
  sed "s!\([$]Hg\)[^$]*[$]!\1: ${bn},v $cset $hgdate \$!" > "$f"
 fi
done
exit $?
}}}

=== 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
}
}}}
Hello, very nice site! Please also visit my homepages:
 [URL=http://www.greatprise.org/insurance/index.html]insurance[/URL] [URL=http://www.greatprise.org/insurance-life-settlement/index.html]insurance life settlement[/URL] [URL=http://www.greatprise.org/health-insurance/index.html]health insurance[/URL] [URL=http://www.greatprise.org/care-insurance-long-term/index.html]care insurance long term[/URL] [URL=http://www.greatprise.org/boat-insurance/index.html]boat insurance[/URL] [URL=http://www.greatprise.org/car-cheapest-insurance/index.html]car cheapest insurance[/URL] [URL=http://www.greatprise.org/auto-insurance-progressive/index.html]auto insurance progressive[/URL] [URL=http://www.greatprise.org/florida-health-insurance/index.html]florida health insurance[/URL] [URL=http://www.greatprise.org/insurance-mercury/index.html]insurance mercury[/URL] [URL=http://www.greatprise.org/car-cheap-insurance/index.html]car cheap insurance[/URL] [URL=http://www.greatprise.org/home-insurance-quote/index.html]home insurance quote[/URL] [URL=http://www.greatprise.org/insurance-rv/index.html]insurance rv[/URL] [URL=http://www.greatprise.org/farm-insurance-state/index.html]farm insurance state[/URL] [URL=http://www.greatprise.org/insurance-online-quote/index.html]insurance online quote[/URL] [URL=http://www.greatprise.org/insurance-medical-travel/index.html]insurance medical travel[/URL] [URL=http://www.greatprise.org/automotive-de-insurance-wilmington/index.html]automotive de insurance wilmington[/URL] [URL=http://www.greatprise.org/aetna-health-insurance/index.html]aetna health insurance[/URL] [URL=http://www.greatprise.org/california-car-insurance/index.html]california car insurance[/URL] [URL=http://www.greatprise.org/auto-insurance-rate/index.html]auto insurance rate[/URL] [URL=http://www.greatprise.org/aaa-insurance/index.html]aaa insurance[/URL] [URL=http://www.greatprise.org/insurance-life-quote-term/index.html]insurance life quote term[/URL] [URL=http://www.greatprise.org/adjuster-insurance/index.html]adjuster insurance[/URL] [URL=http://www.greatprise.org/health-insurance-texas/index.html]health insurance texas[/URL] [URL=http://www.greatprise.org/employment-insurance/index.html]employment insurance[/URL] [URL=http://www.greatprise.org/claim-insurance/index.html]claim insurance[/URL] [URL=http://www.greatprise.org/disability-insurance/index.html]disability insurance[/URL] [URL=http://www.greatprise.org/agent-broker-carrier-insurance/index.html]agent broker carrier insurance[/URL] [URL=http://www.greatprise.org/insurance-life/index.html]insurance life[/URL] [URL=http://www.greatprise.org/insurance-quote/index.html]insurance quote[/URL] [URL=http://www.greatprise.org/car-insurance-new-york/index.html]car insurance new york[/URL] [URL=http://www.greatprise.org/attorney-insurance/index.html]attorney insurance[/URL] [URL=http://www.greatprise.org/allstate-insurance/index.html]allstate insurance[/URL] [URL=http://www.greatprise.org/insurance-nationwide/index.html]insurance nationwide[/URL] [URL=http://www.greatprise.org/cost-health-insurance-low/index.html]cost health insurance low[/URL] [URL=http://www.greatprise.org/health-insurance-international-travel/index.html]health insurance international travel[/URL] [URL=http://www.greatprise.org/company-insurance-life/index.html]company insurance life[/URL] [URL=http://www.greatprise.org/car-cost-insurance-low/index.html]car cost insurance low[/URL] [URL=http://www.greatprise.org/dental-insurance/index.html]dental insurance[/URL] [URL=http://www.greatprise.org/car-insurance-online/index.html]car insurance online[/URL] [URL=http://www.greatprise.org/auto-insurance-online/index.html]auto insurance online[/URL] [URL=http://www.greatprise.org/insurance-renters/index.html]insurance renters[/URL] [URL=http://www.greatprise.org/insurance-mortgage/index.html]insurance mortgage[/URL] [URL=http://www.greatprise.org/california-health-insurance/index.html]california health insurance[/URL] [URL=http://www.greatprise.org/business-insurance/index.html]business insurance[/URL] [URL=http://www.greatprise.org/car-insurance-online-quote/index.html]car insurance online quote[/URL] [URL=http://www.greatprise.org/auto-california-insurance/index.html]auto california insurance[/URL] [URL=http://www.greatprise.org/home-insurance-owner/index.html]home insurance owner[/URL] [URL=http://www.greatprise.org/group-health-insurance/index.html]group health insurance[/URL] [URL=http://www.greatprise.org/insurance-traveler/index.html]insurance traveler[/URL] [URL=http://www.greatprise.org/affordable-health-insurance/index.html]affordable health insurance[/URL] [URL=http://www.greatprise.org/insurance-life-term/index.html]insurance life term[/URL] [URL=http://www.greatprise.org/insurance-international-medical-travel/index.html]insurance international medical travel[/URL] [URL=http://www.greatprise.org/company-insurance/index.html]company insurance[/URL] [URL=http://www.greatprise.org/accident-insurance-travel/index.html]accident insurance travel[/URL] [URL=http://www.greatprise.org/insurance-travel/index.html]insurance travel[/URL] [URL=http://www.greatprise.org/insurance-online-travel/index.html]insurance online travel[/URL] [URL=http://www.greatprise.org/insurance-term/index.html]insurance term[/URL] [URL=http://www.greatprise.org/health-insurance-quote/index.html]health insurance quote[/URL] [URL=http://www.greatprise.org/hartford-insurance/index.html]hartford insurance[/URL] [URL=http://www.greatprise.org/insurance-lead/index.html]insurance lead[/URL] [URL=http://www.greatprise.org/health-insurance-plan/index.html]health insurance plan[/URL] [URL=http://www.greatprise.org/car-free-insurance-quote/index.html]car free insurance quote[/URL] [URL=http://www.greatprise.org/health-insurance-short-term/index.html]health insurance short term[/URL] [URL=http://www.greatprise.org/insurance-usaa/index.html]insurance usaa[/URL] [URL=http://www.greatprise.org/insurance-pet/index.html]insurance pet[/URL] [URL=http://www.greatprise.org/car-insurance-quote/index.html]car insurance quote[/URL] [URL=http://www.greatprise.org/insurance-life-whole/index.html]insurance life whole[/URL] [URL=http://www.greatprise.org/car-insurance-rate/index.html]car insurance rate[/URL] [URL=http://www.greatprise.org/home-insurance-owner-quote/index.html]home insurance owner quote[/URL] [URL=http://www.greatprise.org/geico-insurance/index.html]geico insurance[/URL] [URL=http://www.greatprise.org/automobile-insurance-quote/index.html]automobile insurance quote[/URL]
 <a href="http://www.greatprise.org/insurance-international-medical-travel/index.html">insurance international medical travel</a> <a href="http://www.greatprise.org/company-insurance/index.html">company insurance</a> <a href="http://www.greatprise.org/insurance-nationwide/index.html">insurance nationwide</a> <a href="http://www.greatprise.org/car-cheapest-insurance/index.html">car cheapest insurance</a> <a href="http://www.greatprise.org/family-health-insurance/index.html">family health insurance</a> <a href="http://www.greatprise.org/home-insurance/index.html">home insurance</a> <a href="http://www.greatprise.org/home-insurance-owner/index.html">home insurance owner</a> <a href="http://www.greatprise.org/agent-insurance/index.html">agent insurance</a> <a href="http://www.greatprise.org/insurance-medical/index.html">insurance medical</a> <a href="http://www.greatprise.org/disability-insurance/index.html">disability insurance</a> <a href="http://www.greatprise.org/broker-insurance/index.html">broker insurance</a> <a href="http://www.greatprise.org/claim-insurance/index.html">claim insurance</a> <a href="http://www.greatprise.org/car-cost-insurance-low/index.html">car cost insurance low</a> <a href="http://www.greatprise.org/health-individual-insurance/index.html">health individual insurance</a> <a href="http://www.greatprise.org/insurance-term/index.html">insurance term</a> <a href="http://www.greatprise.org/allstate-insurance/index.html">allstate insurance</a> <a href="http://www.greatprise.org/business-health-insurance-small/index.html">business health insurance small</a> <a href="http://www.greatprise.org/auto-insurance-progressive/index.html">auto insurance progressive</a> <a href="http://www.greatprise.org/california-car-insurance/index.html">california car insurance</a> <a href="http://www.greatprise.org/farmer-insurance/index.html">farmer insurance</a> <a href="http://www.greatprise.org/home-insurance-owner-quote/index.html">home insurance owner quote</a> <a href="http://www.greatprise.org/hartford-insurance/index.html">hartford insurance</a> <a href="http://www.greatprise.org/ca-health-insurance/index.html">ca health insurance</a> <a href="http://www.greatprise.org/affordable-health-insurance/index.html">affordable health insurance</a> <a href="http://www.greatprise.org/insurance/index.html">insurance</a> <a href="http://www.greatprise.org/aetna-health-insurance/index.html">aetna health insurance</a> <a href="http://www.greatprise.org/accident-insurance-travel/index.html">accident insurance travel</a> <a href="http://www.greatprise.org/insurance-motorcycle/index.html">insurance motorcycle</a> <a href="http://www.greatprise.org/geico-insurance/index.html">geico insurance</a> <a href="http://www.greatprise.org/car-insurance/index.html">car insurance</a> <a href="http://www.greatprise.org/free-insurance-quote/index.html">free insurance quote</a> <a href="http://www.greatprise.org/business-insurance/index.html">business insurance</a> <a href="http://www.greatprise.org/home-insurance-quote/index.html">home insurance quote</a> <a href="http://www.greatprise.org/insurance-mortgage/index.html">insurance mortgage</a> <a href="http://www.greatprise.org/car-insurance-quote/index.html">car insurance quote</a> <a href="http://www.greatprise.org/automobile-insurance-quote/index.html">automobile insurance quote</a> <a href="http://www.greatprise.org/automotive-de-insurance-wilmington/index.html">automotive de insurance wilmington</a> <a href="http://www.greatprise.org/insurance-pet/index.html">insurance pet</a> <a href="http://www.greatprise.org/car-free-insurance-quote/index.html">car free insurance quote</a> <a href="http://www.greatprise.org/insurance-online-quote/index.html">insurance online quote</a> <a href="http://www.greatprise.org/insurance-medical-travel/index.html">insurance medical travel</a> <a href="http://www.greatprise.org/health-insurance-international-travel/index.html">health insurance international travel</a> <a href="http://www.greatprise.org/insurance-quote/index.html">insurance quote</a> <a href="http://www.greatprise.org/agent-broker-carrier-insurance/index.html">agent broker carrier insurance</a> <a href="http://www.greatprise.org/health-insurance-plan/index.html">health insurance plan</a> <a href="http://www.greatprise.org/insurance-usaa/index.html">insurance usaa</a> <a href="http://www.greatprise.org/auto-insurance-online/index.html">auto insurance online</a> <a href="http://www.greatprise.org/insurance-life-settlement/index.html">insurance life settlement</a> <a href="http://www.greatprise.org/insurance-life-policy/index.html">insurance life policy</a> <a href="http://www.greatprise.org/auto-california-insurance/index.html">auto california insurance</a> <a href="http://www.greatprise.org/insurance-renters/index.html">insurance renters</a> <a href="http://www.greatprise.org/insurance-travel/index.html">insurance travel</a> <a href="http://www.greatprise.org/auto-geico-insurance/index.html">auto geico insurance</a> <a href="http://www.greatprise.org/insurance-mercury/index.html">insurance mercury</a> <a href="http://www.greatprise.org/farm-insurance-state/index.html">farm insurance state</a>
 http://www.greatprise.org/geico-insurance/index.html http://www.greatprise.org/insurance-international-medical-travel/index.html http://www.greatprise.org/insurance-unemployment/index.html http://www.greatprise.org/attorney-insurance/index.html http://www.greatprise.org/insurance-life/index.html http://www.greatprise.org/employment-insurance/index.html http://www.greatprise.org/affordable-health-insurance/index.html http://www.greatprise.org/insurance-life-quote/index.html http://www.greatprise.org/florida-health-insurance/index.html http://www.greatprise.org/insurance-usaa/index.html http://www.greatprise.org/car-insurance-rate/index.html http://www.greatprise.org/automobile-insurance-quote/index.html http://www.greatprise.org/insurance-nationwide/index.html http://www.greatprise.org/health-insurance-quote/index.html http://www.greatprise.org/auto-geico-insurance/index.html http://www.greatprise.org/american-family-insurance/index.html http://www.greatprise.org/boston-insurance/index.html http://www.greatprise.org/dental-insurance/index.html http://www.greatprise.org/home-insurance-owner-quote/index.html http://www.greatprise.org/health-insurance-international-travel/index.html http://www.greatprise.org/insurance-marketing/index.html http://www.greatprise.org/car-insurance-online-quote/index.html
Thanks!
----
CategoryExtension

Hello, very nice site! Please also visit my homepages:

Thanks!


CategoryExtension

TipsAndTricks (last edited 2016-12-05 11:14:36 by ArneBab)