Mercurial > hg > openttd
annotate findversion.sh @ 16729:235fa32934bf draft
(svn r21462) -Codechange [FS#3689]: don't do unnecessary cargo reservations in while loading/unloading vehicles. It is only needed when at least one vehicle is loading; all other times it is a waste of effort. Roughly halves the time it takes to perform loading/unloading of vehicles (fonsinchen)
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sat, 11 Dec 2010 11:00:42 +0000 |
parents | 0a728d98d51e |
children | 04d7d238167c |
rev | line source |
---|---|
10085
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
1 #!/bin/sh |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
2 |
10729
426ed2de6f28
(svn r15062) -Fix: further forgotten svn properties and headers
smatz <smatz@openttd.org>
parents:
10281
diff
changeset
|
3 # $Id$ |
426ed2de6f28
(svn r15062) -Fix: further forgotten svn properties and headers
smatz <smatz@openttd.org>
parents:
10281
diff
changeset
|
4 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12055
diff
changeset
|
5 # This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12055
diff
changeset
|
6 # OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12055
diff
changeset
|
7 # OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12055
diff
changeset
|
8 # See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12055
diff
changeset
|
9 |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12055
diff
changeset
|
10 |
10085
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
11 # Arguments given? Show help text. |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
12 if [ "$#" != "0" ]; then |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
13 cat <<EOF |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
14 Usage: ./findversion.sh |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
15 Finds the current revision and if the code is modified. |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
16 |
10092
c290ad73e4b4
(svn r14273) -Change: make findversion.sh aware of release tags and make it output the REV without the branch name so the CF can use that.
rubidium <rubidium@openttd.org>
parents:
10088
diff
changeset
|
17 Output: <REV>\t<REV_NR>\t<MODIFIED>\t<CLEAN_REV> |
10085
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
18 REV |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
19 a string describing what version of the code the current checkout is |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
20 based on. The exact format of this string depends on the version |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
21 control system in use, but it tries to identify the revision used as |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
22 close as possible (using the svn revision number or hg/git hash). |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
23 This also includes an indication of whether the checkout was |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
24 modified and which branch was checked out. This value is not |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
25 guaranteed to be sortable, but is mainly meant for identifying the |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
26 revision and user display. |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
27 |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
28 If no revision identifier could be found, this is left empty. |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
29 REV_NR |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
30 the revision number of the svn revision this checkout is based on. |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
31 This can be used to determine which functionality is present in this |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
32 checkout. For trunk svn checkouts and hg/git branches based upon it, |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
33 this number should be accurate. For svn branch checkouts, this |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
34 number is mostly meaningless, at least when comparing with the |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
35 REV_NR from other branches or trunk. |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
36 |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
37 This number should be sortable. Within a given branch or trunk, a |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
38 higher number means a newer version. However, when using git or hg, |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
39 this number will not increase on new commits. |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
40 |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
41 If no revision number could be found, this is left empty. |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
42 MODIFIED |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
43 Whether (the src directory of) this checkout is modified or not. A |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
44 value of 0 means not modified, a value of 2 means it was modified. |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
45 Modification is determined in relation to the commit identified by |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
46 REV, so not in relation to the svn revision identified by REV_NR. |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
47 |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
48 A value of 1 means that the modified status is unknown, because this |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
49 is not an svn/git/hg checkout for example. |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
50 |
10092
c290ad73e4b4
(svn r14273) -Change: make findversion.sh aware of release tags and make it output the REV without the branch name so the CF can use that.
rubidium <rubidium@openttd.org>
parents:
10088
diff
changeset
|
51 CLEAN_REV |
c290ad73e4b4
(svn r14273) -Change: make findversion.sh aware of release tags and make it output the REV without the branch name so the CF can use that.
rubidium <rubidium@openttd.org>
parents:
10088
diff
changeset
|
52 the same as REV but without branch name |
c290ad73e4b4
(svn r14273) -Change: make findversion.sh aware of release tags and make it output the REV without the branch name so the CF can use that.
rubidium <rubidium@openttd.org>
parents:
10088
diff
changeset
|
53 |
10085
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
54 By setting the AWK environment variable, a caller can determine which |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
55 version of "awk" is used. If nothing is set, this script defaults to |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
56 "awk". |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
57 EOF |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
58 exit 1; |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
59 fi |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
60 |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
61 # Allow awk to be provided by the caller. |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
62 if [ -z "$AWK" ]; then |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
63 AWK=awk |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
64 fi |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
65 |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
66 # Find out some dirs |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
67 cd `dirname "$0"` |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
68 ROOT_DIR=`pwd` |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
69 |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
70 # Determine if we are using a modified version |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
71 # Assume the dir is not modified |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
72 MODIFIED="0" |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
73 if [ -d "$ROOT_DIR/.svn" ]; then |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
74 # We are an svn checkout |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
75 if [ -n "`svnversion | grep 'M'`" ]; then |
10085
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
76 MODIFIED="2" |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
77 fi |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
78 # Find the revision like: rXXXXM-branch |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
79 BRANCH=`LC_ALL=C svn info | "$AWK" '/^URL:.*branches/ { split($2, a, "/"); for(i in a) if (a[i]=="branches") { print a[i+1]; break } }'` |
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
80 TAG=`LC_ALL=C svn info | "$AWK" '/^URL:.*tags/ { split($2, a, "/"); for(i in a) if (a[i]=="tags") { print a[i+1]; break } }'` |
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
81 REV_NR=`LC_ALL=C svn info | "$AWK" '/^Last Changed Rev:/ { print $4 }'` |
10097
4b82e5d3d313
(svn r14278) -Cleanup [Makefile]: Rename $TAGS to $TAG.
matthijs <matthijs@openttd.org>
parents:
10096
diff
changeset
|
82 if [ -n "$TAG" ]; then |
4b82e5d3d313
(svn r14278) -Cleanup [Makefile]: Rename $TAGS to $TAG.
matthijs <matthijs@openttd.org>
parents:
10096
diff
changeset
|
83 REV=$TAG |
10092
c290ad73e4b4
(svn r14273) -Change: make findversion.sh aware of release tags and make it output the REV without the branch name so the CF can use that.
rubidium <rubidium@openttd.org>
parents:
10088
diff
changeset
|
84 else |
c290ad73e4b4
(svn r14273) -Change: make findversion.sh aware of release tags and make it output the REV without the branch name so the CF can use that.
rubidium <rubidium@openttd.org>
parents:
10088
diff
changeset
|
85 REV="r$REV_NR" |
c290ad73e4b4
(svn r14273) -Change: make findversion.sh aware of release tags and make it output the REV without the branch name so the CF can use that.
rubidium <rubidium@openttd.org>
parents:
10088
diff
changeset
|
86 fi |
10085
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
87 elif [ -d "$ROOT_DIR/.git" ]; then |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
88 # We are a git checkout |
15260
012e08dc46ae
(svn r19895) -Fix [FS#3836]: Git version detection would sometimes mistakenly identify a checkout as modified.
michi_cc <michi_cc@openttd.org>
parents:
12778
diff
changeset
|
89 # Refresh the index to make sure file stat info is in sync, then look for modifications |
012e08dc46ae
(svn r19895) -Fix [FS#3836]: Git version detection would sometimes mistakenly identify a checkout as modified.
michi_cc <michi_cc@openttd.org>
parents:
12778
diff
changeset
|
90 git update-index --refresh >/dev/null |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
91 if [ -n "`git diff-index HEAD`" ]; then |
10085
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
92 MODIFIED="2" |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
93 fi |
10281
e89498278e19
(svn r14519) -Fix [FS#2376]: do not use the short hash form for getting a specific mercurial/git revision as those can collide quite easily causing reversion detection to fail (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10239
diff
changeset
|
94 HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null` |
e89498278e19
(svn r14519) -Fix [FS#2376]: do not use the short hash form for getting a specific mercurial/git revision as those can collide quite easily causing reversion detection to fail (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10239
diff
changeset
|
95 REV="g`echo $HASH | cut -c1-8`" |
15407
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15263
diff
changeset
|
96 BRANCH=`git symbolic-ref -q HEAD 2>/dev/null | sed 's@.*/@@;s@^master$@@'` |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
97 REV_NR=`LC_ALL=C git log --pretty=format:%s --grep="^(svn r[0-9]*)" -1 | sed "s@.*(svn r\([0-9]*\)).*@\1@"` |
15407
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15263
diff
changeset
|
98 if [ -z "$REV_NR" ]; then |
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15263
diff
changeset
|
99 # No rev? Maybe it is a custom git-svn clone |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
100 REV_NR=`LC_ALL=C git log --pretty=format:%b --grep="git-svn-id:.*@[0-9]*" -1 | sed "s@.*\@\([0-9]*\).*@\1@"` |
15407
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15263
diff
changeset
|
101 fi |
10085
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
102 elif [ -d "$ROOT_DIR/.hg" ]; then |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
103 # We are a hg checkout |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
104 if [ -n "`hg status | grep -v '^?'`" ]; then |
10085
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
105 MODIFIED="2" |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
106 fi |
15263
73fd236bcc2f
(svn r19898) -Fix [FS#3853]: hg version detection fails for uncommited merges (planetmaker)
rubidium <rubidium@openttd.org>
parents:
15260
diff
changeset
|
107 HASH=`LC_ALL=C hg id -i | cut -c1-12` |
10281
e89498278e19
(svn r14519) -Fix [FS#2376]: do not use the short hash form for getting a specific mercurial/git revision as those can collide quite easily causing reversion detection to fail (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10239
diff
changeset
|
108 REV="h`echo $HASH | cut -c1-8`" |
11916
1be572ca9966
(svn r16318) -Change: use !! instead of @@ in src/*.in too.
rubidium <rubidium@openttd.org>
parents:
10729
diff
changeset
|
109 BRANCH=`hg branch | sed 's@^default$@@'` |
15648
c60e7a193072
(svn r20313) -Fix (r20309): Mercurial version detection picked up a bit more than it should've picked up.
rubidium <rubidium@openttd.org>
parents:
15644
diff
changeset
|
110 REV_NR=`LC_ALL=C hg log -f -k "(svn r" -l 1 --template "{desc}\n" | head -n 1 | sed "s@.*(svn r\([0-9]*\)).*@\1@"` |
16621
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15648
diff
changeset
|
111 elif [ -f "$ROOT_DIR/.ottdrev" ]; then |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15648
diff
changeset
|
112 # We are an exported source bundle |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15648
diff
changeset
|
113 cat $ROOT_DIR/.ottdrev |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15648
diff
changeset
|
114 exit |
10085
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
115 else |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
116 # We don't know |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
117 MODIFIED="1" |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
118 BRANCH="" |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
119 REV="" |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
120 REV_NR="" |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
121 fi |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
122 |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
123 if [ "$MODIFIED" -eq "2" ]; then |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
124 REV="${REV}M" |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
125 fi |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
126 |
10092
c290ad73e4b4
(svn r14273) -Change: make findversion.sh aware of release tags and make it output the REV without the branch name so the CF can use that.
rubidium <rubidium@openttd.org>
parents:
10088
diff
changeset
|
127 CLEAN_REV=${REV} |
c290ad73e4b4
(svn r14273) -Change: make findversion.sh aware of release tags and make it output the REV without the branch name so the CF can use that.
rubidium <rubidium@openttd.org>
parents:
10088
diff
changeset
|
128 |
10085
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
129 if [ -n "$BRANCH" ]; then |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
130 REV="${REV}-$BRANCH" |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
131 fi |
6e5a5c7f13c3
(svn r14261) -Change [Makefile]: Move the revision detection code from Makefile.src.in to a
matthijs <matthijs@openttd.org>
parents:
diff
changeset
|
132 |
10092
c290ad73e4b4
(svn r14273) -Change: make findversion.sh aware of release tags and make it output the REV without the branch name so the CF can use that.
rubidium <rubidium@openttd.org>
parents:
10088
diff
changeset
|
133 echo "$REV $REV_NR $MODIFIED $CLEAN_REV" |