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

bookmark: fix doc string

Changeset 56e337034fae

Parent 760cf066f67a

by Yuki KODAMA

Changes to one file · Browse files at 56e337034fae Showing diff from parent 760cf066f67a Diff from another changeset...

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
 
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
-# bookmarkadd.py - TortoiseHg dialog to add bookmark +# bookmark.py - TortoiseHg dialog to add/remove/rename bookmarks  #  # Copyright 2007 TK Soh <teekaysoh@gmail.com>  # Copyright 2007 Steve Borho <steve@borho.org>  # Copyright 2009 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 gtk  import traceback    from mercurial import ui, util  from hgext import bookmarks    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, i18n    from tortoisehg.hgtk import dialog, gtklib    RESPONSE_ADD = 1  RESPONSE_REMOVE = 2    class BookmarkAddDialog(gtk.Dialog):   """ Dialog to add bookmark to Mercurial repo """   def __init__(self, repo, bookmark='', rev=''):   """ Initialize the Dialog """   gtk.Dialog.__init__(self)   gtklib.set_tortoise_keys(self)   self.set_title(_('Bookmark - %s') % hglib.get_reponame(repo))   self.set_resizable(False)   self.set_has_separator(False)   self.connect('response', self.dialog_response)     self.repo = repo     # add buttons   self.add_button(_('Add'), RESPONSE_ADD)   self.add_button(_('Remove'), RESPONSE_REMOVE)   self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)     # layout table   table = gtklib.LayoutTable()   self.vbox.pack_start(table, True, True, 2)     ## bookmark name input   self._bookmarkslist = gtk.ListStore(str)   self._bookmarklistbox = gtk.ComboBoxEntry(self._bookmarkslist, 0)   self._bookmark_input = self._bookmarklistbox.get_child()   self._bookmark_input.connect('activate',   lambda w: self.response(RESPONSE_ADD))   self._bookmark_input.set_text(bookmark)   table.add_row(_('Bookmark:'), self._bookmarklistbox, padding=False)     ## revision input   self._rev_input = gtk.Entry()   self._rev_input.set_width_chars(12)   self._rev_input.set_text(rev)   table.add_row(_('Revision:'), self._rev_input)     # prepare to show   self._refresh()   self._bookmarklistbox.grab_focus()     def _refresh(self):   """ update display on dialog with recent repo data """   self.repo.invalidate()   self._bookmarkslist.clear()   self._bookmark_input.set_text('')     # add bookmarks to drop-down list   bookmarks = hglib.get_repo_bookmarks(self.repo)   bookmarks.sort()   for bookmarkname in bookmarks:   if bookmarkname != 'tip':   self._bookmarkslist.append([bookmarkname])     def dialog_response(self, dialog, response_id):   # Add button   if response_id == RESPONSE_ADD:   self._do_add_bookmark()   # Remove button   elif response_id == RESPONSE_REMOVE:   self._do_remove_bookmark()   # Close button or closed by the user   elif response_id in (gtk.RESPONSE_CLOSE, gtk.RESPONSE_DELETE_EVENT):   self.destroy()   return # close dialog   else:   raise _('unexpected response id: %s') % response_id     self.run() # don't close dialog     def _do_add_bookmark(self):   # gather input data   name = self._bookmark_input.get_text()   rev = self._rev_input.get_text()     # verify input   if name == '':   dialog.error_dialog(self, _('Bookmark input is empty'),   _('Please enter bookmark name'))   self._bookmark_input.grab_focus()   return False     # add bookmark to repo   try:   self._add_hg_bookmark(name, rev)   dialog.info_dialog(self, _('Bookmarking completed'),   _('Bookmark "%s" has been added') % name)   self._refresh()   except util.Abort, inst:   dialog.error_dialog(self, _('Error in bookmarking'), str(inst))   return False   except:   dialog.error_dialog(self, _('Error in bookmarking'),   traceback.format_exc())   return False     def _do_remove_bookmark(self):   # gather input data   name = self._bookmark_input.get_text()     # verify input   if name == '':   dialog.error_dialog(self, _('Bookmark name is empty'),   _('Please select bookmark name to remove'))   self._bookmark_input.grab_focus()   return False     try:   self._remove_hg_bookmark(name)   dialog.info_dialog(self, _('Bookmarking completed'),   _('Bookmark "%s" has been removed') % name)   self._refresh()   except util.Abort, inst:   dialog.error_dialog(self, _('Error in bookmarking'), str(inst))   return False   except:   dialog.error_dialog(self, _('Error in bookmarking'),   traceback.format_exc())   return False     def _add_hg_bookmark(self, name, revision):   if name in hglib.get_repo_bookmarks(self.repo):   raise util.Abort(_('a bookmark named "%s" already exists') % name)     bookmarks.bookmark(ui=ui.ui(),   repo=self.repo,   rev=revision,   mark=name)     def _remove_hg_bookmark(self, name):   if not name in hglib.get_repo_bookmarks(self.repo):   raise util.Abort(_("Bookmark '%s' does not exist") % name)     bookmarks.bookmark(ui=ui.ui(),   repo=self.repo,   mark=name,   delete=True)    class BookmarkRenameDialog(gtk.Dialog):   """ Dialog to rename a bookmark """   def __init__(self, repo, bookmark='', rev=''):   """ Initialize the Dialog """   gtk.Dialog.__init__(self,   buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))   gtklib.set_tortoise_keys(self)   self.set_title(_('Bookmark - %s') % hglib.get_reponame(repo))   self.set_resizable(False)   self.set_has_separator(False)   self.connect('response', self.dialog_response)     self.repo = repo     # add Rename button   renamebutton = gtk.Button(_('Rename'))   renamebutton.connect('clicked', lambda b: self._do_rename_bookmark())   self.action_area.pack_end(renamebutton)     # top layout table   table = gtklib.LayoutTable()   self.vbox.pack_start(table, True, True, 2)     ## bookmark name input   self._bookmarkslist = gtk.ListStore(str)   self._bookmarklistbox = gtk.ComboBoxEntry(self._bookmarkslist, 0)   self._bookmark_input = self._bookmarklistbox.get_child()   self._bookmark_input.connect('activate', self._bookmarkinput_activated)   self._bookmark_input.set_text(bookmark)   table.add_row(_('Bookmark:'), self._bookmarklistbox, padding=False)     ## revision input   self._name_input = gtk.Entry()   table.add_row(_('New name:'), self._name_input)     # prepare to show   self._refresh()   self._bookmarklistbox.grab_focus()     def _refresh(self):   """ update display on dialog with recent repo data """   self.repo.invalidate()   self._bookmarkslist.clear()   self._bookmark_input.set_text('')     # add bookmarks to drop-down list   bookmarks = hglib.get_repo_bookmarks(self.repo)   bookmarks.sort()   for bookmarkname in bookmarks:   if bookmarkname == 'tip':   continue   self._bookmarkslist.append([bookmarkname])     def dialog_response(self, dialog, response_id):   if response_id == gtk.RESPONSE_CLOSE \   or response_id == gtk.RESPONSE_DELETE_EVENT:   self.destroy()     def _bookmarkinput_activated(self, bookmarkinput):   self._do_rename_bookmark()     def _do_rename_bookmark(self):   # gather input data   name = self._bookmark_input.get_text()   new_name = self._name_input.get_text()     # verify input   if name == '':   dialog.error_dialog(self, _('Bookmark input is empty'),   _('Please enter bookmark name'))   self._bookmark_input.grab_focus()   return False     if new_name == '':   dialog.error_dialog(self, _('Bookmark new name input is empty'),   _('Please enter new bookmark name'))   self._bookmark_input.grab_focus()   return False     # rename bookmark   try:   self._rename_hg_bookmark(name, new_name)   dialog.info_dialog(self, _('Bookmarking completed'),   _('Bookmark "%s" has been renamed to "%s"') %   (name, new_name))   self._refresh()   except util.Abort, inst:   dialog.error_dialog(self, _('Error in bookmarking'), str(inst))   return False   except:   dialog.error_dialog(self, _('Error in bookmarking'),   traceback.format_exc())   return False     def _rename_hg_bookmark(self, name, new_name):   if new_name in hglib.get_repo_bookmarks(self.repo):   raise util.Abort(_('a bookmark named "%s" already exists') % new_name)   bookmarks.bookmark(ui=ui.ui(),   repo=self.repo,   mark=new_name,   rename=name)