Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.7, 0.7.1, and 0.7.2

many errors moved to error.py in mercurial tip

Changeset 95bec2d6ed59

Parent 9a9e4fe2ac0b

by Steve Borho

Changes to 20 files · Browse files at 95bec2d6ed59 Showing diff from parent 9a9e4fe2ac0b Diff from another changeset...

Change 1 of 2 Show Entire File contrib/​hgtk Stacked
 
18
19
20
21
22
23
24
25
 
 
 
 
 
 
 
 
26
27
28
 
82
83
84
85
86
 
 
87
88
89
 
90
91
92
 
18
19
20
 
21
22
 
 
23
24
25
26
27
28
29
30
31
32
33
 
87
88
89
 
 
90
91
92
93
 
94
95
96
97
@@ -18,11 +18,16 @@
 import shlex  from mercurial.i18n import _  from mercurial import hg, util, fancyopts, commands, cmdutil -from mercurial.repo import RepoError  import mercurial.ui as _ui   -class ParseError(Exception): - """Exception raised on errors in parsing the command line.""" +try: + from mercurial.error import RepoError, UnknownCommand, AmbiguousCommand + from mercurial.error import ParseError +except ImportError: + from mercurial.repo import RepoError + from mercurial.cmdutil import UnknownCommand, AmbiguousCommand + class ParseError(Exception): + """Exception raised on errors in parsing the command line."""    nonrepo_commands = 'userconfig clone init about help'   @@ -82,11 +87,11 @@
  help_(ui, inst.args[0])   else:   ui.warn(_("hgtk: %s\n") % inst.args[1]) - help_('shortlist') - except cmdutil.AmbiguousCommand, inst: + help_(ui, 'shortlist') + except AmbiguousCommand, inst:   ui.warn(_("hgtk: command '%s' is ambiguous:\n %s\n") %   (inst.args[0], " ".join(inst.args[1]))) - except cmdutil.UnknownCommand, inst: + except UnknownCommand, inst:   ui.warn(_("hgtk: unknown command '%s'\n") % inst.args[0])   help_(ui, 'shortlist')   except RepoError, inst:
 
12
13
14
15
 
16
17
18
 
21
22
23
 
 
 
 
 
 
24
25
26
 
71
72
73
74
 
75
76
77
 
12
13
14
 
15
16
17
18
 
21
22
23
24
25
26
27
28
29
30
31
32
 
77
78
79
 
80
81
82
83
@@ -12,7 +12,7 @@
 import gconf  import gtk  import gobject -from mercurial import hg, ui, repo, match, util +from mercurial import hg, ui, match, util  from mercurial.node import short  import nautilus  import os @@ -21,6 +21,12 @@
 import tempfile  import time  import urllib + +try: + from mercurial.error import RepoError +except ImportError: + from mercurial.repo import RepoError +  TORTOISEHG_PATH = '~/tools/tortoisehg-dev'  TERMINAL_KEY = '/desktop/gnome/applications/terminal/exec'   @@ -71,7 +77,7 @@
  self.cacheroot = p   self.cacherepo = hg.repository(ui.ui(), path=p)   return self.cacherepo - except repo.RepoError: + except RepoError:   self.cacheroot = None   self.cacherepo = None   return None
 
16
17
18
19
20
21
22
 
23
24
25
26
27
 
 
 
 
 
28
29
30
 
268
269
270
271
 
272
273
274
 
293
294
295
296
 
297
298
299
 
623
624
625
626
 
627
628
629
 
16
17
18
 
19
 
 
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 
271
272
273
 
274
275
276
277
 
296
297
298
 
299
300
301
302
 
626
627
628
 
629
630
631
632
@@ -16,15 +16,18 @@
 import pango  import StringIO   -from mercurial.i18n import _  from mercurial.node import * -from mercurial import cmdutil, util, ui, hg, commands -from mercurial import context, patch, revlog +from mercurial import cmdutil, context, util, ui, hg, patch  from gdialog import *  from hgcmd import CmdDialog  from hglib import toutf, fromutf, displaytime, hgcmd_toq, diffexpand  from gtklib import StatusBar   +try: + from mercurial.error import LookupError +except ImportError: + from mercurial.revlog import LookupError +  class ChangeSet(GDialog):   """GTK+ based dialog for displaying repository logs   """ @@ -268,7 +271,7 @@
  if f in files:   try:   src = getfilectx(f, c).renamed() - except revlog.LookupError: + except LookupError:   return None   if src:   f = src[0] @@ -293,7 +296,7 @@
  s = 'A'   ctx1.filectx(f)   s = 'M' - except revlog.LookupError: + except LookupError:   pass   status[f] = s   return s @@ -623,7 +626,7 @@
  try:   fctx = ctx.filectx(self.curfile)   has_filelog = fctx.filelog().linkrev(fctx.filerev()) == ctx.rev() - except revlog.LookupError: + except LookupError:   has_filelog = False   self._ann_menu.set_sensitive(has_filelog)   self._save_menu.set_sensitive(has_filelog)
Change 1 of 1 Show Entire File hggtk/​commit.py Stacked
 
16
17
18
 
19
20
21
 
16
17
18
19
20
21
22
@@ -16,6 +16,7 @@
 import cStringIO    from mercurial.i18n import _ +from mercurial.node import *  from mercurial import ui, hg  from shlib import shell_notify  from gdialog import *
Change 1 of 2 Show Entire File hggtk/​diff.py Stacked
 
12
13
14
15
 
16
17
18
 
110
111
112
113
 
114
115
116
 
12
13
14
 
15
16
17
18
 
110
111
112
 
113
114
115
116
@@ -12,7 +12,7 @@
 import gtk  import pango  import sys -from hglib import gettabwidth +from hglib import gettabwidth, RepoError  from mercurial import hg, ui, cmdutil, util, patch  from mercurial.i18n import _  from shlib import set_tortoise_icon @@ -110,7 +110,7 @@
  self.ui = ui.ui()   try:   self.repo = hg.repository(self.ui, path=self.root) - except hg.RepoError: + except RepoError:   return None     matcher = cmdutil.match(self.repo, self.files)
Change 1 of 1 Show Entire File hggtk/​gdialog.py Stacked
 
24
25
26
27
28
 
 
29
30
31
 
24
25
26
 
 
27
28
29
30
31
@@ -24,8 +24,8 @@
 import pango    from mercurial.i18n import _ -from mercurial.node import * -from mercurial import cmdutil, util, ui, hg, commands, patch +from mercurial.node import short +from mercurial import cmdutil, util, ui, hg, commands  from hgext import extdiff  from shlib import shell_notify, set_tortoise_icon, Settings  from thgconfig import ConfigDialog
Change 1 of 1 Show Entire File hggtk/​hgemail.py Stacked
 
14
15
16
17
 
18
19
20
 
14
15
16
 
17
18
19
20
@@ -14,7 +14,7 @@
 from tempfile import mkstemp  from dialog import *  from mercurial import hg, ui, extensions -from mercurial.repo import RepoError +from hglib import RepoError  from thgconfig import ConfigDialog  from hgcmd import CmdDialog  
Change 1 of 2 Show Changes Only hggtk/​hginit.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
 
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
 
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
 #  # TortoiseHg dialog to initialize a repo  #  # Copyright (C) 2008 TK Soh <teekaysoh@gmail.com>  #    import pygtk  pygtk.require("2.0")  import os  import sys  import gtk  import pango  from dialog import error_dialog, info_dialog -from mercurial import hg, ui, util, repo +from mercurial import hg, ui, util +from hglib import RepoError  import shlib    class InitDialog(gtk.Window):   """ Dialog to add tag to Mercurial repo """   def __init__(self, cwd='', repos=[]):   """ Initialize the Dialog """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)     # set dialog title and icon   self.cwd = cwd and cwd or os.getcwd()   title = 'Hg init - %s' % (self.cwd)   self.set_title(title)   shlib.set_tortoise_icon(self, 'menucreaterepos.ico')     # preconditioning info   self._dest_path = os.path.abspath(repos and repos[0] or os.getcwd())     # build dialog   self._create()     def _create(self):   self.set_default_size(350, 150)   self.connect('destroy', gtk.main_quit)     # add toolbar with tooltips   self.tbar = gtk.Toolbar()   self.tips = gtk.Tooltips()     self._btn_init = self._toolbutton(   gtk.STOCK_NEW,   'Create',   self._btn_init_clicked,   tip='Create a new repository in destination directory')   tbuttons = [   self._btn_init,   ]   for btn in tbuttons:   self.tbar.insert(btn, -1)   sep = gtk.SeparatorToolItem()   sep.set_expand(True)   sep.set_draw(False)   self.tbar.insert(sep, -1)   button = self._toolbutton(gtk.STOCK_CLOSE, 'Close',   self._close_clicked, tip='Close Application')   self.tbar.insert(button, -1)   vbox = gtk.VBox()   self.add(vbox)   vbox.pack_start(self.tbar, False, False, 2)     # clone source   srcbox = gtk.HBox()   lbl = gtk.Label(" Destination :")   lbl.set_property("width-chars", 12)   lbl.set_alignment(0, 0.5)   self._dest_input = gtk.Entry()   self._dest_input.set_text(self._dest_path)   self._dest_input.set_position(-1)     self._btn_dest_browse = gtk.Button("...")   self._btn_dest_browse.connect('clicked', self._btn_dest_clicked)   srcbox.pack_start(lbl, False, False)   srcbox.pack_start(self._dest_input, True, True)   srcbox.pack_end(self._btn_dest_browse, False, False, 5)   vbox.pack_start(srcbox, False, False, 2)     # options   option_box = gtk.VBox()   self._opt_specialfiles = gtk.CheckButton(   "Add special files (.hgignore, ...)")   self._opt_oldrepoformat = gtk.CheckButton(   "Make repo compatible with Mercurial 1.0")   option_box.pack_start(self._opt_specialfiles, False, False)   option_box.pack_start(self._opt_oldrepoformat, False, False)   vbox.pack_start(option_box, False, False, 15)     # set option states   self._opt_specialfiles.set_active(True)   try:   usefncache = ui.ui().configbool('format', 'usefncache', True)   self._opt_oldrepoformat.set_active(not usefncache)   except:   pass     def _close_clicked(self, toolbutton, data=None):   gtk.main_quit()     def _toolbutton(self, stock, label, handler,   menu=None, userdata=None, tip=None):   if menu:   tbutton = gtk.MenuToolButton(stock)   tbutton.set_menu(menu)   else:   tbutton = gtk.ToolButton(stock)     tbutton.set_label(label)   if tip:   tbutton.set_tooltip(self.tips, tip)   tbutton.connect('clicked', handler, userdata)   return tbutton     def _btn_dest_clicked(self, button):   """ select source folder to clone """   dialog = gtk.FileChooserDialog(title=None,   action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,   buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,   gtk.STOCK_OPEN,gtk.RESPONSE_OK))   dialog.set_default_response(gtk.RESPONSE_OK)   dialog.set_current_folder(self.cwd)   response = dialog.run()   if response == gtk.RESPONSE_OK:   self._dest_input.set_text(dialog.get_filename())   self._dest_input.set_position(-1)   dialog.destroy()     def _btn_init_clicked(self, toolbutton, data=None):   # gather input data   dest = self._dest_input.get_text()     # verify input   if dest == "":   error_dialog(self, "Destination path is empty",   "Please enter the directory path")   self._dest_input.grab_focus()   return False     # start   u = ui.ui()     # fncache is the new default repo format in Mercurial 1.1   if self._opt_oldrepoformat.get_active():   u.setconfig('format', 'usefncache', 'False')     try:   hg.repository(u, dest, create=1) - except repo.RepoError, inst: + except RepoError, inst:   error_dialog(self, "Unable to create new repository",   str(inst))   return False   except util.Abort, inst:   error_dialog(self, "Error when creating repository",   str(inst))   return False   except:   import traceback   error_dialog(self, "Error when creating repository",   traceback.format_exc())   return False     # create the .hg* file, mainly to workaround   # Explorer's problem in creating files with name   # begins with a dot.   if self._opt_specialfiles.get_active():   hgignore = os.path.join(dest, '.hgignore')   if not os.path.exists(hgignore):   try:   open(hgignore, 'wb')   except:   pass     info_dialog(self, "New repository created",   "in directory %s" % os.path.abspath(dest))    def run(cwd='', files=[], **opts):   dialog = InitDialog(cwd, repos=files)   dialog.show_all()   gtk.gdk.threads_init()   gtk.gdk.threads_enter()   gtk.main()   gtk.gdk.threads_leave()    if __name__ == "__main__":   import sys   opts = {}   opts['cwd'] = os.getcwd()   opts['files'] = sys.argv[1:]   run(**opts)
Change 1 of 1 Show Entire File hggtk/​hglib.py Stacked
 
5
6
7
8
9
10
11
12
13
 
 
 
 
 
 
14
15
16
 
5
6
7
 
 
8
9
10
11
12
13
14
15
16
17
18
19
20
@@ -5,12 +5,16 @@
 import threading, thread2  import Queue  from mercurial import hg, ui, util, extensions, commands, hook -from mercurial.repo import RepoError -from mercurial.node import *  from mercurial.i18n import _  from dialog import entry_dialog    try: + from mercurial.error import RepoError, ParseError +except ImportError: + from mercurial.repo import RepoError + from mercurial.cmdutil import ParseError + +try:   try:   from mercurial import demandimport   except:
 
11
12
13
14
15
16
 
17
18
19
 
11
12
13
 
14
 
15
16
17
18
@@ -11,9 +11,8 @@
 import sys  import gtk  from gdialog import * -from mercurial.node import *  from mercurial import cmdutil, util, hg, ui -from mercurial.repo import RepoError +from hglib import RepoError  from shlib import shell_notify, set_tortoise_icon    class FilterDialog(gtk.Dialog):
Change 1 of 1 Show Entire File hggtk/​merge.py Stacked
 
12
13
14
 
15
16
17
18
19
20
 
12
13
14
15
16
17
 
18
19
20
@@ -12,9 +12,9 @@
 from dialog import *  from mercurial.node import *  from mercurial import util, hg, ui +from hglib import RepoError  from hgcmd import CmdDialog  from shlib import set_tortoise_icon, shell_notify -from mercurial.repo import RepoError  import histselect    class MergeDialog(gtk.Window):
Change 1 of 1 Show Entire File hggtk/​recovery.py Stacked
 
17
18
19
20
21
22
 
23
24
 
25
26
27
 
17
18
19
 
 
 
20
21
 
22
23
24
25
@@ -17,11 +17,9 @@
 import Queue  import os  import threading -from mercurial import hg, ui, util -from mercurial.repo import RepoError -from mercurial.node import * +from mercurial import hg, ui, util  from dialog import error_dialog, question_dialog -from hglib import HgThread, toutf +from hglib import HgThread, toutf, RepoError  from shlib import set_tortoise_icon, shell_notify  import gtklib  
 
14
15
16
17
18
19
20
21
22
 
23
24
25
 
14
15
16
 
17
 
18
19
20
21
22
23
24
@@ -14,12 +14,11 @@
 import gobject  import pango  from mercurial import hg, ui, cmdutil, util -from mercurial.repo import RepoError  from mercurial.i18n import _ -from mercurial.node import *  from dialog import error_dialog, question_dialog  from revtree import RevisionTree  from shlib import set_tortoise_icon +from hglib import RepoError    class RevisionDialog(gtk.Dialog):   def __init__(self, root=''):
Change 1 of 2 Show Entire File hggtk/​serve.py Stacked
 
24
25
26
27
28
29
30
 
124
125
126
127
 
128
129
130
 
24
25
26
 
27
28
29
 
123
124
125
 
126
127
128
129
@@ -24,7 +24,6 @@
 import hglib  from dialog import question_dialog, error_dialog  from mercurial import hg, ui, commands, cmdutil, util -from mercurial.repo import RepoError  from mercurial.hgweb import server  from mercurial.i18n import _  from shlib import set_tortoise_icon @@ -124,7 +123,7 @@
  def _get_config(self):   try:   repo = hg.repository(ui.ui(), path=self._root) - except RepoError: + except hglib.RepoError:   print 'no repository found'   gtk.main_quit()   self.defport = repo.ui.config('web', 'port') or '8000'
Change 1 of 1 Show Entire File hggtk/​status.py Stacked
 
15
16
17
18
19
20
21
 
15
16
17
 
18
19
20
@@ -15,7 +15,6 @@
 import pango    from mercurial.i18n import _ -from mercurial.node import *  from mercurial import cmdutil, util, ui, hg, commands, patch, mdiff  from mercurial import merge as merge_  from shlib import shell_notify
Change 1 of 1 Show Entire File hggtk/​synch.py Stacked
 
18
19
20
21
22
23
 
24
25
26
 
18
19
20
 
21
 
22
23
24
25
@@ -18,9 +18,8 @@
 import os  import threading  from mercurial import hg, ui, util, extensions -from mercurial.repo import RepoError  from dialog import error_dialog, question_dialog, info_dialog -from hglib import HgThread, toutf, rootpath +from hglib import HgThread, toutf, rootpath, RepoError  import shlib  import gtklib  import urllib
Change 1 of 1 Show Entire File hggtk/​tagadd.py Stacked
 
15
16
17
18
19
20
 
 
21
22
23
 
15
16
17
 
18
 
19
20
21
22
23
@@ -15,9 +15,9 @@
 import gtk  from dialog import question_dialog, error_dialog, info_dialog  from mercurial import hg, ui, cmdutil, util -from mercurial.repo import RepoError  from mercurial.i18n import _ -from mercurial.node import * +from mercurial.node import short +from hglib import RepoError    class TagAddDialog(gtk.Window):   """ Dialog to add tag to Mercurial repo """
Change 1 of 1 Show Entire File hggtk/​tags.py Stacked
 
14
15
16
17
18
 
19
20
21
 
14
15
16
 
17
18
19
20
21
@@ -14,8 +14,8 @@
 import gtk  import gobject  from mercurial import hg, ui, cmdutil, util, node -from mercurial.repo import RepoError  from mercurial.i18n import _ +from hglib import RepoError    def get_tag_list(path):   root = path
 
10
11
12
13
14
 
15
16
17
 
10
11
12
 
13
14
15
16
17
@@ -10,8 +10,8 @@
 import os  import pango  from mercurial import hg, ui, cmdutil, util -from mercurial.repo import RepoError  from dialog import error_dialog, question_dialog +from hglib import RepoError  import shlib  import shelve  import iniparse
Change 1 of 1 Show Entire File hggtk/​update.py Stacked
 
11
12
13
 
14
15
16
17
18
 
19
20
21
 
11
12
13
14
15
 
 
16
 
17
18
19
20
@@ -11,11 +11,10 @@
 import sys  import gtk  from dialog import * +from mercurial import util, hg, ui  from mercurial.node import * -from mercurial import util, hg, ui -from mercurial.repo import RepoError  from shlib import shell_notify, set_tortoise_icon -from hglib import rootpath +from hglib import rootpath, RepoError    class UpdateDialog(gtk.Window):   """ Dialog to update Mercurial repo """