hg
author Gilles Moris <gilles.moris@free.fr>
Sun, 18 Oct 2009 14:35:36 +0200
changeset 9615 f51d1822d6fd
parent 8225 46293a0c7e9f
child 10263 25e572394f5c
permissions -rwxr-xr-x
setup: refactor the version string to a subset of tag+tagdist-hash+date Here is an array summarizing the mercurial version string: [A] [B] [C] [D] [1] clone tag clean => tag [2] clone hash clean => latesttag+latesttagdistance-hash [3] clone tag dirty => tag+date [4] clone hash dirty => latesttag+latesttagdistance-hash+date [5] archive tag clean => tag [6] archive hash clean => latesttag+latesttagdistance-hash Column [A]: Mercurial built from an hg *archive* or hg *clone* working directory Column [B]: revision built has a *tag* or else default to the SHA1 *hash* Column [C]: working tree *clean* or *dirty* Column [D]: Mercurial version string Over the previous version: - row [5] did return just the node hash, now it returns the tag - prepend the latest tag and the distance to it to rows [2][4][6] - append also the date to row [3]; previously, it was just the tag - the version string is with an empty string to avoid possible TypeError exceptions during string manipulations - factorize the function to run hg commands; remove the error message as it is no more specific to the function. This scheme enables to have first part of the version strings that can be compared, whether it has been built from a tagged or untagged revision. The second part of the version adds a hash for untagged revisions and today's date if the working tree has local modifications. As the version string does not contain spaces or special characters, it should not break script parsing the 'hg version' command and should be usable for use in file names. The new code also ensure that the version string has exactly the same version string, whether it has been built from an archive or from a clone.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     1
#!/usr/bin/env python
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     2
#
1698
ad4a2eefe4d7 Update copyright notice
Matt Mackall <mpm@selenic.com>
parents: 515
diff changeset
     3
# mercurial - scalable distributed SCM
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     4
#
4635
63b9d2deed48 Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3877
diff changeset
     5
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     6
#
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 7672
diff changeset
     7
# This software may be used and distributed according to the terms of the
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 7672
diff changeset
     8
# GNU General Public License version 2, incorporated herein by reference.
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     9
5197
55860a45bbf2 Enable demandimport only in scripts, not in importable modules (issue605)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5178
diff changeset
    10
# enable importing on demand to reduce startup time
7672
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    11
try:
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    12
    from mercurial import demandimport; demandimport.enable()
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    13
except ImportError:
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    14
    import sys
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    15
    sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    16
                     ' '.join(sys.path))
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    17
    sys.stderr.write("(check your install and PYTHONPATH)\n")
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    18
    sys.exit(-1)
5197
55860a45bbf2 Enable demandimport only in scripts, not in importable modules (issue605)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5178
diff changeset
    19
5531
a3fe91b4f6eb Change standard streams mode to binary at hg startup
Patrick Mezard <pmezard@gmail.com>
parents: 5197
diff changeset
    20
import sys
a3fe91b4f6eb Change standard streams mode to binary at hg startup
Patrick Mezard <pmezard@gmail.com>
parents: 5197
diff changeset
    21
import mercurial.util
5178
18a9fbb5cd78 dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents: 4635
diff changeset
    22
import mercurial.dispatch
5531
a3fe91b4f6eb Change standard streams mode to binary at hg startup
Patrick Mezard <pmezard@gmail.com>
parents: 5197
diff changeset
    23
a3fe91b4f6eb Change standard streams mode to binary at hg startup
Patrick Mezard <pmezard@gmail.com>
parents: 5197
diff changeset
    24
for fp in (sys.stdin, sys.stdout, sys.stderr):
a3fe91b4f6eb Change standard streams mode to binary at hg startup
Patrick Mezard <pmezard@gmail.com>
parents: 5197
diff changeset
    25
    mercurial.util.set_binary(fp)
a3fe91b4f6eb Change standard streams mode to binary at hg startup
Patrick Mezard <pmezard@gmail.com>
parents: 5197
diff changeset
    26
5178
18a9fbb5cd78 dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents: 4635
diff changeset
    27
mercurial.dispatch.run()