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.
# synch.py - Repository synchronization dialog for TortoiseHg## Copyright 2007 TK Soh <teekaysoh@gmail.com># Copyright 2007 Steve Borho <steve@borho.org>## This software may be used and distributed according to the terms of the# GNU General Public License version 2, incorporated herein by reference.importgtkimportgobjectimportpangoimportQueueimportosimportsysimportthreadingimporturllibfrommercurialimporthg,ui,extensions,urlfromthgutil.i18nimport_fromthgutilimporthglib,settings,pathsfromhggtkimportdialog,gtklib,hgthread,history,thgconfig,hgemailclassSynchDialog(gtk.Window):def__init__(self,repos=[],pushmode=False,fromlog=False):""" Initialize the Dialog. """gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL)gtklib.set_tortoise_icon(self,'menusynch.ico')gtklib.set_tortoise_keys(self)self.root=paths.find_root()self.selected_path=Noneself.hgthread=Noneself.fromlog=fromlogself.notify_func=Noneself.last_drop_time=Noneself.lastcmd=[]# Replace stdout file descriptor with our own pipeself.oldstdout=os.dup(sys.__stdout__.fileno())self.stdoutq=Queue.Queue()self.readfd,writefd=os.pipe()os.dup2(writefd,sys.__stdout__.fileno())# persistent app dataself._settings=settings.Settings('synch')self.set_default_size(655,552)self.paths=self.get_paths()self.origchangecount=len(self.repo)name=self.repo.ui.config('web','name')oros.path.basename(self.root)self.set_title(_('TortoiseHg Synchronize - ')+hglib.toutf(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(), ]
for btn in tbuttons:
self.tbar.insert(btn, -1)
++ # Base box basevbox = gtk.VBox()
self.add(basevbox)
basevbox.pack_start(self.tbar, False, False, 2)
- # synctargetselection buttons+ # SyncTargetPath targethbox = gtk.HBox()
++ ## target selection buttons lbl = gtk.Button(_('Repo:'))
lbl.unset_flags(gtk.CAN_FOCUS)
lbl.connect('clicked', self.btn_remotepath_clicked)
targethbox.pack_start(lbl,False,False)lbl=gtk.Button(_('Bundle:'))lbl.unset_flags(gtk.CAN_FOCUS) lbl.connect('clicked', self.btn_bundlepath_clicked)
targethbox.pack_start(lbl, False, False)
- # target path combobox
+ ## target path combobox
self.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)targethbox.pack_start(self.pathbox,True,True)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(hglib.toutf(repos[0]))elifdefpushrowisnotNoneandpushmode:self.pathbox.set_active(defpushrow) elif defrow is not None:
self.pathbox.set_active(defrow)
- # support dropping of repos or bundle files- self.drag_dest_set(gtk.DEST_DEFAULT_ALL,- [("text/uri-list", 0, 1)], gtk.gdk.ACTION_COPY)- self.connect('drag_data_received', self._drag_receive)-- # group for 'Post pulloperation'+ # Post PullOperation ppullhbox = gtk.HBox()
self.ppulldata = [('none', _('Nothing')), ('update', _('Update')),
('fetch', _('Fetch')), ('rebase', _('Rebase'))]
self.ppullcombo=combo=gtk.combo_box_new_text()for(index,(name,label))inenumerate(self.ppulldata):combo.insert_text(index,label) ppullhbox.pack_start(gtk.Label(_('Post Pull: ')), False, False, 2)
ppullhbox.pack_start(self.ppullcombo, True, True)
- # Advanced options
- self.expander = expander = gtk.Expander(_('Advanced Options'))
- expander.set_expanded(False)- expander.connect_after('activate', self.expanded)- opthbox = gtk.HBox()- expander.add(opthbox)-+ # Fixed options box (non-foldable)
fixedhbox = gtk.HBox()
fixedhbox.pack_start(targethbox, True, True, 2)
fixedhbox.pack_start(ppullhbox, False, False, 2)
-topvbox = gtk.VBox()
-topvbox.pack_start(fixedhbox,True, True, 2)
-topvbox.pack_start(expander, False, False, 2)
-basevbox.pack_start(topvbox, False, False, 2)
+# Advanced options (foldable)+ opthbox = gtk.HBox()
+self.expander = expander = gtk.Expander(_('AdvancedOptions'))
+expander.set_expanded(False)
+expander.connect_after('activate', self.expanded)
+ expander.add(opthbox)- # checkbox options
+ ## checkbox options
chkopthbox = gtk.HBox()
self.force = gtk.CheckButton(_('Force pull or push'))
+ self.tips.set_tip(self.force, _('Run even when remote repository'+ ' is unrelated.')) self.use_proxy = gtk.CheckButton(_('use proxy server'))
if ui.ui().config('http_proxy', 'host', ''):
self.use_proxy.set_active(True)
else:self.use_proxy.set_sensitive(False) chkopthbox.pack_start(self.force, False, False, 4)
chkopthbox.pack_start(self.use_proxy, False, False, 4)
- # otheroptions+ ##targetrevision option+ revhbox = gtk.HBox() self.reventry = gtk.Entry()
- self.cmdentry = gtk.Entry()- 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.'))
+ ## remote command option cmdhbox = gtk.HBox()
+ self.cmdentry = gtk.Entry() 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=gtk.VBox()revvbox.pack_start(chkopthbox,False,False,8)revvbox.pack_start(reveventbox,False,False,4) revvbox.pack_start(cmdeventbox, False, False, 4)
opthbox.pack_start(revvbox, True, True, 4)
- # groupboxfor 'Incoming/Outgoing'+ ##incoming/outgoingoptions frame = gtk.Frame(_('Incoming/Outgoing'))
opthbox.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'))iovbox=gtk.VBox()iovbox.pack_start(self.showpatch,False,False,2)iovbox.pack_start(self.newestfirst,False,False,2) iovbox.pack_start(self.nomerge, False, False, 2)
frame.add(iovbox)
+ # Main option box+ topvbox = gtk.VBox()+ topvbox.pack_start(fixedhbox, True, True, 2)+ topvbox.pack_start(expander, False, False, 2)+ basevbox.pack_start(topvbox, False, False, 2)+ # hg output window
scrolledwindow = 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.connect('populate-popup',self.add_to_popup)self.textbuffer=self.textview.get_buffer()self.textbuffer.create_tag('error',weight=pango.WEIGHT_HEAVY,foreground='#900000')basevbox.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)
basevbox.pack_start(self.buttonhbox, False, False, 2)
+ # statusbar self.stbar = gtklib.StatusBar()
basevbox.pack_start(self.stbar, False, False, 2)
+ # support dropping of repos or bundle files+ self.drag_dest_set(gtk.DEST_DEFAULT_ALL,+ [("text/uri-list", 0, 1)], gtk.gdk.ACTION_COPY)+ self.connect('drag_data_received', self._drag_receive)++ # prepare to show self.load_settings()
self.update_pull_setting()
gobject.idle_add(self.finalize_startup)
deffinalize_startup(self,*args):self.update_buttons()defpollstdout(*args):whileTrue:# blocking read of stdout pipeo=os.read(self.readfd,1024)ifo:self.stdoutq.put(o)else:breakthread=threading.Thread(target=pollstdout,args=[])thread.start()defupdate_pull_setting(self):ppull=self.repo.ui.config('tortoisehg','postpull','none')for(index,(name,label))inenumerate(self.ppulldata):ifppull==name:pos=indexbreak;else:pos=[indexfor(index,(name,label))inenumerate(self.ppulldata)ifname=='none'][0]self.ppullcombo.set_active(pos)deffill_path_combo(self):self.pathlist.clear()foralias,pathinself.paths:path=url.hidepassword(path)self.pathlist.append([hglib.toutf(path),hglib.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:])ifpaths.find_root(path)==path:self.pathtext.set_text(hglib.toutf(path))elifnotos.path.isdir(path)andpath.endswith('.hg'):self.pathtext.set_text(hglib.toutf(path))defupdate_buttons(self):self.buttonhbox.hide()try:# open a new repo, rebase can confuse cached reporepo=hg.repository(ui.ui(),path=self.root)excepthglib.RepoError:returntip=len(repo)if' '.join(self.lastcmd[:2])=='pull --rebase':# if last operation was a rebase, do not show 'viewpulled'# and reset our remembered tip changesetself.origchangecount=tipself.viewpulled.hide()elifself.origchangecount==tiporself.fromlog:self.viewpulled.hide()else:self.buttonhbox.show()self.viewpulled.show()wc=repo[None]branchhead=repo.branchtags().get(wc.branch())parents=repo.parents()iflen(parents)>1orparents[0].node()==branchheadornotbranchhead:self.updatetip.hide()else:self.buttonhbox.show()self.updatetip.show()self.repo=repodef_view_pulled_changes(self,button):opts={'orig-tip':self.origchangecount,'from-synch':True}dlg=history.GLog(self.ui,None,None,[],opts)dlg.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.HgThread(cmdline)self.hgthread.start()self.stbar.begin()self.stbar.set_status_text('hg '+' '.join(cmdline))defget_paths(self,sort="value"):""" retrieve symbolic paths """try:self.ui=ui.ui()self.repo=hg.repository(self.ui,path=self.root)uipaths=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'")%sortuipaths.sort(sortfunc)returnuipathsexcepthglib.RepoError:returnNonedefbtn_remotepath_clicked(self,button):""" select source folder to clone """response=gtklib.NativeFolderSelectDialog(initial=self.root,title=_('Select Repository')).run()ifresponse:self.pathtext.set_text(response)defbtn_bundlepath_clicked(self,button):""" select bundle to read from """response=gtklib.NativeSaveFileDialogWrapper(InitialDir=self.root,Title=_('Select Bundle'),Filter=((_('Bundle (*.hg)'),'*.hg'),(_('Bundle (*)'),'*.*')),Open=True).run()ifresponse:self.pathtext.set_text(response)defshould_live(self):ifself.cmd_running():dialog.error_dialog(self,_('Cannot close now'),_('command is running'))returnTrueelse:self.update_settings()self._settings.write()os.dup2(self.oldstdout,sys.__stdout__.fileno())os.close(self.oldstdout)returnFalsedefdelete(self,widget,event):ifnotself.should_live():self.destroy()deftoolbutton(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)returntbuttondefget_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]returnoptsdefpull_clicked(self,toolbutton,data=None):sel=self.ppullcombo.get_active_text()ppull=[namefor(name,label)inself.ppulldataifsel==label][0]aopts=self.get_advanced_options()ifppull=='fetch':cmd=['fetch','--message','merge']# load the fetch extensions explicitlyextensions.load(self.ui,'fetch',None)else:cmd=['pull']cmd+=aopts.get('force',[])cmd+=aopts.get('remotecmd',[])ifppull=='update':cmd.append('--update')elifppull=='rebase':cmd.append('--rebase')# load the rebase extensions explicitlyextensions.load(self.ui,'rebase',None)cmd+=aopts.get('rev',[])self.exec_cmd(cmd)defpush_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)defconf_clicked(self,toolbutton,data=None):newpath=hglib.fromutf(self.pathtext.get_text()).strip()foralias,pathinself.paths:ifnewpathin(path,url.hidepassword(path)):newpath=Nonebreakdlg=thgconfig.ConfigDialog(True)dlg.show_all()ifnewpath:dlg.new_path(newpath,'default')else:dlg.focus_field('tortoisehg.postpull')dlg.run()dlg.hide()self.paths=self.get_paths()self.fill_path_combo()self.update_pull_setting()defemail_clicked(self,toolbutton,data=None):opts=[]path=hglib.fromutf(self.pathtext.get_text()).strip()rev=self.get_advanced_options().get('rev')ifpath:opts.extend(['--outgoing',path])elifnotrev:dialog.info_dialog(self,_('No repository selected'),_('Select a peer repository to compare with'))self.pathbox.grab_focus()returnifrev:opts.extend(rev)dlg=hgemail.EmailDialog(self.root,opts)dlg.set_transient_for(self)dlg.show_all()dlg.present()dlg.set_transient_for(None)defincoming_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)defoutgoing_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)defstop_clicked(self,toolbutton,data=None):ifself.cmd_running():self.hgthread.terminate()self.stop_button.set_sensitive(False)defexec_cmd(self,cmd):ifself.cmd_running():dialog.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=hglib.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']ifproxy_hostandnotuse_proxy:cmdline+=["--config","http_proxy.host="]cmdline+=[remote_path]self.lastcmd=cmdline# show command to be executedself.write("",False)# execute command and show output on text widgetgobject.timeout_add(10,self.process_queue)self.hgthread=hgthread.HgThread(cmdline,parent=self)self.hgthread.start()self.stbar.begin()self.stbar.set_status_text('hg '+' '.join(cmd))self.add_src_to_recent(remote_path)defcmd_running(self):ifself.hgthreadandself.hgthread.isAlive():returnTrueelse:returnFalsedefadd_src_to_recent(self,src):# add src path to recent list in history (read by clone tool)self._settings.mrul('src_paths').add(src)self._settings.write()defflush(self,*args):passdefwrite(self,msg,append=True):msg=hglib.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)defwrite_err(self,msg):enditer=self.textbuffer.get_end_iter()self.textbuffer.insert_with_tags_by_name(enditer,msg,'error')self.textview.scroll_to_mark(self.textbuffer.get_insert(),0)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:passwhileself.hgthread.geterrqueue().qsize():try:msg=self.hgthread.geterrqueue().get(0)self.write_err(msg)exceptQueue.Empty:passwhileself.stdoutq.qsize():try:msg=self.stdoutq.get(0)self.write_err(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_err(_('[command interrupted]'))ifnotself.notify_funcorself.lastcmd[0]!='pull':returnFalseif' '.join(self.lastcmd[:2])=='pull --rebase':# disable notification; rebase can be poisonousself.notify_func=Noneself.notify_args=Noneelse:self.notify_func(self.notify_args)returnFalse# Stop polling this functionAdvancedDefaults={'expander.expanded':False,'reventry.text':'','cmdentry.text':'','force.active':False,'showpatch.active':False,'newestfirst.active':False,'nomerge.active':False,}defexpanded(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)defadd_to_popup(self,textview,menu):menu_items=(('----',None),(_('Toggle _Wordwrap'),self.toggle_wordwrap),)forlabel,handlerinmenu_items:iflabel=='----':menuitem=gtk.SeparatorMenuItem()else:menuitem=gtk.MenuItem(label)ifhandler:menuitem.connect('activate',handler)menu.append(menuitem)menu.show_all()deftoggle_wordwrap(self,sender):ifself.textview.get_wrap_mode()!=gtk.WRAP_NONE:self.textview.set_wrap_mode(gtk.WRAP_NONE)else:self.textview.set_wrap_mode(gtk.WRAP_WORD)defset_notify_func(self,func,*args):self.notify_func=funcself.notify_args=argsdefrun(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.