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>## This software may be used and distributed according to the terms of the# GNU General Public License version 2, incorporated herein by reference.importosimportgtkimportgobjectimportpangofrommercurialimporthg,uifromtortoisehg.util.i18nimport_fromtortoisehg.utilimporthglib,pathsfromtortoisehg.hgtkimporthgcmd,gtklib,gdialogWD_PARENT=_('= Working Directory Parent =')MODE_NORMAL='normal'MODE_WORKING='working'classArchiveDialog(gtk.Dialog):""" Dialog to archive a Mercurial repo """def__init__(self,rev=None):""" Initialize the Dialog """gtk.Dialog.__init__(self)gtklib.set_tortoise_icon(self,'menucheckout.ico')gtklib.set_tortoise_keys(self)self.set_resizable(False)self.set_has_separator(False)self.connect('response',self.dialog_response)# buttonsself.archivebtn=self.add_button(_('Archive'),gtk.RESPONSE_OK)self.closebtn=self.add_button(gtk.STOCK_CLOSE,gtk.RESPONSE_CLOSE)try:repo=hg.repository(ui.ui(),path=paths.find_root())excepthglib.RepoError:gobject.idle_add(self.destroy)returnself.set_title(_('Archive - %s')%hglib.get_reponame(repo))# layout tableself.table=table=gtklib.LayoutTable()self.vbox.pack_start(table,True,True,2)## revision comboself.combo=gtk.combo_box_entry_new_text()self.combo.child.set_width_chars(24)self.combo.child.connect('activate',lambdab:self.response(gtk.RESPONSE_OK))ifrev:self.combo.append_text(str(rev))else:self.combo.append_text(WD_PARENT)self.combo.set_active(0)forbinrepo.branchtags():self.combo.append_text(b)tags=list(repo.tags())tags.sort()tags.reverse()fortintags:self.combo.append_text(t)table.add_row(_('Archive revision:'),self.combo)## dest combo & browse buttondestcombo=gtk.combo_box_entry_new_text()self.destentry=destcombo.get_child()self.destentry.set_width_chars(46)destbrowse=gtk.Button(_('Browse...'))destbrowse.connect('clicked',self.browse_clicked)table.add_row(_('Destination path:'),destcombo,0,destbrowse)## archive typesself.filesradio=gtk.RadioButton(None,_('Directory of files'))self.filesradio.connect('toggled',self.type_changed)table.add_row(_('Archive types:'),self.filesradio)defadd_type(label):radio=gtk.RadioButton(self.filesradio,label)radio.connect('toggled',self.type_changed)table.add_row(None,radio)returnradioself.tarradio=add_type(_('Uncompressed tar archive'))self.tbz2radio=add_type(_('Tar archive compressed using bzip2'))self.tgzradio=add_type(_('Tar archive compressed using gzip'))self.uzipradio=add_type(_('Uncompressed zip archive'))self.zipradio=add_type(_('Zip archive compressed using deflate'))# register signal handlersself.combo.connect('changed',lambdac:self.update_path())# prepare to showself.update_path(hglib.toutf(repo.root))self.archivebtn.grab_focus()gobject.idle_add(self.after_init)defafter_init(self):# CmdWidgetself.cmd=hgcmd.CmdWidget()self.cmd.show_all()self.cmd.hide()self.vbox.pack_start(self.cmd,True,True,6)# abort buttonself.abortbtn=self.add_button(_('Abort'),gtk.RESPONSE_CANCEL)self.abortbtn.hide()defdialog_response(self,dialog,response_id):defabort():self.cmd.stop()self.cmd.show_log()self.switch_to(MODE_NORMAL,cmd=False)# Archive buttonifresponse_id==gtk.RESPONSE_OK:self.archive()# Close button or dialog closing by the userelifresponse_idin(gtk.RESPONSE_CLOSE,gtk.RESPONSE_DELETE_EVENT):ifself.cmd.is_alive():ret=gdialog.Confirm(_('Confirm Abort'),[],self,_('Do you want to abort?')).run() if ret == gtk.RESPONSE_YES:
abort()
else:
- self.destroy() return # close dialog
# Abort button
elif response_id == gtk.RESPONSE_CANCEL:
abort() else:
raise _('unexpected response id: %s') % response_id
- self.run() # doesn't close dialog
+ self.run() # don't close dialog
def type_changed(self, radio):
if not radio.get_active():
returnself.update_path()defupdate_path(self,path=None):defremove_ext(path):forextin('.tar','.tar.bz2','.tar.gz','.zip'):ifpath.endswith(ext):returnpath.replace(ext,'')returnpathdefremove_rev(path):model=self.combo.get_model()forrevin['_'+rev[0]forrevinmodel]:ifpath.endswith(rev):returnpath.replace(rev,'')returnpathdefadd_rev(path):rev=self.combo.get_active_text()ifrev==WD_PARENT:rev='tip'return'%s_%s'%(path,rev)defadd_ext(path):select=self.get_selected_archive_type()ifselect['type']!='files':path+=select['ext']returnpathifpathisNone:path=self.destentry.get_text()path=remove_ext(path)path=remove_rev(path)path=add_rev(path)path=add_ext(path)self.destentry.set_text(path)defget_selected_archive_type(self):"""Return a dictionary describing the selected archive type"""ifself.tarradio.get_active():return{'type':'tar','ext':'.tar','label':_('Tar archives')}elifself.tbz2radio.get_active():return{'type':'tbz2','ext':'.tar.bz2','label':_('Bzip2 tar archives')}elifself.tgzradio.get_active():return{'type':'tgz','ext':'.tar.gz','label':_('Gzip tar archives')}elifself.uzipradio.get_active():return{'type':'uzip','ext':'.zip','label':('Uncompressed zip archives')}elifself.zipradio.get_active():return{'type':'zip','ext':'.zip','label':_('Compressed zip archives')}return{'type':'files','ext':None,'label':None}defbrowse_clicked(self,button):"""Select the destination directory or file"""dest=hglib.fromutf(self.destentry.get_text())ifnotos.path.exists(dest):dest=os.path.dirname(dest)select=self.get_selected_archive_type()ifselect['type']=='files':response=gtklib.NativeFolderSelectDialog(initial=dest,title=_('Select Destination Folder')).run()else:ext='*'+select['ext']label='%s (%s)'%(select['label'],ext)response=gtklib.NativeSaveFileDialogWrapper(initial=dest,title=_('Select Destination File'),filter=((label,ext),(_('All Files (*.*)'),'*.*'))).run()ifresponse:self.destentry.set_text(response)defswitch_to(self,mode,cmd=True):ifmode==MODE_NORMAL:normal=Trueself.closebtn.grab_focus()elifmode==MODE_WORKING:normal=Falseself.abortbtn.grab_focus()else:raise_('unknown mode name: %s')%modeworking=notnormalself.table.set_sensitive(normal)self.archivebtn.set_property('visible',normal)self.closebtn.set_property('visible',normal)ifcmd:self.cmd.set_property('visible',working)self.abortbtn.set_property('visible',working)defarchive(self):# verify inputtype=self.get_selected_archive_type()['type']dest=self.destentry.get_text()ifos.path.exists(dest):iftype!='files':ret=gdialog.Confirm(_('Confirm Overwrite'),[],self,_('The destination "%s" already exists!\n\n''Do you want to overwrite it?')%dest).run()ifret!=gtk.RESPONSE_YES:returnFalseeliflen(os.listdir(dest))>0:ret=gdialog.Confirm(_('Confirm Overwrite'),[],self,_('The directory "%s" isn\'t empty!\n\n''Do you want to overwrite it?')%dest).run()ifret!=gtk.RESPONSE_YES:returnFalsecmdline=['hg','archive','--verbose']rev=self.combo.get_active_text()ifrev!=WD_PARENT:cmdline.append('--rev')cmdline.append(rev)cmdline.append('-t')cmdline.append(type)cmdline.append(hglib.fromutf(dest))defcmd_done(returncode):self.switch_to(MODE_NORMAL,cmd=False)ifreturncode==0andnotself.cmd.is_show_log():self.response(gtk.RESPONSE_CLOSE)self.switch_to(MODE_WORKING)self.cmd.execute(cmdline,cmd_done)defrun(ui,*pats,**opts):returnArchiveDialog(opts.get('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.