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

hglib: remove errors from hglib, import directly from mercurial.error

While doing this sweep through the code, I actually fixed a few bugs in the
importing of errors. mercurial.error has been in place since 1.3, so it's now
safe to remove these shims from hglib.py

Changeset 010080f4f72b

Parent 409e8380d224

by Steve Borho

Changes to 31 files · Browse files at 010080f4f72b Showing diff from parent 409e8380d224 Diff from another changeset...

 
25
26
27
28
 
29
30
31
 
40
41
42
43
 
44
45
46
 
107
108
109
110
 
111
112
113
 
25
26
27
 
28
29
30
31
 
40
41
42
 
43
44
45
46
 
107
108
109
 
110
111
112
113
@@ -25,7 +25,7 @@
 import subprocess  import urllib   -from mercurial import hg, ui, match, util +from mercurial import hg, ui, match, util, error  from mercurial.node import short    def _thg_path(): @@ -40,7 +40,7 @@
  sys.path.insert(0, thgpath)  _thg_path()   -from tortoisehg.util import paths, debugthg, hglib, cachethg +from tortoisehg.util import paths, debugthg, cachethg  from tortoisehg.hgtk import gtklib    if debugthg.debug('N'): @@ -107,7 +107,7 @@
  return None   try:   return hg.repository(ui.ui(), path=p) - except hglib.RepoError: + except error.RepoError:   return None   except StandardError, e:   debugf(e)
 
10
11
12
13
 
14
15
16
 
39
40
41
42
 
43
44
45
 
176
177
178
179
 
180
181
182
 
10
11
12
 
13
14
15
16
 
39
40
41
 
42
43
44
45
 
176
177
178
 
179
180
181
182
@@ -10,7 +10,7 @@
 import gobject  import pango   -from mercurial import hg, ui +from mercurial import hg, ui, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, paths @@ -39,7 +39,7 @@
    try:   repo = hg.repository(ui.ui(), path=paths.find_root()) - except hglib.RepoError: + except error.RepoError:   gtklib.idle_add_single_call(self.destroy)   return   self.repo = repo @@ -176,7 +176,7 @@
  else:   try:   self.repo[text] - except (hglib.RepoError, hglib.LookupError): + except (error.RepoError, error.LookupError):   return   if path is None:   path = self.destentry.get_text()
 
10
11
12
13
 
14
15
16
 
43
44
45
46
 
47
48
49
 
10
11
12
 
13
14
15
16
 
43
44
45
 
46
47
48
49
@@ -10,7 +10,7 @@
 import gobject  import pango   -from mercurial import hg, ui +from mercurial import hg, ui, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, paths, i18n, settings @@ -43,7 +43,7 @@
    try:   repo = hg.repository(ui.ui(), path=paths.find_root()) - except hglib.RepoError: + except error.RepoError:   gtklib.idle_add_single_call(self.destroy)   return  
 
14
15
16
17
18
19
20
 
14
15
16
 
17
18
19
@@ -14,7 +14,6 @@
   from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, paths, shlib, menuthg -from tortoisehg.util.hglib import RepoError    from tortoisehg.hgtk import hgcmd, gtklib, gdialog  
 
12
13
14
15
 
16
17
18
 
303
304
305
306
 
307
308
309
 
315
316
317
318
 
319
320
321
 
514
515
516
517
 
518
519
520
 
808
809
810
811
 
812
813
814
 
842
843
844
845
 
846
847
848
 
12
13
14
 
15
16
17
18
 
303
304
305
 
306
307
308
309
 
315
316
317
 
318
319
320
321
 
514
515
516
 
517
518
519
520
 
808
809
810
 
811
812
813
814
 
842
843
844
 
845
846
847
848
@@ -12,7 +12,7 @@
 import pango  import Queue   -from mercurial import cmdutil, util, patch, mdiff +from mercurial import cmdutil, util, patch, mdiff, error    from tortoisehg.util.i18n import _  from tortoisehg.util import shlib, hglib, paths @@ -303,7 +303,7 @@
    try:   fctx = self.repo[rev].filectx(wfile) - except hglib.LookupError: + except error.LookupError:   fctx = None   if fctx and fctx.size() > hglib.getmaxdiffsize(self.repo.ui):   lines = ['diff', @@ -315,7 +315,7 @@
  try:   for s in patch.diff(self.repo, n1, n2, match=m, opts=opts):   lines.extend(s.splitlines()) - except (hglib.RepoLookupError, hglib.RepoError, hglib.LookupError), e: + except (error.RepoLookupError, error.RepoError, error.LookupError), e:   err = _('Repository Error: %s, refresh suggested') % str(e)   lines = ['diff', '', err]   tags, lines = self.prepare_diff(lines, offset, wfile) @@ -514,7 +514,7 @@
  try:   tctx = self.repo[ts]   return revline_data(tctx) - except (hglib.LookupError, hglib.RepoLookupError, hglib.RepoError): + except (error.LookupError, error.RepoLookupError, error.RepoError):   return ts   elif item == 'patch':   if hasattr(ctx, '_patchname'): @@ -808,7 +808,7 @@
  self.graphview.set_revision_id(rev, load=True)   else:   self.load_details(rev) - except hglib.RepoError: + except error.RepoError:   pass     def get_link_text(self, tag, widget, liter): @@ -842,7 +842,7 @@
  try:   fctx = ctx.filectx(self.curfile)   has_filelog = fctx.filelog().linkrev(fctx.filerev()) == ctx.rev() - except hglib.LookupError: + except error.LookupError:   has_filelog = False   self.ann_menu.set_sensitive(has_filelog)   self.save_menu.set_sensitive(has_filelog)
 
12
13
14
15
 
16
17
18
 
113
114
115
116
 
117
118
119
 
165
166
167
168
 
169
170
171
 
12
13
14
 
15
16
17
18
 
113
114
115
 
116
117
118
119
 
165
166
167
 
168
169
170
171
@@ -12,7 +12,7 @@
 import gtk  import binascii   -from mercurial import patch, util +from mercurial import patch, util, error  from mercurial.node import short, hex    from tortoisehg.util.i18n import _ @@ -113,7 +113,7 @@
  return None   try:   ctx = repo[rev] - except (hglib.LookupError, hglib.RepoLookupError, hglib.RepoError): + except (error.LookupError, error.RepoLookupError, error.RepoError):   ctx = None   return ctx   @@ -165,7 +165,7 @@
  continue   try:   self._parents.append(repo[p]) - except (hglib.LookupError, hglib.RepoLookupError, hglib.RepoError): + except (error.LookupError, error.RepoLookupError, error.RepoError):   self._parents.append(p)     def __str__(self):
 
13
14
15
16
 
17
18
19
 
191
192
193
194
 
195
196
197
 
208
209
210
211
 
212
213
214
 
453
454
455
456
 
457
458
459
 
580
581
582
583
 
584
585
586
 
752
753
754
755
 
756
757
758
 
13
14
15
 
16
17
18
19
 
191
192
193
 
194
195
196
197
 
208
209
210
 
211
212
213
214
 
453
454
455
 
456
457
458
459
 
580
581
582
 
583
584
585
586
 
752
753
754
 
755
756
757
758
@@ -13,7 +13,7 @@
 import threading  import re   -from mercurial import util +from mercurial import util, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, thread2 @@ -191,7 +191,7 @@
  parent_ctx = self.repo[parent_revid]   try:   parent_ctx.filectx(filepath) - except LookupError: + except error.LookupError:   # file was renamed/moved, try to find previous file path   end_iter = iter   path = graphview.get_path_at_revid(int(anotrev)) @@ -208,7 +208,7 @@
  if renamed:   filepath = renamed[0]   break - except LookupError: + except error.LookupError:   # break iteration, but don't use 'break' statement   # so that execute 'else' block for showing prompt.   iter = end_iter @@ -453,7 +453,7 @@
  def threadfunc(q, *args):   try:   hglib.hgcmd_toq(q, *args) - except (util.Abort, hglib.LookupError), e: + except (util.Abort, error.LookupError), e:   self.stbar.set_status_text(_('Abort: %s') % str(e))     thread = thread2.Thread(target=threadfunc, args=args) @@ -580,7 +580,7 @@
  ctx = self.repo.parents()[0]   try:   fctx = ctx.filectx(path) - except LookupError: + except error.LookupError:   gdialog.Prompt(_('File is unrevisioned'),   _('Unable to annotate ') + path, self).run()   return @@ -752,7 +752,7 @@
  def threadfunc(q, *args):   try:   hglib.hgcmd_toq(q, *args) - except (util.Abort, hglib.LookupError), e: + except (util.Abort, error.LookupError), e:   self.stbar.set_status_text(_('Abort: %s') % str(e))     (frame, treeview, origpath, graphview) = objs
 
9
10
11
12
 
 
13
14
15
 
54
55
56
57
 
58
59
60
61
 
62
63
64
 
9
10
11
 
12
13
14
15
16
 
55
56
57
 
58
59
60
61
 
62
63
64
65
@@ -9,7 +9,8 @@
 import os  import gtk  import gobject -import mercurial + +from mercurial import error    from tortoisehg.util.i18n import _  from tortoisehg.hgtk import gtklib, gdialog @@ -54,11 +55,11 @@
  self.gotofunc(revision)   self.revEntry.set_text('')   self.hide() - except mercurial.error.LookupError, e: + except error.LookupError, e:   gdialog.Prompt(_('Ambiguous Revision'), str(e), self).run()   self.revEntry.grab_focus()   return - except mercurial.error.RepoError, e: + except error.RepoError, e:   gdialog.Prompt(_('Invalid Revision'), str(e), self).run()   self.revEntry.grab_focus()   return
 
13
14
15
16
 
17
18
19
 
44
45
46
47
 
48
49
50
 
13
14
15
 
16
17
18
19
 
44
45
46
 
47
48
49
50
@@ -13,7 +13,7 @@
 import cStringIO  import Queue   -from mercurial import hg, ui, mdiff, cmdutil, match, util +from mercurial import hg, ui, mdiff, cmdutil, match, util, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, shlib, paths, thread2, settings @@ -44,7 +44,7 @@
    try:   repo = hg.repository(ui.ui(), path=paths.find_root()) - except hglib.RepoError: + except error.RepoError:   gtklib.idle_add_single_call(self.destroy)   return   self.repo = repo
 
13
14
15
16
 
17
18
19
 
232
233
234
235
 
236
237
238
 
13
14
15
 
16
17
18
19
 
232
233
234
 
235
236
237
238
@@ -13,7 +13,7 @@
 import pango  import tempfile   -from mercurial import hg, ui, extensions +from mercurial import hg, ui, extensions, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, settings @@ -232,7 +232,7 @@
  try:   repo = hg.repository(ui.ui(), path=self.root)   self.repo = repo - except hglib.RepoError: + except error.RepoError:   self.repo = None   return  
 
10
11
12
13
 
14
15
16
 
28
29
30
31
 
32
33
34
 
10
11
12
 
13
14
15
16
 
28
29
30
 
31
32
33
34
@@ -10,7 +10,7 @@
 import gobject  import re   -from mercurial import hg, ui, match, util +from mercurial import hg, ui, match, util, error    from tortoisehg.util.i18n import _  from tortoisehg.util import shlib, hglib, paths @@ -28,7 +28,7 @@
    try:   repo = hg.repository(ui.ui(), path=paths.find_root()) - except hglib.RepoError: + except error.RepoError:   gtklib.idle_add_single_call(self.destroy)   return   self.repo = repo
 
8
9
10
11
 
12
13
14
 
110
111
112
113
 
114
115
116
 
8
9
10
 
11
12
13
14
 
110
111
112
 
113
114
115
116
@@ -8,7 +8,7 @@
 import os  import gtk   -from mercurial import hg, ui, util +from mercurial import hg, ui, util, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, shlib @@ -110,7 +110,7 @@
    try:   hg.repository(u, dest, create=1) - except hglib.RepoError, inst: + except error.RepoError, inst:   dialog.error_dialog(self, _('Unable to create new repository'),   hglib.toutf(str(inst)))   return False
 
10
11
12
13
 
14
15
16
 
169
170
171
172
 
173
174
175
 
10
11
12
 
13
14
15
16
 
169
170
171
 
172
173
174
175
@@ -10,7 +10,7 @@
 import time  import urllib2   -from mercurial import ui, util +from mercurial import ui, util, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, thread2 @@ -169,7 +169,7 @@
  self.postfunc(ret)   except util.Abort, e:   self.ui.write_err(_('abort: ') + str(e) + '\n') - except (hglib.RepoError, urllib2.HTTPError), e: + except (error.RepoError, urllib2.HTTPError), e:   self.ui.write_err(str(e) + '\n')   except (Exception, OSError, IOError), e:   self.ui.write_err(str(e) + '\n')
 
20
21
22
23
 
24
25
26
 
141
142
143
144
 
145
146
147
 
164
165
166
167
 
168
169
170
 
185
186
187
188
 
189
190
191
192
193
194
195
 
196
197
198
 
199
200
201
 
202
203
204
 
246
247
248
249
 
250
251
252
 
256
257
258
259
 
260
261
262
 
399
400
401
402
 
403
404
405
 
477
478
479
480
 
481
482
483
 
546
547
548
549
 
550
551
552
 
564
565
566
567
 
568
569
570
 
20
21
22
 
23
24
25
26
 
141
142
143
 
144
145
146
147
 
164
165
166
 
167
168
169
170
 
185
186
187
 
188
189
190
191
192
193
194
 
195
196
197
 
198
199
200
 
201
202
203
204
 
246
247
248
 
249
250
251
252
 
256
257
258
 
259
260
261
262
 
399
400
401
 
402
403
404
405
 
477
478
479
 
480
481
482
483
 
546
547
548
 
549
550
551
552
 
564
565
566
 
567
568
569
570
@@ -20,7 +20,7 @@
 import gobject    import mercurial.ui as _ui -from mercurial import hg, util, fancyopts, cmdutil, extensions +from mercurial import hg, util, fancyopts, cmdutil, extensions, error    from tortoisehg.util.i18n import agettext as _  from tortoisehg.util import hglib, paths, shlib @@ -141,7 +141,7 @@
  try:   args = fancyopts.fancyopts(args, globalopts, options)   except fancyopts.getopt.GetoptError, inst: - raise hglib.ParseError(None, inst) + raise error.ParseError(None, inst)     if args:   alias, args = args[0], args[1:] @@ -164,7 +164,7 @@
  try:   args = fancyopts.fancyopts(args, c, cmdoptions)   except fancyopts.getopt.GetoptError, inst: - raise hglib.ParseError(cmd, inst) + raise error.ParseError(cmd, inst)     # separate global options back out   for o in globalopts: @@ -185,20 +185,20 @@
  return runcommand(ui, args)   finally:   ui.flush() - except hglib.ParseError, inst: + except error.ParseError, inst:   if inst.args[0]:   ui.status(_("hgtk %s: %s\n") % (inst.args[0], inst.args[1]))   help_(ui, inst.args[0])   else:   ui.status(_("hgtk: %s\n") % inst.args[1])   help_(ui, 'shortlist') - except hglib.AmbiguousCommand, inst: + except error.AmbiguousCommand, inst:   ui.status(_("hgtk: command '%s' is ambiguous:\n %s\n") %   (inst.args[0], " ".join(inst.args[1]))) - except hglib.UnknownCommand, inst: + except error.UnknownCommand, inst:   ui.status(_("hgtk: unknown command '%s'\n") % inst.args[0])   help_(ui, 'shortlist') - except hglib.RepoError, inst: + except error.RepoError, inst:   ui.status(_("abort: %s!\n") % inst)     return -1 @@ -246,7 +246,7 @@
  ui.quiet = True     if cmd not in nonrepo_commands.split() and not path: - raise hglib.RepoError(_("There is no Mercurial repository here" + raise error.RepoError(_("There is no Mercurial repository here"   " (.hg not found)"))     try: @@ -256,7 +256,7 @@
  tb = traceback.extract_tb(sys.exc_info()[2])   if len(tb) != 1: # no   raise - raise hglib.ParseError(cmd, _("invalid arguments")) + raise error.ParseError(cmd, _("invalid arguments"))    mainwindow = None  def thgexit(win): @@ -399,7 +399,7 @@
  """web server"""   from tortoisehg.hgtk.serve import run   if paths.find_root() == None and not opts['webdir_conf']: - raise hglib.RepoError(_("There is no Mercurial repository here" + raise error.RepoError(_("There is no Mercurial repository here"   " (.hg not found)"))   gtkrun(run, ui, *pats, **opts)   @@ -477,7 +477,7 @@
    try:   aliases, i = cmdutil.findcmd(name, table, False) - except hglib.AmbiguousCommand, inst: + except error.AmbiguousCommand, inst:   select = lambda c: c.lstrip('^').startswith(inst.args[0])   helplist(_('list of commands:\n\n'), select)   return @@ -546,7 +546,7 @@
  if name in names:   break   else: - raise hglib.UnknownCommand(name) + raise error.UnknownCommand(name)     # description   if not doc: @@ -564,7 +564,7 @@
  f(name)   i = None   break - except hglib.UnknownCommand, inst: + except error.UnknownCommand, inst:   i = inst   if i:   raise i
 
15
16
17
18
 
19
20
21
 
2055
2056
2057
2058
 
2059
2060
2061
 
15
16
17
 
18
19
20
21
 
2055
2056
2057
 
2058
2059
2060
2061
@@ -15,7 +15,7 @@
 import atexit    from mercurial import ui, hg, cmdutil, commands, extensions, util, match, url -from mercurial import hbisect +from mercurial import hbisect, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib @@ -2055,7 +2055,7 @@
  parent = self.repo[rev].parents()[0].rev()   # Special case for revision 0's parent.   if parent == -1: parent = 'null' - except (ValueError, hglib.LookupError): + except (ValueError, error.LookupError):   return   filename = "%s_rev%d_to_tip.hg" % (os.path.basename(self.repo.root), rev)   result = gtklib.NativeSaveFileDialogWrapper(title=_('Write bundle to'),
 
18
19
20
21
 
22
23
24
 
263
264
265
266
 
267
268
269
 
18
19
20
 
21
22
23
24
 
263
264
265
 
266
267
268
269
@@ -18,7 +18,7 @@
 import gobject  import re   -from mercurial import util, templatefilters +from mercurial import util, error  from tortoisehg.util import hglib  from tortoisehg.hgtk import gtklib   @@ -263,7 +263,7 @@
  self.author_pats.append((re.compile(pat, re.I), v))   try:   enabled = self.repo.ui.configbool('tortoisehg', 'authorcolor') - except hglib.ConfigError: + except error.ConfigError:   enabled = False   if self.author_pats or enabled:   self.color_func = self.text_color_author
 
10
11
12
13
 
14
15
16
 
38
39
40
41
 
42
43
44
 
10
11
12
 
13
14
15
16
 
38
39
40
 
41
42
43
44
@@ -10,7 +10,7 @@
 import gtk  import gobject   -from mercurial import hg, ui, commands +from mercurial import hg, ui, commands, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, paths @@ -38,7 +38,7 @@
    try:   repo = hg.repository(ui.ui(), path=paths.find_root()) - except hglib.RepoError: + except error.RepoError:   gtklib.idle_add_single_call(self.destroy)   return   self.set_title(_('Merging in %s') % hglib.get_reponame(repo))
 
10
11
12
13
 
14
15
16
17
18
19
20
 
34
35
36
37
 
38
39
40
 
10
11
12
 
13
14
15
16
 
17
18
19
 
33
34
35
 
36
37
38
39
@@ -10,11 +10,10 @@
 import gobject  import pango   -from mercurial import hg, ui, cmdutil +from mercurial import hg, ui, cmdutil, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, paths, shlib -from tortoisehg.util.hglib import RepoError    from tortoisehg.hgtk import hgcmd, gtklib, gdialog   @@ -34,7 +33,7 @@
    try:   repo = hg.repository(ui.ui(), path=paths.find_root()) - except hglib.RepoError: + except error.RepoError:   gtklib.idle_add_single_call(self.destroy)   return  
 
13
14
15
16
 
17
18
19
 
32
33
34
35
 
36
37
38
 
13
14
15
 
16
17
18
19
 
32
33
34
 
35
36
37
38
@@ -13,7 +13,7 @@
 import os  import time   -from mercurial import hg, ui +from mercurial import hg, ui, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, shlib, paths @@ -32,7 +32,7 @@
    try:   repo = hg.repository(ui.ui(), path=paths.find_root()) - except hglib.RepoError: + except error.RepoError:   gtklib.idle_add_single_call(self.destroy)   return   self.repo = repo
 
11
12
13
14
 
15
16
17
 
47
48
49
50
 
51
52
53
 
72
73
74
75
 
76
77
78
 
11
12
13
 
14
15
16
17
 
47
48
49
 
50
51
52
53
 
72
73
74
 
75
76
77
78
@@ -11,7 +11,7 @@
 import cStringIO  import shutil   -from mercurial import hg, ui, util, commands +from mercurial import hg, ui, util, commands, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, paths @@ -47,7 +47,7 @@
  try:   root = paths.find_root()   repo = hg.repository(ui.ui(), root) - except (ImportError, hglib.RepoError): + except (ImportError, error.RepoError):   dlg.destroy()   return   @@ -72,7 +72,7 @@
  shutil.move(dlg.orig, new_name)   commands.rename(repo.ui, repo, dlg.orig, new_name, **opts)   toquit = True - except (OSError, IOError, util.Abort, hglib.RepoError), inst: + except (OSError, IOError, util.Abort, error.RepoError), inst:   dialog.error_dialog(None, _('rename error'), str(inst))   toquit = False   finally:
 
17
18
19
20
 
21
22
23
 
113
114
115
116
 
117
118
119
 
17
18
19
 
20
21
22
23
 
113
114
115
 
116
117
118
119
@@ -17,7 +17,7 @@
 import threading  import time   -from mercurial import hg, ui, commands, cmdutil, util +from mercurial import hg, ui, commands, cmdutil, util, error  from mercurial.hgweb import server    from tortoisehg.util.i18n import _ @@ -113,7 +113,7 @@
  if self._root:   try:   repo = hg.repository(ui.ui(), path=self._root) - except hglib.RepoError: + except error.RepoError:   self.destroy()   self.defport = repo.ui.config('web', 'port') or '8000'   self.webname = repo.ui.config('web', 'name') or \
 
15
16
17
18
 
19
20
21
 
1062
1063
1064
1065
 
1066
1067
1068
 
15
16
17
 
18
19
20
21
 
1062
1063
1064
 
1065
1066
1067
1068
@@ -15,7 +15,7 @@
 import pango  import threading   -from mercurial import cmdutil, util, commands, patch, mdiff +from mercurial import cmdutil, util, commands, patch, mdiff, error  from mercurial import merge as merge_    from tortoisehg.util.i18n import _ @@ -1062,7 +1062,7 @@
  try:   pfile = util.pconvert(wfile)   fctx = ctx.filectx(pfile) - except hglib.LookupError: + except error.LookupError:   fctx = None   if fctx and fctx.size() > hglib.getmaxdiffsize(self.repo.ui):   # Fake patch that displays size warning
 
15
16
17
18
 
19
20
21
 
329
330
331
332
 
333
334
335
 
367
368
369
370
 
371
372
373
 
15
16
17
 
18
19
20
21
 
329
330
331
 
332
333
334
335
 
367
368
369
 
370
371
372
373
@@ -15,7 +15,7 @@
 import threading  import urllib   -from mercurial import hg, ui, extensions, url +from mercurial import hg, ui, extensions, url, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, settings, paths @@ -329,7 +329,7 @@
  try:   # open a new repo, rebase can confuse cached repo   repo = hg.repository(ui.ui(), path=self.root) - except hglib.RepoError: + except error.RepoError:   return     wc = repo[None] @@ -367,7 +367,7 @@
  raise _("unknown sort key '%s'") % sort   uipaths.sort(sortfunc)   return uipaths - except hglib.RepoError: + except error.RepoError:   return None     def btn_remotepath_clicked(self, button):
 
12
13
14
15
 
16
17
18
 
535
536
537
538
 
539
540
541
 
12
13
14
 
15
16
17
18
 
535
536
537
 
538
539
540
541
@@ -12,7 +12,7 @@
 import urlparse  import threading   -from mercurial import hg, ui, util, url, filemerge +from mercurial import hg, ui, util, url, filemerge, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, settings, paths @@ -535,7 +535,7 @@
  else:   repo = None   self.root = root - except hglib.RepoError: + except error.RepoError:   repo = None   if configrepo:   dialog.error_dialog(self, _('No repository found'),
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
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
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
 
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
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
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
 
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
 # thgmq.py - embeddable widget for MQ extension  #  # Copyright 2009 Yuki KODAMA <endflow.net@gmail.com>  #  # 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  import gtk  import gtk.keysyms  import gobject  import pango   -from mercurial import extensions +from mercurial import extensions, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib    from tortoisehg.hgtk import gdialog, gtklib, hgcmd    # MQ patches row enumerations  MQ_INDEX = 0  MQ_STATUS = 1  MQ_NAME = 2  MQ_SUMMARY = 3  MQ_ESCAPED = 4    # Special patch indices  INDEX_SEPARATOR = -1  INDEX_QPARENT = -2    class MQWidget(gtk.VBox):     __gproperties__ = {   'index-column-visible': (gobject.TYPE_BOOLEAN,   'Index',   'Show index column',   False,   gobject.PARAM_READWRITE),   'status-column-visible': (gobject.TYPE_BOOLEAN,   'Status',   'Show status column',   False,   gobject.PARAM_READWRITE),   'name-column-visible': (gobject.TYPE_BOOLEAN,   'Name',   'Show name column',   False,   gobject.PARAM_READWRITE),   'summary-column-visible': (gobject.TYPE_BOOLEAN,   'Summary',   'Show summary column',   False,   gobject.PARAM_READWRITE),   'editable-cell': (gobject.TYPE_BOOLEAN,   'EditableCell',   'Enable editable cells',   False,   gobject.PARAM_READWRITE),   'show-qparent': (gobject.TYPE_BOOLEAN,   'ShowQParent',   "Show 'qparent'",   False,   gobject.PARAM_READWRITE)   }     __gsignals__ = {   'repo-invalidated': (gobject.SIGNAL_RUN_FIRST,   gobject.TYPE_NONE,   ()),   'patch-selected': (gobject.SIGNAL_RUN_FIRST,   gobject.TYPE_NONE,   (int, # revision number   str)) # patch name   }     def __init__(self, repo, statusbar, accelgroup=None, tooltips=None):   gtk.VBox.__init__(self)     self.repo = repo   self.mqloaded = hasattr(repo, 'mq')   self.statusbar = statusbar     try:   extensions.find('qup')   self.hasqup = True   except KeyError:   self.hasqup = False     # top toolbar   tbar = gtklib.SlimToolbar(tooltips)     ## buttons   self.btn = {}   popallbtn = tbar.append_stock(gtk.STOCK_GOTO_FIRST,   _('Unapply all patches'))   popallbtn.connect('clicked', self.popall_clicked)   self.btn['popall'] = popallbtn     popbtn = tbar.append_stock(gtk.STOCK_GO_BACK,   _('Unapply last patch'))   popbtn.connect('clicked', self.pop_clicked)   self.btn['pop'] = popbtn     pushbtn = gtk.ToolButton(gtk.STOCK_GO_FORWARD)   pushbtn = tbar.append_stock(gtk.STOCK_GO_FORWARD,   _('Apply next patch'))   pushbtn.connect('clicked', self.push_clicked)   self.btn['push'] = pushbtn     pushallbtn = tbar.append_stock(gtk.STOCK_GOTO_LAST,   _('Apply all patches'))   pushallbtn.connect('clicked', self.pushall_clicked)   self.btn['pushall'] = pushallbtn     ## separator   tbar.append_space()     ## drop-down menu   menubtn = gtk.MenuToolButton('')   menubtn.set_menu(self.create_view_menu())   tbar.append_widget(menubtn, padding=0)   self.btn['menu'] = menubtn   def after_init():   menubtn.child.get_children()[0].hide()   gtklib.idle_add_single_call(after_init)   self.pack_start(tbar, False, False)     # center pane   mainbox = gtk.VBox()   self.pack_start(mainbox, True, True)     ## scrolled pane   pane = gtk.ScrolledWindow()   pane.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   pane.set_shadow_type(gtk.SHADOW_IN)   mainbox.pack_start(pane)     ### patch list   self.model = gtk.ListStore(int, # patch index   str, # patch status   str, # patch name   str, # summary (utf-8)   str) # escaped summary (utf-8)   self.list = gtk.TreeView(self.model)   self.list.set_row_separator_func(self.row_sep_func)   # To support old PyGTK (<2.12)   if hasattr(self.list, 'set_tooltip_column'):   self.list.set_tooltip_column(MQ_ESCAPED)   self.list.connect('cursor-changed', self.list_sel_changed)   self.list.connect('button-press-event', self.list_pressed)   self.list.connect('row-activated', self.list_row_activated)   self.list.connect('size-allocate', self.list_size_allocated)     self.cols = {}   self.cells = {}     def addcol(header, col_idx, right=False, resizable=False,   editable=False, editfunc=None):   header = (right and '%s ' or ' %s') % header   cell = gtk.CellRendererText()   if editfunc:   cell.set_property('editable', editable)   cell.connect('edited', editfunc)   col = gtk.TreeViewColumn(header, cell)   col.add_attribute(cell, 'text', col_idx)   col.set_cell_data_func(cell, self.cell_data_func)   col.set_resizable(resizable)   col.set_visible(self.get_property(self.col_to_prop(col_idx)))   if right:   col.set_alignment(1)   cell.set_property('xalign', 1)   self.list.append_column(col)   self.cols[col_idx] = col   self.cells[col_idx] = cell     def cell_edited(cell, path, newname):   row = self.model[path]   if row[MQ_INDEX] < 0:   return   patchname = row[MQ_NAME]   if newname != patchname:   self.qrename(newname, patch=patchname)     addcol(_('#'), MQ_INDEX, right=True)   addcol(_('st'), MQ_STATUS)   addcol(_('Patch'), MQ_NAME, editfunc=cell_edited)   addcol(_('Summary'), MQ_SUMMARY, resizable=True)     pane.add(self.list)     ## command widget   self.cmd = hgcmd.CmdWidget(style=hgcmd.STYLE_COMPACT,   tooltips=tooltips)   mainbox.pack_start(self.cmd, False, False)     # accelerators   if accelgroup:     key, mod = gtk.accelerator_parse('F2')   self.list.add_accelerator('thg-rename', accelgroup,   key, mod, gtk.ACCEL_VISIBLE)   def thgrename(list):   sel = self.list.get_selection()   if sel.count_selected_rows() == 1:   model, paths = sel.get_selected_rows()   self.qrename_ui(model[paths[0]][MQ_NAME])   self.list.connect('thg-rename', thgrename)     mod = gtk.gdk.CONTROL_MASK     def mq_move(tree, key):   oldrow = tree.get_cursor()[0][0]   minval = self.separator_pos + 1   if oldrow < minval:   return True   maxval = len(self.model) - 1   if key == gtk.keysyms.Up:   newrow = oldrow - 1   elif key == gtk.keysyms.Down:   newrow = oldrow + 1   elif key == gtk.keysyms.Page_Up:   newrow = minval   elif key == gtk.keysyms.Page_Down:   newrow = maxval   else:   return True   if newrow != oldrow and newrow >= minval and newrow <= maxval:   self.move_patch(oldrow, newrow)   return True     def add(name, key, hook=None):   self.list.add_accelerator(name, accelgroup, key, mod, 0)   if hook:   self.list.connect(name, hook)   else:   self.list.connect(name, mq_move, key)     add('mq-move-up', gtk.keysyms.Up)   add('mq-move-down', gtk.keysyms.Down)   add('mq-move-top', gtk.keysyms.Page_Up)   add('mq-move-bottom', gtk.keysyms.Page_Down)   add('mq-pop', gtk.keysyms.Left, lambda _: self.qpop())   add('mq-push', gtk.keysyms.Right, lambda _: self.qpush())     def move_patch(self, oldidx, newidx):     def list_move_item(list, oldpos, newpos):   olditem = list[oldpos]   del list[oldpos]   list.insert(newpos, olditem)     # Update series   p = self.repo.mq   model = self.model   oldrow = model[oldidx]   newrow = model[newidx]   list_move_item(p.full_series, p.find_series(oldrow[MQ_NAME]),   p.find_series(newrow[MQ_NAME]))   p.series_dirty = True   p.save_dirty()     # Update TreeView   if newidx < oldidx:   model.move_before(oldrow.iter, newrow.iter)   else:   model.move_after(oldrow.iter, newrow.iter)   begin = min(oldidx, newidx)   offset = min(oldrow[MQ_INDEX], newrow[MQ_INDEX]) - begin   for i in xrange(begin, max(oldidx, newidx) + 1):   model[i][MQ_INDEX] = i + offset       ### public functions ###     def refresh(self):   """   Refresh the list of patches.   This operation will try to keep selection state.   """   if not self.mqloaded:   return     # store selected patch name   selname = None   model, paths = self.list.get_selection().get_selected_rows()   if len(paths) > 0:   selname = model[paths[0]][MQ_NAME]     # clear model data   self.model.clear()     # insert 'qparent' row   top = None   if self.get_property('show-qparent'):   top = self.model.append((INDEX_QPARENT, None, None, None, None))     # add patches   from hgext import mq   q = self.repo.mq   q.parse_series()   applied = set([p.name for p in q.applied])   for index, patchname in enumerate(q.series):   stat = patchname in applied and 'A' or 'U'   try:   msg = hglib.toutf(mq.patchheader(q.join(patchname)).message[0])   msg_esc = gtklib.markup_escape_text(msg)   except IndexError:   msg = msg_esc = None   iter = self.model.append((index, stat, patchname, msg, msg_esc))   if stat == 'A':   top = iter     # insert separator   if top:   row = self.model.insert_after(top, (INDEX_SEPARATOR, None, None, None, None))   self.separator_pos = self.model.get_path(row)[0]     # restore patch selection   if selname:   iter = self.get_iter_by_patchname(selname)   if iter:   self.list.get_selection().select_iter(iter)     # update UI sensitives   self.update_sensitives()     # report status   status_text = ''   idle_text = None   if self.has_mq():   nser = len(self.repo.mq.series)   if nser:   napp = len(self.repo.mq.applied)   status_text = _('%(count)d of %(total)d Patches applied') % {   'count': napp, 'total': nser}   if napp:   pn = self.get_qtip_patchname()   idle_text = _("Patch '%s' applied") % pn   self.statusbar.set_right3_text(status_text)   self.statusbar.set_idle_text(idle_text)     def set_repo(self, repo):   self.repo = repo     def qgoto(self, patch):   """   [MQ] Execute 'qgoto' command.     patch: the patch name or an index to specify the patch.   """   if not self.is_operable():   return   cmdline = ['hg', 'qgoto', patch]   self.cmd.execute(cmdline, self.cmd_done)     def qpop(self, all=False):   """   [MQ] Execute 'qpop' command.     all: if True, use '--all' option. (default: False)   """   if not self.is_operable():   return   cmdline = ['hg', 'qpop']   if all:   cmdline.append('--all')   self.cmd.execute(cmdline, self.cmd_done)     def qpush(self, all=False):   """   [MQ] Execute 'qpush' command.     all: if True, use '--all' option. (default: False)   """   if not self.is_operable():   return   cmdline = ['hg', 'qpush']   if all:   cmdline.append('--all')   self.cmd.execute(cmdline, self.cmd_done)     def qdelete(self, patch, keep=False):   """   [MQ] Execute 'qdelete' command.     patch: the patch name or an index to specify the patch.   keep: if True, use '--keep' option. (default: False)   """   if not self.has_patch():   return   if not keep:   ret = gdialog.CustomPrompt(_('Confirm Delete'),   _('Do you want to delete?'), None,   (_('&Yes'), _('Yes (&keep)'),   _('&Cancel')), default=2, esc=2).run()   if ret == 0:   pass   elif ret == 1:   keep = True   else:   return   cmdline = ['hg', 'qdelete', patch]   if keep:   cmdline.append('--keep')   self.cmd.execute(cmdline, self.cmd_done, noemit=True)     def qrename(self, name, patch='qtip'):   """   [MQ] Execute 'qrename' command.   If 'patch' param isn't specified, renaming should be applied   'qtip' (current) patch.     name: the new patch name for renaming.   patch: the target patch name or index. (default: 'qtip')   """   if not name or not self.has_patch():   return   cmdline = ['hg', 'qrename', patch, name]   self.cmd.execute(cmdline, self.cmd_done)     def qrename_ui(self, patch='qtip'):   """   Prepare the user interface for renaming the patch.   If 'patch' param isn't specified, renaming should be started   'qtip' (current) patch.     Return True if succeed to prepare; otherwise False.     patch: the target patch name or index. (default: 'qtip')   """   if not self.mqloaded or \   patch == 'qtip' and 'qtip' in self.repo.tags():   return False   target = self.repo.mq.lookup(patch)   if not target:   return False   path = self.get_path_by_patchname(target)   if not path:   return False   # make the cell editable   cell = self.cells[MQ_NAME]   if not cell.get_property('editable'):   cell.set_property('editable', True)   def canceled(cell, *arg):   cell.disconnect(cancel_id)   cell.disconnect(edited_id)   cell.set_property('editable', False)   cancel_id = cell.connect('editing-canceled', canceled)   edited_id = cell.connect('edited', canceled)   # start editing patchname cell   self.list.set_cursor_on_cell(path, self.cols[MQ_NAME], None, True)   return True     def qfinish(self, applied=False):   """   [MQ] Execute 'qfinish' command.     applied: if True, enable '--applied' option. (default: False)   """   if not self.has_applied():   return   cmdline = ['hg', 'qfinish']   if applied:   cmdline.append('--applied')   self.cmd.execute(cmdline, self.cmd_done)     def qfold(self, patch):   """   [MQ] Execute 'qfold' command.     patch: the patch name or an index to specify the patch.   """   if not patch or not self.has_applied():   return   data = dict(target=patch, qtip=self.get_qtip_patchname())   ret = gdialog.Confirm(_('Confirm Fold'), [], None,   _("Do you want to fold un-applied patch '%(target)s'"   " into current patch '%(qtip)s'?") % data).run()   if ret != gtk.RESPONSE_YES:   return   cmdline = ['hg', 'qfold', patch]   self.cmd.execute(cmdline, self.cmd_done)     def mknext(self, patch):   """   [MQ] Execute 'qup patch'     patch: the patch name or an index to specify the patch.   """   if not (self.hasqup and patch and self.is_operable()):   return   cmdline = ['hg', 'qup', patch]   self.cmd.execute(cmdline, self.cmd_done)     def has_mq(self):   return self.mqloaded and os.path.isdir(self.repo.mq.path)     def has_patch(self):   """ return True if MQ has applicable patch """   if self.mqloaded:   return len(self.repo.mq.series) > 0   return False     def has_applied(self):   """ return True if MQ has applied patches """   if self.mqloaded:   return len(self.repo.mq.applied) > 0   return False     def number_applied(self):   """ return the number of applied patches """   if self.mqloaded:   return len(self.repo.mq.applied)   return 0     def is_operable(self):   """ return True if MQ is operable """   if self.mqloaded:   repo = self.repo   if 'qtip' in self.repo.tags():   return repo['.'] == repo['qtip']   return len(repo.mq.series) > 0   return False     def is_qtip(self, patchname):   if patchname:   return patchname == self.get_qtip_patchname()   return False     ### internal functions ###     def get_iter_by_patchname(self, name):   """ return iter has specified patch name """   if name:   for row in self.model:   if row[MQ_NAME] == name:   return row.iter   return None     def get_path_by_patchname(self, name):   """ return path has specified patch name """   return self.model.get_path(self.get_iter_by_patchname(name))     def get_qtip_patchname(self):   if self.mqloaded and 'qtip' in self.repo.tags():   return self.repo.mq.applied[-1].name   return None     def update_sensitives(self):   """ Update the sensitives of entire UI """   def disable_mqmoves():   for name in ('popall', 'pop', 'push', 'pushall'):   self.btn[name].set_sensitive(False)   if self.mqloaded:   self.list.set_sensitive(True)   self.btn['menu'].set_sensitive(True)   if self.is_operable():   q = self.repo.mq   in_bottom = len(q.applied) == 0   in_top = len(q.unapplied(self.repo)) == 0   self.btn['popall'].set_sensitive(not in_bottom)   self.btn['pop'].set_sensitive(not in_bottom)   self.btn['push'].set_sensitive(not in_top)   self.btn['pushall'].set_sensitive(not in_top)   else:   disable_mqmoves()   else:   self.list.set_sensitive(False)   self.btn['menu'].set_sensitive(False)   disable_mqmoves()     def scroll_to_current(self):   """   Scroll to current patch in the patch list.   If the patch is selected, it will do nothing.   """   if self.list.get_selection().count_selected_rows() > 0:   return   qtipname = self.get_qtip_patchname()   if not qtipname:   return   path = self.get_path_by_patchname(qtipname)   if path:   self.list.scroll_to_cell(path)     def cell_data_func(self, column, cell, model, iter):   row = model[iter]     if row[MQ_INDEX] == INDEX_QPARENT:   if column == self.cols[MQ_INDEX]:   cell.set_property('text', '')   elif column == self.cols[MQ_NAME]:   cell.set_property('text', '[qparent]')     stat = row[MQ_STATUS]   if stat == 'A':   cell.set_property('foreground', 'blue')   elif stat == 'U':   cell.set_property('foreground', '#909090')   else:   cell.set_property('foreground', 'black')     patchname = row[MQ_NAME]   if self.is_qtip(patchname):   cell.set_property('weight', pango.WEIGHT_BOLD)   else:   cell.set_property('weight', pango.WEIGHT_NORMAL)     def row_sep_func(self, model, iter, data=None):   return model[iter][MQ_INDEX] == INDEX_SEPARATOR     def show_patch_cmenu(self, list, path):   row = self.model[path]   if row[MQ_INDEX] == INDEX_SEPARATOR:   return     menu = gtk.Menu()   def append(label, handler=None):   item = gtk.MenuItem(label, True)   item.set_border_width(1)   if handler:   item.connect('activate', handler, row)   menu.append(item)     is_operable = self.is_operable()   has_patch = self.has_patch()   has_applied = self.has_applied()   is_qtip = self.is_qtip(row[MQ_NAME])   is_qparent = row[MQ_INDEX] == INDEX_QPARENT   is_applied = row[MQ_STATUS] == 'A'   is_next = row[MQ_INDEX] == self.number_applied()     if is_operable and not is_qtip and (not is_qparent or has_applied):   append(_('_Goto'), self.goto_activated)   if has_patch and not is_qparent:   append(_('_Rename'), self.rename_activated)   if has_applied and not is_qparent:   append(_('_Finish Applied'), self.finish_activated)   if not is_applied and not is_qparent:   append(_('_Delete'), self.delete_activated)   if has_applied and not is_qparent:   append(_('F_old'), self.fold_activated)   if self.hasqup and not is_next:   append(_('Make It _Next'), self.mknext_activated)     if len(menu.get_children()) > 0:   menu.show_all()   menu.popup(None, None, None, 0, 0)     def create_view_menu(self):   menu = gtk.Menu()   def append(item=None, handler=None, check=False,   active=False, sep=False):   if sep:   item = gtk.SeparatorMenuItem()   else:   if isinstance(item, str):   if check:   item = gtk.CheckMenuItem(item)   item.set_active(active)   else:   item = gtk.MenuItem(item)   item.set_border_width(1)   if handler:   item.connect('activate', handler)   menu.append(item)   return item   def colappend(label, col_idx, active=True):   def handler(menuitem):   col = self.cols[col_idx]   col.set_visible(menuitem.get_active())   propname = self.col_to_prop(col_idx)   item = append(label, handler, check=True, active=active)   self.vmenu[propname] = item     self.vmenu = {}     colappend(_('Show Index'), MQ_INDEX)   colappend(_('Show Status'), MQ_STATUS, active=False)   colappend(_('Show Summary'), MQ_SUMMARY, active=False)     append(sep=True)     def enable_editable(item):   self.cells[MQ_NAME].set_property('editable', item.get_active())   item = append(_('Enable editable cells'), enable_editable,   check=True, active=False)   self.vmenu['editable-cell'] = item   item = append(_("Show 'qparent'"), lambda item: self.refresh(),   check=True, active=True)   self.vmenu['show-qparent'] = item     menu.show_all()   return menu     def qgoto_by_row(self, row):   if self.get_qtip_patchname() == row[MQ_NAME]:   return   if row[MQ_INDEX] == INDEX_QPARENT:   self.qpop(all=True)   else:   self.qgoto(row[MQ_NAME])     def cmd_done(self, returncode, useraborted, noemit=False):   if returncode == 0:   if self.cmd.get_pbar():   self.cmd.set_result(_('Succeed'), style='ok')   elif useraborted:   self.cmd.set_result(_('Canceled'), style='error')   else:   self.cmd.set_result(_('Failed'), style='error')   self.repo.mq.invalidate()   self.refresh()   if not noemit:   self.emit('repo-invalidated')     def do_get_property(self, property):   if property.name == 'name-column-visible':   return True   try:   return self.vmenu[property.name].get_active()   except:   raise AttributeError, 'unknown property %s' % property.name     def do_set_property(self, property, value):   try:   self.vmenu[property.name].set_active(value)   except:   raise AttributeError, 'unknown property %s' % property.name     def col_to_prop(self, col_idx):   if col_idx == MQ_INDEX:   return 'index-column-visible'   if col_idx == MQ_STATUS:   return 'status-column-visible'   elif col_idx == MQ_NAME:   return 'name-column-visible'   elif col_idx == MQ_SUMMARY:   return 'summary-column-visible'   return ''     ### signal handlers ###     def list_pressed(self, list, event):   x, y = int(event.x), int(event.y)   pathinfo = list.get_path_at_pos(x, y)   if event.button == 1:   if not pathinfo:   # HACK: clear selection after this function calling,   # against selection by getting focus   def unselect():   selection = list.get_selection()   selection.unselect_all()   gtklib.idle_add_single_call(unselect)   elif event.button == 3:   if pathinfo:   self.show_patch_cmenu(self.list, pathinfo[0])     def list_sel_changed(self, list):   path, focus = list.get_cursor()   row = self.model[path]   if row[MQ_INDEX] < 0:   return   patchname = row[MQ_NAME]   try:   ctx = self.repo[patchname]   revid = ctx.rev() - except hglib.RepoError: + except (error.RepoError, error.RepoLookupError):   revid = -1   self.emit('patch-selected', revid, patchname)     def list_row_activated(self, list, path, column):   self.qgoto_by_row(self.model[path])     def list_size_allocated(self, list, req):   if self.mqloaded and self.has_applied():   self.scroll_to_current()     def popall_clicked(self, toolbutton):   self.qpop(all=True)     def pop_clicked(self, toolbutton):   self.qpop()     def push_clicked(self, toolbutton):   self.qpush()     def pushall_clicked(self, toolbutton):   self.qpush(all=True)     ### context menu signal handlers ###     def goto_activated(self, menuitem, row):   self.qgoto_by_row(row)     def delete_activated(self, menuitem, row):   self.qdelete(row[MQ_NAME])     def rename_activated(self, menuitem, row):   self.qrename_ui(row[MQ_NAME])     def finish_activated(self, menuitem, row):   self.qfinish(applied=True)     def fold_activated(self, menuitem, row):   self.qfold(row[MQ_NAME])     def mknext_activated(self, menuitem, row):   self.mknext(row[MQ_NAME])
 
11
12
13
14
 
15
16
17
 
41
42
43
44
 
45
46
47
 
335
336
337
338
 
339
340
341
 
11
12
13
 
14
15
16
17
 
41
42
43
 
44
45
46
47
 
335
336
337
 
338
339
340
341
@@ -11,7 +11,7 @@
 import gobject  import pango   -from mercurial import hg, ui +from mercurial import hg, ui, error  from mercurial.node import nullrev    from tortoisehg.util.i18n import _ @@ -41,7 +41,7 @@
    try:   repo = hg.repository(ui.ui(), path=paths.find_root()) - except hglib.RepoError: + except error.RepoError:   gtklib.idle_add_single_call(self.destroy)   return   self.repo = repo @@ -335,7 +335,7 @@
  return None   try:   revnum = self.repo[revstr].rev() - except (hglib.RepoError, hglib.LookupError): + except (error.RepoError, error.LookupError):   return None   return revnum  
 
10
11
12
13
 
14
15
16
17
18
19
20
 
34
35
36
37
 
38
39
40
 
182
183
184
185
 
186
187
188
 
10
11
12
 
13
14
15
16
 
17
18
19
 
33
34
35
 
36
37
38
39
 
181
182
183
 
184
185
186
187
@@ -10,11 +10,10 @@
 import gtk  import gobject   -from mercurial import hg, ui +from mercurial import hg, ui, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, paths -from tortoisehg.util.hglib import LookupError, RepoLookupError, RepoError    from tortoisehg.hgtk import csinfo, gtklib, gdialog, hgcmd   @@ -34,7 +33,7 @@
    try:   repo = hg.repository(ui.ui(), path=paths.find_root()) - except hglib.RepoError: + except error.RepoError:   gtklib.idle_add_single_call(self.destroy)   return   self.repo = repo @@ -182,7 +181,7 @@
  else:   self.target_label.update(self.repo[newrev])   self.updatebtn.set_sensitive(True) - except (LookupError, RepoLookupError, RepoError): + except (error.LookupError, error.RepoLookupError, error.RepoError):   self.target_label.set_label(_('unknown revision!'))   self.updatebtn.set_sensitive(False)  
 
14
15
16
17
 
18
19
20
 
96
97
98
99
 
100
101
102
 
368
369
370
371
 
372
373
374
 
14
15
16
 
17
18
19
20
 
96
97
98
 
99
100
101
102
 
368
369
370
 
371
372
373
374
@@ -14,7 +14,7 @@
 import tempfile  import re   -from mercurial import hg, ui, cmdutil, util +from mercurial import hg, ui, cmdutil, util, error  from mercurial.node import short, nullid    from tortoisehg.util.i18n import _ @@ -96,7 +96,7 @@
  try:   path = opts.get('bundle') or paths.find_root()   repo = hg.repository(ui.ui(), path=path) - except hglib.RepoError: + except error.RepoError:   # hgtk should catch this earlier   gdialog.Prompt(_('No repository'),   _('No repository found here'), None).run() @@ -368,7 +368,7 @@
  try:   path = opts.get('bundle') or paths.find_root()   repo = hg.repository(ui, path=path) - except hglib.RepoError: + except error.RepoError:   # hgtk should catch this earlier   ui.warn(_('No repository found here') + '\n')   return
 
8
9
10
11
 
12
13
14
 
188
189
190
191
 
192
193
194
 
8
9
10
 
11
12
13
14
 
188
189
190
 
191
192
193
194
@@ -8,7 +8,7 @@
 import os  import sys   -from mercurial import hg, cmdutil, util, ui, node, merge +from mercurial import hg, cmdutil, util, ui, node, merge, error  import paths  import debugthg  import hglib @@ -188,7 +188,7 @@
  if not repo or (repo.root != root and repo.root != real(root)):   repo = hg.repository(ui.ui(), path=root)   debugf("hg.repository() took %g ticks", (GetTickCount() - tc1)) - except hglib.RepoError: + except error.RepoError:   # We aren't in a working tree   debugf("%s: not in repo", pdir)   add(pdir + '*', IGNORED)
 
11
12
13
14
15
16
17
 
18
19
20
 
11
12
13
 
 
14
15
16
17
18
19
@@ -11,10 +11,9 @@
 import shlib  import time   -from mercurial.error import RepoError, ParseError, LookupError, RepoLookupError -from mercurial.error import UnknownCommand, AmbiguousCommand, ConfigError  from mercurial import hg, ui, util, extensions, commands, hook, match  from mercurial import dispatch, encoding, templatefilters, bundlerepo, url +  _encoding = encoding.encoding  _encodingmode = encoding.encodingmode  _fallbackencoding = encoding.fallbackencoding
 
7
8
9
10
 
11
12
13
 
207
208
209
210
 
211
212
213
 
7
8
9
 
10
11
12
13
 
207
208
209
 
210
211
212
213
@@ -7,7 +7,7 @@
   import os   -from mercurial import hg, ui, node +from mercurial import hg, ui, node, error    from tortoisehg.util.i18n import _ as gettext  from tortoisehg.util import cachethg, paths, hglib @@ -207,7 +207,7 @@
  try:   repo = hg.repository(ui.ui(), path=root)   return repo - except hglib.RepoError: + except error.RepoError:   pass   except StandardError, e:   print "error while opening repo %s:" % path