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.
## Repository synchronization dialog for TortoiseHg## Copyright (C) 2007 Steve Borho <steve@borho.org># Copyright (C) 2007 TK Soh <teekaysoh@gmail.com>#try:importpygtkpygtk.require("2.0")except:passimportgtkimportgobjectimportpangoimportQueueimportosimportthreadingfrommercurialimporthg,ui,util,extensionsfromdialogimporterror_dialog,question_dialog,info_dialogfromhglibimportHgThread,fromutf,toutf,rootpath,RepoErrorimportshlibimportgtklibimporturllibclassSynchDialog(gtk.Window):def__init__(self,cwd='',root='',repos=[],pushmode=False):""" Initialize the Dialog. """gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL)shlib.set_tortoise_icon(self,'menusynch.ico')self.root=rootself.cwd=cwdself.selected_path=Noneself.hgthread=None# persistent app dataself._settings=shlib.Settings('synch')self._recent_src=self._settings.mrul('src_paths')self.set_default_size(610,400)self.paths=self._get_paths()self.origchangecount=len(self.repo.changelog)# load the fetch extension explicitlyextensions.load(self.ui,'fetch',None)name=self.repo.ui.config('web','name')oros.path.basename(root)self.set_title("TortoiseHg Synchronize - "+name)self.connect('delete-event',self._delete)# toolbarself.tbar=gtk.Toolbar()self.tips=gtk.Tooltips()self._stop_button=self._toolbutton(gtk.STOCK_STOP,'Stop',self._stop_clicked,tip='Stop the hg operation')self._stop_button.set_sensitive(False)tbuttons=[self._toolbutton(gtk.STOCK_GO_DOWN,'Incoming',self._incoming_clicked,tip='Display changes that can be pulled'' from selected repository'),self._toolbutton(gtk.STOCK_GOTO_BOTTOM,' Pull ',self._pull_clicked,self._pull_menu(),tip='Pull changes from selected'' repository'),gtk.SeparatorToolItem(),self._toolbutton(gtk.STOCK_GO_UP,'Outgoing',self._outgoing_clicked,tip='Display local changes that will be pushed'' to selected repository'),self._toolbutton(gtk.STOCK_GOTO_TOP,'Push',self._push_clicked,tip='Push local changes to selected'' repository'),self._toolbutton(gtk.STOCK_GOTO_LAST,'Email',self._email_clicked,tip='Email local outgoing changes to'' one or more recipients'),gtk.SeparatorToolItem(),self._stop_button,gtk.SeparatorToolItem(),self._toolbutton(gtk.STOCK_PREFERENCES,'Configure',self._conf_clicked,tip='Configure peer repository paths'),gtk.SeparatorToolItem(),]forbtnintbuttons:self.tbar.insert(btn,-1)vbox=gtk.VBox()self.add(vbox)vbox.pack_start(self.tbar,False,False,2)# revision inputrevbox=gtk.HBox()lbl=gtk.Button("Repo:")lbl.unset_flags(gtk.CAN_FOCUS)lbl.connect('clicked',self._btn_remotepath_clicked)revbox.pack_start(lbl,False,False)lbl=gtk.Button("Bundle:")lbl.unset_flags(gtk.CAN_FOCUS)lbl.connect('clicked',self._btn_bundlepath_clicked)revbox.pack_start(lbl,False,False)# revisions combo boxself.pathlist=gtk.ListStore(str,str,bool)self._pathbox=gtk.ComboBoxEntry(self.pathlist,0)self._pathbox.set_row_separator_func(lambdamodel,i:model[i][2])self._pathtext=self._pathbox.get_child()self.fill_path_combo()defrow=Nonedefpushrow=Nonefori,(path,name,sep)inenumerate(self.pathlist):ifname=='default':defrow=iifdefpushrowisNone:defpushrow=ielifname=='default-push':defpushrow=iifrepos:self._pathtext.set_text(toutf(repos[0]))elifdefpushrowisnotNoneandpushmode:self._pathbox.set_active(defpushrow)elifdefrowisnotNone:self._pathbox.set_active(defrow)else:iflen(self.pathlist)>1andnotself.pathlist[0][3]:self._pathbox.set_active(0)# support dropping of repos or bundle filesself.drag_dest_set(gtk.DEST_DEFAULT_ALL,[("text/uri-list",0,1)],gtk.gdk.ACTION_COPY)self.connect('drag_data_received',self._drag_receive)# create checkbox to disable proxyself._use_proxy=gtk.CheckButton("use proxy server")ifui.ui().config('http_proxy','host',''):self._use_proxy.set_active(True)else:self._use_proxy.set_sensitive(False)revbox.pack_start(self._pathbox,True,True)revbox.pack_end(self._use_proxy,False,False)vbox.pack_start(revbox,False,False,2)self.expander=expander=gtk.Expander('Advanced Options')expander.set_expanded(False)expander.connect_after('activate',self._expanded)hbox=gtk.HBox()expander.add(hbox)revvbox=gtk.VBox()revhbox=gtk.HBox()self._reventry=gtk.Entry()self._force=gtk.CheckButton('Force pull or push')self.tips.set_tip(self._force,'Run even when remote repository'' is unrelated.')revhbox.pack_start(gtk.Label('Target Revision:'),False,False,2)revhbox.pack_start(self._reventry,True,True,2)eventbox=gtk.EventBox()eventbox.add(revhbox)self.tips.set_tip(eventbox,'A specific revision up to which you'' would like to push or pull.')revvbox.pack_start(eventbox,True,True,8)revvbox.pack_start(self._force,False,False,2)hbox.pack_start(revvbox,True,True,4)frame=gtk.Frame('Incoming/Outgoing')hbox.pack_start(frame,False,False,2)self._showpatch=gtk.CheckButton('Show Patches')self._newestfirst=gtk.CheckButton('Show Newest First')self._nomerge=gtk.CheckButton('Show No Merges')hbox=gtk.HBox()hbox.pack_start(self._showpatch,False,False,2)hbox.pack_start(self._newestfirst,False,False,2)hbox.pack_start(self._nomerge,False,False,2)frame.add(hbox)vbox.pack_start(expander,False,False,2)# hg output windowscrolledwindow=gtk.ScrolledWindow()scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)self.textview=gtk.TextView(buffer=None)self.textview.set_editable(False)self.textview.modify_font(pango.FontDescription("Monospace"))scrolledwindow.add(self.textview)self.textview.set_editable(False)self.textbuffer=self.textview.get_buffer()vbox.pack_start(scrolledwindow,True,True)self.buttonhbox=gtk.HBox()self.viewpulled=gtk.Button('View Pulled Revisions')self.viewpulled.connect('clicked',self._view_pulled_changes)self.updatetip=gtk.Button('Update to Tip')self.updatetip.connect('clicked',self._update_to_tip)self.buttonhbox.pack_start(self.viewpulled,False,False,2)self.buttonhbox.pack_start(self.updatetip,False,False,2)vbox.pack_start(self.buttonhbox,False,False,2)self.stbar=gtklib.StatusBar()vbox.pack_start(self.stbar,False,False,2)self.connect('map',self.update_buttons)self._last_drop_time=Noneself.load_settings()deffill_path_combo(self):self.pathlist.clear()sympaths=[]forname,pathinself.paths:sympaths.append(path)self.pathlist.append([toutf(path),name,False])separator=Falseforpinself._recent_src:ifpinsympaths:continueifnotseparator:self.pathlist.append(['-'*20,'',True])separator=Trueself.pathlist.append([toutf(p),'',False])def_drag_receive(self,widget,context,x,y,selection,targetType,time):iftime!=self._last_drop_time:files=selection.get_uris()gobject.idle_add(self._set_path,files[0])self._last_drop_time=timedef_set_path(self,uri):ifnoturi.startswith("file://"):returnpath=urllib.unquote(uri[7:])ifrootpath(path)==path:self._pathtext.set_text(toutf(path))elifnotos.path.isdir(path)andpath.endswith('.hg'):self._pathtext.set_text(toutf(path))defupdate_buttons(self,*args):self.buttonhbox.hide()self.repo.invalidate()tip=len(self.repo.changelog)ifself.origchangecount==tip:self.viewpulled.hide()else:self.buttonhbox.show()self.viewpulled.show()self.repo.dirstate.invalidate()parent=self.repo.changectx(None).parents()[0].rev()ifparent==tip-1:self.updatetip.hide()else:self.buttonhbox.show()self.updatetip.show()def_view_pulled_changes(self,button):fromhistoryimportGLogcountpulled=len(self.repo.changelog)-self.origchangecountopts={'limit':countpulled}dialog=GLog(self.ui,self.repo,self.cwd,[],opts,False)dialog.display()def_update_to_tip(self,button):self.repo.invalidate()wc=self.repo.changectx(None)pl=wc.parents()p1,p2=pl[0],self.repo.changectx('tip')pa=p1.ancestor(p2)warning=''flags=[]iflen(pl)>1:warning="Outstanding uncommitted merges"elifpa!=p1andpa!=p2:warning="Update spans branches"ifwarning:flags=['--clean']msg='Lose all changes in your working directory?'warning+=', requires clean checkout'ifquestion_dialog(self,msg,warning)!=gtk.RESPONSE_YES:returnself.write("",False)# execute command and show output on text widgetgobject.timeout_add(10,self.process_queue)cmdline=['update','-v','-R',self.repo.root]+flags+['tip']self.hgthread=HgThread(cmdline)self.hgthread.start()self.stbar.begin()self.stbar.set_status_text('hg '+' '.join(cmdline))def_pull_menu(self):menu=gtk.Menu()# define menu itemsself._pull_default=gtk.RadioMenuItem(None,"Default Pull")self._pull_update=gtk.RadioMenuItem(self._pull_default,"Update to new tip")self._pull_fetch=gtk.RadioMenuItem(self._pull_default,"Do fetch")self._pull_menu_items=[self._pull_default,self._pull_update,self._pull_fetch,]# add them to the menuforiteminself._pull_menu_items:menu.append(item)# restore states from previous sessionst=self._settings.get_value('_pull_default_state',0)self._pull_menu_items[st].set_active(True)menu.show_all()returnmenudef_get_paths(self,sort="value"):""" retrieve symbolic paths """try:self.ui=ui.ui()self.repo=hg.repository(self.ui,path=self.root)paths=self.repo.ui.configitems('paths')ifsort:ifsort=="value":sortfunc=lambdaa,b:cmp(a[1],b[1])elifsort=="name":sortfunc=lambdaa,b:cmp(a[0],b[0])else:raise"unknown sort key '%s'"%sortpaths.sort(sortfunc)returnpathsexceptRepoError:returnNonedef_btn_remotepath_clicked(self,button):""" select source folder to clone """dialog=gtk.FileChooserDialog(title="Select Repository",action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))dialog.set_default_response(gtk.RESPONSE_OK)dialog.set_current_folder(self.root)response=dialog.run()ifresponse==gtk.RESPONSE_OK:self._pathtext.set_text(dialog.get_filename())dialog.destroy()def_btn_bundlepath_clicked(self,button):""" select bundle to read from """dialog=gtk.FileChooserDialog(title="Select Bundle",action=gtk.FILE_CHOOSER_ACTION_OPEN,buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))dialog.set_default_response(gtk.RESPONSE_OK)dialog.set_current_folder(self.root)filefilter=gtk.FileFilter()filefilter.set_name("Bundle (*.hg)")filefilter.add_pattern("*.hg")dialog.add_filter(filefilter)filefilter=gtk.FileFilter()filefilter.set_name("Bundle (*)")filefilter.add_pattern("*")dialog.add_filter(filefilter)response=dialog.run()ifresponse==gtk.RESPONSE_OK:self._pathtext.set_text(dialog.get_filename())dialog.destroy()def_close_clicked(self,toolbutton,data=None):self._do_close()def_do_close(self):ifself._cmd_running():error_dialog(self,"Can't close now","command is running")else:self._save_settings()gtk.main_quit()def_save_settings(self):self.update_settings()pullstate=0foriinxrange(0,len(self._pull_menu_items)):ifself._pull_menu_items[i].get_active():pullstate=iself._settings.set_value('_pull_default_state',pullstate)self._settings.write()def_delete(self,widget,event):self._do_close()returnTruedef_toolbutton(self,stock,label,handler,menu=None,userdata=None,tip=None):ifmenu:tbutton=gtk.MenuToolButton(stock)tbutton.set_menu(menu)else:tbutton=gtk.ToolButton(stock)tbutton.set_label(label)iftip:tbutton.set_tooltip(self.tips,tip)tbutton.connect('clicked',handler,userdata)returntbuttondef_get_advanced_options(self):opts={}ifself._showpatch.get_active():opts['patch']=['--patch']ifself._nomerge.get_active():opts['no-merges']=['--no-merges']ifself._force.get_active():opts['force']=['--force']ifself._newestfirst.get_active():opts['newest-first']=['--newest-first']target_rev=self._reventry.get_text().strip()iftarget_rev!="":opts['rev']=['--rev',target_rev]returnoptsdef_pull_clicked(self,toolbutton,data=None):aopts=self._get_advanced_options()ifself._pull_fetch.get_active():cmd=['fetch','--message','merge']else:cmd=['pull']cmd+=aopts.get('force',[])ifself._pull_update.get_active():cmd.append('--update')cmd+=aopts.get('rev',[])self._exec_cmd(cmd)def_push_clicked(self,toolbutton,data=None):aopts=self._get_advanced_options()cmd=['push']cmd+=aopts.get('rev',[])cmd+=aopts.get('force',[])self._exec_cmd(cmd)def_conf_clicked(self,toolbutton,data=None):newpath=fromutf(self._pathtext.get_text()).strip()forname,pathinself.paths:ifpath==newpath:newpath=NonebreakfromthgconfigimportConfigDialogdlg=ConfigDialog(self.root,True)dlg.show_all()ifnewpath:dlg.new_path(newpath)else:dlg.focus_field('paths.default')dlg.run()dlg.hide()self.paths=self._get_paths() self.fill_path_combo()
def _email_clicked(self, toolbutton, data=None):
+ opts = [] path = fromutf(self._pathtext.get_text()).strip()
- if not path:
+ rev = self._get_advanced_options().get('rev')+ if path:
+ opts.extend(['--outgoing', path])+ elif not rev: info_dialog(self, 'No repository selected',
'Select a peer repository to compare with')
self._pathbox.grab_focus()
return
+ if rev:+ opts.extend(rev) from hgemail import EmailDialog
- dlg = EmailDialog(self.root, ['--outgoing', path])
+ dlg = EmailDialog(self.root, opts)
dlg.set_transient_for(self)
dlg.show_all()
dlg.present()
dlg.set_transient_for(None)def_incoming_clicked(self,toolbutton,data=None):aopts=self._get_advanced_options()cmd=['incoming']cmd+=aopts.get('rev',[])cmd+=aopts.get('patch',[])cmd+=aopts.get('no-merges',[])cmd+=aopts.get('force',[])cmd+=aopts.get('newest-first',[])self._exec_cmd(cmd)def_outgoing_clicked(self,toolbutton,data=None):aopts=self._get_advanced_options()cmd=['outgoing']cmd+=aopts.get('rev',[])cmd+=aopts.get('patch',[])cmd+=aopts.get('no-merges',[])cmd+=aopts.get('force',[])cmd+=aopts.get('newest-first',[])self._exec_cmd(cmd)def_stop_clicked(self,toolbutton,data=None):ifself._cmd_running():self.hgthread.terminate()self._stop_button.set_sensitive(False)def_exec_cmd(self,cmd):ifself._cmd_running():error_dialog(self,"Can't run now","Pleas try again after the previous command is completed")returnself._stop_button.set_sensitive(True)proxy_host=ui.ui().config('http_proxy','host','')use_proxy=self._use_proxy.get_active()text_entry=self._pathbox.get_child()remote_path=fromutf(text_entry.get_text()).strip()cmdline=cmd[:]cmdline+=['--verbose','--repository',self.root]ifproxy_hostandnotuse_proxy:cmdline+=["--config","http_proxy.host="]cmdline+=[remote_path]# show command to be executedself.write("",False)# execute command and show output on text widgetgobject.timeout_add(10,self.process_queue)self.hgthread=HgThread(cmdline,parent=self)self.hgthread.start()self.stbar.begin()self.stbar.set_status_text('hg '+' '.join(cmd+[remote_path]))self._add_src_to_recent(remote_path)def_cmd_running(self):ifself.hgthreadandself.hgthread.isAlive():returnTrueelse:returnFalsedef_add_src_to_recent(self,src):ifos.path.exists(src):src=os.path.abspath(src)# save path to recent list in historyself._recent_src.add(src)self._settings.write()# update drop-down listself.fill_path_combo()defwrite(self,msg,append=True):msg=toutf(msg)ifappend:enditer=self.textbuffer.get_end_iter()self.textbuffer.insert(enditer,msg)self.textview.scroll_to_mark(self.textbuffer.get_insert(),0)else:self.textbuffer.set_text(msg)defprocess_queue(self):""" Handle all the messages currently in the queue (if any). """self.hgthread.process_dialogs()whileself.hgthread.getqueue().qsize():try:msg=self.hgthread.getqueue().get(0)self.write(msg)exceptQueue.Empty:passifself._cmd_running():returnTrueelse:# Update button statesself.update_buttons()self.stbar.end()self._stop_button.set_sensitive(False)ifself.hgthread.return_code()isNone:self.write("[command interrupted]")returnFalse# Stop polling this functionAdvancedDefaults={'expander.expanded':False,'_reventry.text':'','_force.active':False,'_showpatch.active':False,'_newestfirst.active':False,'_nomerge.active':False,}def_expanded(self,expander):ifnotexpander.get_expanded():self.load_settings(SynchDialog.AdvancedDefaults.get)defload_settings(self,get_value=None):get_value=get_valueorself._settings.get_valueforkey,defaultinSynchDialog.AdvancedDefaults.iteritems():member,attr=key.split('.')value=get_value(key,default)getattr(getattr(self,member),'set_%s'%attr)(value)defupdate_settings(self,set_value=None):set_value=set_valueorself._settings.set_valueforkey,defaultinSynchDialog.AdvancedDefaults.iteritems():member,attr=key.split('.')value=getattr(getattr(self,member),'get_%s'%attr)()set_value(key,value)defrun(cwd='',root='',files=[],pushmode=False,**opts):dialog=SynchDialog(cwd,root,files,pushmode)dialog.show_all()gtk.gdk.threads_init()gtk.gdk.threads_enter()gtk.main()gtk.gdk.threads_leave()if__name__=="__main__":run(**{})
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.