tests/test-merge-tools
author Nicolas Dumazet <nicdumz.commits@gmail.com>
Sun, 24 May 2009 18:43:05 +0900
changeset 8599 1f706b1b62f3
parent 8539 9a4fe59b1eca
child 8674 0941ee76489e
permissions -rwxr-xr-x
inotify: server: refactor updatestatus() * Instead of one entry point, use two entry points, updatefile() and deletefile(), both internally calling the helper function _updatestatus * Do not rely on TypeError to detect the type of oldstatus: use isinstance * The call updatestatus(wpath, None) in deleted() was a bit particular: because no osstat and no newstatus was given, the newstatus was determined using the data stored internally. To replace this exact behavior with the new code, one would use: root, fn = self.split(wpath) d = self.dir(self.tree, root) self.filedeleted(wpath, d.get(fn)) This, however, duplicates code with _updatestatus(), which led us to an interesting question: why are we basing ourselves on repowatcher data to update the status, where everywhere else, we are comparing against dirsate? There is no reason to do this, which is why the new code is: self.filedeleted(wpath, self.repo.dirstate[wpath]) Incidentally, after this, the test for issue1371 passes again.

#!/bin/sh

# test merge-tools configuration - mostly exercising filemerge.py

unset HGMERGE # make sure HGMERGE doesn't interfere with the test

hg init

echo "# revision 0"
echo "revision 0" > f
echo "space" >> f
hg commit -Am "revision 0" -d "1000000 0"

echo "# revision 1"
echo "revision 1" > f
echo "space" >> f
hg commit -Am "revision 1" -d "1000000 0"

hg update 0 > /dev/null
echo "# revision 2"
echo "revision 2" > f
echo "space" >> f
hg commit -Am "revision 2" -d "1000000 0"

hg update 0 > /dev/null
echo "# revision 3 - simple to merge"
echo "revision 3" >> f
hg commit -Am "revision 3" -d "1000000 0"


echo "[merge-tools]" > .hg/hgrc
echo

beforemerge() {
  cat .hg/hgrc
  echo "# hg update -C 1"
  hg update -C 1 > /dev/null
}

aftermerge() {
  echo "# cat f"
  cat f
  echo "# hg stat"
  hg stat
  rm -f f.orig
  echo
}

domerge() {
  beforemerge
  echo "# hg merge $*"
  hg merge $*
  aftermerge
}

echo
echo Tool selection
echo

echo "# default is internal merge:"
beforemerge
echo "# hg merge -r 2"
PATH=$BINDIR hg merge -r 2
aftermerge

echo "# simplest hgrc using false for merge:"
echo "false.whatever=" >> .hg/hgrc
domerge -r 2

echo "# true with higher .priority gets precedence:"
echo "true.priority=1" >> .hg/hgrc
domerge -r 2

echo "# unless lowered on command line:"
domerge -r 2 --config merge-tools.true.priority=-7

echo "# or false set higher on command line:"
domerge -r 2 --config merge-tools.false.priority=117

echo "# or true.executable not found in PATH:"
domerge -r 2 --config merge-tools.true.executable=nonexistingmergetool

echo "# or true.executable with bogus path:"
domerge -r 2 --config merge-tools.true.executable=/bin/nonexistingmergetool

echo "# but true.executable set to cat found in PATH works:"
echo "true.executable=cat" >> .hg/hgrc
domerge -r 2

echo "# and true.executable set to cat with path works:"
domerge -r 2 --config merge-tools.true.executable=cat

echo
echo Tool selection and merge-patterns
echo

echo "# merge-patterns specifies new tool false:"
domerge -r 2 --config merge-patterns.f=false

echo "# merge-patterns specifies executable not found in PATH and gets warning:"
domerge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=nonexistingmergetool

echo "# merge-patterns specifies executable with bogus path and gets warning:"
domerge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=/bin/nonexistingmergetool

echo
echo ui.merge overrules priority
echo

echo "# ui.merge specifies false:"
domerge -r 2 --config ui.merge=false

echo "# ui.merge specifies internal:fail:"
domerge -r 2 --config ui.merge=internal:fail

echo "# ui.merge specifies internal:local:"
domerge -r 2 --config ui.merge=internal:local

echo "# ui.merge specifies internal:other:"
domerge -r 2 --config ui.merge=internal:other

echo "# ui.merge specifies internal:other but is overruled by pattern for false:"
domerge -r 2 --config ui.merge=internal:other --config merge-patterns.f=false

echo
echo Premerge
echo

echo "# Default is silent simplemerge:"
domerge -r 3

echo "# .premerge=True is same:"
domerge -r 3 --config merge-tools.true.premerge=True

echo "# .premerge=False executes merge-tool:"
domerge -r 3 --config merge-tools.true.premerge=False


echo
echo Tool execution
echo

echo '# set tools.args explicit to include $base $local $other $output:' # default '$local $base $other'
beforemerge
hg merge -r 2 --config merge-tools.true.executable=head --config merge-tools.true.args='$base $local $other $output' \
  | sed 's,==> .* <==,==> ... <==,g'
aftermerge

echo '# Merge with "echo mergeresult > $local":'
beforemerge
hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $local'
aftermerge

echo '# - and $local is the file f:'
beforemerge
hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > f'
aftermerge

echo '# Merge with "echo mergeresult > $output" - the variable is a bit magic:'
beforemerge
hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $output'
aftermerge


echo
echo Merge post-processing
echo

echo "# cat is a bad merge-tool and doesn't change:"
domerge -y -r 2 --config merge-tools.true.checkchanged=1