##// END OF EJS Templates
filemerge: add support for partial conflict resolution by external tool...
filemerge: add support for partial conflict resolution by external tool A common class of merge conflicts is in imports/#includes/etc. It's relatively easy to write a tool that can resolve these conflicts, perhaps by naively just unioning the statements and leaving any cleanup to other tools to do later [1]. Such specialized tools cannot generally resolve all conflicts in a file, of course. Let's therefore call them "partial merge tools". Note that the internal simplemerge algorithm is such a partial merge tool - one that only resolves trivial "conflicts" where one side is unchanged or both sides change in the same way. One can also imagine having smarter language-aware partial tools that merge the AST. It may be useful for such tools to interactively let the user resolve any conflicts it can't resolve itself. However, having the option of implementing it as a partial merge tool means that the developer doesn't *need* to create a UI for it. Instead, the user can resolve any remaining conflicts with their regular merge tool (e.g. `:merge3` or `meld). We don't currently have a way to let the user define such partial merge tools. That's what this patch addresses. It lets the user configure partial merge tools to run. Each tool can be configured to run only on files matching certain patterns (e.g. "*.py"). The tool takes three inputs (local, base, other) and resolves conflicts by updating these in place. For example, let's say the inputs are these: base: ``` import sys def main(): print('Hello') ``` local: ``` import os import sys def main(): print('Hi') ``` other: ``` import re import sys def main(): print('Howdy') ``` A partial merge tool could now resolve the conflicting imports by replacing the import statements in *all* files by the following snippet, while leaving the remainder of the files unchanged. ``` import os import re import sys ``` As a result, simplemerge and any regular merge tool that runs after the partial merge tool(s) will consider the imports to be non-conflicting and will only present the conflict in `main()` to the user. Differential Revision: https://phab.mercurial-scm.org/D12356

File last commit:

r46597:97205cf0 default
r49838:f3aafd78 default
Show More
buildrpm
172 lines | 4.4 KiB | text/plain | TextLexer
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 #!/bin/bash -e
#
Mads Kiilerich
packaging: drop outdated buildrpm "tested on" comment...
r43661 # Build a Mercurial RPM from the current repo, mainly for Fedora/CentOS/RHEL
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028
. $(dirname $0)/packagelib.sh
BUILD=1
RPMBUILDDIR="$PWD/rpmbuild"
Mads Kiilerich
packaging: use "python3" for fedora29 ... and as buildrpm default...
r43675 PYTHONEXE=python3
Mathias De Mare
packaging: switch centos 7 packaging to python 3...
r46440 DOCUTILSPACKAGE=python3-docutils
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028
while [ "$1" ]; do
case "$1" in
--prepare )
shift
BUILD=
;;
Mads Kiilerich
packaging: use "--python python" for centos7 to avoid explicit "python2"...
r43674 --python)
Mads Kiilerich
packaging: introduce Python3 support as buildrpm --python3...
r43650 shift
Mads Kiilerich
packaging: use "--python python" for centos7 to avoid explicit "python2"...
r43674 PYTHONEXE=$1
shift
Mads Kiilerich
packaging: introduce Python3 support as buildrpm --python3...
r43650 ;;
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 --withpython | --with-python)
shift
Antonio Muci
buildrpm: bump bundled Python version to 2.7.16 when building for centos{5,6}...
r42378 PYTHONVER=2.7.16
PYTHONMD5=f1a2ace631068444831d01485466ece0
Mads Kiilerich
packaging: fix docker-centos5 - use pythonexe and set to "python" as before...
r43673 PYTHONEXE=python
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 ;;
Mathias De Mare
packaging: switch centos 7 packaging to python 3...
r46440 --docutilspackage)
shift
DOCUTILSPACKAGE="$1"
shift
;;
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 --rpmbuilddir )
shift
RPMBUILDDIR="$1"
shift
;;
* )
echo "Invalid parameter $1!" 1>&2
exit 1
;;
esac
done
cd "`dirname $0`/../.."
specfile=$PWD/contrib/packaging/mercurial.spec
if [ ! -f $specfile ]; then
echo "Cannot find $specfile!" 1>&2
exit 1
fi
if [ ! -d .hg ]; then
echo 'You are not inside a Mercurial repository!' 1>&2
exit 1
fi
Mathias De Mare
packaging: don't use plain 'python' if another python has been specified...
r46597 gethgversion $PYTHONEXE
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028
if [ -z "$type" ] ; then
Mads Kiilerich
packaging: fix buildrpm whitespace
r43662 release=1
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 else
release=0.9_$type
fi
if [ -n "$distance" ] ; then
Augie Fackler
buildrpm: fix embarassing bug in shell variable expansions...
r39495 release=$release+${distance}_${node}
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 fi
if [ "$PYTHONVER" ]; then
release=$release+$PYTHONVER
RPMPYTHONVER=$PYTHONVER
else
RPMPYTHONVER=%{nil}
fi
mkdir -p $RPMBUILDDIR/{SOURCES,BUILD,SRPMS,RPMS}
Mathias De Mare
packaging: don't use plain 'python' if another python has been specified...
r46597 $PYTHONEXE $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 if [ "$PYTHONVER" ]; then
(
mkdir -p build
cd build
PYTHON_SRCFILE=Python-$PYTHONVER.tgz
[ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
if [ "$PYTHONMD5" ]; then
echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c
fi
ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE
DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile`
DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz
[ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE
DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile`
if [ "$DOCUTILSMD5" ]; then
echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c
fi
ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE
)
fi
mkdir -p $RPMBUILDDIR/SPECS
rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
sed -e "s,^Version:.*,Version: $version," \
-e "s,^Release:.*,Release: $release," \
Mads Kiilerich
packaging: introduce Python3 support as buildrpm --python3...
r43650 -e "s/^%global pythonexe .*/%global pythonexe $PYTHONEXE/" \
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 $specfile > $rpmspec
echo >> $rpmspec
echo "%changelog" >> $rpmspec
if echo $version | grep '+' > /dev/null 2>&1; then
latesttag="`echo $version | sed -e 's/+.*//'`"
Mathias De Mare
packaging: don't use plain 'python' if another python has been specified...
r46597 $PYTHONEXE $HG log -r .:"$latesttag" -fM \
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c '
import sys, time
def datestr(date, format):
return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
changelog = []
for l in sys.stdin.readlines():
tok = l.split("\t")
hgdate = tuple(int(v) for v in tok[0].split())
changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2]))
prevtitle = ""
for l in sorted(changelog, reverse=True):
title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1])
if prevtitle != title:
prevtitle = title
print
Mads Kiilerich
packaging: make python snippets in rpm building python3 compatible...
r43648 print(title)
print("- %s" % l[3].strip())
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 ' >> $rpmspec
else
Mathias De Mare
packaging: don't use plain 'python' if another python has been specified...
r46597 $PYTHONEXE $HG log \
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \
Mathias De Mare
packaging: don't use plain 'python' if another python has been specified...
r46597 .hgtags | $PYTHONEXE -c '
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 import sys, time
def datestr(date, format):
return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
for l in sys.stdin.readlines():
tok = l.split("\t")
hgdate = tuple(int(v) for v in tok[0].split())
Mads Kiilerich
packaging: make python snippets in rpm building python3 compatible...
r43648 print("* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2]))
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028 ' >> $rpmspec
fi
sed -i \
-e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
$rpmspec
Mathias De Mare
packaging: switch centos 7 packaging to python 3...
r46440 sed -i \
-e "s/^%global pythondocutils.*$/%global pythondocutils $DOCUTILSPACKAGE/" \
$rpmspec
Gregory Szorc
packaging: move buildrpm to contrib/packaging/...
r38028
if [ "$BUILD" ]; then
rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
if [ $? = 0 ]; then
echo
echo "Built packages for $version-$release:"
find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec
fi
else
echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:"
echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
fi