Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

hggtk: refactor markup escape function

Changeset db7973affdc8

Parent 906363e76fc7

by Wagner Bruna

Changes to 7 files · Browse files at db7973affdc8 Showing diff from parent 906363e76fc7 Diff from another changeset...

 
45
46
47
 
48
49
50
 
341
342
343
344
 
345
346
347
 
45
46
47
48
49
50
51
 
342
343
344
 
345
346
347
348
@@ -45,6 +45,7 @@
 _thg_path()    from thgutil import paths, debugthg, hglib, cachethg +from hggtk import gtklib    if debugthg.debug('N'):   debugf = debugthg.debugf @@ -341,7 +342,7 @@
  parents = '\n'.join([short(p.node()) for p in ctx.parents()])   description = ctx.description()   user = ctx.user() - user = gobject.markup_escape_text(user) + user = gtklib.markup_escape_text(user)   tags = ', '.join(ctx.tags())   branch = ctx.branch()  
Change 1 of 1 Show Entire File hggtk/​backout.py Stacked
 
91
92
93
94
 
95
96
97
 
91
92
93
 
94
95
96
97
@@ -91,7 +91,7 @@
  revstr = str(ctx.rev())   summary = ctx.description().replace('\0', '')   summary = summary.split('\n')[0] - escape = gobject.markup_escape_text + escape = gtklib.markup_escape_text   desc = '<b>' + _('rev') + '</b>\t\t: %s\n' % escape(revstr)   desc += '<b>' + _('summary') + '</b>\t: %s\n' % escape(summary[:80])   desc += '<b>' + _('user') + '</b>\t\t: %s\n' % escape(ctx.user())
Change 1 of 1 Show Entire File hggtk/​datamine.py Stacked
 
177
178
179
180
 
181
182
183
 
177
178
179
 
180
181
182
183
@@ -177,7 +177,7 @@
  author = util.shortuser(ctx.user())   summary = ctx.description().replace('\0', '')   summary = toutf(summary.split('\n')[0]) - summary = gobject.markup_escape_text(summary) + summary = gtklib.markup_escape_text(summary)   date = displaytime(ctx.date())   desc = toutf(author+'@'+str(rev)+' '+date+' "') + summary + '"'   author = toutf(author)
Change 1 of 1 Show Entire File hggtk/​gtklib.py Stacked
 
15
16
17
 
 
18
19
20
 
15
16
17
18
19
20
21
22
@@ -15,6 +15,8 @@
   from hggtk import hgtk   +from gobject import markup_escape_text +  def set_tortoise_icon(window, thgicon):   ico = paths.get_tortoise_icon(thgicon)   if ico: window.set_icon_from_file(ico)
 
13
14
15
 
16
17
18
 
120
121
122
123
 
124
125
126
 
13
14
15
16
17
18
19
 
121
122
123
 
124
125
126
127
@@ -13,6 +13,7 @@
 from mercurial import util  from mercurial.hgweb import webutil  from thgutil import hglib +from hggtk import gtklib    # treemodel row enumerated attributes  LINES = 0 @@ -120,7 +121,7 @@
  summary = summary[0:80]   else:   summary = summary.split('\n')[0] - summary = gobject.markup_escape_text(hglib.toutf(summary)) + summary = gtklib.markup_escape_text(hglib.toutf(summary))   node = self.repo.lookup(revid)   tags = self.repo.nodetags(node)   taglist = hglib.toutf(', '.join(tags))
Change 1 of 1 Show Changes Only hggtk/​merge.py Stacked
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
 
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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
 #  # merge.py - TortoiseHg's dialog for merging revisions  #  # Copyright (C) 2007 TK Soh <teekaysoh@gmail.com>  #    import os  import gtk  import gobject    from mercurial import hg, ui    from thgutil.i18n import _  from thgutil import hglib, paths    from hggtk import gtklib, commit, gdialog, hgcmd    class MergeDialog(gtk.Window):   """ Dialog to merge revisions of a Mercurial repo """   def __init__(self, rev=None):   """ Initialize the Dialog """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)   gtklib.set_tortoise_icon(self, 'menumerge.ico')   gtklib.set_tortoise_keys(self)   self.notify_func = None     if not rev:   gdialog.Prompt(_('Unable to merge'),   _('Must supply a target revision'), self).run()   gobject.idle_add(self.destroy)   return     try:   repo = hg.repository(ui.ui(), path=paths.find_root())   except hglib.RepoError:   gobject.idle_add(self.destroy)   return     title = _("Merging in ") + hglib.toutf(os.path.basename(repo.root))   self.set_title(title)   self.set_default_size(350, 120)     vbox = gtk.VBox()   self.add(vbox)     frame = gtk.Frame(_('Merge target (other)'))   lbl = gtk.Label()   other, desc = self.revdesc(repo, rev)   lbl.set_markup(desc)   lbl.set_alignment(0, 0)   frame.add(lbl)   frame.set_border_width(5)   vbox.pack_start(frame, False, False, 2)     frame = gtk.Frame(_('Current revision (local)'))   lbl = gtk.Label()   local, desc = self.revdesc(repo, '.')   lbl.set_markup(desc)   lbl.set_alignment(0, 0)   frame.add(lbl)   frame.set_border_width(5)   vbox.pack_start(frame, False, False, 2)     accelgroup = gtk.AccelGroup()   self.add_accel_group(accelgroup)   mod = gtklib.get_thg_modifier()     hbbox = gtk.HButtonBox()   hbbox.set_layout(gtk.BUTTONBOX_END)   vbox.pack_start(hbbox, False, False, 2)     close = gtk.Button(_('Close'))   close.connect('clicked', lambda x: self.destroy())   key, modifier = gtk.accelerator_parse('Escape')   close.add_accelerator('clicked', accelgroup, key, 0,   gtk.ACCEL_VISIBLE)   hbbox.add(close)     undo = gtk.Button(_('Undo'))   hbbox.add(undo)   undo.set_sensitive(False)     commit = gtk.Button(_('Commit'))   hbbox.add(commit)   commit.set_sensitive(False)     merge = gtk.Button(_('Merge'))   key, modifier = gtk.accelerator_parse(mod+'Return')   merge.add_accelerator('clicked', accelgroup, key, modifier,   gtk.ACCEL_VISIBLE)   hbbox.add(merge)   merge.grab_focus()     undo.connect('clicked', self.undo, local, merge, commit)   merge.connect('clicked', self.merge, other, commit, undo)   commit.connect('clicked', self.commit)     def revdesc(self, repo, revid):   ctx = repo[revid]   revstr = str(ctx.rev())   summary = ctx.description().replace('\0', '')   summary = summary.split('\n')[0] - escape = gobject.markup_escape_text + escape = gtklib.markup_escape_text   desc = '<b>' + _('rev') + '</b>\t\t: %s\n' % escape(revstr)   desc += '<b>' + _('summary') + '</b>\t: %s\n' % escape(summary[:80])   desc += '<b>' + _('user') + '</b>\t\t: %s\n' % escape(ctx.user())   desc += '<b>' + _('date') + '</b>\t\t: %s\n' \   % escape(hglib.displaytime(ctx.date()))   node = repo.lookup(revid)   tags = repo.nodetags(node)   desc += '<b>' + _('branch') + '</b>\t: ' + escape(ctx.branch())   if tags:   desc += '\n<b>' + _('tags') + '</b>\t\t: ' \   + escape(', '.join(tags))   if node not in repo.heads():   desc += '\n<b>' + _('Not a head revision!') + '</b>'   return revstr, hglib.toutf(desc)     def set_notify_func(self, func, *args):   self.notify_func = func   self.notify_args = args     def merge(self, button, other, commit, undo):   cmdline = ['hg', 'merge', '--rev', other]   dlg = hgcmd.CmdDialog(cmdline)   dlg.run()   dlg.hide()   repo = hg.repository(ui.ui(), path=paths.find_root())   if len(repo.parents()) == 1:   return   if self.notify_func:   self.notify_func(self.notify_args)   button.set_sensitive(False)   undo.set_sensitive(True)   commit.set_sensitive(True)   commit.grab_focus()     def commit(self, button):   dlg = commit.run(ui.ui())   dlg.set_modal(True)   dlg.set_notify_func(self.commit_notify, dlg)   dlg.display()     def commit_notify(self, dlg):   # refresh the log tool   if self.notify_func:   self.notify_func(self.notify_args)   # close merge dialog   self.destroy()   # close commit tool after allowing it to finish post-processing   gobject.idle_add(dlg.destroy)     def undo(self, button, local, merge, commit):   response = gdialog.Confirm(_('Confirm undo merge'), [], self,   _('Clean checkout of original revision?')).run()   if response != gtk.RESPONSE_YES:   return   cmdline = ['hg', 'update', '--rev', local, '--clean']   dlg = hgcmd.CmdDialog(cmdline)   dlg.run()   dlg.hide()   if self.notify_func:   self.notify_func(self.notify_args)   button.set_sensitive(False)   commit.set_sensitive(False)   merge.set_sensitive(True)   merge.grab_focus()    def run(ui, *pats, **opts):   return MergeDialog(opts.get('rev'))
Change 1 of 2 Show Entire File hggtk/​status.py Stacked
 
42
43
44
45
 
46
47
48
 
60
61
62
63
 
64
65
66
 
42
43
44
 
45
46
47
48
 
60
61
62
 
63
64
65
66
@@ -42,7 +42,7 @@
  hunk = ""   lines = text.split('\n')   for line in lines: - line = gobject.markup_escape_text(hglib.toutf(line[:512])) + '\n' + 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('-'): @@ -60,7 +60,7 @@
  hunk = ""   lines = text.split('\n')   for line in lines: - line = gobject.markup_escape_text(hglib.toutf(line[:512])) + '\n' + line = gtklib.markup_escape_text(hglib.toutf(line[:512])) + '\n'   hunk += line   return hunk