comparison hgext/mq.py @ 37084:f0b6fbea00cf

stringutil: bulk-replace call sites to point to new module This might conflict with other patches floating around, sorry.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 22 Mar 2018 21:56:20 +0900
parents e77cee5de1c7
children 54435fd09f1d
comparison
equal deleted inserted replaced
37083:f99d64e8a4e4 37084:f0b6fbea00cf
96 smartset, 96 smartset,
97 subrepoutil, 97 subrepoutil,
98 util, 98 util,
99 vfs as vfsmod, 99 vfs as vfsmod,
100 ) 100 )
101 from mercurial.utils import dateutil 101 from mercurial.utils import (
102 dateutil,
103 stringutil,
104 )
102 105
103 release = lockmod.release 106 release = lockmod.release
104 seriesopts = [('s', 'summary', None, _('print first line of patch header'))] 107 seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
105 108
106 cmdtable = {} 109 cmdtable = {}
467 self.guardspath = "guards" 470 self.guardspath = "guards"
468 self.activeguards = None 471 self.activeguards = None
469 self.guardsdirty = False 472 self.guardsdirty = False
470 # Handle mq.git as a bool with extended values 473 # Handle mq.git as a bool with extended values
471 gitmode = ui.config('mq', 'git').lower() 474 gitmode = ui.config('mq', 'git').lower()
472 boolmode = util.parsebool(gitmode) 475 boolmode = stringutil.parsebool(gitmode)
473 if boolmode is not None: 476 if boolmode is not None:
474 if boolmode: 477 if boolmode:
475 gitmode = 'yes' 478 gitmode = 'yes'
476 else: 479 else:
477 gitmode = 'no' 480 gitmode = 'no'
722 return 725 return
723 try: 726 try:
724 os.unlink(undo) 727 os.unlink(undo)
725 except OSError as inst: 728 except OSError as inst:
726 self.ui.warn(_('error removing undo: %s\n') % 729 self.ui.warn(_('error removing undo: %s\n') %
727 util.forcebytestr(inst)) 730 stringutil.forcebytestr(inst))
728 731
729 def backup(self, repo, files, copy=False): 732 def backup(self, repo, files, copy=False):
730 # backup local changes in --force case 733 # backup local changes in --force case
731 for f in sorted(files): 734 for f in sorted(files):
732 absf = repo.wjoin(f) 735 absf = repo.wjoin(f)
855 try: 858 try:
856 fuzz = patchmod.patch(self.ui, repo, patchfile, strip=1, 859 fuzz = patchmod.patch(self.ui, repo, patchfile, strip=1,
857 files=files, eolmode=None) 860 files=files, eolmode=None)
858 return (True, list(files), fuzz) 861 return (True, list(files), fuzz)
859 except Exception as inst: 862 except Exception as inst:
860 self.ui.note(util.forcebytestr(inst) + '\n') 863 self.ui.note(stringutil.forcebytestr(inst) + '\n')
861 if not self.ui.verbose: 864 if not self.ui.verbose:
862 self.ui.warn(_("patch failed, unable to continue (try -v)\n")) 865 self.ui.warn(_("patch failed, unable to continue (try -v)\n"))
863 self.ui.traceback() 866 self.ui.traceback()
864 return (False, list(files), False) 867 return (False, list(files), False)
865 868
1915 msg = '' 1918 msg = ''
1916 1919
1917 if self.ui.formatted(): 1920 if self.ui.formatted():
1918 width = self.ui.termwidth() - len(pfx) - len(patchname) - 2 1921 width = self.ui.termwidth() - len(pfx) - len(patchname) - 2
1919 if width > 0: 1922 if width > 0:
1920 msg = util.ellipsis(msg, width) 1923 msg = stringutil.ellipsis(msg, width)
1921 else: 1924 else:
1922 msg = '' 1925 msg = ''
1923 self.ui.write(patchname, label='qseries.' + state) 1926 self.ui.write(patchname, label='qseries.' + state)
1924 self.ui.write(': ') 1927 self.ui.write(': ')
1925 self.ui.write(msg, label='qseries.message.' + state) 1928 self.ui.write(msg, label='qseries.message.' + state)