Mercurial and Git clients can push and pull from this alias URL to interact with this repository. You can change to which repository an alias points by going to the Aliases link on the project page.
# rename.py - TortoiseHg's dialogs for handling renames## Copyright 2009 Steve Borho <steve@borho.org># Copyright 2010 Johan Samyn <johan.samyn@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.importos,sysfromPyQt4.QtCoreimport*fromPyQt4.QtGuiimport*frommercurialimportutil,errorfromtortoisehg.hgqt.i18nimport_fromtortoisehg.hgqtimportcmdui,qtlib,thgrepo,manifestmodelfromtortoisehg.utilimporthglib,paths# TODO: this dialog should take a repo argument, not uiclassRenameDialog(QDialog):"""TortoiseHg rename dialog"""output=pyqtSignal(QString,QString)makeLogVisible=pyqtSignal(bool)progress=pyqtSignal(QString,object,QString,QString,object)def__init__(self,ui,pats,parent=None,**opts):super(RenameDialog,self).__init__(parent)self.iscopy=(opts.get('alias')=='copy')# pats: local; src, dest: unicodesrc,dest=self.init_data(ui,pats)self.init_view(src,dest)definit_data(self,ui,pats):"""calculate initial values for widgets"""fname=''target=''cwd=os.getcwd()try:self.root=paths.find_root()self.repo=thgrepo.repository(ui,path=self.root)except(error.RepoError):qtlib.ErrorMsgBox(_('Error'),_('Could not find or initialize the repository ''from folder<p>%s</p>'%cwd))return('','')try:fname=hglib.canonpath(self.root,cwd,pats[0])target=hglib.canonpath(self.root,cwd,pats[1])except:passos.chdir(self.root)fname=hglib.tounicode(util.normpath(fname))iftarget:target=hglib.tounicode(util.normpath(target))else:target=fnamereturn(fname,target)definit_view(self,src,dest):"""define the view"""# widgetsself.src_lbl=QLabel(_('Source:'))self.src_lbl.setAlignment(Qt.AlignRight|Qt.AlignVCenter)self.src_txt=QLineEdit(src)self.src_txt.setMinimumWidth(300)self.src_btn=QPushButton(_('Browse...'))self.dest_lbl=QLabel(_('Destination:'))self.dest_lbl.setAlignment(Qt.AlignRight|Qt.AlignVCenter)self.dest_txt=QLineEdit(dest)self.dest_btn=QPushButton(_('Browse...'))self.copy_chk=QCheckBox(_('Copy source -> destination'))comp=manifestmodel.ManifestCompleter(self)comp.setModel(manifestmodel.ManifestModel(self.repo,parent=comp))self.src_txt.setCompleter(comp)self.dest_txt.setCompleter(comp)# some extrasself.dummy_lbl=QLabel('')self.hgcmd_lbl=QLabel(_('Hg command:'))self.hgcmd_lbl.setAlignment(Qt.AlignRight|Qt.AlignVCenter)self.hgcmd_txt=QLineEdit()self.hgcmd_txt.setReadOnly(True)self.show_command(self.compose_command(self.get_src(),self.get_dest()))self.keep_open_chk=QCheckBox(_('Always show output'))# command widgetself.cmd=cmdui.Widget(True,False,self)self.cmd.commandStarted.connect(self.command_started)self.cmd.commandFinished.connect(self.command_finished)self.cmd.commandCanceling.connect(self.command_canceling)self.cmd.output.connect(self.output)self.cmd.makeLogVisible.connect(self.makeLogVisible)self.cmd.progress.connect(self.progress)self.cmd.setHidden(True)# bottom buttonsself.rename_btn=QPushButton('')self.rename_btn.setDefault(True)self.rename_btn.setFocus(True)self.close_btn=QPushButton(_('&Close'))self.close_btn.setAutoDefault(False)self.detail_btn=QPushButton(_('&Detail'))self.detail_btn.setAutoDefault(False)self.detail_btn.setHidden(True)self.cancel_btn=QPushButton(_('Cancel'))self.cancel_btn.setAutoDefault(False)self.cancel_btn.setHidden(True)# connecting slotsself.src_txt.textChanged.connect(self.src_dest_edited)self.src_btn.clicked.connect(self.src_btn_clicked)self.dest_txt.textChanged.connect(self.src_dest_edited)self.dest_btn.clicked.connect(self.dest_btn_clicked)self.copy_chk.toggled.connect(self.copy_chk_toggled)self.rename_btn.clicked.connect(self.rename)self.detail_btn.clicked.connect(self.detail_clicked)self.close_btn.clicked.connect(self.close)self.cancel_btn.clicked.connect(self.cancel_clicked)# main layoutself.grid=QGridLayout()self.grid.setSpacing(6)self.grid.addWidget(self.src_lbl,0,0)self.grid.addWidget(self.src_txt,0,1)self.grid.addWidget(self.src_btn,0,2)self.grid.addWidget(self.dest_lbl,1,0)self.grid.addWidget(self.dest_txt,1,1)self.grid.addWidget(self.dest_btn,1,2)self.grid.addWidget(self.copy_chk,2,1)self.grid.addWidget(self.dummy_lbl,3,1)self.grid.addWidget(self.hgcmd_lbl,4,0)self.grid.addWidget(self.hgcmd_txt,4,1)self.grid.addWidget(self.keep_open_chk,5,1)self.hbox=QHBoxLayout()self.hbox.addWidget(self.detail_btn)self.hbox.addStretch(0)self.hbox.addWidget(self.rename_btn)self.hbox.addWidget(self.close_btn)self.hbox.addWidget(self.cancel_btn)self.vbox=QVBoxLayout()self.vbox.setSpacing(6)self.vbox.addLayout(self.grid)self.vbox.addWidget(self.cmd)self.vbox.addLayout(self.hbox)# dialog settingself.setWindowIcon(qtlib.geticon('hg-rename'))self.setWindowFlags(self.windowFlags()&~Qt.WindowContextHelpButtonHint)self.copy_chk.setChecked(self.iscopy)self.setLayout(self.vbox)self.layout().setSizeConstraint(QLayout.SetFixedSize)self.dest_txt.setFocus()self._readsettings()self.setRenameCopy()defsetRenameCopy(self):ifself.windowTitle()=='':self.reponame=self.repo.displaynameifself.copy_chk.isChecked():wt=(_('Copy - %s')%self.reponame)self.msgTitle=_('Copy')self.errTitle=_('Copy Error')else:wt=(_('Rename - %s')%self.reponame)self.msgTitle=_('Rename')self.errTitle=_('Rename Error')self.rename_btn.setText(self.msgTitle)self.setWindowTitle(wt)defget_src(self):returnhglib.fromunicode(self.src_txt.text())defget_dest(self):returnhglib.fromunicode(self.dest_txt.text())defsrc_dest_edited(self):self.show_command(self.compose_command(self.get_src(),self.get_dest()))defsrc_btn_clicked(self):"""Select the source file of folder"""self.get_file_or_folder('src')defdest_btn_clicked(self):"""Select the destination file of folder"""self.get_file_or_folder('dest')defget_file_or_folder(self,mode):ifmode=='src':curr=self.get_src()ifos.path.isfile(curr):caption=_('Select Source File')else:caption=_('Select Source Folder')else:curr=self.get_dest()ifos.path.isfile(curr):caption=_('Select Destination File')else:caption=_('Select Destination Folder')FD=QFileDialogifos.path.isfile(curr):path=FD.getOpenFileName(parent=self,caption=caption,options=FD.ReadOnly)else:path=FD.getExistingDirectory(parent=self,caption=caption,options=FD.ShowDirsOnly|FD.ReadOnly)ifpath:path=util.normpath(unicode(path))pathprefix=util.normpath(hglib.tounicode(self.root))+'/'ifnotpath.startswith(pathprefix):returnrelpath=path[len(pathprefix):]ifmode=='src':self.src_txt.setText(relpath)else:self.dest_txt.setText(relpath)defcopy_chk_toggled(self):self.setRenameCopy()self.show_command(self.compose_command(self.get_src(),self.get_dest()))defisCaseFoldingOnWin(self):fullsrc=os.path.abspath(self.get_src())fulldest=os.path.abspath(self.get_dest())return(fullsrc.upper()==fulldest.upper()andsys.platform=='win32')defcompose_command(self,src,dest):'src and dest are expected to be in local encoding'ifself.copy_chk.isChecked():cmdline=['copy']else:cmdline=['rename']cmdline+=['-R',self.repo.root]cmdline.append('-v')ifself.isCaseFoldingOnWin():cmdline.append('-A')cmdline.append(src)cmdline.append(dest)returncmdlinedefshow_command(self,cmdline):self.hgcmd_txt.setText(hglib.tounicode('hg '+' '.join(cmdline)))defrename(self):"""execute the rename"""# check inputssrc=self.get_src()dest=self.get_dest()ifnotos.path.exists(src):qtlib.WarningMsgBox(self.msgTitle,_('Source does not exists.'))returnfullsrc=os.path.abspath(src)ifnotfullsrc.startswith(self.repo.root):qtlib.ErrorMsgBox(self.errTitle,_('The source must be within the repository tree.'))returnfulldest=os.path.abspath(dest)ifnotfulldest.startswith(self.repo.root):qtlib.ErrorMsgBox(self.errTitle,_('The destination must be within the repository tree.'))returnifsrc==dest:qtlib.ErrorMsgBox(self.errTitle,_('Please give a destination that differs from the source'))returnif(os.path.isfile(dest)andnotself.isCaseFoldingOnWin()):res=qtlib.QuestionMsgBox(self.msgTitle,'<p>%s</p><p>%s</p>'%(_('Destination file already exists.'),_('Are you sure you want to overwrite it ?')),defaultbutton=QMessageBox.No)ifnotres:returncmdline=self.compose_command(src,dest)self.show_command(cmdline)ifself.isCaseFoldingOnWin():# We do the rename ourselves if it's a pure casefolding# action on Windows. Because there is no way to make Hg# do 'hg mv foo Foo' correctly there.ifself.copy_chk.isChecked():qtlib.ErrorMsgBox(self.errTitle,_('Cannot do a pure casefolding copy on Windows')) return
else:
try:
- targetdir = os.path.dirname(dest)
+ targetdir = os.path.dirname(fulldest)
if not os.path.isdir(targetdir):
os.makedirs(targetdir)
os.rename(fullsrc, fulldest)
except(OSError,IOError),inst:ifself.copy_chk.isChecked():txt=_('The following error was caught while copying:')else:txt=_('The following error was caught while renaming:')qtlib.ErrorMsgBox(self.errTitle,txt,hglib.tounicode(str(inst)))returnself.cmd.run(cmdline)defdetail_clicked(self):ifself.cmd.outputShown():self.cmd.setShowOutput(False)else:self.cmd.setShowOutput(True)defcancel_clicked(self):self.cmd.cancel()defcommand_started(self):self.src_txt.setEnabled(False)self.src_btn.setEnabled(False)self.dest_txt.setEnabled(False)self.dest_btn.setEnabled(False)self.cmd.setShown(True)self.rename_btn.setHidden(True)self.close_btn.setHidden(True)self.cancel_btn.setShown(True)self.detail_btn.setShown(True)defcommand_finished(self,ret):if(retisnot0orself.cmd.outputShown()orself.keep_open_chk.isChecked()):ifnotself.cmd.outputShown():self.detail_btn.click()self.cancel_btn.setHidden(True)self.close_btn.setShown(True)self.close_btn.setAutoDefault(True)self.close_btn.setFocus()else:self.reject()defcommand_canceling(self):self.cancel_btn.setDisabled(True)defcloseEvent(self,event):self._writesettings()super(RenameDialog,self).closeEvent(event)def_readsettings(self):s=QSettings()self.restoreGeometry(s.value('rename/geom').toByteArray())def_writesettings(self):s=QSettings()s.setValue('rename/geom',self.saveGeometry())defrun(ui,*pats,**opts):returnRenameDialog(ui,pats,**opts)
Attach a Trello Card
Add a tag
Your session has expired
You are no longer logged in. Please log in and try your request again.
Filter RSS Feed
This RSS feed URL allows you to see the contents of your current filter using any feed reader.
This link includes a special authentication token. If you share the URL with anyone else, they can see this RSS feed's activity. You can disable these tokens when needed.
Your current filter is unsaved; changing it won't affect this RSS feed.