Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

version: try to fetch version from live repository

This should improve bug reports from people who follow hgtk wiki page
install instructions.

Changeset fb8960740a92

Parent f71e733c54b1

by Steve Borho

Changes to one file · Browse files at fb8960740a92 Showing diff from parent f71e733c54b1 Diff from another changeset...

 
5
6
7
 
 
8
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
11
12
13
14
15
 
 
 
 
16
17
 
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
42
43
44
45
46
47
@@ -5,13 +5,43 @@
 # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.   +import os +from mercurial import ui, hg, commands  from tortoisehg.util.i18n import _   +def liveversion(): + 'Attempt to read the version from the live repository' + utilpath = os.path.dirname(os.path.realpath(__file__)) + thgpath = os.path.dirname(os.path.dirname(utilpath)) + if not os.path.isdir(os.path.join(thgpath, '.hg')): + return _('unknown') + + u = ui.ui() + repo = hg.repository(u, path=thgpath) + + u.pushbuffer() + commands.identify(u, repo, id=True, tags=True) + l = u.popbuffer().split() + while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags + l.pop() + if len(l) > 1: # tag found + version = l[-1] + if l[0].endswith('+'): # propagate the dirty status to the tag + version += '+' + elif len(l) == 1: # no tag found + u.pushbuffer() + commands.parents(u, repo, template='{latesttag}+{latesttagdistance}-') + version = u.popbuffer() + l[0] + return version +  def version():   try:   import __version__   return __version__.version   except ImportError: - return _('unknown') + try: + return liveversion() + except: + return _('unknown')