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

hggtk, thgutil: move Python packages under tortoisehg

During the move, take the opportunity to rename hggtk->hgtk and thgutil->util
This serves two purposes, to make us better Python citizens and to dogfood our
support for renames.

Changeset db36d1f7e96a

Parent 61482ea34fd0

by Steve Borho

Changes to 64 files · Browse files at db36d1f7e96a Showing diff from parent 61482ea34fd0 Diff from another changeset...

 
35
36
37
38
 
39
40
41
42
43
44
 
 
45
46
47
 
62
63
64
65
 
66
67
68
 
35
36
37
 
38
39
40
41
42
 
 
43
44
45
46
47
 
62
63
64
 
65
66
67
68
@@ -35,13 +35,13 @@
  pfile = pfile[:-1]   path = os.path.dirname(os.path.dirname(os.path.realpath(pfile)))   thgpath = os.path.normpath(path) - testpath = os.path.join(thgpath, 'thgutil') + testpath = os.path.join(thgpath, 'tortoisehg')   if os.path.isdir(testpath) and thgpath not in sys.path:   sys.path.insert(0, thgpath)  _thg_path()   -from thgutil import paths, debugthg, hglib, cachethg -from hggtk import gtklib +from tortoisehg.util import paths, debugthg, hglib, cachethg +from tortoisehg.hgtk import gtklib    if debugthg.debug('N'):   debugf = debugthg.debugf @@ -62,7 +62,7 @@
  self.allvfs = {}   self.inv_dirs = set()   - from thgutil import menuthg + from tortoisehg.util import menuthg   self.hgtk = paths.find_in_path('hgtk')   self.menu = menuthg.menuThg()   self.notify = os.path.expanduser('~/.tortoisehg/notify')
 
35
36
37
38
 
39
40
41
 
62
63
64
65
66
 
 
67
68
69
 
35
36
37
 
38
39
40
41
 
62
63
64
 
 
65
66
67
68
69
@@ -35,7 +35,7 @@
 # Fix for nautilus python extensions in lib64 on x86_64  sed -i "s,lib/nautilus,%{_lib}/nautilus,g" setup.py   -cat > thgutil/config.py << EOT +cat > tortoisehg/util/config.py << EOT  bin_path = "%{_bindir}"  license_path = "%{_docdir}/%{name}-%{version}/COPYING.txt"  locale_path = "%{_datadir}/locale" @@ -62,8 +62,8 @@
 %defattr(-,root,root,-)  %doc COPYING.txt ReleaseNotes.txt doc/build/html/  %{_bindir}/hgtk -%{python_sitelib}/hggtk/ -%{python_sitelib}/thgutil/ +%{python_sitelib}/tortoisehg/hgtk/ +%{python_sitelib}/tortoisehg/util/  %{python_sitelib}/tortoisehg-*.egg-info  %{_datadir}/pixmaps/tortoisehg/  %{_datadir}/locale/*/LC_MESSAGES/tortoisehg.mo
Change 1 of 1 Show Entire File hggtk/​rename.py Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,73 +0,0 @@
-# rename.py - TortoiseHg's dialogs for handling renames -# -# Copyright 2009 Steve Borho <steve@borho.org> -# -# This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. - -import sys -import gtk -import cStringIO - -from mercurial import hg, ui, util, commands - -from thgutil.i18n import _ -from thgutil import hglib, paths - -from hggtk import dialog - -def run(ui, *pats, **opts): - fname, target = '', '' - try: - fname = pats[0] - target = pats[1] - except IndexError: - pass - fname = util.normpath(fname) - if target: - target = hglib.toutf(util.normpath(target)) - else: - target = hglib.toutf(fname) - title = _('Rename ') + hglib.toutf(fname) - dlg = dialog.entry_dialog(None, title, True, target, rename_resp) - dlg.orig = fname - return dlg - -def rename_resp(dlg, response): - if response != gtk.RESPONSE_OK: - dlg.destroy() - return - try: - root = paths.find_root() - repo = hg.repository(ui.ui(), root) - except (ImportError, hglib.RepoError): - dlg.destroy() - return - - new_name = hglib.fromutf(dlg.entry.get_text()) - opts = {} - opts['force'] = False # Checkbox? Nah. - opts['after'] = False - opts['dry_run'] = False - - saved = sys.stderr - errors = cStringIO.StringIO() - toquit = False - try: - sys.stderr = errors - repo.ui.pushbuffer() - repo.ui.quiet = True - try: - commands.rename(repo.ui, repo, dlg.orig, new_name, **opts) - toquit = True - except (util.Abort, hglib.RepoError), inst: - dlg.error_dialog(None, _('rename error'), str(inst)) - toquit = False - finally: - sys.stderr = saved - textout = errors.getvalue() + repo.ui.popbuffer() - errors.close() - if len(textout) > 1: - dlg.error_dialog(None, _('rename error'), textout) - elif toquit: - dlg.destroy()
Change 1 of 3 Show Entire File hgtk Stacked
 
11
12
13
14
 
15
16
17
18
19
20
 
21
22
23
 
30
31
32
33
 
34
35
36
37
38
 
39
40
 
41
42
43
 
51
52
53
54
 
55
56
57
58
59
60
 
61
62
63
64
65
66
 
 
67
68
69
 
11
12
13
 
14
15
16
17
18
19
 
20
21
22
23
 
30
31
32
 
33
34
35
36
37
 
38
39
 
40
41
42
43
 
51
52
53
 
54
55
56
57
58
59
 
60
61
62
63
64
 
 
65
66
67
68
69
@@ -11,13 +11,13 @@
   if hasattr(sys, "frozen"):   # Prepend C:\Program Files\TortoiseHg\gtk (equiv) to the path - from thgutil import paths + from tortoisehg.util import paths   gtkpath = os.path.join(paths.bin_path, 'gtk')   os.environ['PATH'] = os.pathsep.join([gtkpath, os.environ['PATH']])  else:   # if hgtk is a symlink, insert symlink target directory in sys.path   thgpath = os.path.dirname(os.path.realpath(__file__)) - testpath = os.path.join(thgpath, 'thgutil') + testpath = os.path.join(thgpath, 'tortoisehg')   if os.path.isdir(testpath) and thgpath not in sys.path:   sys.path.insert(0, thgpath)   @@ -30,14 +30,14 @@
 demandimport.ignore.append('win32com.shell')  demandimport.enable()  from mercurial import ui, util -from thgutil.hgversion import hgversion, checkhgversion +from tortoisehg.util.hgversion import hgversion, checkhgversion  import cStringIO  import traceback    try: - import hggtk.hgtk + import tortoisehg.hgtk.hgtk  except ImportError: - sys.stderr.write("abort: couldn't find hggtk libraries in [%s]\n" % + sys.stderr.write("abort: couldn't find hgtk libraries in [%s]\n" %   ';'.join(sys.path))   sys.stderr.write("(check your install and PYTHONPATH)\n")   sys.exit(-1) @@ -51,19 +51,19 @@
  sys.exit(1)    if not capt or 'THGDEBUG' in os.environ: - sys.exit(hggtk.hgtk.dispatch(sys.argv[1:])) + sys.exit(tortoisehg.hgtk.hgtk.dispatch(sys.argv[1:]))  else:   mystderr = cStringIO.StringIO()   origstderr = sys.stderr   sys.stderr = mystderr   try: - ret = hggtk.hgtk.dispatch(sys.argv[1:]) + ret = tortoisehg.hgtk.hgtk.dispatch(sys.argv[1:])   sys.stderr = origstderr   mystderr.seek(0)   for l in mystderr.readlines():   if l.startswith('Traceback') or l.startswith('TypeError'): - from hggtk.bugreport import run - from hggtk.hgtk import gtkrun + from tortoisehg.hgtk.bugreport import run + from tortoisehg.hgtk.hgtk import gtkrun   error = 'Recoverable runtime error (stderr):\n'   error += mystderr.getvalue()   opts = {}
Change 1 of 4 Show Entire File setup.py Stacked
 
56
57
58
59
 
 
60
61
62
 
128
129
130
131
 
 
132
133
134
 
139
140
141
142
 
143
144
145
 
168
169
170
171
 
172
173
174
175
176
177
178
179
 
 
180
181
182
 
56
57
58
 
59
60
61
62
63
 
129
130
131
 
132
133
134
135
136
 
141
142
143
 
144
145
146
147
 
170
171
172
 
173
174
175
176
177
178
179
 
 
180
181
182
183
184
@@ -56,7 +56,8 @@
  # Specific definitios for Windows NT-alike installations   _scripts = []   _data_files = [] - _packages = ['hggtk', 'hggtk.logview', 'thgutil'] + _packages = ['tortoisehg.hgtk', 'tortoisehg.hgtk.logview', + 'tortoisehg.util']   extra = {}   hgextmods = []   @@ -128,7 +129,8 @@
  # Specific definitios for Posix installations   _extra = {}   _scripts = ['hgtk'] - _packages = ['hggtk', 'hggtk.logview', 'thgutil'] + _packages = ['tortoisehg.hgtk', 'tortoisehg.hgtk.logview', + 'tortoisehg.util']   _data_files = [(os.path.join('share/pixmaps/tortoisehg', root),   [os.path.join(root, file_) for file_ in files])   for root, dirs, files in os.walk('icons')] @@ -139,7 +141,7 @@
  ['contrib/nautilus-thg.py'])]     # Create a config.py. Distributions will need to supply their own - cfgfile = os.path.join('thgutil', 'config.py') + cfgfile = os.path.join('tortoisehg', 'util', 'config.py')   if not os.path.exists(cfgfile) and not os.path.exists('.hg/requires'):   f = open(cfgfile, "w")   f.write('bin_path = "/usr/bin"\n') @@ -168,15 +170,15 @@
 except OSError:   version = "unknown"   -verfile = os.path.join("thgutil", "__version__.py") +verfile = os.path.join('tortoisehg', 'util', '__version__.py')  if version != 'unknown' or not os.path.exists(verfile):   f = file(verfile, "w")   f.write('# this file is autogenerated by setup.py\n')   f.write('version = "%s"\n' % version)   f.close()  else: - import thgutil.__version__ - version = thgutil.__version__.version + import tortoisehg.util.__version__ + version = tortoisehg.util.__version__.version    setup(name="tortoisehg",   version=version,
Change 1 of 3 Show Entire File thgtaskbar.py Stacked
 
24
25
26
27
28
 
 
29
30
31
32
33
34
35
 
45
46
47
48
 
49
50
51
 
172
173
174
175
 
176
177
178
 
24
25
26
 
 
27
28
29
30
31
 
32
33
34
 
44
45
46
 
47
48
49
50
 
171
172
173
 
174
175
176
177
@@ -24,12 +24,11 @@
 demandimport.ignore.append('win32com.shell')  demandimport.enable()  from mercurial import ui, error -from thgutil.i18n import agettext as _ -from thgutil import thread2, paths, shlib +from tortoisehg.util.i18n import agettext as _ +from tortoisehg.util import thread2, paths, shlib    if hasattr(sys, "frozen"):   # Insert PATH to binary installer gtk directory - from thgutil import paths   gtkpath = os.path.join(paths.bin_path, 'gtk')   os.environ['PATH'] = os.pathsep.join([gtkpath, os.environ['PATH']])   # Give stdout/stderr closed attributes to prevent ui.py errors @@ -45,7 +44,7 @@
  # Try and find a custom icon   print "SetIcon(%s)" % name   hinst = GetModuleHandle(None) - from thgutil.paths import get_tortoise_icon + from tortoisehg.util.paths import get_tortoise_icon   iconPathName = get_tortoise_icon(name)   if iconPathName and os.path.isfile(iconPathName):   icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE @@ -172,7 +171,7 @@
  def launchgui(self):   def launch():   import gtk - from hggtk import taskbarui, hgtk + from tortoisehg.hgtk import taskbarui   dlg = taskbarui.TaskBarUI(logger.getqueue(), requests)   dlg.show_all()   dlg.connect('destroy', gtk.main_quit)
Show Entire File tortoisehg/​__init__.py Stacked
copied from hggtk/__init__.py
(No changes)
Show Entire File tortoisehg/​hgtk/​__init__.py Stacked
renamed from hggtk/__init__.py
(No changes)
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​about.py Stacked
renamed from hggtk/about.py
 
11
12
13
14
15
 
 
16
17
 
18
19
20
 
11
12
13
 
 
14
15
16
 
17
18
19
20
@@ -11,10 +11,10 @@
 import gtk  import threading   -from thgutil.i18n import _ -from thgutil import version, paths, hglib +from tortoisehg.util.i18n import _ +from tortoisehg.util import version, paths, hglib   -from hggtk import gtklib, hgtk +from tortoisehg.hgtk import gtklib, hgtk    def browse_url(url):   def start_browser():
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​archive.py Stacked
renamed from hggtk/archive.py
 
12
13
14
15
16
 
 
17
18
 
19
20
21
 
12
13
14
 
 
15
16
17
 
18
19
20
21
@@ -12,10 +12,10 @@
   from mercurial import hg, ui   -from thgutil.i18n import _ -from thgutil import hglib, paths +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, paths   -from hggtk import hgcmd, gtklib +from tortoisehg.hgtk import hgcmd, gtklib    _working_dir_parent_ = _('= Working Directory Parent =')  
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​backout.py Stacked
renamed from hggtk/backout.py
 
12
13
14
15
16
 
 
17
18
 
19
20
21
 
12
13
14
 
 
15
16
17
 
18
19
20
21
@@ -12,10 +12,10 @@
   from mercurial import hg, ui   -from thgutil.i18n import _ -from thgutil import hglib, paths, i18n, settings +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, paths, i18n, settings   -from hggtk import changesetinfo, gtklib, hgcmd, gdialog +from tortoisehg.hgtk import changesetinfo, gtklib, hgcmd, gdialog    keep = i18n.keepgettext()  
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​bugreport.py Stacked
renamed from hggtk/bugreport.py
 
10
11
12
13
14
15
 
 
 
16
17
18
 
10
11
12
 
 
 
13
14
15
16
17
18
@@ -10,9 +10,9 @@
 import pango    from mercurial import extensions -from thgutil.i18n import _ -from thgutil import hglib, version -from hggtk import gdialog +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, version +from tortoisehg.hgtk import gdialog    class BugReport(gdialog.GDialog):   """GTK+ based dialog for displaying traceback info to the user in a
Change 1 of 3 Show Entire File tortoisehg/​hgtk/​changeset.py Stacked
renamed from hggtk/changeset.py
 
13
14
15
16
17
18
 
 
 
19
20
 
21
22
23
 
677
678
679
680
 
681
682
683
 
694
695
696
697
 
698
699
700
 
13
14
15
 
 
 
16
17
18
19
 
20
21
22
23
 
677
678
679
 
680
681
682
683
 
694
695
696
 
697
698
699
700
@@ -13,11 +13,11 @@
   from mercurial import cmdutil, context, util, ui, hg, patch, mdiff   -from thgutil.i18n import _ -from thgutil.hglib import * -from thgutil import shlib +from tortoisehg.util.i18n import _ +from tortoisehg.util.hglib import * +from tortoisehg.util import shlib   -from hggtk import gdialog, gtklib, hgcmd +from tortoisehg.hgtk import gdialog, gtklib, hgcmd    class ChangeSet(gdialog.GDialog):   'GTK+ based dialog for displaying repository logs' @@ -677,7 +677,7 @@
    def ann_file(self, menuitem):   'User selected annotate file from the file list context menu' - from hggtk import datamine + from tortoisehg.hgtk import datamine   rev = self.currev   dialog = datamine.DataMineDialog(self.ui, self.repo, self.cwd, [], {})   dialog.display() @@ -694,7 +694,7 @@
  self.glog_parent.reload_log(**opts)   else:   # Else launch our own glog instance - from hggtk import history + from tortoisehg.hgtk import history   dlg = history.run(self.ui, filehist=self.curfile)   dlg.display()  
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​changesetinfo.py Stacked
renamed from hggtk/changesetinfo.py
 
10
11
12
13
14
 
 
15
16
 
17
18
19
 
10
11
12
 
 
13
14
15
 
16
17
18
19
@@ -10,10 +10,10 @@
 import os  import gtk   -from thgutil.i18n import _ -from thgutil import hglib +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib   -from hggtk import gtklib +from tortoisehg.hgtk import gtklib    def changesetinfo(repo, revid, head=False):   def lbl(str, bold=False, right=False):
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​clone.py Stacked
renamed from hggtk/clone.py
 
12
13
14
15
16
17
 
 
 
18
19
20
 
12
13
14
 
 
 
15
16
17
18
19
20
@@ -12,9 +12,9 @@
 import traceback    from mercurial import ui, util -from thgutil.i18n import _ -from thgutil import hglib, shlib, settings -from hggtk import gdialog, gtklib, hgcmd +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, shlib, settings +from tortoisehg.hgtk import gdialog, gtklib, hgcmd    class CloneDialog(gtk.Dialog):   """ Dialog to clone a Mercurial repo """
Change 1 of 2 Show Entire File tortoisehg/​hgtk/​commit.py Stacked
renamed from hggtk/commit.py
 
18
19
20
21
22
 
 
23
24
25
26
 
 
27
28
29
 
745
746
747
748
 
749
750
751
 
18
19
20
 
 
21
22
23
 
 
 
24
25
26
27
28
 
744
745
746
 
747
748
749
750
@@ -18,12 +18,11 @@
   from mercurial import ui, hg, util, patch, cmdutil   -from thgutil.i18n import _ -from thgutil import shlib, hglib +from tortoisehg.util.i18n import _ +from tortoisehg.util import shlib, hglib   -from hggtk.status import GStatus, FM_STATUS, FM_CHECKED, FM_PATH_UTF8 -from hggtk.status import DM_REJECTED, DM_CHUNK_ID -from hggtk import gtklib, thgconfig, gdialog, hgcmd +from tortoisehg.hgtk.status import GStatus, FM_STATUS, FM_CHECKED, FM_PATH_UTF8 +from tortoisehg.hgtk import gtklib, thgconfig, gdialog, hgcmd    class BranchOperationDialog(gtk.Dialog):   def __init__(self, branch, close, mergebranches): @@ -745,7 +744,7 @@
      def changelog_clicked(self, toolbutton, data=None): - from hggtk import history + from tortoisehg.hgtk import history   dlg = history.run(self.ui)   dlg.display()   return True
Change 1 of 2 Show Entire File tortoisehg/​hgtk/​datamine.py Stacked
renamed from hggtk/datamine.py
 
15
16
17
18
19
20
 
 
21
22
23
24
25
 
 
 
 
26
27
28
 
161
162
163
164
 
165
166
167
 
15
16
17
 
 
 
18
19
20
 
 
 
 
21
22
23
24
25
26
27
 
160
161
162
 
163
164
165
166
@@ -15,14 +15,13 @@
   from mercurial import util   -from thgutil.i18n import _ -from thgutil import hglib -from thgutil import thread2 +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, thread2   -from hggtk.logview.colormap import AnnotateColorMap, AnnotateColorSaturation -from hggtk.logview.treeview import TreeView as LogTreeView - -from hggtk import gtklib, gdialog, changeset +from tortoisehg.hgtk.logview.colormap import AnnotateColorMap +from tortoisehg.hgtk.logview.colormap import AnnotateColorSaturation +from tortoisehg.hgtk.logview.treeview import TreeView as LogTreeView +from tortoisehg.hgtk import gtklib, gdialog, changeset    class DataMineDialog(gdialog.GDialog):   COL_REVID = 0 @@ -161,7 +160,7 @@
  self.add_annotate_page(self.curpath, self.currev)     def cmenu_file_log(self, menuitem): - from hggtk import history + from tortoisehg.hgtk import history   dlg = history.run(self.ui, filehist=self.curpath)   dlg.display()  
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​dialog.py Stacked
renamed from hggtk/dialog.py
 
15
16
17
18
19
 
 
20
21
22
 
15
16
17
 
 
18
19
20
21
22
@@ -15,8 +15,8 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    import gtk -from thgutil.i18n import _ -from hggtk import gtklib +from tortoisehg.util.i18n import _ +from tortoisehg.hgtk import gtklib    def entry_dialog(parent, msg, visible=True, default='', respfunc=None):   """ Allow a user to enter a text string (username/password)
Change 1 of 4 Show Entire File tortoisehg/​hgtk/​gdialog.py Stacked
renamed from hggtk/gdialog.py
 
17
18
19
20
21
 
 
22
23
 
24
25
26
 
344
345
346
347
 
348
349
350
 
517
518
519
520
 
521
522
523
 
530
531
532
533
 
534
535
536
 
17
18
19
 
 
20
21
22
 
23
24
25
26
 
344
345
346
 
347
348
349
350
 
517
518
519
 
520
521
522
523
 
530
531
532
 
533
534
535
536
@@ -17,10 +17,10 @@
   from mercurial import cmdutil, util, ui, hg, commands   -from thgutil.i18n import _ -from thgutil import settings, hglib, paths +from tortoisehg.util.i18n import _ +from tortoisehg.util import settings, hglib, paths   -from hggtk import gtklib +from tortoisehg.hgtk import gtklib    class SimpleMessage(gtklib.MessageDialog):   def run(self): @@ -344,7 +344,7 @@
  if not url.startswith('http'):   docpath = os.path.dirname(paths.get_license_path())   url = os.path.join(docpath, url) - from hggtk import about + from tortoisehg.hgtk import about   about.browseurl(url)     def launch(self, item, app): @@ -517,7 +517,7 @@
  return True, textout     def _do_diff(self, canonpats, options): - from hggtk import visdiff + from tortoisehg.hgtk import visdiff   options['canonpats'] = canonpats   dialog = visdiff.run(self.ui, **options)   if not dialog: @@ -530,7 +530,7 @@
  self._do_diff(file and [file] or [], self.opts)     def _view_files(self, files, otherparent): - from hggtk import thgconfig + from tortoisehg.hgtk import thgconfig   def cleanup():   shutil.rmtree(self.tmproot)  
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​gorev.py Stacked
renamed from hggtk/gorev.py
 
11
12
13
14
15
 
 
16
17
18
 
11
12
13
 
 
14
15
16
17
18
@@ -11,8 +11,8 @@
 import gobject  import mercurial   -from thgutil.i18n import _ -from hggtk import gtklib, gdialog +from tortoisehg.util.i18n import _ +from tortoisehg.hgtk import gtklib, gdialog      class GotoRevDialog(gtk.Dialog):
Change 1 of 2 Show Entire File tortoisehg/​hgtk/​gtklib.py Stacked
renamed from hggtk/gtklib.py
 
12
13
14
15
16
 
 
17
18
 
19
20
21
 
329
330
331
332
 
333
334
335
 
12
13
14
 
 
15
16
17
 
18
19
20
21
 
329
330
331
 
332
333
334
335
@@ -12,10 +12,10 @@
 import gobject  import pango   -from thgutil.i18n import _ -from thgutil import paths, hglib +from tortoisehg.util.i18n import _ +from tortoisehg.util import paths, hglib   -from hggtk import hgtk +from tortoisehg.hgtk import hgtk    if gtk.gtk_version < (2, 14, 0):   # at least on 2.12.12, gtk widgets can be confused by control @@ -329,7 +329,7 @@
  pass   else:   def selectlang(senderitem): - from hggtk import dialog + from tortoisehg.hgtk import dialog   spell = gtkspell.get_from_text_view(textview)   lang = ''   while True:
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​guess.py Stacked
renamed from hggtk/guess.py
 
15
16
17
18
19
20
 
 
 
21
22
 
23
24
25
 
15
16
17
 
 
 
18
19
20
21
 
22
23
24
25
@@ -15,11 +15,11 @@
   from mercurial import hg, ui, mdiff, cmdutil, match, util   -from thgutil.i18n import _ -from thgutil.hglib import toutf, fromutf, diffexpand, RepoError -from thgutil import shlib, paths, thread2, settings +from tortoisehg.util.i18n import _ +from tortoisehg.util.hglib import toutf, fromutf, diffexpand, RepoError +from tortoisehg.util import shlib, paths, thread2, settings   -from hggtk import gtklib +from tortoisehg.hgtk import gtklib    # This function and some key bits below borrowed ruthelessly from  # Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​hgcmd.py Stacked
renamed from hggtk/hgcmd.py
 
12
13
14
15
16
 
 
17
18
 
19
20
21
 
12
13
14
 
 
15
16
17
 
18
19
20
21
@@ -12,10 +12,10 @@
 import os  import Queue   -from thgutil.i18n import _ -from thgutil import shlib, hglib +from tortoisehg.util.i18n import _ +from tortoisehg.util import shlib, hglib   -from hggtk import gtklib, hgthread +from tortoisehg.hgtk import gtklib, hgthread    class CmdDialog(gtk.Dialog):   def __init__(self, cmdline, progressbar=True):
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​hgemail.py Stacked
renamed from hggtk/hgemail.py
 
15
16
17
18
19
 
 
20
21
 
22
23
24
 
15
16
17
 
 
18
19
20
 
21
22
23
24
@@ -15,10 +15,10 @@
   from mercurial import hg, ui, extensions   -from thgutil.i18n import _ -from thgutil import hglib, settings +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, settings   -from hggtk import gtklib, dialog, thgconfig, hgcmd +from tortoisehg.hgtk import gtklib, dialog, thgconfig, hgcmd    class EmailDialog(gtk.Window):   """ Send patches or bundles via email """
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​hgignore.py Stacked
renamed from hggtk/hgignore.py
 
12
13
14
15
16
 
 
17
18
 
19
20
21
 
12
13
14
 
 
15
16
17
 
18
19
20
21
@@ -12,10 +12,10 @@
   from mercurial import hg, ui, match, util   -from thgutil.i18n import _ -from thgutil import shlib, hglib, paths +from tortoisehg.util.i18n import _ +from tortoisehg.util import shlib, hglib, paths   -from hggtk import gtklib, gdialog +from tortoisehg.hgtk import gtklib, gdialog    class HgIgnoreDialog(gtk.Window):   'Edit a reposiory .hgignore file'
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​hginit.py Stacked
renamed from hggtk/hginit.py
 
10
11
12
13
14
 
 
15
16
 
17
18
19
 
10
11
12
 
 
13
14
15
 
16
17
18
19
@@ -10,10 +10,10 @@
   from mercurial import hg, ui, util   -from thgutil.i18n import _ -from thgutil import hglib, shlib +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, shlib   -from hggtk import dialog, gtklib +from tortoisehg.hgtk import dialog, gtklib    class InitDialog(gtk.Dialog):   """ Dialog to initialize a Mercurial repo """
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​hgthread.py Stacked
renamed from hggtk/hgthread.py
 
11
12
13
14
15
 
 
16
17
 
18
19
20
 
11
12
13
 
 
14
15
16
 
17
18
19
20
@@ -11,10 +11,10 @@
   from mercurial import ui, util   -from thgutil.i18n import _ -from thgutil import hglib, thread2 +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, thread2   -from hggtk import dialog, gdialog +from tortoisehg.hgtk import dialog, gdialog    class GtkUi(ui.ui):   '''
Change 1 of 8 Show Entire File tortoisehg/​hgtk/​hgtk.py Stacked
renamed from hggtk/hgtk.py
 
22
23
24
25
26
27
 
 
 
28
29
30
 
55
56
57
58
 
59
60
61
 
275
276
277
278
 
279
280
281
 
286
287
288
289
 
290
291
292
293
294
 
295
296
297
 
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
 
392
393
394
395
 
396
397
398
399
400
 
401
402
403
 
407
408
409
410
 
411
412
413
414
415
 
416
417
418
 
614
615
616
617
 
618
619
620
 
22
23
24
 
 
 
25
26
27
28
29
30
 
55
56
57
 
58
59
60
61
 
275
276
277
 
278
279
280
281
 
286
287
288
 
289
290
291
292
293
 
294
295
296
297
 
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
 
392
393
394
 
395
396
397
398
399
 
400
401
402
403
 
407
408
409
 
410
411
412
413
414
 
415
416
417
418
 
614
615
616
 
617
618
619
620
@@ -22,9 +22,9 @@
 import mercurial.ui as _ui  from mercurial import hg, util, fancyopts, cmdutil, extensions   -from thgutil.i18n import agettext as _ -from thgutil import hglib, paths, shlib -from thgutil import version as thgversion +from tortoisehg.util.i18n import agettext as _ +from tortoisehg.util import hglib, paths, shlib +from tortoisehg.util import version as thgversion    nonrepo_commands = '''userconfig clone debugcomplete init about help  version thgstatus serve''' @@ -55,7 +55,7 @@
  except KeyboardInterrupt:   print _('\nCaught keyboard interrupt, aborting.\n')   except: - from hggtk.bugreport import run + from tortoisehg.hgtk.bugreport import run   if '--debugger' in args:   pdb.post_mortem(sys.exc_info()[2])   error = traceback.format_exc() @@ -275,7 +275,7 @@
   def about(ui, *pats, **opts):   """about TortoiseHg""" - from hggtk.about import run + from tortoisehg.hgtk.about import run   gtkrun(run, ui, *pats, **opts)    def add(ui, *pats, **opts): @@ -286,12 +286,12 @@
   def thgstatus(ui, *pats, **opts):   """update TortoiseHg status cache""" - from hggtk.thgstatus import run + from tortoisehg.util.thgstatus import run   run(ui, *pats, **opts)    def clone(ui, *pats, **opts):   """clone tool""" - from hggtk.clone import run + from tortoisehg.hgtk.clone import run   gtkrun(run, ui, *pats, **opts)    def commit(ui, *pats, **opts): @@ -302,89 +302,89 @@
  if len(repo.parents()) > 1:   os.chdir(repo.root)   pats = [] - from hggtk.commit import run + from tortoisehg.hgtk.commit import run   gtkrun(run, ui, *pats, **opts)    def shelve(ui, *pats, **opts):   """shelve/unshelve tool""" - from hggtk.thgshelve import run + from tortoisehg.hgtk.thgshelve import run   gtkrun(run, ui, *pats, **opts)    def userconfig(ui, *pats, **opts):   """user configuration editor""" - from hggtk.thgconfig import run + from tortoisehg.hgtk.thgconfig import run   opts['repomode'] = False   gtkrun(run, ui, *pats, **opts)    def repoconfig(ui, *pats, **opts):   """repository configuration editor""" - from hggtk.thgconfig import run + from tortoisehg.hgtk.thgconfig import run   opts['repomode'] = True   gtkrun(run, ui, *pats, **opts)    def rename(ui, *pats, **opts):   """rename a single file or directory"""   if not pats or len(pats) > 2: - from hggtk import gdialog + from tortoisehg.hgtk import gdialog   gdialog.Prompt(_('Rename error'),   _('rename takes one or two path arguments'), None).run()   return - from hggtk.rename import run + from tortoisehg.hgtk.rename import run   gtkrun(run, ui, *pats, **opts)    def guess(ui, *pats, **opts):   """guess previous renames or copies""" - from hggtk.guess import run + from tortoisehg.hgtk.guess import run   gtkrun(run, ui, *pats, **opts)    def datamine(ui, *pats, **opts):   """repository search and annotate tool""" - from hggtk.datamine import run + from tortoisehg.hgtk.datamine import run   gtkrun(run, ui, *pats, **opts)    def hgignore(ui, *pats, **opts):   """ignore filter editor""" - from hggtk.hgignore import run + from tortoisehg.hgtk.hgignore import run   gtkrun(run, ui, *pats, **opts)    def hginit(ui, *pats, **opts):   """repository initialization tool""" - from hggtk.hginit import run + from tortoisehg.hgtk.hginit import run   gtkrun(run, ui, *pats, **opts)    def log(ui, *pats, **opts):   """changelog viewer""" - from hggtk.history import run + from tortoisehg.hgtk.history import run   gtkrun(run, ui, *pats, **opts)    def merge(ui, *pats, **opts):   """merge tool""" - from hggtk.merge import run + from tortoisehg.hgtk.merge import run   gtkrun(run, ui, *pats, **opts)    def recovery(ui, *pats, **opts):   """recover, rollback & verify""" - from hggtk.recovery import run + from tortoisehg.hgtk.recovery import run   gtkrun(run, ui, *pats, **opts)    def remove(ui, *pats, **opts):   """file status viewer in remove mode""" - from hggtk.status import run + from tortoisehg.hgtk.status import run   gtkrun(run, ui, *pats, **opts)    def revert(ui, *pats, **opts):   """file status viewer in revert mode""" - from hggtk.status import run + from tortoisehg.hgtk.status import run   gtkrun(run, ui, *pats, **opts)    def forget(ui, *pats, **opts):   """file status viewer in forget mode""" - from hggtk.status import run + from tortoisehg.hgtk.status import run   gtkrun(run, ui, *pats, **opts)    def serve(ui, *pats, **opts):   """web server""" - from hggtk.serve import run + 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"   " (.hg not found)")) @@ -392,12 +392,12 @@
   def status(ui, *pats, **opts):   """file status & diff viewer""" - from hggtk.status import run + from tortoisehg.hgtk.status import run   gtkrun(run, ui, *pats, **opts)    def synch(ui, *pats, **opts):   """repository synchronization tool""" - from hggtk.synch import run + from tortoisehg.hgtk.synch import run   cmd = opts['alias']   if cmd in ('push', 'outgoing', 'email'):   opts['pushmode'] = True @@ -407,12 +407,12 @@
   def update(ui, *pats, **opts):   """update/checkout tool""" - from hggtk.update import run + from tortoisehg.hgtk.update import run   gtkrun(run, ui, *pats, **opts)    def vdiff(ui, *pats, **opts):   """launch configured visual diff tool""" - from hggtk.visdiff import run, rawextdiff + from tortoisehg.hgtk.visdiff import run, rawextdiff   if opts.get('raw'):   rawextdiff(ui, *pats, **opts)   return @@ -614,7 +614,7 @@
   def archive(ui, *pats, **opts):   """create an unversioned archive of a repository revision""" - from hggtk.archive import run + from tortoisehg.hgtk.archive import run   gtkrun(run, ui, *pats, **opts)    globalopts = [
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​histdetails.py Stacked
renamed from hggtk/histdetails.py
 
8
9
10
11
 
12
13
 
14
15
16
 
8
9
10
 
11
12
 
13
14
15
16
@@ -8,9 +8,9 @@
 import gtk  import gobject   -from thgutil.i18n import _ +from tortoisehg.util.i18n import _   -from hggtk import gtklib +from tortoisehg.hgtk import gtklib    class LogDetailsDialog(gtk.Dialog):  
Change 1 of 2 Show Entire File tortoisehg/​hgtk/​history.py Stacked
renamed from hggtk/history.py
 
14
15
16
17
18
 
 
19
20
 
21
22
23
24
 
 
 
25
26
27
 
122
123
124
125
 
126
127
128
 
14
15
16
 
 
17
18
19
 
20
21
 
 
 
22
23
24
25
26
27
 
122
123
124
 
125
126
127
128
@@ -14,14 +14,14 @@
   from mercurial import ui, hg, cmdutil, commands, extensions, util   -from thgutil.i18n import _ -from thgutil import hglib, paths +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, paths   -from hggtk.logview.treeview import TreeView as LogTreeView +from tortoisehg.hgtk.logview.treeview import TreeView as LogTreeView   -from hggtk import gdialog, gtklib, hgcmd, datamine, logfilter, gorev -from hggtk import backout, status, hgemail, tagadd, update, merge, archive -from hggtk import changeset, thgconfig, thgmq, histdetails +from tortoisehg.hgtk import gdialog, gtklib, hgcmd, datamine, logfilter, gorev +from tortoisehg.hgtk import backout, status, hgemail, tagadd, update, merge +from tortoisehg.hgtk import archive, changeset, thgconfig, thgmq, histdetails    def create_menu(label, callback):   menuitem = gtk.MenuItem(label, True) @@ -122,7 +122,7 @@
  elif not parents == newparents:   self.refresh_model()   - from hggtk import synch + from tortoisehg.hgtk import synch   parents = [x.node() for x in self.repo.parents()]   dlg = synch.SynchDialog([], False, True)   dlg.set_notify_func(synch_callback, parents)
Show Entire File tortoisehg/​hgtk/​logview/​__init__.py Stacked
renamed from hggtk/logview/__init__.py
(No changes)
Show Entire File tortoisehg/​hgtk/​logview/​colormap.py Stacked
renamed from hggtk/logview/colormap.py
(No changes)
Show Entire File tortoisehg/​hgtk/​logview/​graphcell.py Stacked
renamed from hggtk/logview/graphcell.py
(No changes)
Show Entire File tortoisehg/​hgtk/​logview/​revgraph.py Stacked
renamed from hggtk/logview/revgraph.py
(No changes)
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​logview/​treemodel.py Stacked
renamed from hggtk/logview/treemodel.py
 
17
18
19
20
21
 
 
22
23
24
 
17
18
19
 
 
20
21
22
23
24
@@ -17,8 +17,8 @@
 import gtk  import gobject  from mercurial import util, templatefilters -from thgutil import hglib -from hggtk import gtklib +from tortoisehg.util import hglib +from tortoisehg.hgtk import gtklib    # treemodel row enumerated attributes  LINES = 0 # These elements come from the changelog walker
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​logview/​treeview.py Stacked
renamed from hggtk/logview/treeview.py
 
21
22
23
24
25
 
 
26
27
28
29
 
 
 
30
31
32
 
21
22
23
 
 
24
25
26
 
 
 
27
28
29
30
31
32
@@ -21,12 +21,12 @@
 import re  import time   -from thgutil.i18n import _ -from thgutil import hglib +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib   -from hggtk.logview import treemodel -from hggtk.logview.graphcell import CellRendererGraph -from hggtk.logview.revgraph import * +from tortoisehg.hgtk.logview import treemodel +from tortoisehg.hgtk.logview.graphcell import CellRendererGraph +from tortoisehg.hgtk.logview.revgraph import *      class TreeView(gtk.ScrolledWindow):
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​merge.py Stacked
renamed from hggtk/merge.py
 
12
13
14
15
16
 
 
17
18
 
19
20
21
 
12
13
14
 
 
15
16
17
 
18
19
20
21
@@ -12,10 +12,10 @@
   from mercurial import hg, ui   -from thgutil.i18n import _ -from thgutil import hglib, paths +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, paths   -from hggtk import changesetinfo, gtklib, commit, gdialog, hgcmd +from tortoisehg.hgtk import changesetinfo, gtklib, commit, gdialog, hgcmd    class MergeDialog(gtk.Window):   """ Dialog to merge revisions of a Mercurial repo """
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​recovery.py Stacked
renamed from hggtk/recovery.py
 
15
16
17
18
19
 
 
20
21
 
22
23
24
 
15
16
17
 
 
18
19
20
 
21
22
23
24
@@ -15,10 +15,10 @@
   from mercurial import hg, ui   -from thgutil.i18n import _ -from thgutil import hglib, shlib, paths +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, shlib, paths   -from hggtk import gdialog, dialog, gtklib, hgthread +from tortoisehg.hgtk import gdialog, dialog, gtklib, hgthread    class RecoveryDialog(gtk.Window):   def __init__(self):
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​rename.py Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
@@ -0,0 +1,73 @@
+# rename.py - TortoiseHg's dialogs for handling renames +# +# Copyright 2009 Steve Borho <steve@borho.org> +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2, incorporated herein by reference. + +import sys +import gtk +import cStringIO + +from mercurial import hg, ui, util, commands + +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, paths + +from tortoisehg.hgtk import dialog + +def run(ui, *pats, **opts): + fname, target = '', '' + try: + fname = pats[0] + target = pats[1] + except IndexError: + pass + fname = util.normpath(fname) + if target: + target = hglib.toutf(util.normpath(target)) + else: + target = hglib.toutf(fname) + title = _('Rename ') + hglib.toutf(fname) + dlg = dialog.entry_dialog(None, title, True, target, rename_resp) + dlg.orig = fname + return dlg + +def rename_resp(dlg, response): + if response != gtk.RESPONSE_OK: + dlg.destroy() + return + try: + root = paths.find_root() + repo = hg.repository(ui.ui(), root) + except (ImportError, hglib.RepoError): + dlg.destroy() + return + + new_name = hglib.fromutf(dlg.entry.get_text()) + opts = {} + opts['force'] = False # Checkbox? Nah. + opts['after'] = False + opts['dry_run'] = False + + saved = sys.stderr + errors = cStringIO.StringIO() + toquit = False + try: + sys.stderr = errors + repo.ui.pushbuffer() + repo.ui.quiet = True + try: + commands.rename(repo.ui, repo, dlg.orig, new_name, **opts) + toquit = True + except (util.Abort, hglib.RepoError), inst: + dlg.error_dialog(None, _('rename error'), str(inst)) + toquit = False + finally: + sys.stderr = saved + textout = errors.getvalue() + repo.ui.popbuffer() + errors.close() + if len(textout) > 1: + dlg.error_dialog(None, _('rename error'), textout) + elif toquit: + dlg.destroy()
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​serve.py Stacked
renamed from hggtk/serve.py
 
20
21
22
23
24
 
 
25
26
 
27
28
29
 
20
21
22
 
 
23
24
25
 
26
27
28
29
@@ -20,10 +20,10 @@
 from mercurial import hg, ui, commands, cmdutil, util  from mercurial.hgweb import server   -from thgutil.i18n import _ -from thgutil import hglib, paths +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, paths   -from hggtk import dialog, gdialog, gtklib, thgconfig +from tortoisehg.hgtk import dialog, gdialog, gtklib, thgconfig    gservice = None  class ServeDialog(gtk.Window):
Change 1 of 2 Show Changes Only tortoisehg/​hgtk/​status.py Stacked
renamed from hggtk/status.py
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
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
 
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
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
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
 
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
 # status.py - status dialog for TortoiseHg  #  # Copyright 2007 Brad Schick, brad at gmail . com  # Copyright 2007 TK Soh <teekaysoh@gmail.com>  # Copyright 2008 Steve Borho <steve@borho.org>  # Copyright 2008 Emmanuel Rosa <goaway1000@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 cStringIO  import gtk  import gobject  import pango  import threading    from mercurial import cmdutil, util, commands, patch, mdiff  from mercurial import merge as merge_   -from thgutil.i18n import _ -from thgutil import hglib, shlib, paths +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, shlib, paths, hgshelve   -from hggtk import dialog, gdialog, hgshelve, gtklib, guess, hgignore +from tortoisehg.hgtk import dialog, gdialog, gtklib, guess, hgignore    # file model row enumerations  FM_CHECKED = 0  FM_STATUS = 1  FM_PATH_UTF8 = 2  FM_PATH = 3  FM_MERGE_STATUS = 4  FM_PARTIAL_SELECTED = 5    # diffmodel row enumerations  DM_REJECTED = 0  DM_DISP_TEXT = 1  DM_IS_HEADER = 2  DM_PATH = 3  DM_CHUNK_ID = 4  DM_FONT = 5    def hunk_markup(text):   'Format a diff hunk for display in a TreeView row with markup'   hunk = ""   # don't use splitlines, should split with only LF for the patch   lines = hglib.tounicode(text).split(u'\n')   for line in lines:   line = gtklib.markup_escape_text(hglib.toutf(line[:512])) + '\n'   if line.startswith('---') or line.startswith('+++'):   hunk += '<span foreground="#000090">%s</span>' % line   elif line.startswith('-'):   hunk += '<span foreground="#900000">%s</span>' % line   elif line.startswith('+'):   hunk += '<span foreground="#006400">%s</span>' % line   elif line.startswith('@@'):   hunk = '<span foreground="#FF8000">%s</span>' % line   else:   hunk += line   return hunk    def hunk_unmarkup(text):   'Format a diff hunk for display in a TreeView row without markup'   hunk = ""   # don't use splitlines, should split with only LF for the patch   lines = hglib.tounicode(text).split(u'\n')   for line in lines:   hunk += gtklib.markup_escape_text(hglib.toutf(line[:512])) + '\n'   return hunk    class GStatus(gdialog.GDialog):   """GTK+ based dialog for displaying repository status     Also provides related operations like add, delete, remove, revert, refresh,   ignore, diff, and edit.     The following methods are meant to be overridden by subclasses. At this   point GCommit is really the only intended subclass.     auto_check(self)   """     ### Following methods are meant to be overridden by subclasses ###     def init(self):   gdialog.GDialog.init(self)   self.mode = 'status'   self.ready = False   self.filerowstart = {}   self.filechunks = {}     def auto_check(self):   # Only auto-check files once, and only if a pattern was given.   if self.pats and self.opts.get('check'):   for entry in self.filemodel:   entry[FM_CHECKED] = True   self.update_check_count()   self.opts['check'] = False     def get_custom_menus(self):   return []     ### End of overridable methods ###       ### Overrides of base class methods ###     def parse_opts(self):   # Disable refresh while we toggle checkboxes   self.ready = False     # Determine which files to display   if self.test_opt('all'):   for check in self._show_checks.values():   check.set_active(True)   else:   wasset = False   for opt in self.opts:   if opt in self._show_checks and self.opts[opt]:   wasset = True   self._show_checks[opt].set_active(True)   if not wasset:   for check in [item[1] for item in self._show_checks.iteritems()   if item[0] in ('modified', 'added', 'removed',   'deleted', 'unknown')]:   check.set_active(True)   if self.pats:   for name, check in self._show_checks.iteritems():   check.set_sensitive(False)   self.ready = True       def get_title(self):   root = self.get_reponame()   revs = self.opts.get('rev')   name = self.pats and _('filtered status') or _('status')   r = revs and ':'.join(revs) or ''   return ' '.join([root, name, r])     def get_icon(self):   return 'menushowchanged.ico'     def get_defsize(self):   return self._setting_defsize       def get_tbbuttons(self):   tbuttons = []     if self.count_revs() == 2:   tbuttons += [   self.make_toolbutton(gtk.STOCK_SAVE_AS, _('Save As'),   self.save_clicked, tip=_('Save selected changes'))]   else:   tbuttons += [   self.make_toolbutton(gtk.STOCK_JUSTIFY_FILL, _('_Diff'),   self.diff_clicked,   tip=_('Visual diff checked files')),   self.make_toolbutton(gtk.STOCK_MEDIA_REWIND, _('Re_vert'),   self.revert_clicked,   tip=_('Revert checked files')),   self.make_toolbutton(gtk.STOCK_ADD, _('_Add'),   self.add_clicked,   tip=_('Add checked files')),   self.make_toolbutton(gtk.STOCK_JUMP_TO, _('Move'),   self.move_clicked,   tip=_('Move checked files to other directory')),   self.make_toolbutton(gtk.STOCK_DELETE, _('_Remove'),   self.remove_clicked,   tip=_('Remove or delete checked files')),   self.make_toolbutton(gtk.STOCK_CLEAR, _('_Forget'),   self.forget_clicked,   tip=_('Forget checked file(s) on next commit')),   gtk.SeparatorToolItem(),   self.make_toolbutton(gtk.STOCK_REFRESH, _('Re_fresh'),   self.refresh_clicked,   tip=_('refresh')),   gtk.SeparatorToolItem()]   return tbuttons       def save_settings(self):   settings = gdialog.GDialog.save_settings(self)   settings['gstatus-hpane'] = self.diffpane.get_position()   settings['gstatus-lastpos'] = self.setting_lastpos   return settings       def load_settings(self, settings):   gdialog.GDialog.load_settings(self, settings)   self.setting_pos = 270   self.setting_lastpos = 64000   try:   self.setting_pos = settings['gstatus-hpane']   self.setting_lastpos = settings['gstatus-lastpos']   except KeyError:   pass   self.mqmode, repo = None, self.repo   if hasattr(repo, 'mq') and repo.mq.applied and repo['.'] == repo['qtip']:   self.mqmode = True       def get_body(self):   self.merging = (self.count_revs() < 2   and len(self.repo.parents()) == 2)     # model stores the file list.   fm = gtk.ListStore(bool, str, str, str, str, bool)   fm.set_sort_func(1001, self.sort_by_stat)   fm.set_default_sort_func(self.sort_by_stat)   self.filemodel = fm     self.filetree = gtk.TreeView(self.filemodel)   self.filetree.connect('popup-menu', self.tree_popup_menu)   self.filetree.connect('button-release-event', self.tree_button_release)   self.filetree.connect('row-activated', self.tree_row_act)   self.filetree.connect('key-press-event', self.tree_key_press)   self.filetree.set_reorderable(False)   self.filetree.set_enable_search(True)   self.filetree.set_search_equal_func(self.search_filelist)   if hasattr(self.filetree, 'set_rubber_banding'):   self.filetree.set_rubber_banding(True)   self.filetree.modify_font(pango.FontDescription(self.fontlist))   self.filetree.set_headers_clickable(True)     accelgroup = gtk.AccelGroup()   self.add_accel_group(accelgroup)   mod = gtklib.get_thg_modifier()   key, modifier = gtk.accelerator_parse(mod+'d')   self.filetree.add_accelerator('thg-diff', accelgroup, key,   modifier, gtk.ACCEL_VISIBLE)   self.filetree.connect('thg-diff', self.thgdiff)   self.connect('thg-refresh', self.thgrefresh)     toggle_cell = gtk.CellRendererToggle()   toggle_cell.connect('toggled', self.select_toggle)   toggle_cell.set_property('activatable', True)     path_cell = gtk.CellRendererText()   stat_cell = gtk.CellRendererText()     if self.merging:   self.selcb = None   else:   # show file selection checkboxes only when applicable   col0 = gtk.TreeViewColumn('', toggle_cell)   col0.add_attribute(toggle_cell, 'active', FM_CHECKED)   if gtk.pygtk_version >= (2, 12, 0):   col0.add_attribute(toggle_cell, 'inconsistent',   FM_PARTIAL_SELECTED)   else:   col0.add_attribute(toggle_cell, 'radio',   FM_PARTIAL_SELECTED)   col0.set_resizable(False)   self.filetree.append_column(col0)   self.selcb = self.add_header_checkbox(col0, self.sel_clicked)     col1 = gtk.TreeViewColumn(_('st'), stat_cell)   col1.add_attribute(stat_cell, 'text', FM_STATUS)   col1.set_cell_data_func(stat_cell, self.text_color)   col1.set_sort_column_id(1001)   col1.set_resizable(False)   self.filetree.append_column(col1)     if self.count_revs() <= 1:   col = gtk.TreeViewColumn(_('ms'), stat_cell)   col.add_attribute(stat_cell, 'text', FM_MERGE_STATUS)   col.set_sort_column_id(4)   col.set_resizable(False)   self.filetree.append_column(col)     col2 = gtk.TreeViewColumn(_('path'), path_cell)   col2.add_attribute(path_cell, 'text', FM_PATH_UTF8)   col2.set_cell_data_func(path_cell, self.text_color)   col2.set_sort_column_id(2)   col2.set_resizable(True)   self.filetree.append_column(col2)     scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   scroller.add(self.filetree)     tvbox = gtk.VBox()   tvbox.pack_start( scroller, True, True, 0)   if self.pats:   button = gtk.Button(_('Remove filter, show root'))   button.connect('pressed', self.remove_filter)   tvbox.pack_start( button, False, False, 2)     tree_frame = gtk.Frame()   tree_frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)   tree_frame.add(tvbox)     diff_frame = gtk.Frame()   diff_frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)     self.diff_notebook = gtk.Notebook()   self.diff_notebook.set_tab_pos(gtk.POS_BOTTOM)     self.difffont = pango.FontDescription(self.fontlist)     self.clipboard = None   self.diff_text = gtk.TextView()   self.diff_text.set_wrap_mode(gtk.WRAP_NONE)   self.diff_text.set_editable(False)   self.diff_text.modify_font(self.difffont)   scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   scroller.add(self.diff_text)   self.diff_notebook.append_page(scroller, gtk.Label(_('Text Diff')))     if self.merging:   difftree = None   else:   # use treeview to show selectable diff hunks   sel = (os.name == 'nt') and 'CLIPBOARD' or 'PRIMARY'   self.clipboard = gtk.Clipboard(selection=sel)     self.diffmodel = gtk.ListStore(   bool, # DM_REJECTED   str, # DM_DISP_TEXT   bool, # DM_IS_HEADER   str, # DM_PATH   int, # DM_CHUNK_ID   pango.FontDescription)     difftree = gtk.TreeView(self.diffmodel)     # set CTRL-c accelerator for copy-clipboard   mod = gtklib.get_thg_modifier()   key, modifier = gtk.accelerator_parse(mod+'c')   difftree.add_accelerator('copy-clipboard', accelgroup, key,   modifier, gtk.ACCEL_VISIBLE)   difftree.connect('copy-clipboard', self.copy_to_clipboard)     difftree.get_selection().set_mode(gtk.SELECTION_MULTIPLE)   difftree.set_headers_visible(False)   difftree.set_enable_search(False)   if getattr(difftree, 'enable-grid-lines', None) is not None:   difftree.set_property('enable-grid-lines', True)   difftree.connect('row-activated', self.diff_tree_row_act)     cell = gtk.CellRendererText()   diffcol = gtk.TreeViewColumn('diff', cell)   diffcol.set_resizable(True)   diffcol.add_attribute(cell, 'markup', DM_DISP_TEXT)     # differentiate header chunks   cell.set_property('cell-background', '#DDDDDD')   diffcol.add_attribute(cell, 'cell_background_set', DM_IS_HEADER)   self.headerfont = self.difffont.copy()   self.headerfont.set_weight(pango.WEIGHT_HEAVY)     # differentiate rejected hunks   self.rejfont = self.difffont.copy()   self.rejfont.set_weight(pango.WEIGHT_LIGHT)   diffcol.add_attribute(cell, 'font-desc', DM_FONT)   cell.set_property('background', '#EEEEEE')   cell.set_property('foreground', '#888888')   diffcol.add_attribute(cell, 'background-set', DM_REJECTED)   diffcol.add_attribute(cell, 'foreground-set', DM_REJECTED)   difftree.append_column(diffcol)   scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   scroller.add(difftree)   self.diff_notebook.append_page(   scroller, gtk.Label(_('Hunk Selection')))     # Add a page for selection preview   self.preview_text = gtk.TextView()   self.preview_text.set_wrap_mode(gtk.WRAP_NONE)   self.preview_text.set_editable(False)   self.preview_text.modify_font(self.difffont)   scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   scroller.add(self.preview_text)   self.diff_notebook.append_page(scroller,   gtk.Label(_('Preview Selection')))     diff_frame.add(self.diff_notebook)     if self.diffbottom:   self.diffpane = gtk.VPaned()   else:   self.diffpane = gtk.HPaned()     self.diffpane.pack1(tree_frame, shrink=False)   self.diffpane.pack2(diff_frame, shrink=False)   self.filetree.set_headers_clickable(True)     sel = self.filetree.get_selection()   sel.set_mode(gtk.SELECTION_MULTIPLE)   self.treeselid = sel.connect('changed', self.tree_sel_changed,   difftree)     self.diff_notebook.connect('switch-page', self.page_switched,   sel, difftree)   return self.diffpane     def page_switched(self, notebook, page, page_num, filesel, difftree):   self.tree_sel_changed(filesel, difftree, page_num)     def get_extras(self):   table = gtk.Table(rows=2, columns=3)   table.set_col_spacings(8)     self._show_checks = {}   row, col = 0, 0   # Tuple: (ctype, translated label)   checks = (('modified', _('M: modified')),   ('added', _('A: added')),   ('removed', _('R: removed')))   if self.count_revs() <= 1:   checks += (('deleted', _('!: deleted')),   ('unknown', _('?: unknown')),   ('clean', _('C: clean')),   ('ignored', _('I: ignored')))     for ctuple in checks:   check = gtk.CheckButton(ctuple[1])   check.connect('toggled', self.show_toggle, ctuple[0])   table.attach(check, col, col+1, row, row+1)   self._show_checks[ctuple[0]] = check   col += row   row = not row     self.counter = gtk.Label('')   self.counter.set_alignment(1.0, 0.0) # right up     self.stbar = gtklib.StatusBar()     rightbox = gtk.VBox()   rightbox.pack_start(self.counter)   rightbox.pack_start(self.stbar, False, False)     hbox = gtk.HBox()   hbox.pack_start(table, False, False)   hbox.pack_start(gtk.Label(''), True, True, 2)   hbox.pack_end(rightbox, False, False, 2)     return hbox     def add_header_checkbox(self, col, post=None, pre=None, toggle=False):   def cbclick(hdr, cb):   state = cb.get_active()   if pre:   pre(state)   if toggle:   cb.set_active(not state)   if post:   post(not state)     cb = gtk.CheckButton(col.get_title())   cb.show()   col.set_widget(cb)   wgt = cb.get_parent()   while wgt:   if type(wgt) == gtk.Button:   wgt.connect('clicked', cbclick, cb)   return cb   wgt = wgt.get_parent()   return     def update_check_count(self):   file_count = 0   check_count = 0   for row in self.filemodel:   file_count = file_count + 1   if row[FM_CHECKED]:   check_count = check_count + 1   self.counter.set_text(_('%d selected, %d total') % (check_count,   file_count))   if self.selcb:   self.selcb.set_active(file_count and file_count == check_count)   if self.count_revs() == 2:   return   sensitive = check_count and not self.merging   self.get_toolbutton(_('_Diff')).set_sensitive(sensitive)   self.get_toolbutton(_('Re_vert')).set_sensitive(sensitive)   self.get_toolbutton(_('_Add')).set_sensitive(sensitive)   self.get_toolbutton(_('_Remove')).set_sensitive(sensitive)   self.get_toolbutton(_('Move')).set_sensitive(sensitive)   self.get_toolbutton(_('_Forget')).set_sensitive(sensitive)   if self.diff_notebook.get_current_page() == 2:   self.update_selection_preview()     def prepare_display(self):   gobject.idle_add(self.realize_status_settings)     def refresh_complete(self):   pass     ### End of overrides ###     def realize_status_settings(self):   self.diffpane.set_position(self.setting_pos)   self.reload_status()     def remove_filter(self, button):   button.hide()   self.pats = []   for name, check in self._show_checks.iteritems():   check.set_sensitive(True)   self.reload_status()     def search_filelist(self, model, column, key, iter):   'case insensitive filename search'   key = key.lower()   if key in model.get_value(iter, FM_PATH).lower():   return False   return True     def thgdiff(self, treeview):   selection = treeview.get_selection()   model, tpaths = selection.get_selected_rows()   files = [model[p][FM_PATH] for p in tpaths]   self._do_diff(files, self.opts)     def thgrefresh(self, window):   self.reload_status()     def copy_to_clipboard(self, treeview):   'Write highlighted hunks to the clipboard'   if not treeview.is_focus():   w = self.get_focus()   w.emit('copy-clipboard')   return False   saves = {}   model, tpaths = treeview.get_selection().get_selected_rows()   for row, in tpaths:   wfile, cid = model[row][DM_PATH], model[row][DM_CHUNK_ID]   if wfile not in saves:   saves[wfile] = [cid]   else:   saves[wfile].append(cid)   fp = cStringIO.StringIO()   for wfile in saves.keys():   chunks = self.filechunks[wfile]   chunks[0].write(fp)   for cid in saves[wfile]:   if cid != 0:   chunks[cid].write(fp)   fp.seek(0)   self.clipboard.set_text(fp.read())     def refresh_file_tree(self):   """Clear out the existing ListStore model and reload it from the   repository status. Also recheck and reselect files that remain   in the list.   """   selection = self.filetree.get_selection()   if selection is None:   return     (modified, added, removed, deleted, unknown, ignored, clean) = self.status   changetypes = (('M', 'modified', modified),   ('A', 'added', added),   ('R', 'removed', removed),   ('!', 'deleted', deleted),   ('?', 'unknown', unknown),   ('I', 'ignored', ignored),   ('C', 'clean', clean))     # List of the currently checked and selected files to pass on to   # the new data   model, tpaths = selection.get_selected_rows()   model = self.filemodel   reselect = [model[path][FM_PATH] for path in tpaths]   waschecked = {}   for row in model:   waschecked[row[FM_PATH]] = row[FM_CHECKED], row[FM_PARTIAL_SELECTED]     # merge-state of files   ms = merge_.mergestate(self.repo)     # Load the new data into the tree's model   self.filetree.hide()   selection.handler_block(self.treeselid)   self.filemodel.clear()     types = [ct for ct in changetypes if self.opts.get(ct[1])]   for stat, _, wfiles in types:   for wfile in wfiles:   mst = wfile in ms and ms[wfile].upper() or ""   wfile = util.localpath(wfile)   ck, p = waschecked.get(wfile, (stat in 'MAR', False))   model.append([ck, stat, hglib.toutf(wfile), wfile, mst, p])     self.auto_check() # may check more files     # recover selections   firstrow = None   for i, row in enumerate(model):   if row[FM_PATH] in reselect:   if firstrow is None:   firstrow = i   else:   selection.select_iter(row.iter)   selection.handler_unblock(self.treeselid)     if len(model):   selection.select_path((firstrow or 0,))   else:   # clear diff pane if no files   self.diff_text.set_buffer(gtk.TextBuffer())   if not self.merging:   self.diffmodel.clear()     self.filetree.show()   if self.mode == 'commit':   self.text.grab_focus()   else:   self.filetree.grab_focus()   return True       def reload_status(self):   if not self.ready: return False     def get_repo_status():   if self.mqmode and self.mode != 'status':   # when a patch is applied, show diffs to parent of top patch   qtip = repo['.']   n1 = qtip.parents()[0].node()   n2 = None   else:   # node2 is None (the working dir) when 0 or 1 rev is specificed   n1, n2 = cmdutil.revpair(repo, self.opts.get('rev'))     matcher = cmdutil.match(repo, self.pats, self.opts)   status = repo.status(node1=n1, node2=n2, match=matcher,   ignored=self.test_opt('ignored'),   clean=self.test_opt('clean'),   unknown=self.test_opt('unknown'))     self.status = status   self._node1, self._node2, = n1, n2     def status_wait(thread):   if thread.isAlive():   return True   else:   self.refresh_file_tree()   self.update_check_count()   self.refresh_complete()   self.ready = True   self.stbar.end()   return False     repo = self.repo   hglib.invalidaterepo(repo)   if hasattr(repo, 'mq'):   self.mqmode = repo.mq.applied and repo['.'] == repo['qtip']   self.set_title(self.get_title())     self.ready = False   self.stbar.begin()   thread = threading.Thread(target=get_repo_status)   thread.setDaemon(True)   thread.start()   gobject.timeout_add(50, status_wait, thread)   return True     def select_toggle(self, cellrenderer, path):   'User manually toggled file status via checkbox'   self.filemodel[path][FM_CHECKED] = not self.filemodel[path][FM_CHECKED]   self.update_chunk_state(self.filemodel[path])   self.update_check_count()   return True     def update_chunk_state(self, fileentry):   'Update chunk toggle state to match file toggle state'   fileentry[FM_PARTIAL_SELECTED] = False   wfile = fileentry[FM_PATH]   selected = fileentry[FM_CHECKED]   if wfile not in self.filechunks:   return   chunks = self.filechunks[wfile]   for chunk in chunks:   chunk.active = selected   # this file's chunks may not be in diffmodel   if wfile not in self.filerowstart:   return   rowstart = self.filerowstart[wfile]   for n, chunk in enumerate(chunks):   if n == 0:   continue   self.diffmodel[rowstart+n][DM_REJECTED] = not selected   self.update_diff_hunk(self.diffmodel[rowstart+n])   self.update_diff_header(self.diffmodel, wfile, selected)     def update_diff_hunk(self, row):   'Update the contents of a diff row based on its chunk state'   wfile = row[DM_PATH]   chunks = self.filechunks[wfile]   chunk = chunks[row[DM_CHUNK_ID]]   buf = cStringIO.StringIO()   chunk.pretty(buf)   buf.seek(0)   if chunk.active:   row[DM_REJECTED] = False   row[DM_FONT] = self.difffont   row[DM_DISP_TEXT] = hunk_markup(buf.read())   else:   row[DM_REJECTED] = True   row[DM_FONT] = self.rejfont   row[DM_DISP_TEXT] = hunk_unmarkup(buf.read())     def update_diff_header(self, dmodel, wfile, selected):   try:   hc = self.filerowstart[wfile]   chunks = self.filechunks[wfile]   except IndexError:   return   lasthunk = len(chunks)-1   sel = lambda x: x >= lasthunk or not dmodel[hc+x+1][DM_REJECTED]   newtext = chunks[0].selpretty(sel)   if not selected:   newtext = "<span foreground='#888888'>" + newtext + "</span>"   dmodel[hc][DM_DISP_TEXT] = newtext       def show_toggle(self, check, toggletype):   self.opts[toggletype] = check.get_active()   self.reload_status()   return True       def sort_by_stat(self, model, iter1, iter2):   order = 'MAR!?IC'   lhs, rhs = (model.get_value(iter1, FM_STATUS),   model.get_value(iter2, FM_STATUS))   # GTK+ bug that calls sort before a full row is inserted causing   # values to be None. When this happens, just return any value   # since the call is irrelevant and will be followed by another   # with the correct (non-None) value   if None in (lhs, rhs):   return 0     result = order.find(lhs) - order.find(rhs)   return min(max(result, -1), 1)       def text_color(self, column, text_renderer, model, row_iter):   stat = model[row_iter][FM_STATUS]   if stat == 'M':   text_renderer.set_property('foreground', '#000090')   elif stat == 'A':   text_renderer.set_property('foreground', '#006400')   elif stat == 'R':   text_renderer.set_property('foreground', '#900000')   elif stat == 'C':   text_renderer.set_property('foreground', 'black')   elif stat == '!':   text_renderer.set_property('foreground', 'red')   elif stat == '?':   text_renderer.set_property('foreground', '#AA5000')   elif stat == 'I':   text_renderer.set_property('foreground', 'black')   else:   text_renderer.set_property('foreground', 'black')       def rename_file(self, wfile):   fdir, fname = os.path.split(wfile)   newfile = dialog.entry_dialog(self, _('Rename file to:'), True, fname)   if newfile and newfile != fname:   self.hg_move([wfile, os.path.join(fdir, newfile)])   return True       def copy_file(self, wfile):   wfile = self.repo.wjoin(wfile)   fdir, fname = os.path.split(wfile)   response = gtklib.NativeSaveFileDialogWrapper(   Title=_('Copy file to'),   InitialDir=fdir,   FileName=fname).run()   if not response:   return   if response != wfile:   self.hg_copy([wfile, response])   return True       def hg_remove(self, files):   wfiles = [self.repo.wjoin(x) for x in files]   if self.count_revs() > 1:   gdialog.Prompt(_('Nothing Removed'),   _('Remove is not enabled when multiple revisions are specified.'),   self).run()   return     # Create new opts, so nothing unintented gets through   removeopts = self.merge_opts(commands.table['^remove|rm'][1],   ('include', 'exclude'))   def dohgremove():   commands.remove(self.ui, self.repo, *wfiles, **removeopts)   success, outtext = self._hg_call_wrapper('Remove', dohgremove)   if success:   self.reload_status()       def hg_move(self, files):   wfiles = [self.repo.wjoin(x) for x in files]   if self.count_revs() > 1:   gdialog.Prompt(_('Nothing Moved'), _('Move is not enabled when '   'multiple revisions are specified.'), self).run()   return     # Create new opts, so nothing unintented gets through   moveopts = self.merge_opts(commands.table['rename|mv'][1],   ('include', 'exclude'))   def dohgmove():   #moveopts['force'] = True   commands.rename(self.ui, self.repo, *wfiles, **moveopts)   success, outtext = self._hg_call_wrapper('Move', dohgmove)   if success:   self.reload_status()       def hg_copy(self, files):   wfiles = [self.repo.wjoin(x) for x in files]   if self.count_revs() > 1:   gdialog.Prompt(_('Nothing Copied'), _('Copy is not enabled when '   'multiple revisions are specified.'), self).run()   return     # Create new opts, so nothing unintented gets through   cmdopts = self.merge_opts(commands.table['copy|cp'][1],   ('include', 'exclude'))   def dohgcopy():   commands.copy(self.ui, self.repo, *wfiles, **cmdopts)   success, outtext = self._hg_call_wrapper('Copy', dohgcopy)   if success:   self.reload_status()     def tree_sel_changed(self, selection, tree, page_num=None):   'Selection changed in file tree'   # page_num may be supplied, if called from switch-page event   model, paths = selection.get_selected_rows()   if not paths:   return   row = paths[0]   if page_num is None:   page_num = self.diff_notebook.get_current_page()   if page_num == 0:   buf = self.generate_text_diffs(row)   self.diff_text.set_buffer(buf)   elif page_num == 1:   self.update_hunk_model(row, tree)   elif page_num == 2:   self.update_selection_preview()     def update_selection_preview(self):   'Refresh selected hunk view'   buf = cStringIO.StringIO()   dmodel = self.diffmodel   for row in self.filemodel:   if not row[FM_CHECKED]:   continue   wfile = row[FM_PATH]   if wfile in self.filechunks:   chunks = self.filechunks[wfile]   else:   chunks = self.read_file_chunks(wfile)   for c in chunks:   c.active = True   self.filechunks[wfile] = chunks   for i, chunk in enumerate(chunks):   if i == 0:   chunk.write(buf)   elif chunk.active:   chunk.write(buf)   difftext = buf.getvalue().splitlines(True)   self.preview_text.set_buffer(self.diff_highlight_buffer(difftext))     def diff_highlight_buffer(self, difftext):   buf = gtk.TextBuffer()   buf.create_tag('removed', foreground='#900000')   buf.create_tag('added', foreground='#006400')   buf.create_tag('position', foreground='#FF8000')   buf.create_tag('header', foreground='#000090')     bufiter = buf.get_start_iter()   for line in difftext:   line = hglib.toutf(line)   if line.startswith('---') or line.startswith('+++'):   buf.insert_with_tags_by_name(bufiter, line, 'header')   elif line.startswith('-'):   line = hglib.diffexpand(line)   buf.insert_with_tags_by_name(bufiter, line, 'removed')   elif line.startswith('+'):   line = hglib.diffexpand(line)   buf.insert_with_tags_by_name(bufiter, line, 'added')   elif line.startswith('@@'):   buf.insert_with_tags_by_name(bufiter, line, 'position')   else:   line = hglib.diffexpand(line)   buf.insert(bufiter, line)   return buf     def generate_text_diffs(self, row):   wfile = self.filemodel[row][FM_PATH]   pfile = util.pconvert(wfile)   difftext = []   if self.merging:   difftext = [_('===== Diff to first parent =====\n')]   matcher = cmdutil.matchfiles(self.repo, [pfile])   for s in patch.diff(self.repo, self._node1, self._node2,   match=matcher, opts=patch.diffopts(self.ui, self.opts)):   difftext.extend(s.splitlines(True))   if self.merging:   pctxs = self.repo[None].parents()   difftext.append(_('\n===== Diff to second parent =====\n'))   for s in patch.diff(self.repo, pctxs[1].node(), None,   match=matcher, opts=patch.diffopts(self.ui, self.opts)):   difftext.extend(s.splitlines(True))   return self.diff_highlight_buffer(difftext)       def update_hunk_model(self, row, tree):   # Read this file's diffs into hunk selection model   wfile = self.filemodel[row][FM_PATH]   self.filerowstart = {}   self.diffmodel.clear()   self.append_diff_hunks(wfile)   if len(self.diffmodel):   tree.scroll_to_cell(0, use_align=True, row_align=0.0)     def read_file_chunks(self, wfile):   'Get diffs of working file, parse into (c)hunks'   difftext = cStringIO.StringIO()   ctx = self.repo[self._node1]   try:   pfile = util.pconvert(wfile)   fctx = ctx.filectx(pfile)   except hglib.LookupError:   fctx = None   if fctx and fctx.size() > hglib.getmaxdiffsize(self.repo.ui):   # Fake patch that displays size warning   lines = ['diff --git a/%s b/%s\n' % (wfile, wfile)]   lines.append(_('File is larger than the specified max size.\n'))   lines.append(_('Hunk selection is disabled for this file.\n'))   lines.append('--- a/%s\n' % wfile)   lines.append('+++ b/%s\n' % wfile)   difftext.writelines(lines)   difftext.seek(0)   else:   matcher = cmdutil.matchfiles(self.repo, [pfile])   diffopts = mdiff.diffopts(git=True, nodates=True)   for s in patch.diff(self.repo, self._node1, self._node2,   match=matcher, opts=diffopts):   difftext.writelines(s.splitlines(True))   difftext.seek(0)   return hgshelve.parsepatch(difftext)     def append_diff_hunks(self, wfile):   'Append diff hunks of one file to the diffmodel'   chunks = self.read_file_chunks(wfile)   if not chunks:   if wfile in self.filechunks:   del self.filechunks[wfile]   return     for fr in self.filemodel:   if fr[FM_PATH] == wfile:   break   else:   # should not be possible   return     rows = []   for n, chunk in enumerate(chunks):   if isinstance(chunk, hgshelve.header):   # header chunk is always active   chunk.active = True   rows.append([False, '', True, wfile, n, self.headerfont])   if chunk.special():   chunks = chunks[:1]   break   else:   # chunks take file's selection state by default   chunk.active = fr[FM_CHECKED]   rows.append([False, '', False, wfile, n, self.difffont])       # recover old chunk selection/rejection states, match fromline   if wfile in self.filechunks:   ochunks = self.filechunks[wfile]   next = 1   for oc in ochunks[1:]:   for n in xrange(next, len(chunks)):   nc = chunks[n]   if oc.fromline == nc.fromline:   nc.active = oc.active   next = n+1   break   elif nc.fromline > oc.fromline:   break     self.filerowstart[wfile] = len(self.diffmodel)   self.filechunks[wfile] = chunks     # Set row status based on chunk state   rej, nonrej = False, False   for n, row in enumerate(rows):   if not row[DM_IS_HEADER]:   if chunks[n].active:   nonrej = True   else:   rej = True   row[DM_REJECTED] = not chunks[n].active   self.update_diff_hunk(row)   self.diffmodel.append(row)     if len(rows) == 1:   newvalue = fr[FM_CHECKED]   else:   newvalue = nonrej   partial = rej and nonrej   if fr[FM_PARTIAL_SELECTED] != partial:   fr[FM_PARTIAL_SELECTED] = partial   if fr[FM_CHECKED] != newvalue:   fr[FM_CHECKED] = newvalue   self.update_check_count()   self.update_diff_header(self.diffmodel, wfile, newvalue)       def diff_tree_row_act(self, dtree, path, column):   'Row in diff tree (hunk) activated/toggled'   dmodel = dtree.get_model()   row = dmodel[path]   wfile = row[DM_PATH]   try:   startrow = self.filerowstart[wfile]   chunks = self.filechunks[wfile]   except IndexError:   pass   chunkrows = xrange(startrow+1, startrow+len(chunks))   for fr in self.filemodel:   if fr[FM_PATH] == wfile:   break   if row[DM_IS_HEADER]:   for n, chunk in enumerate(chunks[1:]):   chunk.active = not fr[FM_CHECKED]   self.update_diff_hunk(dmodel[startrow+n+1])   newvalue = not fr[FM_CHECKED]   partial = False   else:   chunk = chunks[row[DM_CHUNK_ID]]   chunk.active = not chunk.active   self.update_diff_hunk(row)   rej = [ n for n in chunkrows if dmodel[n][DM_REJECTED] ]   nonrej = [ n for n in chunkrows if not dmodel[n][DM_REJECTED] ]   newvalue = nonrej and True or False   partial = rej and nonrej and True or False     # Update file's check status   if fr[FM_PARTIAL_SELECTED] != partial:   fr[FM_PARTIAL_SELECTED] = partial   if fr[FM_CHECKED] != newvalue:   fr[FM_CHECKED] = newvalue   chunks[0].active = newvalue   self.update_check_count()   self.update_diff_header(dmodel, wfile, newvalue)       def refresh_clicked(self, toolbutton, data=None):   self.reload_status()   return True     def save_clicked(self, toolbutton, data=None):   'Write selected diff hunks to a patch file'   revrange = self.opts.get('rev')[0]   filename = "%s.patch" % revrange.replace(':', '_to_')   fd = gtklib.NativeSaveFileDialogWrapper(Title=_('Save patch to'),   InitialDir=self.repo.root,   FileName=filename)   result = fd.run()   if not result:   return     buf = cStringIO.StringIO()   dmodel = self.diffmodel   for row in self.filemodel:   if not row[FM_CHECKED]:   continue   wfile = row[FM_PATH]   if wfile in self.filechunks:   chunks = self.filechunks[wfile]   else:   chunks = self.read_file_chunks(wfile)   for c in chunks:   c.active = True   for i, chunk in enumerate(chunks):   if i == 0:   chunk.write(buf)   elif chunk.active:   chunk.write(buf)   buf.seek(0)   try:   try:   fp = open(result, "w")   fp.write(buf.read())   except OSError:   pass   finally:   fp.close()     def diff_clicked(self, toolbutton, data=None):   diff_list = self.relevant_checked_files('MAR!')   if len(diff_list) > 0:   self._do_diff(diff_list, self.opts)   else:   gdialog.Prompt(_('Nothing Diffed'),   _('No diffable files selected'), self).run()   return True     def revert_clicked(self, toolbutton, data=None):   revert_list = self.relevant_checked_files('MAR!')   if len(revert_list) > 0:   self.hg_revert(revert_list)   else:   gdialog.Prompt(_('Nothing Reverted'),   _('No revertable files selected'), self).run()   return True       def hg_revert(self, files):   wfiles = [self.repo.wjoin(x) for x in files]   if self.count_revs() > 1:   gdialog.Prompt(_('Nothing Reverted'),   _('Revert not allowed when viewing revision range.'),   self).run()   return     # Create new opts, so nothing unintented gets through.   revertopts = self.merge_opts(commands.table['revert'][1],   ('include', 'exclude', 'rev'))   def dohgrevert():   commands.revert(self.ui, self.repo, *wfiles, **revertopts)     def filelist(files):   text = '\n'.join(files[:5])   if len(files) > 5:   text += ' ...\n'   return text     if self.merging:   res = gdialog.CustomPrompt(   _('Uncommited merge - please select a parent revision'),   _('Revert file(s) to local or other parent?'),   self, (_('&Local'), _('&Other'), _('&Cancel')), 2).run()   if res == 0:   revertopts['rev'] = self.repo[None].p1().rev()   elif res == 1:   revertopts['rev'] = self.repo[None].p2().rev()   else:   return   response = None   else:   # response: 0=Yes, 1=Yes,no backup, 2=Cancel   revs = revertopts['rev']   if revs and type(revs) == list:   revertopts['rev'] = revs[0]   else:   revertopts['rev'] = str(self.repo['.'].rev())   response = gdialog.CustomPrompt(_('Confirm Revert'),   _('Revert file(s) to revision %s?\n\n%s') % (revertopts['rev'],   filelist(files)), self, (_('&Yes (backup changes)'),   _('Yes (&discard changes)'),   _('&Cancel')), 2, 2).run()   if response in (None, 0, 1):   if response == 1:   revertopts['no_backup'] = True   success, outtext = self._hg_call_wrapper('Revert', dohgrevert)   if success:   shlib.shell_notify(wfiles)   self.reload_status()     def hg_forget(self, files):   wfiles = [self.repo.wjoin(x) for x in files]   commands.forget(self.ui, self.repo, *wfiles)   self.reload_status()     def add_clicked(self, toolbutton, data=None):   add_list = self.relevant_checked_files('?I')   if len(add_list) > 0:   self.hg_add(add_list)   else:   gdialog.Prompt(_('Nothing Added'),   _('No addable files selected'), self).run()   return True     def hg_add(self, files):   wfiles = [self.repo.wjoin(x) for x in files]   # Create new opts, so nothing unintented gets through   addopts = self.merge_opts(commands.table['^add'][1],   ('include', 'exclude'))   def dohgadd():   commands.add(self.ui, self.repo, *wfiles, **addopts)   success, outtext = self._hg_call_wrapper('Add', dohgadd)   if success:   shlib.shell_notify(wfiles)   self.reload_status()     def remove_clicked(self, toolbutton, data=None):   remove_list = self.relevant_checked_files('C!')   delete_list = self.relevant_checked_files('?I')   if len(remove_list) > 0:   self.hg_remove(remove_list)   if len(delete_list) > 0:   self.delete_files(delete_list)   if not remove_list and not delete_list:   gdialog.Prompt(_('Nothing Removed'),   _('No removable files selected'), self).run()   return True     def move_clicked(self, toolbutton, data=None):   move_list = self.relevant_checked_files('C')   if move_list:   # get destination directory to files into   dlg = gtklib.NativeFolderSelectDialog(   title=_('Move files to directory...'),   initial=self.repo.root)   destdir = dlg.run()   if not destdir:   return True     # verify directory   destroot = paths.find_root(destdir)   if destroot != self.repo.root:   gdialog.Prompt(_('Nothing Moved'),   _('Cannot move outside repo!'), self).run()   return True     # move the files to dest directory   move_list.append(hglib.fromutf(destdir))   self.hg_move(move_list)   else:   gdialog.Prompt(_('Nothing Moved'), _('No movable files selected\n\n'   'Note: only clean files can be moved.'), self).run()   return True     def forget_clicked(self, toolbutton, data=None):   forget_list = self.relevant_checked_files('CM')   if len(forget_list) > 0:   self.hg_forget(forget_list)   else:   gdialog.Prompt(_('Nothing Forgotten'),   _('No clean files selected'), self).run()     def delete_files(self, files):   dlg = gdialog.Confirm(_('Confirm Delete Unrevisioned'), files, self,   _('Delete the following unrevisioned files?'))   if dlg.run() == gtk.RESPONSE_YES:   errors = ''   for wfile in files:   try:   os.unlink(self.repo.wjoin(wfile))   except Exception, inst:   errors += str(inst) + '\n\n'     if errors:   errors = errors.replace('\\\\', '\\')   if len(errors) > 500:   errors = errors[:errors.find('\n',500)] + '\n...'   gdialog.Prompt(_('Delete Errors'), errors, self).run()     self.reload_status()   return True     def ignoremask_updated(self):   '''User has changed the ignore mask in hgignore dialog'''   self.reload_status()     def relevant_checked_files(self, stats):   return [item[FM_PATH] for item in self.filemodel \   if item[FM_CHECKED] and item[FM_STATUS] in stats]     def sel_clicked(self, state):   'selection header checkbox clicked'   for entry in self.filemodel:   if entry[FM_CHECKED] != state:   entry[FM_CHECKED] = state   self.update_chunk_state(entry)   self.update_check_count()     def tree_button_release(self, treeview, event):   if event.button != 3:   return False   self.tree_popup_menu(treeview)   return True     def tree_popup_menu(self, treeview):   model, tpaths = treeview.get_selection().get_selected_rows()   types = {'M':[], 'A':[], 'R':[], '!':[], 'I':[], '?':[], 'C':[],   'r':[], 'u':[]}   all = []   for p in tpaths:   row = model[p]   file = util.pconvert(row[FM_PATH])   ms = row[FM_MERGE_STATUS]   if ms == 'R':   types['r'].append(file)   elif ms == 'U':   types['u'].append(file)   else:   types[row[FM_STATUS]].append(file)   all.append(file)     def make(label, handler, stats):   files = []   for t in stats:   files.extend(types[t])   if not files:   return   item = gtk.MenuItem(label, True)   item.connect('activate', handler, files)   item.set_border_width(1)   menu.append(item)   return files     def vdiff(menuitem, files):   self._do_diff(files, self.opts)   def viewmissing(menuitem, files):   self._view_files(files, True)   def edit(menuitem, files):   self._view_files(files, False)   def other(menuitem, files):   self._view_files(files, True)   def revert(menuitem, files):   self.hg_revert(files)   def remove(menuitem, files):   self.hg_remove(files)   def log(menuitem, files): - from hggtk import history + from tortoisehg.hgtk import history   dlg = history.run(self.ui, canonpats=files)   dlg.display()   def forget(menuitem, files):   self.hg_forget(files)   def add(menuitem, files):   self.hg_add(files)   def delete(menuitem, files):   self.delete_files(files)   def unmark(menuitem, files):   ms = merge_.mergestate(self.repo)   for wfile in files:   ms.mark(wfile, "u")   self.reload_status()   def mark(menuitem, files):   ms = merge_.mergestate(self.repo)   for wfile in files:   ms.mark(wfile, "r")   self.reload_status()   def resolve(stat, files):   wctx = self.repo[None]   mctx = wctx.parents()[-1]   for wfile in files:   ms = merge_.mergestate(self.repo)   ms.resolve(wfile, wctx, mctx)   self.reload_status()   def resolve_with(stat, tool, files):   if tool:   oldmergeenv = os.environ.get('HGMERGE')   os.environ['HGMERGE'] = tool   resolve(stat, files)   if tool:   if oldmergeenv:   os.environ['HGMERGE'] = oldmergeenv   else:   del os.environ['HGMERGE']   def rename(menuitem, files):   self.rename_file(files[0])   def copy(menuitem, files):   self.copy_file(files[0])   def guess_rename(menuitem, files):   dlg = guess.DetectRenameDialog()   dlg.show_all()   dlg.set_notify_func(self.ignoremask_updated)   def ignore(menuitem, files):   dlg = hgignore.HgIgnoreDialog(files[0])   dlg.show_all()   dlg.set_notify_func(self.ignoremask_updated)     menu = gtk.Menu()   make(_('_visual diff'), vdiff, 'MAR!ru')   make(_('edit'), edit, 'MACI?ru')   make(_('view missing'), viewmissing, 'R!')   if self.merging:   make(_('view other'), other, 'MAru')   make(_('_revert'), revert, 'MAR!ru')   make(_('l_og'), log, 'MARC!ru')   make(_('_forget'), forget, 'MARC!ru')   make(_('_add'), add, 'I?')   make(_('_guess rename'), guess_rename, '?')   make(_('_ignore'), ignore, '?')   make(_('remove versioned'), remove, 'C')   make(_('_delete unversioned'), delete, '?I')   if len(all) == 1:   make(_('_copy'), copy, 'MC')   make(_('rename'), rename, 'MC')   f = make(_('restart merge'), resolve, 'u')   make(_('mark unresolved'), unmark, 'r')   make(_('mark resolved'), mark, 'u')   if f:   rmenu = gtk.Menu()   for tool in hglib.mergetools(self.repo.ui):   item = gtk.MenuItem(tool, True)   item.connect('activate', resolve_with, tool, f)   item.set_border_width(1)   rmenu.append(item)   item = gtk.MenuItem(_('restart merge with'), True)   item.set_submenu(rmenu)   menu.append(item)     for label, func, stats in self.get_custom_menus():   make(label, func, stats)     if len(menu.get_children()) > 0:   menu.show_all()   menu.popup(None, None, None, 0, 0)   return True       def tree_key_press(self, tree, event):   'Make spacebar toggle selected rows'   if event.keyval == 32:   def toggler(model, path, bufiter):   model[path][FM_CHECKED] = not model[path][FM_CHECKED]   self.update_chunk_state(model[path])     selection = self.filetree.get_selection()   selection.selected_foreach(toggler)   self.update_check_count()   return True   return False       def tree_row_act(self, tree, path, column):   'Activation (return) triggers visual diff of selected rows'   # Ignore activations (like double click) on the first column   if column.get_sort_column_id() == 0:   return True     model, tpaths = self.filetree.get_selection().get_selected_rows()   files = [model[p][FM_PATH] for p in tpaths]   self._do_diff(files, self.opts)   return True     def isuptodate(self):   oldparents = self.repo.dirstate.parents()   self.repo.dirstate.invalidate()   if oldparents == self.repo.dirstate.parents():   return True   response = gdialog.CustomPrompt(_('not up to date'),   _('The parents have changed since the last refresh.\n'   'Continue anyway?'),   self, (_('&Yes'), _('&Refresh'), _('&Cancel')), 1, 2).run()   if response == 0: # Yes   return True   if response == 1:   self.reload_status()   return False    def run(ui, *pats, **opts):   showclean = pats and True or False   rev = opts.get('rev', [])   cmdoptions = {   'all':False, 'clean':showclean, 'ignored':False, 'modified':True,   'added':True, 'removed':True, 'deleted':True, 'unknown':True,   'exclude':[], 'include':[], 'debug':True, 'verbose':True, 'git':False,   'rev':rev, 'check':True   }   return GStatus(ui, None, None, pats, cmdoptions)
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​synch.py Stacked
renamed from hggtk/synch.py
 
17
18
19
20
21
 
 
22
23
24
 
 
25
26
27
 
17
18
19
 
 
20
21
22
 
 
23
24
25
26
27
@@ -17,11 +17,11 @@
   from mercurial import hg, ui, extensions, url   -from thgutil.i18n import _ -from thgutil import hglib, settings, paths +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, settings, paths   -from hggtk import dialog, gtklib, hgthread, history, thgconfig, hgemail -from hggtk import thgshelve +from tortoisehg.hgtk import dialog, gtklib, hgthread, history, thgconfig +from tortoisehg.hgtk import thgshelve, hgemail    class SynchDialog(gtk.Window):   def __init__(self, repos=[], pushmode=False, fromlog=False):
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​tagadd.py Stacked
renamed from hggtk/tagadd.py
 
12
13
14
15
16
 
 
17
18
 
19
20
21
 
12
13
14
 
 
15
16
17
 
18
19
20
21
@@ -12,10 +12,10 @@
   from mercurial import hg, ui, util   -from thgutil.i18n import _ -from thgutil import hglib, settings, i18n +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, settings, i18n   -from hggtk import dialog, gtklib +from tortoisehg.hgtk import dialog, gtklib    keep = i18n.keepgettext()  
Change 1 of 2 Show Entire File tortoisehg/​hgtk/​taskbarui.py Stacked
renamed from hggtk/taskbarui.py
 
9
10
11
12
13
14
 
 
 
15
16
17
 
207
208
209
210
 
211
212
213
 
9
10
11
 
 
 
12
13
14
15
16
17
 
207
208
209
 
210
211
212
213
@@ -9,9 +9,9 @@
 import gtk  import gobject   -from thgutil.i18n import _ -from thgutil import hglib, settings, menuthg -from hggtk import gtklib +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, settings, menuthg +from tortoisehg.hgtk import gtklib    shellcmds = '''about add clone commit datamine init log recovery  shelve synch status thgstatus userconf repoconf remove rename @@ -207,7 +207,7 @@
  return frame     def about(self, button): - from hggtk import about + from tortoisehg.hgtk import about   dlg = about.AboutDialog()   dlg.show_all()  
Change 1 of 2 Show Entire File tortoisehg/​hgtk/​thgconfig.py Stacked
renamed from hggtk/thgconfig.py
 
14
15
16
17
18
 
 
19
20
 
21
22
23
 
734
735
736
737
 
738
739
740
 
14
15
16
 
 
17
18
19
 
20
21
22
23
 
734
735
736
 
737
738
739
740
@@ -14,10 +14,10 @@
   from mercurial import hg, ui, util, url, filemerge   -from thgutil.i18n import _ -from thgutil import hglib, settings, paths +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, settings, paths   -from hggtk import dialog, gdialog, gtklib, hgcmd +from tortoisehg.hgtk import dialog, gdialog, gtklib, hgcmd    _unspecstr = _('<unspecified>')  _unspeclocalstr = hglib.fromutf(_unspecstr) @@ -734,7 +734,7 @@
  self.pathdata.get_path(i),   self.pathtree.get_column(0))   self.refresh_path_list() - # This method may be called from hggtk.sync, so ensure page is visible + # This method may be called from hgtk.sync, so ensure page is visible   self.notebook.set_current_page(3)   self.dirty_event()  
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​thgmq.py Stacked
renamed from hggtk/thgmq.py
 
10
11
12
13
14
 
 
15
16
 
17
18
19
 
10
11
12
 
 
13
14
15
 
16
17
18
19
@@ -10,10 +10,10 @@
 import gobject  import pango   -from thgutil.i18n import _ -from thgutil import hglib +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib   -from hggtk import gtklib, hgcmd +from tortoisehg.hgtk import gtklib, hgcmd    # MQ patches row enumerations  MQ_INDEX = 0
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​thgshelve.py Stacked
renamed from hggtk/thgshelve.py
 
12
13
14
15
16
 
 
17
18
19
 
 
20
21
22
 
12
13
14
 
 
15
16
17
 
 
18
19
20
21
22
@@ -12,11 +12,11 @@
   from mercurial import util   -from thgutil.i18n import _ -from thgutil import hglib +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, hgshelve   -from hggtk.status import GStatus, FM_STATUS, FM_CHECKED -from hggtk import hgshelve, gdialog, gtklib +from tortoisehg.hgtk.status import GStatus, FM_STATUS, FM_CHECKED +from tortoisehg.hgtk import gdialog, gtklib    class GShelve(GStatus):   """GTK+ based dialog for displaying repository status and shelving changes.
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​update.py Stacked
renamed from hggtk/update.py
 
12
13
14
15
16
 
 
17
18
 
19
20
21
 
12
13
14
 
 
15
16
17
 
18
19
20
21
@@ -12,10 +12,10 @@
   from mercurial import hg, ui   -from thgutil.i18n import _ -from thgutil import hglib, paths +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, paths   -from hggtk import hgcmd, gtklib +from tortoisehg.hgtk import hgcmd, gtklib    _branch_tip_ = _('= Current Branch Tip =')  
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​visdiff.py Stacked
renamed from hggtk/visdiff.py
 
15
16
17
18
19
 
 
20
21
 
22
23
24
 
15
16
17
 
 
18
19
20
 
21
22
23
24
@@ -15,10 +15,10 @@
   from mercurial import hg, ui, cmdutil, util   -from thgutil.i18n import _ -from thgutil import hglib, settings, paths +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib, settings, paths   -from hggtk import gdialog, gtklib +from tortoisehg.hgtk import gdialog, gtklib    try:   import win32con
Show Entire File tortoisehg/​util/​__init__.py Stacked
renamed from thgutil/__init__.py
(No changes)
Show Entire File tortoisehg/​util/​cachethg.py Stacked
renamed from thgutil/cachethg.py
(No changes)
Show Entire File tortoisehg/​util/​debugthg.py Stacked
renamed from thgutil/debugthg.py
(No changes)
Change 1 of 1 Show Entire File tortoisehg/​util/​hglib.py Stacked
renamed from thgutil/hglib.py
 
22
23
24
25
 
26
27
28
 
22
23
24
 
25
26
27
28
@@ -22,7 +22,7 @@
 _encodingmode = encoding.encodingmode  _fallbackencoding = encoding.fallbackencoding   -from thgutil.hgversion import hgversion +from tortoisehg.util.hgversion import hgversion    def tounicode(s):   """
Change 1 of 1 Show Entire File tortoisehg/​util/​hgshelve.py Stacked
renamed from hggtk/hgshelve.py
 
21
22
23
24
25
 
 
26
27
28
 
21
22
23
 
 
24
25
26
27
28
@@ -21,8 +21,8 @@
 from mercurial import cmdutil, commands, cmdutil, hg, mdiff, patch, revlog  from mercurial import util, fancyopts   -from thgutil.i18n import _ -from thgutil import hglib +from tortoisehg.util.i18n import _ +from tortoisehg.util import hglib    lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')  
Show Entire File tortoisehg/​util/​hgversion.py Stacked
renamed from thgutil/hgversion.py
(No changes)
Change 1 of 1 Show Entire File tortoisehg/​util/​i18n.py Stacked
renamed from thgutil/i18n.py
 
7
8
9
10
 
11
12
13
 
7
8
9
 
10
11
12
13
@@ -7,7 +7,7 @@
   import gettext, sys  from gettext import gettext as _ -from thgutil import paths, hglib +from tortoisehg.util import paths, hglib    gettext.bindtextdomain("tortoisehg", paths.get_locale_path())  gettext.textdomain("tortoisehg")
Show Entire File tortoisehg/​util/​menuthg.py Stacked
renamed from thgutil/menuthg.py
(No changes)
Change 1 of 2 Show Entire File tortoisehg/​util/​paths.py Stacked
renamed from thgutil/paths.py
 
66
67
68
69
 
70
71
72
 
99
100
101
102
 
103
104
105
 
66
67
68
 
69
70
71
72
 
99
100
101
 
102
103
104
105
@@ -66,7 +66,7 @@
  return _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE,   r"Software\TortoiseHg")   except: - return os.path.dirname(os.path.dirname(__file__)) + return os.path.dirname(os.path.dirname(os.path.dirname(__file__)))     def netdrive_status(drive):   """ @@ -99,7 +99,7 @@
  return None     def get_prog_root(): - path = os.path.dirname(os.path.dirname(__file__)) + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))   return path     def netdrive_status(drive):
Show Entire File tortoisehg/​util/​settings.py Stacked
renamed from thgutil/settings.py
(No changes)
Show Entire File tortoisehg/​util/​shlib.py Stacked
renamed from thgutil/shlib.py
(No changes)
Change 1 of 1 Show Entire File tortoisehg/​util/​thgstatus.py Stacked
renamed from hggtk/thgstatus.py
 
8
9
10
11
 
12
13
14
 
8
9
10
 
11
12
13
14
@@ -8,7 +8,7 @@
 '''update TortoiseHg status cache'''    from mercurial import hg -from thgutil import paths, shlib +from tortoisehg.util import paths, shlib  import os    def cachefilepath(repo):
Show Entire File tortoisehg/​util/​thread2.py Stacked
renamed from thgutil/thread2.py
(No changes)
Change 1 of 1 Show Entire File tortoisehg/​util/​version.py Stacked
renamed from thgutil/version.py
 
5
6
7
8
 
9
10
11
 
5
6
7
 
8
9
10
11
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.   -from thgutil.i18n import _ +from tortoisehg.util.i18n import _    def version():   try:
Change 1 of 1 Show Entire File win32/​reggen.py Stacked
 
18
19
20
21
 
22
23
24
25
26
 
27
28
29
 
18
19
20
 
21
22
23
24
25
 
26
27
28
29
@@ -18,12 +18,12 @@
  pfile = pfile[:-1]   path = os.path.dirname(os.path.dirname(os.path.realpath(pfile)))   thgpath = os.path.normpath(path) - testpath = os.path.join(thgpath, 'thgutil') + testpath = os.path.join(thgpath, 'tortoisehg')   if os.path.isdir(testpath) and thgpath not in sys.path:   sys.path.insert(0, thgpath)  _thg_path()   -from thgutil.menuthg import thgcmenu +from tortoisehg.util.menuthg import thgcmenu    regkeytmpl = u'[HKEY_CURRENT_USER\\Software\\TortoiseHg\\CMenu\\%s\\%s]'  regheaders = ( u'Windows Registry Editor Version 5.00',