Wed, 20 Jul 2016 17:47:42 +0300
Made String::vsprintf behave properly with long strings.
1
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | # |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | # Copyright 2014 Teemu Piippo |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | # All rights reserved. |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | # |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | # Redistribution and use in source and binary forms, with or without |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | # modification, are permitted provided that the following conditions |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | # are met: |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | # |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | # 1. Redistributions of source code must retain the above copyright |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | # notice, this list of conditions and the following disclaimer. |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | # 2. Redistributions in binary form must reproduce the above copyright |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | # notice, this list of conditions and the following disclaimer in the |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | # documentation and/or other materials provided with the distribution. |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | # 3. Neither the name of the copyright holder nor the names of its |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | # contributors may be used to endorse or promote products derived from |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | # this software without specific prior written permission. |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | # |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | # |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | import sys |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | import subprocess |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | from datetime import datetime |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | if len (sys.argv) != 2: |
77
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
36 | print 'usage: %s <output>' % sys.argv[0] |
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
37 | quit (1) |
1
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | |
124
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
39 | oldcompare = '' |
1
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | try: |
77
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
42 | with open (sys.argv[1]) as fp: |
124
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
43 | oldcompare = fp.readline().replace ('\n', '').replace ('// ', '') |
1
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | except IOError: |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | pass |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | |
77
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
47 | delim='@'*10 |
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
48 | rev, branch, timestampstr, tags = subprocess.check_output (['hg', 'log', '-r.', '--template', |
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
49 | delim.join (['{node|short}', '{branch}', '{date|hgdate}', '{tags}'])]).replace ('\n', '').split (delim) |
1
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
77
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
51 | timestamp = int (timestampstr.split(' ')[0]) |
1
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | date = datetime.utcfromtimestamp (timestamp) |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | datestring = date.strftime ('%y%m%d-%H%M') if date.year >= 2000 else '000000-0000' |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | |
124
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
55 | if tags and tags != 'tip': |
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
56 | tag = tags.split(' ')[0] |
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
57 | else: |
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
58 | tag = None |
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
59 | |
1
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | if len(rev) > 7: |
77
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
61 | rev = rev[0:7] |
1
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | if subprocess.check_output (['hg', 'id', '-n']).replace ('\n', '')[-1] == '+': |
77
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
64 | rev += '+' |
1
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | |
124
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
66 | compare = tag or rev |
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
67 | |
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
68 | if compare == oldcompare: |
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
69 | print "%s is up to date at %s" % (sys.argv[1], compare) |
77
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
70 | quit (0) |
1
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | |
4dd5bde4e777
- a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | with open (sys.argv[1], 'w') as fp: |
124
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
73 | fp.write ('// %s\n' % compare) |
77
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
74 | fp.write ('#define HG_NODE "%s"\n' % rev) |
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
75 | fp.write ('#define HG_BRANCH "%s"\n' % branch) |
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
76 | fp.write ('#define HG_DATE_VERSION "%s"\n' % datestring) |
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
77 | fp.write ('#define HG_DATE_STRING "%s"\n' % date.strftime ('%d %b %Y')) |
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
78 | fp.write ('#define HG_DATE_TIME %d\n' % int (timestamp)) |
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
79 | |
124
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
80 | if tag: |
77
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
81 | fp.write ('#define HG_TAG "%s"\n' % tags.split(' ')[0]) |
32ef969adeed
Updated updaterevision.py, now handles tags and provides HG_TAG if appropriate
Teemu Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
82 | |
124
c5ff5a4704dd
Use tags as a compare basis for updating the revision if available, so that when a revision gets tagged, hginfo.h gets updated.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
77
diff
changeset
|
83 | print '%s updated to %s' % (sys.argv[1], compare) |