Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
replacev2.sh: replace V2 classes and methods
  • Loading branch information
jef-n committed Aug 10, 2016
1 parent d5516fa commit 8a45744
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/core/geometry/qgsgeometrycollectionv2.sip
Expand Up @@ -26,7 +26,7 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
*/
QgsAbstractGeometryV2* geometryN( int n );

//methods inherited from QgsAbstractGeometry
//methods inherited from QgsAbstractGeometryV2
virtual int dimension() const;
virtual QString geometryType() const;
virtual void clear();
Expand Down
44 changes: 44 additions & 0 deletions scripts/replacev2.sh
@@ -0,0 +1,44 @@
#!/bin/bash

set -e

codepaths=$(echo python/{analysis,console,core,custom_widgets,gui,networkanalysis,plugins,pyplugin_installer,server,sip_helpers,testing} src/ tests/)
repl=

s=$(mktemp -t skipped.XXXX.log)
r=$(mktemp -t repl.XXXX.pl)
d=$(mktemp -t apibreak.XXXX.txt)

# Rename classes
for i in $(git --no-pager grep "Qgs[a-zA-Z0-9_]*V2" $codepaths | perl -pe 's#^.*(Qgs[a-zA-Z0-9_]*)V2([a-zA-Z0-9_]*).*$#$1V2$2#' | sort -u)
do
src=$i
dst=${src/V2/}
if git --no-pager grep -l "\<$dst\>" $codepaths; then
echo "$src vs $dst" >>$s
else
echo " REPLACE $src => $dst"
echo "s/\b$src\b/$dst/g;" >>$r
echo "s/\bsipType_$src\b/sipType_$dst/;" >>$r
echo "<tr><td>$src<td>$dst" >>$d
fi
done

for i in $(git --no-pager grep "::[a-zA-Z0-9_]*V2" $codepaths | perl -pe 's#^.*::([a-zA-Z0-9_]*)V2([a-zA-Z0-9_]*).*$#$1V2$2#' | egrep -v "^Qgs|SslV2" | sort -u)
do
src=$i
dst=${src/V2/}

if git --no-pager grep -l "\<$dst\>" $codepaths; then
echo "$src vs $dst" >>$s
else
echo " REPLACE $src => $dst"
echo "s/\b$src\b/$dst/g;" >>$r
echo "<tr><td>$src<td>$dst" >>$d
fi
done

echo "API breaks logged to: $d"
echo "Skipped V2 symbols: $s"
echo "Replacing from $r"
find $codepaths -type f | xargs perl -i -p $r
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometrycollectionv2.h
Expand Up @@ -50,7 +50,7 @@ class CORE_EXPORT QgsGeometryCollectionV2: public QgsAbstractGeometryV2
*/
QgsAbstractGeometryV2* geometryN( int n );

//methods inherited from QgsAbstractGeometry
//methods inherited from QgsAbstractGeometryV2
virtual int dimension() const override;
virtual QString geometryType() const override { return "GeometryCollection"; }
virtual void clear() override;
Expand Down

0 comments on commit 8a45744

Please sign in to comment.