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>#importgtkimportgobjectimportpangoimportQueueimportosimportthreadingfrommercurial.i18nimport_frommercurialimporthg,ui,util,extensions,urlfromdialogimporterror_dialog,question_dialog,info_dialogfromhglibimportHgThread,fromutf,toutf,rootpath,RepoErrorimportshlibimportgtklibimporturllibclassSynchDialog(gtk.Window):def__init__(self,repos=[],pushmode=False):""" Initialize the Dialog. """gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL)shlib.set_tortoise_icon(self,'menusynch.ico')shlib.set_tortoise_keys(self)self.root=rootpath()self.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 and rebase extensions explicitly- extensions.load(self.ui, 'fetch', None)- extensions.load(self.ui, 'rebase', None)- name = self.repo.ui.config('web', 'name') or os.path.basename(self.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,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)self._pathbox=gtk.ComboBoxEntry(self.pathlist,0)self._pathtext=self._pathbox.get_child()cell=gtk.CellRendererText()self._pathbox.pack_end(cell,False)self._pathbox.add_attribute(cell,'text',1)self.fill_path_combo()defrow=Nonedefpushrow=Nonefori,(path,alias)inenumerate(self.pathlist):ifalias=='default':defrow=iifdefpushrowisNone:defpushrow=ielifalias=='default-push':defpushrow=iifrepos:self._pathtext.set_text(toutf(repos[0]))elifdefpushrowisnotNoneandpushmode:self._pathbox.set_active(defpushrow)elifdefrowisnotNone:self._pathbox.set_active(defrow)# 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)frame=gtk.Frame(_('Post pull operation'))hbox=gtk.HBox()self.nothingradio=gtk.RadioButton(None,_('Nothing'))self.updateradio=gtk.RadioButton(self.nothingradio,_('Update'))self.fetchradio=gtk.RadioButton(self.nothingradio,_('Fetch'))self.rebaseradio=gtk.RadioButton(self.nothingradio,_('Rebase'))hbox.pack_start(self.nothingradio,True,True,2)hbox.pack_start(self.updateradio,True,True,2)hbox.pack_start(self.fetchradio,True,True,2)hbox.pack_start(self.rebaseradio,True,True,2)frame.add(hbox)frame.set_border_width(2)vbox.pack_start(frame,False,False,2)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()self._reventry=gtk.Entry()self._cmdentry=gtk.Entry()self._force=gtk.CheckButton(_('Force pull or push'))self.tips.set_tip(self._force,_('Run even when remote repository'' is unrelated.'))revhbox=gtk.HBox()revhbox.pack_start(gtk.Label(_('Target Revision:')),False,False,2)revhbox.pack_start(self._reventry,True,True,2)reveventbox=gtk.EventBox()reveventbox.add(revhbox)self.tips.set_tip(reveventbox,_('A specific revision up to which you'' would like to push or pull.'))cmdhbox=gtk.HBox()cmdhbox.pack_start(gtk.Label(_('Remote Command:')),False,False,2)cmdhbox.pack_start(self._cmdentry,True,True,2)cmdeventbox=gtk.EventBox()cmdeventbox.add(cmdhbox)self.tips.set_tip(cmdeventbox,_('Name of hg executable on remote'' machine.'))revvbox.pack_start(self._force,False,False,8)revvbox.pack_start(reveventbox,True,True,2)revvbox.pack_start(cmdeventbox,True,True,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 branch 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()self.update_pull_setting()defupdate_pull_setting(self):ppull=self.repo.ui.config('tortoisehg','postpull','None')self.nothingradio.set_active(True)ifppull=='update':self.updateradio.set_active(True)elifppull=='fetch':self.fetchradio.set_active(True)elifppull=='rebase':self.rebaseradio.set_active(True)deffill_path_combo(self):self.pathlist.clear()foralias,pathinself.paths:path=url.hidepassword(path)self.pathlist.append([toutf(path),toutf(alias)])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()try:# open a new repo, rebase can confuse cached reporepo=hg.repository(ui.ui(),path=self.root)exceptRepoError:returntip=len(repo.changelog)ifself.origchangecount==tip:self.viewpulled.hide()else:self.buttonhbox.show()self.viewpulled.show()wc=repo[None]branchhead=repo.branchtags()[wc.branch()]parents=repo.parents()iflen(parents)>1orparents[0].node()==branchhead:self.updatetip.hide()else:self.buttonhbox.show()self.updatetip.show()self.repo=repodef_view_pulled_changes(self,button):fromhistoryimportGLogcountpulled=len(self.repo.changelog)-self.origchangecountopts={'limit':countpulled}dialog=GLog(self.ui,None,None,[],opts,False)dialog.display()def_update_to_tip(self,button):# execute command and show output on text widgetgobject.timeout_add(10,self.process_queue)self.write("",False)cmdline=['update','-v']self.hgthread=HgThread(cmdline)self.hgthread.start()self.stbar.begin()self.stbar.set_status_text('hg '+' '.join(cmdline))def_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,_('Cannot close now'),_('command is running'))else:self._save_settings()gtk.main_quit()def_save_settings(self):self.update_settings()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']remotecmd=self._cmdentry.get_text().strip()ifremotecmd!="":opts['remotecmd']=['--remotecmd',remotecmd]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()
if self.fetchradio.get_active():
cmd = ['fetch', '--message', 'merge']
+ # load the fetch extensions explicitly+ extensions.load(self.ui, 'fetch', None) else:
cmd = ['pull']
cmd += aopts.get('force', [])
cmd+=aopts.get('remotecmd',[])ifself.updateradio.get_active(): cmd.append('--update')
elif self.rebaseradio.get_active():
cmd.append('--rebase')
+ # load the rebase extensions explicitly+ extensions.load(self.ui, 'rebase', None) 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',[])cmd+=aopts.get('remotecmd',[])self._exec_cmd(cmd)def_conf_clicked(self,toolbutton,data=None):newpath=fromutf(self._pathtext.get_text()).strip()foralias,pathinself.paths:ifpath==newpath:newpath=NonebreakfromthgconfigimportConfigDialogdlg=ConfigDialog(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()self.update_pull_setting()def_email_clicked(self,toolbutton,data=None):opts=[]path=fromutf(self._pathtext.get_text()).strip()rev=self._get_advanced_options().get('rev')ifpath:opts.extend(['--outgoing',path])elifnotrev:info_dialog(self,_('No repository selected'),_('Select a peer repository to compare with'))self._pathbox.grab_focus()returnifrev:opts.extend(rev)fromhgemailimportEmailDialogdlg=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',[])cmd+=aopts.get('remotecmd',[])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',[])cmd+=aopts.get('remotecmd',[])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,_('Cannot run now'),_('Please 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()foralias,pathinself.paths:ifremote_path==alias:remote_path=pathelifremote_path==url.hidepassword(path):remote_path=pathcmdline=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':'','_cmdentry.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(ui,*pats,**opts):returnSynchDialog(pats,opts.get('pushmode'))
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.