Mercurial > public > mercurial-scm > hg
comparison setup.py @ 8548:3ccbe42ff72f
setup: read .hg_archival.txt for version info (issue1670)
Previously, setup.py was enhanced to identify the Mercurial version
from either .hg/ or mercurial/__version__.py. When archives are
created using 'hg archive' or via hgweb, neither of those options are
available. However, there is a .hg_archival.txt file in the root of
the archive that has the information. This patch enhances setup.py to
identify the Mercurial version from the .hg_archival.txt file when
there is no .hg/ or mercurial/__version__.py available.
author | Jeremy Whitlock <jcscoobyrs@gmail.com> |
---|---|
date | Fri, 22 May 2009 21:03:06 +0200 |
parents | 548fd7a05373 |
children | 9f85da260508 |
comparison
equal
deleted
inserted
replaced
8547:548fd7a05373 | 8548:3ccbe42ff72f |
---|---|
95 extra['console'] = ['hg'] | 95 extra['console'] = ['hg'] |
96 | 96 |
97 except ImportError: | 97 except ImportError: |
98 pass | 98 pass |
99 | 99 |
100 version = None | |
101 | |
100 if os.path.isdir('.hg'): | 102 if os.path.isdir('.hg'): |
101 # execute hg out of this directory with a custom environment which | 103 # execute hg out of this directory with a custom environment which |
102 # includes the pure Python modules in mercurial/pure | 104 # includes the pure Python modules in mercurial/pure |
103 pypath = os.environ.get('PYTHONPATH', '') | 105 pypath = os.environ.get('PYTHONPATH', '') |
104 purepath = os.path.join('mercurial', 'pure') | 106 purepath = os.path.join('mercurial', 'pure') |
105 os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath]) | 107 os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath]) |
106 os.environ['HGRCPATH'] = '' # do not read any config file | 108 os.environ['HGRCPATH'] = '' # do not read any config file |
107 cmd = [sys.executable, 'hg', 'id', '-i', '-t'] | 109 cmd = [sys.executable, 'hg', 'id', '-i', '-t'] |
108 version = None | |
109 | 110 |
110 l, e = subprocess.Popen(cmd, stdout=subprocess.PIPE, | 111 l, e = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
111 stderr=subprocess.PIPE).communicate() | 112 stderr=subprocess.PIPE).communicate() |
112 os.environ['PYTHONPATH'] = pypath | 113 os.environ['PYTHONPATH'] = pypath |
113 | 114 |
120 l.pop() | 121 l.pop() |
121 if l: | 122 if l: |
122 version = l[-1] # latest tag or revision number | 123 version = l[-1] # latest tag or revision number |
123 if version.endswith('+'): | 124 if version.endswith('+'): |
124 version += time.strftime('%Y%m%d') | 125 version += time.strftime('%Y%m%d') |
125 | 126 elif os.path.exists('.hg_archival.txt'): |
126 if version: | 127 hgarchival = open('.hg_archival.txt') |
127 f = file("mercurial/__version__.py", "w") | 128 for line in hgarchival: |
128 f.write('# this file is autogenerated by setup.py\n') | 129 if line.startswith('node:'): |
129 f.write('version = "%s"\n' % version) | 130 version = line.split(':')[1].strip()[:12] |
130 f.close() | 131 break |
132 | |
133 if version: | |
134 f = file("mercurial/__version__.py", "w") | |
135 f.write('# this file is autogenerated by setup.py\n') | |
136 f.write('version = "%s"\n' % version) | |
137 f.close() | |
138 | |
131 | 139 |
132 try: | 140 try: |
133 from mercurial import __version__ | 141 from mercurial import __version__ |
134 version = __version__.version | 142 version = __version__.version |
135 except ImportError: | 143 except ImportError: |