/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/win32/bzr-win32-bdist-postinstall.py

  • Committer: wang
  • Date: 2006-10-29 13:41:32 UTC
  • mto: (2104.4.1 wang_65714)
  • mto: This revision was merged to the branch mainline in revision 2109.
  • Revision ID: wang@ubuntu-20061029134132-3d7f4216f20c4aef
Replace python's difflib by patiencediff because the worst case 
performance is cubic for difflib and people commiting large data 
files are often hurt by this. The worst case performance of patience is 
quadratic. Fix bug 65714.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# [bialix]: bzr de-facto does not support win98.
17
17
#           Although it seems to work on. Sometimes.
18
18
# 2006/07/30    added minimal support of win98.
19
 
# 2007/01/30    added *real* support of win98.
20
19
 
21
20
import os
22
21
import sys
23
22
import _winreg
24
23
 
25
 
from bzrlib import win32utils
26
 
 
27
24
 
28
25
def _quoted_path(path):
29
26
    if ' ' in path:
32
29
        return path
33
30
 
34
31
def _win_batch_args():
35
 
    if win32utils.winver == 'Windows NT':
 
32
    if os.name == 'nt':
36
33
        return '%*'
37
34
    else:
38
35
        return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
65
62
        python_path = _quoted_path(os.path.join(prefix, "python.exe"))
66
63
        args = _win_batch_args()
67
64
        batch_str = "@%s %s %s" % (python_path, script_path, args)
68
 
        # support of win98
69
 
        # if there is no HOME for bzr then set it for Bazaar manually
70
 
        base = os.environ.get('BZR_HOME', None)
71
 
        if base is None:
72
 
            base = win32utils.get_appdata_location()
73
 
        if base is None:
74
 
            base = os.environ.get('HOME', None)
75
 
        if base is None:
76
 
            base = os.path.splitdrive(sys.prefix)[0] + '\\'
77
 
            batch_str = ("@SET BZR_HOME=" + _quoted_path(base) + "\n" +
 
65
        # minimal support of win98
 
66
        # if there is no HOME in system then set it for Bazaar manually
 
67
        homes = ('BZR_HOME', 'APPDATA', 'HOME')
 
68
        for home in homes:
 
69
            bzr_home = os.environ.get(home, None)
 
70
            if bzr_home is not None:
 
71
                break
 
72
        else:
 
73
            try:
 
74
                bzr_home = get_special_folder('CSIDL_APPDATA')
 
75
            except OSError:
 
76
                # no Application Data
 
77
                bzr_home = ''
 
78
 
 
79
            if not bzr_home:
 
80
                bzr_home = os.path.splitdrive(sys.prefix)[0] + '\\'
 
81
 
 
82
            batch_str = ("@SET BZR_HOME=" + _quoted_path(bzr_home) + "\n" +
78
83
                         batch_str)
79
84
 
80
 
        batch_path = os.path.join(scripts_dir, "bzr.bat")
 
85
        batch_path = script_path + ".bat"
81
86
        f = file(batch_path, "w")
82
87
        f.write(batch_str)
83
88
        f.close()
90
95
    except Exception, e:
91
96
        print "ERROR: Unable to create %s: %s" % (batch_path, e)
92
97
 
 
98
    # make entry in bzr home directory
 
99
    dst = os.path.join(bzr_home, "bazaar", "2.0")
 
100
    if not os.path.isdir(dst):
 
101
        os.makedirs(dst)
 
102
        import locale
 
103
        print "Configuration files stored in %s" % \
 
104
              dst.encode(locale.getpreferredencoding(), 'replace')
 
105
        # create dummy bazaar.conf
 
106
        f = file(os.path.join(dst,'bazaar.conf'), 'w')
 
107
        f.write("# main configuration file of Bazaar\n"
 
108
                "[DEFAULT]\n"
 
109
                "#email=Your Name <you@domain.com>\n")
 
110
        f.close()
 
111
 
93
112
    ## this hunk borrowed from pywin32_postinstall.py
94
113
    # use bdist_wininst builtins to create a shortcut.
95
114
    # CSIDL_COMMON_PROGRAMS only available works on NT/2000/XP, and
111
130
        directory_created(fldr)
112
131
 
113
132
    # link to documentation
114
 
    docs = os.path.join(sys.exec_prefix, 'Doc', 'Bazaar', 'index.html')
 
133
    docs = os.path.join(sys.exec_prefix, 'Doc', 'Bazaar', 'index.htm')
115
134
    dst = os.path.join(fldr, 'Documentation.lnk')
116
135
    create_shortcut(docs, 'Bazaar Documentation', dst)
117
136
    file_created(dst)
132
151
                    args,
133
152
                    os.path.join(sys.exec_prefix, 'Scripts'))
134
153
    file_created(dst)
135
 
 
136
 
    # uninstall shortcut
137
 
    uninst = os.path.join(sys.exec_prefix, 'Removebzr.exe')
138
 
    dst = os.path.join(fldr, 'Uninstall Bazaar.lnk')
139
 
    create_shortcut(uninst,
140
 
                    'Uninstall Bazaar',
141
 
                    dst,
142
 
                    '-u bzr-wininst.log',
143
 
                    sys.exec_prefix,
144
 
                    )
145
 
    file_created(dst)