things

Fri, 21 Dec 2018 21:43:06 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 21 Dec 2018 21:43:06 +0200
changeset 1431
2e0e2c696605
parent 1430
6ce6d3da584f
child 1432
4cc687851fbb

things

CMakeLists.txt file | annotate | diff | comparison | revisions
src/basics.h file | annotate | diff | comparison | revisions
src/editmodes/abstractEditMode.cpp file | annotate | diff | comparison | revisions
tools/updaterevision.py file | annotate | diff | comparison | revisions
--- a/CMakeLists.txt	Sat Sep 15 15:57:56 2018 +0300
+++ b/CMakeLists.txt	Fri Dec 21 21:43:06 2018 +0200
@@ -26,7 +26,7 @@
 find_package (OpenGL REQUIRED)
 
 add_custom_target (revision_check ALL
-	COMMAND python "${CMAKE_SOURCE_DIR}/tools/updaterevision.py" hginfo.h
+	COMMAND python3 "${CMAKE_SOURCE_DIR}/tools/updaterevision.py" --cwd "$(CMAKE_SOURCE_DIR)" hginfo.h
 	WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
 
 include_directories (${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
--- a/src/basics.h	Sat Sep 15 15:57:56 2018 +0300
+++ b/src/basics.h	Fri Dec 21 21:43:06 2018 +0200
@@ -91,14 +91,6 @@
 constexpr double pi = 3.14159265358979323846;
 constexpr double inf = std::numeric_limits<double>::infinity();
 
-/*
- * Returns the norm of a vector.
- */
-inline qreal abs(const QVector3D &vector)
-{
-	return vector.length();
-}
-
 template<typename T>
 unsigned int qHash(const std::unique_ptr<T>& pointer)
 {
--- a/src/editmodes/abstractEditMode.cpp	Sat Sep 15 15:57:56 2018 +0300
+++ b/src/editmodes/abstractEditMode.cpp	Fri Dec 21 21:43:06 2018 +0200
@@ -210,7 +210,7 @@
 	if (not config::drawLineLengths())
 		return;
 
-	const QString label = QString::number(abs(v1 - v0), 'f', 2);
+    const QString label = QString::number((v1 - v0).length(), 'f', 2);
 	QPoint origin = QLineF {v0p, v1p}.pointAt(0.5).toPoint();
 	painter.drawText (origin, label);
 }
--- a/tools/updaterevision.py	Sat Sep 15 15:57:56 2018 +0300
+++ b/tools/updaterevision.py	Fri Dec 21 21:43:06 2018 +0200
@@ -25,7 +25,7 @@
 #	EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 #	PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 #	PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-#	LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+#	LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING
 #	NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 #	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
@@ -36,32 +36,33 @@
 def main():
 	import subprocess
 	from datetime import datetime
-	parser = argparse.ArgumentParser (description='Writes a header file with Hg commit information')
-	parser.add_argument ('output')
+	parser = argparse.ArgumentParser(description='Writes a header file with Hg commit information')
+	parser.add_argument('--cwd', default = '.')
+	parser.add_argument('output')
 	args = parser.parse_args()
-	f = outputfile.OutputFile (args.output)
-	data = subprocess.check_output (['hg', 'log', '-r.', '--template',
-		'{node|short} {branch} {date|hgdate}']).replace ('\n', '').split (' ')
+	f = outputfile.OutputFile(args.output)
+	data = subprocess.check_output(['hg', 'log', '--cwd', args.cwd, '-r.', '--template',
+		'{node|short} {branch} {date|hgdate}']).decode().replace('\n', '').split(' ')
 
 	rev = data[0]
 	branch = data[1]
-	timestamp = int (data[2])
-	date = datetime.utcfromtimestamp (timestamp)
-	datestring = date.strftime ('%y%m%d-%H%M') if date.year >= 2000 else '000000-0000'
+	timestamp = int(data[2])
+	date = datetime.utcfromtimestamp(timestamp)
+	datestring = date.strftime('%y%m%d-%H%M') if date.year >= 2000 else '000000-0000'
 
 	if len(rev) > 7:
 		rev = rev[0:7]
 
-	if subprocess.check_output (['hg', 'id', '-n']).replace ('\n', '')[-1] == '+':
+	if subprocess.check_output(['hg', 'id', '--cwd', args.cwd, '-n']).decode().replace('\n', '').endswith('+'):
 		rev += '+'
 
-	f.write ('#define HG_NODE "%s"\n' % rev)
-	f.write ('#define HG_BRANCH "%s"\n' % branch)
-	f.write ('#define HG_DATE_VERSION "%s"\n' % datestring)
-	f.write ('#define HG_DATE_STRING "%s"\n' % date.strftime ('%d %b %Y'))
-	f.write ('#define HG_DATE_TIME %d\n' % int (timestamp))
+	f.write('#define HG_NODE "%s"\n' % rev)
+	f.write('#define HG_BRANCH "%s"\n' % branch)
+	f.write('#define HG_DATE_VERSION "%s"\n' % datestring)
+	f.write('#define HG_DATE_STRING "%s"\n' % date.strftime('%d %b %Y'))
+	f.write('#define HG_DATE_TIME %d\n' % int(timestamp))
 	if f.save():
-		print '%s updated to %s' % (f.filename, rev)
+		print('%s updated to %s' %(f.filename, rev))
 
 if __name__ == '__main__':
 	main()

mercurial