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'),
 
11
12
13
14
 
15
16
17
 
766
767
768
769
 
770
771
772
 
11
12
13
 
14
15
16
17
 
766
767
768
 
769
770
771
772
@@ -11,7 +11,7 @@
 import gobject  import pango   -from mercurial import extensions +from mercurial import extensions, error    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib @@ -766,7 +766,7 @@
  try:   ctx = self.repo[patchname]   revid = ctx.rev() - except hglib.RepoError: + except (error.RepoError, error.RepoLookupError):   revid = -1   self.emit('patch-selected', revid, patchname)  
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
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
 # thgstrip.py - strip dialog for TortoiseHg  #  # 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 re  import os  import gtk  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 _  from tortoisehg.util import hglib, paths    from tortoisehg.hgtk import csinfo, hgcmd, gtklib, gdialog    MODE_NORMAL = 'normal'  MODE_WORKING = 'working'    class StripDialog(gtk.Dialog):   """ Dialog to strip changesets """     def __init__(self, rev=None, *pats):   """ Initialize the Dialog """   gtk.Dialog.__init__(self)   gtklib.set_tortoise_icon(self, 'menudelete.ico')   gtklib.set_tortoise_keys(self)   self.set_resizable(False)   self.set_has_separator(False)   self.connect('response', self.dialog_response)   self.timeout_queue = []     # buttons   self.stripbtn = self.add_button(_('Strip'), gtk.RESPONSE_OK)   self.closebtn = self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)     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   self.set_title(_('Strip - %s') % hglib.get_reponame(repo))     if len(pats) > 0:   rev = pats[0]   elif rev is None:   rev = 'tip'   rev = str(rev)   self.currev = None   self.curnum = None     # layout table   self.table = table = gtklib.LayoutTable()   self.vbox.pack_start(table, True, True, 2)     ## target revision combo   self.revcombo = gtk.combo_box_entry_new_text()   table.add_row(_('Strip:'), self.revcombo)   reventry = self.revcombo.child   reventry.set_width_chars(32)   reventry.connect('activate', lambda b: self.response(gtk.RESPONSE_OK))     ### fill combo list   self.revcombo.append_text(rev)   self.revcombo.set_active(0)   dblist = repo.ui.config('tortoisehg', 'deadbranch', '')   deadbranches = [ x.strip() for x in dblist.split(',') ]   for name in repo.branchtags().keys():   if name not in deadbranches:   self.revcombo.append_text(name)     tags = list(repo.tags())   tags.sort()   tags.reverse()   for tag in tags:   self.revcombo.append_text(tag)     def createlabel():   label = gtk.Label()   label.set_alignment(0, 0.5)   label.set_size_request(-1, 24)   label.size_request()   return label     ## result label   self.resultlbl = createlabel()   table.add_row(_('Preview:'), self.resultlbl, padding=False)     ## preview box   pframe = gtk.Frame()   table.add_row(None, pframe, padding=False)   pframe.set_shadow_type(gtk.SHADOW_IN)   pbox = gtk.VBox()   pframe.add(pbox)     ### preview status box   self.pstatbox = gtk.HBox()   pbox.pack_start(self.pstatbox)   pbox.pack_start(gtk.HSeparator(), False, False, 2)     #### status label   self.pstatlbl = createlabel()   self.pstatbox.pack_start(self.pstatlbl, False, False, 2)     #### show all button   self.allbtn = gtk.Button(_('Show all')) # add later     #### preview option   self.compactopt = gtk.CheckButton(_('Use compact view'))   self.pstatbox.pack_end(self.compactopt, False, False, 2)   self.compactopt.connect('toggled', self.compact_toggled)     ### changeset view   rview = gtk.ScrolledWindow()   pbox.add(rview)   rview.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   rview.set_size_request(400, 180)   rview.size_request()   self.resultbox = gtk.VBox()   rview.add_with_viewport(self.resultbox)   rview.child.set_shadow_type(gtk.SHADOW_NONE)   self.resultbox.set_border_width(4)     ## options   self.expander = gtk.Expander(_('Options:'))   self.expander.connect('notify::expanded', self.options_expanded)     ### force option (fixed)   self.forceopt = gtk.CheckButton(_('Discard local changes, no backup'   ' (-f/--force)'))   table.add_row(self.expander, self.forceopt)     # signal handlers   self.revcombo.connect('changed', lambda c: self.preview(queue=True))   self.allbtn.connect('clicked', lambda b: self.preview(limit=False))     # csetinfo factory   self.factory = csinfo.factory(repo, withupdate=True)   self.lstyle = csinfo.labelstyle(contents=('%(revnum)s:',   ' %(branch)s', ' %(tags)s', ' %(summary)s'))   self.pstyle = csinfo.panelstyle()     # prepare to show   self.preview()   self.stripbtn.grab_focus()   gtklib.idle_add_single_call(self.after_init)     def after_init(self):   # add 'Show all' button   self.pstatbox.pack_start(self.allbtn, False, False, 4)     # backup types (foldable)   self.butable = gtklib.LayoutTable()   self.vbox.pack_start(self.butable, True, True)   def add_type(desc):   group = hasattr(self, 'buopt_all') and self.buopt_all or None   radio = gtk.RadioButton(group, desc)   self.butable.add_row(None, radio, ypad=0)   return radio   self.buopt_all = add_type(_('Backup all (default)'))   self.buopt_part = add_type(_('Backup unrelated changesets'   ' (-b/--backup)'))   self.buopt_none = add_type(_('No backup (-n/--nobackup)'))     # layout group   layout = gtklib.LayoutGroup()   layout.add(self.table, self.butable, force=True)     # CmdWidget   self.cmd = hgcmd.CmdWidget()   self.cmd.show_all()   self.cmd.hide()   self.vbox.pack_start(self.cmd, True, True, 6)     # abort button   self.abortbtn = self.add_button(_('Abort'), gtk.RESPONSE_CANCEL)   self.abortbtn.hide()     def set_notify_func(self, func, *args, **kargs):   self.notify_func = func   self.notify_args = args   self.notify_kargs = kargs     def preview(self, limit=True, queue=False, force=False):   def clear_preview():   self.resultbox.foreach(lambda c: c.parent.remove(c))   def update_info(num=None):   if num is None:   info = '<span weight="bold" foreground="#880000">%s</span>' \   % _('Unknown revision!')   else:   info = _('<span weight="bold">%s changesets</span> will'   ' be stripped') % num   self.resultlbl.set_markup(info)   def update_stat(show=None, total=None):   if show is None or total is None:   all = False   stat = _('No changesets to display')   else:   all = show == total   if all:   stat = _('Displaying all changesets')   else:   stat = _('Displaying %(count)d of %(total)d changesets') \   % dict(count=show, total=total)   self.pstatlbl.set_text(stat)   return all     # check revision   rev = self.get_rev()   if rev is None:   clear_preview()   update_info()   update_stat()   self.timeout_queue = []   self.currev = None   return   elif not force and limit and self.currev == rev: # is already shown?   update_info(self.curnum)   return   elif queue: # queueing if need   def timeout(eid):   if self.timeout_queue and self.timeout_queue[-1] == eid[0]:   self.preview()   self.timeout_queue = []   return False # don't repeat   event_id = [None]   event_id[0] = gobject.timeout_add(600, timeout, event_id)   self.timeout_queue.append(event_id[0])   return   self.currev = rev     # enumerate all descendants   # borrowed from strip() in 'mercurial/repair.py'   cl = self.repo.changelog   tostrip = [rev,]   for r in xrange(rev + 1, len(cl)):   parents = cl.parentrevs(r)   if parents[0] in tostrip or parents[1] in tostrip:   tostrip.append(r)   self.curnum = numtotal = len(tostrip)     LIM = 100   compactview = self.compactopt.get_active()   style = compactview and self.lstyle or self.pstyle   def add_csinfo(revnum):   info = self.factory(revnum, style)   if info.parent:   info.parent.remove(info)   self.resultbox.pack_start(info, False, False, 2)   def add_sep():   if not compactview:   self.resultbox.pack_start(gtk.HSeparator(), False, False)   def add_snip():   snipbox = gtk.HBox()   self.resultbox.pack_start(snipbox, False, False, 4)   spacer = gtk.Label()   snipbox.pack_start(spacer, False, False)   spacer.set_width_chars(24)   sniplbl = gtk.Label()   snipbox.pack_start(sniplbl, False, False)   sniplbl.set_markup('<span size="large" weight="heavy"'   ' font_family="monospace">...</span>')   sniplbl.set_angle(90)   snipbox.pack_start(gtk.Label())     # update changeset preview   if limit and numtotal > LIM:   toshow, lastrev = tostrip[:LIM-1], tostrip[LIM-1:][-1]   else:   toshow, lastrev = tostrip, None   numshow = len(toshow) + (lastrev and 1 or 0)   clear_preview()   for r in toshow:   add_csinfo(r)   if not r == toshow[-1]: # no need to append to the last   add_sep()   if lastrev:   add_snip()   add_csinfo(lastrev)   self.resultbox.show_all()     # update info label   update_info(numtotal)     # update preview status & button   all = update_stat(numshow, numtotal)   self.allbtn.set_property('visible', not all)     def dialog_response(self, dialog, response_id):   def abort():   self.cmd.stop()   self.cmd.show_log()   self.switch_to(MODE_NORMAL, cmd=False)   # Strip button   if response_id == gtk.RESPONSE_OK:   self.strip()   # Close button or dialog closing by the user   elif response_id in (gtk.RESPONSE_CLOSE, gtk.RESPONSE_DELETE_EVENT):   if self.cmd.is_alive():   ret = gdialog.Confirm(_('Confirm Abort'), [], self,   _('Do you want to abort?')).run()   if ret == gtk.RESPONSE_YES:   abort()   else:   self.destroy()   return # close dialog   # Abort button   elif response_id == gtk.RESPONSE_CANCEL:   abort()   else:   raise _('unexpected response id: %s') % response_id     self.run() # don't close dialog     def options_expanded(self, expander, *args):   if expander.get_expanded():   self.butable.show_all()   else:   self.butable.hide()     def compact_toggled(self, checkbtn):   self.preview(force=True)     def get_rev(self):   """ Return integer revision number or None """   revstr = self.revcombo.get_active_text()   if revstr is None or len(revstr) == 0:   return None   try:   revnum = self.repo[revstr].rev() - except (hglib.RepoError, hglib.LookupError): + except (error.RepoError, error.LookupError):   return None   return revnum     def switch_to(self, mode, cmd=True):   if mode == MODE_NORMAL:   normal = True   self.closebtn.grab_focus()   elif mode == MODE_WORKING:   normal = False   self.abortbtn.grab_focus()   else:   raise _('unknown mode name: %s') % mode   working = not normal     self.table.set_sensitive(normal)   self.butable.set_sensitive(normal)   self.stripbtn.set_property('visible', normal)   self.closebtn.set_property('visible', normal)   if cmd:   self.cmd.set_property('visible', working)   self.abortbtn.set_property('visible', working)     def strip(self):   def isclean():   '''whether WD is changed'''   wc = self.repo[None]   return not (wc.modified() or wc.added() or wc.removed())   revstr = self.revcombo.get_active_text()   cmdline = ['hg', 'strip', '--verbose', revstr]     # local changes   if self.forceopt.get_active():   cmdline.append('--force')   else:   if not isclean():   ret = gdialog.CustomPrompt(_('Confirm Strip'),   _('Detected uncommitted local changes.\nDo'   ' you want to discard them and continue?'),   self, (_('&Yes (--force)'), _('&No')),   default=1, esc=1).run()   if ret == 0:   cmdline.append('--force')   else:   return     # backup options   if self.buopt_part.get_active():   cmdline.append('--backup')   elif self.buopt_none.get_active():   cmdline.append('--nobackup')     def cmd_done(returncode, useraborted):   self.switch_to(MODE_NORMAL, cmd=False)   if returncode == 0:   if hasattr(self, 'notify_func'):   self.notify_func(*self.notify_args, **self.notify_kargs)   self.cmd.set_result(_('Stripped successfully'), style='ok')   self.after_strip()   elif useraborted:   self.cmd.set_result(_('Canceled stripping'), style='error')   else:   self.cmd.set_result(_('Failed to strip'), style='error')   self.switch_to(MODE_WORKING)   self.cmd.execute(cmdline, cmd_done)     def after_strip(self):   if self.buopt_none.get_active():   self.response(gtk.RESPONSE_CLOSE)   root = self.repo.root   bakdir = os.path.join(root, r'.hg\strip-backup')   escaped = bakdir.replace('\\', '\\\\')   buf = self.cmd.log.buffer   text = buf.get_text(buf.get_start_iter(), buf.get_end_iter())   m = re.search(escaped + r'\\[0-9abcdef]{12}-backup', text, re.I)   if m:   def open_bakdir():   gtklib.NativeFileManager(bakdir).run()   # backup bundle label & button   self.bubox = gtk.HBox()   self.vbox.pack_start(self.bubox, True, True, 2)   self.bulabel = gtk.Label(_('Saved at: %s') % m.group(0))   self.bubox.pack_start(self.bulabel, True, True, 8)   self.bulabel.set_alignment(0, 0.5)   self.bulabel.set_selectable(True)   self.bubtn = gtk.Button(_('Open...'))   self.bubox.pack_start(self.bubtn, False, False, 2)   self.bubtn.connect('clicked', lambda b: open_bakdir())   self.bubox.show_all()    def run(ui, *pats, **opts):   return StripDialog(None, *pats)
 
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