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.
# archive.py - TortoiseHg's dialog for archiving a repo revision## Copyright 2009 Emmanuel Rosa <goaway1000@gmail.com># 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.# TODO:## - Allow manually adapting the destination path.# - Keep the selection via the browse btn as a basename (instead of repo.root).# - Make what is typed in in the lineedit of the rev_combo change dest_edit (and hgcmd_txt)# - Make what is manually changed in the dest_edit be reflected in the hgcmd.# - Update the hgcmd lineedit when/after manually changing the dest_edit.# - Make the hgcmd_txt expand to show it's complete content (multiline eventualy).## - Save/load qt settings (window position, ...).import os
-from PyQt4.QtCore import Qt, SIGNAL, SLOT, QObject, QString, SIGNAL+from PyQt4.QtCore import Qt, SIGNAL, SLOT, QObject
from PyQt4.QtGui import QDialog, QComboBox, QVBoxLayout, QGridLayout, QLabel
from PyQt4.QtGui import QLineEdit, QPushButton, QLayout, QRadioButton
-from PyQt4.QtGui import QHBoxLayout, QMessageBox, QIcon, QPixmap, QFileDialog
+from PyQt4.QtGui import QHBoxLayout, QIcon, QPixmap, QFileDialog
from PyQt4.QtGui import QCheckBox, QButtonGroup
from mercurial import hg, error
fromtortoisehg.hgqt.i18nimport_fromtortoisehg.utilimporthglib,pathsfromtortoisehg.hgqtimportcmdui,qtlib#import tortoisehg.hgqt # import connectconnect=QObject.connectWD_PARENT=_('= Working Directory Parent =')classArchiveDialog(QDialog):""" Dialog to archive a particular Mercurial revision """def__init__(self,ui,repo,rev=None,parent=None):super(ArchiveDialog,self).__init__(parent=None)self.ui=uiself.repo=repoself.initrev=rev# base layout boxself.vbox=QVBoxLayout()self.vbox.setSpacing(6)# main layout gridself.grid=QGridLayout()self.grid.setSpacing(6)self.vbox.addLayout(self.grid)# revision comboself.rev_combo=QComboBox()self.rev_combo.setEditable(True)self.rev_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)self.rev_lbl=QLabel(_('Archive revision:'))self.rev_lbl.setAlignment(Qt.AlignRight)self.grid.addWidget(self.rev_lbl,0,0)self.grid.addWidget(self.rev_combo,0,1)self.files_in_rev_chk=QCheckBox(_('Only files modified/created in this revision'))self.grid.addWidget(self.files_in_rev_chk,1,1)# destination lineedit and buttonself.dest_edit=QLineEdit()self.dest_edit.setMinimumWidth(300)self.dest_btn=QPushButton(_('Browse...'))self.dest_btn.setAutoDefault(False)self.dest_lbl=QLabel(_('Destination path:'))self.dest_lbl.setAlignment(Qt.AlignRight)self.grid.addWidget(self.dest_lbl,2,0)self.grid.addWidget(self.dest_edit,2,1)self.grid.addWidget(self.dest_btn,2,2)# archive typesdefradio(label):returnQRadioButton(label,None)self.filesradio=radio(_('Directory of files'))self.tarradio=radio(_('Uncompressed tar archive'))self.tbz2radio=radio(_('Tar archive compressed using bzip2'))self.tgzradio=radio(_('Tar archive compressed using gzip'))self.uzipradio=radio(_('Uncompressed zip archive'))self.zipradio=radio(_('Zip archive compressed using deflate'))self.types_lbl=QLabel(_('Archive types:'))self.types_lbl.setAlignment(Qt.AlignRight)self.grid.addWidget(self.types_lbl,3,0)self.grid.addWidget(self.filesradio,3,1)self.grid.addWidget(self.tarradio,4,1)self.grid.addWidget(self.tbz2radio,5,1)self.grid.addWidget(self.tgzradio,6,1)self.grid.addWidget(self.uzipradio,7,1)self.grid.addWidget(self.zipradio,8,1)# some extrasself.keep_open_chk=QCheckBox(_('Always show output'))self.grid.addWidget(self.keep_open_chk,10,1)self.hgcmd_lbl=QLabel(_('Hg command:'))self.hgcmd_lbl.setAlignment(Qt.AlignRight)self.hgcmd_txt=QLineEdit()self.hgcmd_txt.setReadOnly(True)self.grid.addWidget(self.hgcmd_lbl,9,0)self.grid.addWidget(self.hgcmd_txt,9,1)# command widgetself.cmd=cmdui.Widget()self.cmd.commandStarted.connect(self.command_started)self.cmd.commandFinished.connect(self.command_finished)self.cmd.commandCanceling.connect(self.command_canceling)self.cmd.setHidden(True)self.vbox.addWidget(self.cmd)# bottom buttonsself.hbox=QHBoxLayout()self.arch_btn=QPushButton(_('&Archive'))self.arch_btn.setAutoDefault(False)self.close_btn=QPushButton(_('&Close'))self.close_btn.setDefault(True)self.close_btn.setFocus()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)self.hbox.addWidget(self.detail_btn)self.hbox.addStretch(0)self.hbox.addWidget(self.arch_btn)self.hbox.addWidget(self.close_btn)self.hbox.addWidget(self.cancel_btn)self.vbox.addLayout(self.hbox)self.rev_combo.setFocus()# set default valuesself.prevtarget=Noneifself.initrev:self.rev_combo.addItem(str(self.initrev))else:self.rev_combo.addItem(WD_PARENT)self.rev_combo.setCurrentIndex(0)forbinself.repo.branchtags():self.rev_combo.addItem(b)tags=list(self.repo.tags())tags.sort()tags.reverse()fortintags:self.rev_combo.addItem(t)self.rev_combo.setMaxVisibleItems(self.rev_combo.count())self.dest_edit.setText(self.repo.root)self.filesradio.setChecked(True)self.update_path()# connecting slotsself.make_connects()# dialog settingself.setWindowTitle(_('TortoiseHg Archive - %s')%self.repo.root)iconfile=paths.get_tortoise_icon('menucheckout.ico')icon=QIcon()icon.addPixmap(QPixmap(iconfile),QIcon.Normal,QIcon.Off)self.setWindowIcon(icon)self.setWindowFlags(self.windowFlags()&~Qt.WindowContextHelpButtonHint)self.setLayout(self.vbox)self.layout().setSizeConstraint(QLayout.SetFixedSize)self.rev_combo.setFocus()defget_selected_archive_type(self):"""Return a dictionary describing the selected archive type"""ifself.tarradio.isChecked():return{'type':'tar','ext':'.tar','label':_('Tar archives')}elifself.tbz2radio.isChecked():return{'type':'tbz2','ext':'.tar.bz2','label':_('Bzip2 tar archives')}elifself.tgzradio.isChecked():return{'type':'tgz','ext':'.tar.gz','label':_('Gzip tar archives')}elifself.uzipradio.isChecked():return{'type':'uzip','ext':'.zip','label':('Uncompressed zip archives')}elifself.zipradio.isChecked():return{'type':'zip','ext':'.zip','label':_('Compressed zip archives')}return{'type':'files','ext':'','label':_('Directory of files')}defupdate_path(self):defremove_ext(path):forextin('.tar','.tar.bz2','.tar.gz','.zip'):ifpath.endswith(ext):returnpath.replace(ext,'')returnpathdefremove_rev(path):l=''foriinxrange(self.rev_combo.count()-1):l+=hglib.fromunicode(self.rev_combo.itemText(i))revs=[rev[0]forrevinl]revs.append(wdrev)ifnotself.prevtargetisNone:revs.append(self.prevtarget)forrevin['_'+revforrevinrevs]:ifpath.endswith(rev):returnpath.replace(rev,'')returnpathdefadd_rev(path,rev):return'%s_%s'%(path,rev)defadd_ext(path):select=self.get_selected_archive_type()ifselect['type']!='files':path+=select['ext']returnpathtext=self.rev_combo.currentText()iflen(text)==0:returnwdrev=str(self.repo['.'].rev())iftext==WD_PARENT:text=wdrevelse:try:self.repo[hglib.fromunicode(text)]except(error.RepoError,error.LookupError):returnpath=hglib.fromunicode(self.dest_edit.text())path=remove_ext(path)path=remove_rev(path)path=add_rev(path,text)path=add_ext(path)self.dest_edit.setText(path)self.prevtarget=texttype=self.get_selected_archive_type()['type']self.compose_command(path,type)defmake_connects(self):self.connect(self.rev_combo,SIGNAL('currentIndexChanged(int)'),self.rev_combo_changed)self.dest_btn.clicked.connect(self.browse_clicked)self.filesradio.toggled.connect(self.update_path)self.tarradio.toggled.connect(self.update_path)self.tbz2radio.toggled.connect(self.update_path)self.tgzradio.toggled.connect(self.update_path)self.uzipradio.toggled.connect(self.update_path)self.zipradio.toggled.connect(self.update_path)self.arch_btn.clicked.connect(self.archive)self.detail_btn.clicked.connect(self.detail_clicked)self.close_btn.clicked.connect(self.close)defrev_combo_changed(self,index):self.update_path()defbrowse_clicked(self):"""Select the destination directory or file"""dest=hglib.fromunicode(self.dest_edit.text())ifnotos.path.exists(dest):dest=os.path.dirname(dest)select=self.get_selected_archive_type()FD=QFileDialogifselect['type']=='files':caption=_('Select Destination Folder')path=FD.getExistingDirectory(parent=self,caption=caption,options=FD.ShowDirsOnly|FD.ReadOnly)response=str(path)else:caption=_('Open File')ext='*'+select['ext']filter='%s (%s)\nAll Files (*.*)'%(select['label'],ext)filename=FD.getOpenFileName(parent=self,caption=caption,directory=dest,filter=filter,options=FD.ReadOnly);response=str(filename)ifresponse:self.dest_edit.setText(response)self.update_path()defcompose_command(self,dest,type):cmdline=['archive']rev=self.rev_combo.currentText()ifrev==WD_PARENT:rev='.'else:rev=hglib.fromunicode(rev)cmdline.append('-r')cmdline.append(rev)cmdline.append('-t')cmdline.append(type)ifself.files_in_rev_chk.isChecked():ctx=self.repo[rev]forfinctx.files():cmdline.append('-I')cmdline.append(f)cmdline.append('--')cmdline.append(hglib.fromunicode(dest))self.hgcmd_txt.setText(' '.join(cmdline))returncmdlinedefarchive(self):# verify inputtype=self.get_selected_archive_type()['type']dest=self.dest_edit.text()ifos.path.exists(dest):iftype=='files':ifos.path.isfile(dest):qtlib.WarningMsgBox(_('Duplicate Name'),_('The destination "%s" already exists as ''a file!'%dest))returnFalseelifos.listdir(dest):ifnotqtlib.QuestionMsgBox(_('Confirm Overwrite'),_('The directory "%s" is not empty!\n\n''Do you want to overwrite it?')%dest,parent=self):returnFalseelse:ifos.path.isfile(dest):ifnotqtlib.QuestionMsgBox(_('Confirm Overwrite'),_('The file "%s" already exists!\n\n''Do you want to overwrite it?')%dest,parent=self):returnFalseelse:qtlib.WarningMsgBox(_('Duplicate Name'),_('The destination "%s" already exists as ''a folder!'%dest))returnFalse# prepare command linecmdline=self.compose_command(dest,type)# start archivingself.cmd.run(cmdline)defdetail_clicked(self):ifself.cmd.is_show_output():self.cmd.show_output(False)else:self.cmd.show_output(True)defcancel_clicked():self.cmd.cancel()defcommand_started(self):self.dest_edit.setEnabled(False)self.rev_combo.setEnabled(False)self.dest_edit.setEnabled(False)self.dest_btn.setEnabled(False)self.filesradio.setEnabled(False)self.tarradio.setEnabled(False)self.tbz2radio.setEnabled(False)self.tgzradio.setEnabled(False)self.uzipradio.setEnabled(False)self.zipradio.setEnabled(False)self.cmd.setShown(True)self.arch_btn.setHidden(True)self.close_btn.setHidden(True)self.cancel_btn.setShown(True)self.detail_btn.setShown(True)defcommand_finished(self,wrapper):ifwrapper.dataisnot0orself.cmd.is_show_output()\
orself.keep_open_chk.isChecked():ifnotself.cmd.is_show_output():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)defrun(ui,*revs,**opts):rev=opts.get('rev')repo=hg.repository(ui,paths.find_root())returnArchiveDialog(repo.ui,repo,rev)
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.