Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9, 0.9.1, and 0.9.1.1

hgtk: make version check independent from hglib

hglib currently imports mercurial.error that isn't present in earlier
versions of Mercurial, causing a demandimport error.

Changeset 3e3040595e92

Parent cee66577eee9

by Henrik Stuart

Changes to 4 files · Browse files at 3e3040595e92 Showing diff from parent cee66577eee9 Diff from another changeset...

Change 1 of 2 Show Entire File hggtk/​hgtk.py Stacked
 
166
167
168
169
170
171
172
173
174
175
176
 
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
 
166
167
168
 
 
 
 
 
169
170
171
 
565
566
567
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
568
569
570
@@ -166,11 +166,6 @@
 def _runcatch(ui, args):   try:   try: - checkhgversion(hglib.hgversion) - except util.Abort, inst: - ui.status(_("abort: %s!\n") % inst) - return 0 - try:   return runcommand(ui, args)   finally:   ui.flush() @@ -570,26 +565,6 @@
  else:   ui.write("%s\n" % first)   -def checkhgversion(v): - """range check the Mercurial version""" - # this is a series of hacks, but Mercurial's versioning scheme - # doesn't lend itself to a "correct" solution. This will at least - # catch people who have old Mercurial packages. - reqver = ['1', '3'] - if not v or v == 'unknown' or len(v) >= 12: - # can't make any intelligent decisions about unknown or hashes - return - vers = v.split('.')[:2] - if vers == reqver or len(vers) < 2: - return - nextver = list(reqver) - nextver[1] = chr(ord(reqver[1])+1) - if vers == nextver: - return - raise util.Abort(_('This version of TortoiseHg requires Mercurial ' - 'version %s.n to %s.n, but finds %s') % - ('.'.join(reqver), '.'.join(nextver), v)) -  def version(ui, **opts):   """output version and copyright information"""   ui.write(_('TortoiseHg Dialogs (version %s), '
Change 1 of 2 Show Entire File hgtk Stacked
 
29
30
31
32
 
 
33
34
35
 
44
45
46
 
 
 
 
 
47
48
49
 
29
30
31
 
32
33
34
35
36
 
45
46
47
48
49
50
51
52
53
54
55
@@ -29,7 +29,8 @@
 from mercurial import demandimport  demandimport.ignore.append('win32com.shell')  demandimport.enable() -from mercurial import ui +from mercurial import ui, util +from thgutil.hgversion import hgversion, checkhgversion  import cStringIO  import traceback   @@ -44,6 +45,11 @@
 _ui = ui.ui()  capt = _ui.configbool('tortoisehg', 'stderrcapt', True)   +err = checkhgversion(hgversion) +if err: + _ui.warn('abort: %s\n' % err) + sys.exit(1) +  if not capt or 'THGDEBUG' in os.environ:   sys.exit(hggtk.hgtk.dispatch(sys.argv[1:]))  else:
Change 1 of 1 Show Entire File thgutil/​hglib.py Stacked
 
22
23
24
25
26
27
28
29
30
31
32
 
33
34
35
 
22
23
24
 
 
 
 
 
 
 
 
25
26
27
28
@@ -22,14 +22,7 @@
 _encodingmode = encoding.encodingmode  _fallbackencoding = encoding.fallbackencoding   -try: - # post 1.1.2 - from mercurial import util - hgversion = util.version() -except AttributeError: - # <= 1.1.2 - from mercurial import version - hgversion = version.get_version() +from thgutil.hgversion import hgversion    def toutf(s):   """
Change 1 of 1 Show Entire File thgutil/​hgversion.py Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
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
@@ -0,0 +1,30 @@
+# hgversion.py - Version information for Mercurial + +try: + # post 1.1.2 + from mercurial import util + hgversion = util.version() +except AttributeError: + # <= 1.1.2 + from mercurial import version + hgversion = version.get_version() + +def checkhgversion(v): + """range check the Mercurial version""" + # this is a series of hacks, but Mercurial's versioning scheme + # doesn't lend itself to a "correct" solution. This will at least + # catch people who have old Mercurial packages. + reqver = ['1', '3'] + if not v or v == 'unknown' or len(v) >= 12: + # can't make any intelligent decisions about unknown or hashes + return + vers = v.split('.')[:2] + if vers == reqver or len(vers) < 2: + return + nextver = list(reqver) + nextver[1] = chr(ord(reqver[1])+1) + if vers == nextver: + return + return (('This version of TortoiseHg requires Mercurial ' + 'version %s.n to %s.n, but finds %s') % + ('.'.join(reqver), '.'.join(nextver), v))