Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9.1, 1.9.2, and 1.9.3

hgqt: branch, tag, bookmark APIs are all in local encoding

Reviewed all code under hgqt and verified all uses of UTF-8 are now valid.

Changeset 7b2980a423b1

Parent b77c00662719

by Steve Borho

Changes to 7 files · Browse files at 7b2980a423b1 Showing diff from parent b77c00662719 Diff from another changeset...

 
142
143
144
145
146
 
 
147
148
149
 
161
162
163
164
 
165
166
167
 
179
180
181
182
183
 
 
184
185
186
 
188
189
190
191
 
192
193
194
 
197
198
199
200
201
 
 
202
203
204
205
206
207
 
208
209
210
 
214
215
216
217
 
218
219
220
221
 
 
222
223
224
225
 
226
227
228
229
230
231
232
233
 
 
234
235
236
 
142
143
144
 
 
145
146
147
148
149
 
161
162
163
 
164
165
166
167
 
179
180
181
 
 
182
183
184
185
186
 
188
189
190
 
191
192
193
194
 
197
198
199
 
 
200
201
202
203
204
205
206
 
207
208
209
210
 
214
215
216
 
217
218
219
 
 
220
221
222
223
224
 
225
226
227
228
229
230
231
 
 
232
233
234
235
236
@@ -142,8 +142,8 @@
    def toggle_new_bookmark(self):   bookmark = self.bookmark_combo.currentText() - bookmarkutf = unicode(bookmark).encode('utf-8') - is_new = bookmarkutf not in self.repo.bookmarks + bookmarklocal = hglib.fromunicode(bookmark) + is_new = bookmarklocal not in self.repo.bookmarks   self.add_btn.setVisible(is_new)   self.add_btn.setDisabled(not is_new)   self.remove_btn.setVisible(not is_new) @@ -161,7 +161,7 @@
    try:   # check if valid revision, tag, or branch - self.repo[unicode(revstr, 'utf-8')] + self.repo[hglib.fromunicode(revstr)]   except (error.LookupError, error.RepoLookupError, error.RepoError):   self.add_btn.setDisabled(True)   self.remove_btn.setDisabled(True) @@ -179,8 +179,8 @@
    def add_bookmark(self):   bookmark = self.bookmark_combo.currentText() - bookmarkutf = unicode(bookmark).encode('utf-8') - if bookmarkutf in self.repo.bookmarks: + bookmarklocal = hglib.fromunicode(bookmark) + if bookmarklocal in self.repo.bookmarks:   self.set_status(_('A bookmark named "%s" already exists') %   bookmark, False)   return @@ -188,7 +188,7 @@
  bookmarks.bookmark(ui=self.repo.ui,   repo=self.repo,   rev=self.initial_rev, - mark=bookmarkutf) + mark=bookmarklocal)     self.bookmark_combo.addItem(bookmark)   self.set_status(_("Bookmark '%s' has been added") % bookmark, True) @@ -197,14 +197,14 @@
    def remove_bookmark(self):   bookmark = self.bookmark_combo.currentText() - bookmarkutf = unicode(bookmark).encode('utf-8') - if not bookmarkutf in self.repo.bookmarks: + bookmarklocal = hglib.fromunicode(bookmark) + if not bookmarklocal in self.repo.bookmarks:   self.set_status(_("Bookmark '%s' does not exist") % bookmark, False)   return     bookmarks.bookmark(ui=self.repo.ui,   repo=self.repo, - mark=bookmarkutf, + mark=bookmarklocal,   delete=True)     self.bookmark_combo.removeItem(self.bookmark_combo.currentIndex()) @@ -214,23 +214,23 @@
    def rename_bookmark(self):   name = self.bookmark_combo.currentText() - nameutf = unicode(name).encode('utf-8') + bookmarklocal = hglib.fromunicode(bookmark)     newname = self.new_name_text.text() - newnameutf = unicode(newname).encode('utf-8') - if not nameutf in self.repo.bookmarks: + newnamelocal = hglib.fromunicode(newname) + if not bookmarklocal in self.repo.bookmarks:   self.set_status(_("Bookmark '%s' does not exist") % name, False)   return   - if newnameutf in self.repo.bookmarks: + if newnamelocal in self.repo.bookmarks:   self.set_status(_('A bookmark named "%s" already exists') %   newname, False)   return     bookmarks.bookmark(ui=self.repo.ui,   repo=self.repo, - mark=newnameutf, - rename=nameutf) + mark=newnamelocal, + rename=namelocal)     self.bookmark_combo.removeItem(self.bookmark_combo.currentIndex())   self.bookmark_combo.addItem(newname)
 
249
250
251
252
 
253
254
255
 
520
521
522
523
524
525
526
 
 
527
528
 
529
530
531
 
532
533
534
 
544
545
546
547
 
548
549
550
 
249
250
251
 
252
253
254
255
 
520
521
522
 
 
 
 
523
524
525
 
526
527
528
 
529
530
531
532
 
542
543
544
 
545
546
547
548
@@ -249,7 +249,7 @@
  self.msgcombo.reset(self.msghistory)     # Update branch operation button - branchu = unicode(self.repo[None].branch(), 'utf-8') + branchu = hglib.tounicode(self.repo[None].branch())   if self.branchop is None:   title = _('Branch: ') + branchu   elif self.branchop == False: @@ -520,15 +520,13 @@
  brcmd = ['--close-branch']   else:   brcmd = [] - # self.branchop - new branch name in QString (unicode) - # branchutf - new branch name in UTF8 - branchutf = unicode(self.branchop).encode('utf-8') - if branchutf in repo.branchtags(): + branch = hglib.fromunicode(self.branchop) + if branch in repo.branchtags():   # response: 0=Yes, 1=No, 2=Cancel - if branchutf in [p.branch() for p in repo.parents()]: + if branch in [p.branch() for p in repo.parents()]:   resp = 0   else: - rev = repo[branchutf].rev() + rev = repo[branch].rev()   resp = qtlib.CustomPrompt(_('Confirm Branch Change'),   _('Named branch "%s" already exists, '   'last used in revision %d\n' @@ -544,7 +542,7 @@
  'Cancel\t- Cancel this commit') % self.branchop,   self, (_('&Yes'), _('&No'), _('Cancel')), 2, 2).run()   if resp == 0: - repo.dirstate.setbranch(branchutf) + repo.dirstate.setbranch(branch)   elif resp == 2:   return   files = self.stwidget.getChecked('MAR?!S')
 
53
54
55
56
 
57
58
 
59
60
61
 
53
54
55
 
56
57
 
58
59
60
61
@@ -53,9 +53,9 @@
  os.chdir(self.root)   fname = util.normpath(fname)   if target: - target = hglib.toutf(util.normpath(target)) + target = hglib.tounicode(util.normpath(target))   else: - target = hglib.toutf(fname) + target = hglib.tounicode(fname)   return (fname, target)     def init_view(self, src, dest):
 
463
464
465
466
 
467
468
469
470
471
472
 
473
474
475
 
492
493
494
495
 
496
497
498
 
509
510
511
512
513
 
514
515
516
 
463
464
465
 
466
467
468
469
470
471
 
472
473
474
475
 
492
493
494
 
495
496
497
498
 
509
510
511
 
 
512
513
514
515
@@ -463,13 +463,13 @@
  self.layoutChanged.emit()     def getbranch(self, ctx, gnode): - return unicode(ctx.branch(), 'utf-8') + return hglib.tounicode(ctx.branch())     def gettags(self, ctx, gnode):   if ctx.rev() is None:   return ''   tags = [t for t in ctx.tags() if t not in self._mqtags] - return unicode(','.join(tags), 'utf-8') + return hglib.tounicode(','.join(tags))     def getauthor(self, ctx, gnode):   try: @@ -492,7 +492,7 @@
    parts = []   if ctx.thgbranchhead(): - branchu = unicode(ctx.branch(), 'utf-8') + branchu = hglib.tounicode(ctx.branch())   effects = qtlib.geteffect('log.branch')   parts.append(qtlib.applyeffects(u' %s ' % branchu, effects))   @@ -509,8 +509,7 @@
  style = 'log.bookmark'   else:   style = 'log.tag' - # tag is in UTF-8, we need it in unicode with style effects - tagu = unicode(tag, 'utf-8') + tagu = hglib.tounicode(tag)   effects = qtlib.geteffect(style)   parts.append(qtlib.applyeffects(u' %s ' % tagu, effects))  
 
859
860
861
862
 
863
864
865
 
859
860
861
 
862
863
864
865
@@ -859,7 +859,7 @@
  """output version and copyright information"""   ui.write(_('TortoiseHg Dialogs (version %s), '   'Mercurial (version %s)\n') % - (hglib.fromutf(thgversion.version()), hglib.hgversion)) + (thgversion.version(), hglib.hgversion))   if not ui.quiet:   ui.write(shortlicense)  
 
27
28
29
30
 
 
31
32
33
 
235
236
237
238
 
239
240
241
 
243
244
245
246
 
247
248
249
250
251
252
253
 
254
255
256
257
258
 
259
260
261
 
270
271
272
273
 
274
275
276
277
278
279
 
280
281
282
 
285
286
287
288
 
289
290
291
292
 
293
294
295
 
27
28
29
 
30
31
32
33
34
 
236
237
238
 
239
240
241
242
 
244
245
246
 
247
248
249
250
251
252
253
 
254
255
256
257
258
 
259
260
261
262
 
271
272
273
 
274
275
276
277
278
279
 
280
281
282
283
 
286
287
288
 
289
290
291
292
 
293
294
295
296
@@ -27,7 +27,8 @@
    def __init__(self, repo, tag='', rev='tip', parent=None, opts={}):   super(TagDialog, self).__init__(parent) - self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) + self.setWindowFlags(self.windowFlags() & \ + ~Qt.WindowContextHelpButtonHint)     self.repo = repo   @@ -235,7 +236,7 @@
  def add_tag(self):   local = self.local_chk.isChecked()   name = self.tag_combo.currentText() - nameutf = unicode(name).encode('utf-8') + namelocal = hglib.fromunicode(name)   rev = hglib.fromunicode(self.rev_text.text())   force = self.replace_chk.isChecked()   english = self.eng_chk.isChecked() @@ -243,19 +244,19 @@
    try:   # tagging - if nameutf in self.repo.tags() and not force: + if namelocal in self.repo.tags() and not force:   raise util.Abort(_("Tag '%s' already exist") % name)   ctx = self.repo[rev]   node = ctx.node()   if not message:   msgset = keep._('Added tag %s for changeset %s')   message = (english and msgset['id'] or msgset['str']) \ - % (name, str(ctx)) + % (namelocal, str(ctx))   if not isinstance(message, str):   message = hglib.fromunicode(message)     self.repo.incrementBusyCount() - self.repo.tag(nameutf, node, message, local, None, None) + self.repo.tag(namelocal, node, message, local, None, None)   self.repo.decrementBusyCount()   if local:   self.localTagChanged.emit() @@ -270,13 +271,13 @@
  def remove_tag(self):   local = self.local_chk.isChecked()   name = self.tag_combo.currentText() - nameutf = unicode(name).encode('utf-8') + namelocal = hglib.fromunicode(name)   english = self.eng_chk.isChecked()   message = hglib.fromunicode(self.custom_text.text())     try:   # tagging - tagtype = self.repo.tagtype(nameutf) + tagtype = self.repo.tagtype(namelocal)   if local:   if tagtype != 'local':   raise util.Abort(_('tag \'%s\' is not a local tag') % name) @@ -285,11 +286,11 @@
  raise util.Abort(_('tag \'%s\' is not a global tag') % name)   if not message:   msgset = keep._('Removed tag %s') - message = (english and msgset['id'] or msgset['str']) % name + message = (english and msgset['id'] or msgset['str']) % namelocal     self.repo.incrementBusyCount()   node = self.repo[-1].node() - self.repo.tag(nameutf, node, message, local, None, None) + self.repo.tag(namelocal, node, message, local, None, None)   self.repo.decrementBusyCount()   if local:   self.localTagChanged.emit()
 
228
229
230
231
232
233
 
234
235
236
 
344
345
346
347
348
349
 
350
351
352
 
483
484
485
486
 
487
488
489
 
595
596
597
598
 
599
600
601
 
 
602
603
604
 
228
229
230
 
231
 
232
233
234
235
 
343
344
345
 
346
 
347
348
349
350
 
481
482
483
 
484
485
486
487
 
593
594
595
 
596
597
 
 
598
599
600
601
602
@@ -228,9 +228,8 @@
    @propertycache   def _thghiddentags(self): - # Assume Mercurial.ini file is in local encoding, need UTF-8   ht = self.ui.config('tortoisehg', 'hidetags', '') - return [hglib.toutf(t).strip() for t in ht.split()] + return [t.strip() for t in ht.split()]     @propertycache   def thgmqunappliedpatches(self): @@ -344,9 +343,8 @@
    @propertycache   def deadbranches(self): - # Assume Mercurial.ini file is in local encoding, need UTF-8   db = self.ui.config('tortoisehg', 'deadbranch', '') - return [hglib.toutf(b).strip() for b in db.split(',')] + return [b.strip() for b in db.split(',')]     @propertycache   def displayname(self): @@ -483,7 +481,7 @@
 def _extendchangectx(changectx):   class thgchangectx(changectx.__class__):   def thgtags(self): - '''Returns all unhidden tags for self in UTF-8''' + '''Returns all unhidden tags for self'''   htlist = self._repo._thghiddentags   return [tag for tag in self.tags() if tag not in htlist]   @@ -595,10 +593,10 @@
  if msg:   msg = '\n'.join(msg)   self._node = node - self._user = user and hglib.tounicode(user) or '' + self._user = user or ''   self._date = date and util.parsedate(date) or util.makedate() - self._desc = msg and msg or '' - self._branch = branch and hglib.tounicode(branch) or '' + self._desc = msg or '' + self._branch = branch or ''   self._parents = []   self._rev = rev   for p in (p1, p2):