Differences between revisions 3 and 11 (spanning 8 versions)
Revision 3 as of 2005-11-11 02:43:06
Size: 1119
Comment: cvs export tag
Revision 11 as of 2006-01-19 19:04:38
Size: 2996
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Available tips:
[[TableOfContents]]
Line 11: Line 14:
hg clone source export-tagged hg clone --noupdate source export-tagged
Line 13: Line 16:
hg update -C mytag hg update mytag
Line 19: Line 22:
Make a private copy of the 'hgeditor' script provided with mercuiral and replace the call to the editor with following command: Make a private copy of the 'hgeditor' script provided with mercurial and replace the call to the editor with following command:
Line 28: Line 31:

=== 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".

=== A script to use the OS X FileMerge application to perform merges ===

{{{
#!/bin/sh

LOCAL=$1
BASE=$2
OTHER=$3

# Attempt to do a non-interactive merge
cp $LOCAL $LOCAL.orig
if merge $LOCAL $BASE $OTHER 2> /dev/null; then
  # success!
  rm $LOCAL.orig
  exit 0
fi

cp $LOCAL.orig $LOCAL
# opendiff "succeeds" as long as FileMerge launches. No way to tell if the
# merge is any good but to ask...
opendiff "$OTHER" "$LOCAL" -ancestor "$BASE" -merge "$LOCAL"
echo "Merge of $LOCAL successful?"
select answer in yes no
do
  if test "$answer" == "yes"
  then
    rm $LOCAL.orig
    exit 0
  elif test "$answer" == "no"
  then
    exit 1
  fi
done

echo "filemerge: failed"
exit 1
}}}

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

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:

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".

A script to use the OS X FileMerge application to perform merges

LOCAL=$1
BASE=$2
OTHER=$3

# Attempt to do a non-interactive merge
cp $LOCAL $LOCAL.orig
if merge $LOCAL $BASE $OTHER 2> /dev/null; then
  # success!
  rm $LOCAL.orig
  exit 0
fi

cp $LOCAL.orig $LOCAL
# opendiff "succeeds" as long as FileMerge launches. No way to tell if the
# merge is any good but to ask...
opendiff "$OTHER" "$LOCAL" -ancestor "$BASE" -merge "$LOCAL"
echo "Merge of $LOCAL successful?"
select answer in yes no
do
  if test "$answer" == "yes"
  then
    rm $LOCAL.orig
    exit 0
  elif test "$answer" == "no"
  then
    exit 1
  fi
done

echo "filemerge: failed"
exit 1

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

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