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.
# update.py - TortoiseHg's dialog for updating repo## 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.importosimportgtkimportgobjectfrommercurialimporthg,uifromtortoisehg.util.i18nimport_fromtortoisehg.utilimporthglib,pathsfromtortoisehg.util.hglibimportLookupError,RepoLookupError,RepoErrorfromtortoisehg.hgtkimporthgcmd,gtklib,gdialogMODE_NORMAL='normal'MODE_UPDATING='updating'classUpdateDialog(gtk.Dialog):""" Dialog to update 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_size_request(450,-1)self.set_has_separator(False)self.connect('response',self.dialog_response)self.connect('delete-event',self.delete_event) try:
repo = hg.repository(ui.ui(), path=paths.find_root())
- self.repo = repo except hglib.RepoError:
gobject.idle_add(self.destroy)
return
--reponame = hglib.toutf(os.path.basename(repo.root))- self.set_title(_('Update - %s') % reponame)
+self.repo = repo
+ self.set_title(_('Update - %s') % hglib.get_reponame(repo))
# add dialog buttons
self.updatebtn = self.add_button(_('Update'), gtk.RESPONSE_OK)
self.closebtn=self.add_button(gtk.STOCK_CANCEL,gtk.RESPONSE_CLOSE)# layout table for fixed itemstable=gtklib.LayoutTable()self.tables=dict(fixed=table)self.vbox.pack_start(table,True,True,2)## revision label & comboboxself.revcombo=combo=gtk.combo_box_entry_new_text()entry=combo.childentry.connect('activate',lambdab:self.update(repo))entry.set_width_chars(38)table.add_row(_('Update to:'),combo,padding=False)## update methodbtn=gtk.CheckButton(_('Discard local changes, no backup (-C/--clean)'))self.opt_clean=btntable.add_row('',btn)## fill list of comboifrev!=None:combo.append_text(str(rev))else:combo.append_text(repo.dirstate.branch())combo.set_active(0)dblist=self.repo.ui.config('tortoisehg','deadbranch','')deadbranches=[x.strip()forxindblist.split(',')]fornameinself.repo.branchtags().keys():ifnamenotindeadbranches:combo.append_text(name)tags=list(repo.tags())tags.sort()tags.reverse()fortintags:combo.append_text(t)# layout table for summariestable=gtklib.LayoutTable()self.tables['summary']=tableself.vbox.pack_start(table)self.show_summaries(True)self.opt_clean.connect('toggled',lambdab:self.update_summaries())# layout groupgroup=gtklib.LayoutGroup()group.add(*self.tables.values())# prepare to showself.updatebtn.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)# cancel buttonself.cancelbtn=gtk.Button(_('Cancel'))self.cancelbtn.connect('clicked',self.cancel_clicked)self.action_area.pack_end(self.cancelbtn)defbuild_summaries(self):table=self.tables['summary']defnew_label():label=gtk.Label('-')label.set_selectable(True)label.set_line_wrap(True)label.set_size_request(350,-1)hb=gtk.HBox()hb.pack_start(label,False,False)returnhb,label# summary of new revisionhb,label=new_label()table.add_row('Target:',hb)self.new_rev_label=label# summary of current revision(s)hb,label=new_label()self.current_rev_label1=labelself.ctxs=self.repo[None].parents()iflen(self.ctxs)==2:table.add_row(_('Parent 1:'),hb)hb,label=new_label()table.add_row('Parent 2:',hb)self.current_rev_label2=labelelse:table.add_row(_('Parent:'),hb)self.current_rev_label2=Nonetable.show_all()self.revcombo.connect('changed',lambdab:self.update_summaries())defdialog_response(self,dialog,response_id):ifresponse_id==gtk.RESPONSE_OK:self.update(self.repo)elifnotself.cmd.is_alive():self.destroy()defdelete_event(self,dialog,event):ifself.cmd.is_alive():ret=gdialog.Confirm(_('Confirm Cancel'),[],self,_('Do you want to cancel updating?')).run()ifret==gtk.RESPONSE_YES:self.cancel_clicked(self.cancelbtn)returnTrueself.destroy()defcancel_clicked(self,button):self.cmd.stop()self.cmd.show_log()self.switch_to(MODE_NORMAL,cmd=False)defswitch_to(self,mode,cmd=True):ifmode==MODE_NORMAL:normal=Trueself.closebtn.grab_focus()elifmode==MODE_UPDATING:normal=Falseself.cancelbtn.grab_focus()else:raise_('unknown mode name: %s')%modeupdating=notnormalfortableinself.tables.values():table.set_sensitive(normal)self.updatebtn.set_property('visible',normal)self.closebtn.set_property('visible',normal)ifcmd:self.cmd.set_property('visible',updating)self.cancelbtn.set_property('visible',updating)defshow_summaries(self,visible=True):ifvisibleandnothasattr(self,'ctxs'):self.build_summaries()ifhasattr(self,'ctxs'):self.update_summaries()table=self.tables['summary']table.set_property('visible',visible)defupdate_summaries(self):defsetlabel(label,ctx):revision=str(ctx.rev())hash=str(ctx)summary=gtklib.markup_escape_text(hglib.toutf(ctx.description().split('\n')[0]))face='monospace'size='9000'format='<span face="%s" size="%s">%s (%s)\n</span>'t=format%(face,size,revision,hash)branch=ctx.branch()ifbranch!='default':format='<span color="%s" background="%s"> %s </span> 't+=format%('black','#aaffaa',branch)tags=self.repo.nodetags(ctx.node())format='<span color="%s" background="%s"> %s </span> 'fortagintags:t+=format%('black','#ffffaa',tag)t+=summarylabel.set_markup(t)ctxs=self.ctxssetlabel(self.current_rev_label1,ctxs[0])merge=len(ctxs)==2ifmerge:setlabel(self.current_rev_label2,ctxs[1])newrev=self.revcombo.get_active_text()try:new_ctx=self.repo[newrev]ifnotmergeandnew_ctx.rev()==ctxs[0].rev():self.new_rev_label.set_label(_('(same as parent)'))self.updatebtn.set_sensitive(self.opt_clean.get_active())else:setlabel(self.new_rev_label,self.repo[newrev])self.updatebtn.set_sensitive(True)except(LookupError,RepoLookupError,RepoError):self.new_rev_label.set_label(_('unknown revision!'))self.updatebtn.set_sensitive(False)defupdate(self,repo):cmdline=['hg','update','--verbose']rev=self.revcombo.get_active_text()cmdline.append('--rev')cmdline.append(rev)ifself.opt_clean.get_active():cmdline.append('--clean')else:cur=self.repo['.']node=self.repo[rev]defisclean():'''whether WD is changed'''wc=self.repo[None]returnnot(wc.modified()orwc.added()orwc.removed())defismergedchange():'''whether the local changes are merged (have 2 parents)'''wc=self.repo[None]returnlen(wc.parents())==2defiscrossbranch(p1,p2):'''whether p1 -> p2 crosses branch'''pa=p1.ancestor(p2)returnp1.branch()!=p2.branch()or(p1!=paandp2!=pa)defislocalmerge(p1,p2,clean=None):ifcleanisNone:clean=isclean()pa=p1.ancestor(p2)returnnotcleanandp1.branch()==p2.branch()and \
(p1==paorp2==pa)defconfirmupdate(clean=None):ifcleanisNone:clean=isclean()msg=_('Detected uncommitted local changes in working tree.\n''Please select to continue:\n\n')data={'discard':(_('&Discard'),_('Discard - discard local changes, no backup')),'shelve':(_('&Shelve'),_('Shelve - launch Shelve tool and continue')),'merge':(_('&Merge'),_('Merge - allow to merge with local changes')),'cancel':(_('&Cancel'),None)}opts=[data['discard']]ifnotismergedchange():opts.append(data['shelve'])ifislocalmerge(cur,node,clean):opts.append(data['merge'])opts.append(data['cancel'])msg+='\n'.join([descforlabel,descinoptsifdesc])buttons=[labelforlabel,descinopts]cancel=len(opts)-1retcode=gdialog.CustomPrompt(_('Confirm Update'),msg,self,buttons,default=cancel,esc=cancel).run()retlabel=buttons[retcode]retid=[idforid,(label,desc)indata.items() \
iflabel==retlabel][0]returndict([(id,id==retid)foridindata.keys()])clean=isclean()ifclean:cmdline.append('--check')else:ret=confirmupdate(clean)ifret['discard']:cmdline.append('--clean')elifret['shelve']:fromtortoisehg.hgtkimportthgshelvedlg=thgshelve.run(ui.ui())dlg.set_transient_for(self)dlg.set_modal(True)dlg.display()dlg.connect('destroy',lambdaw:self.update(repo))return# retry later, no need to destroyelifret['merge']:pass# no argselifret['cancel']:self.destroy()returnelse:raise_('invalid dialog result: %s')%retdefcmd_done(returncode):self.switch_to(MODE_NORMAL,cmd=False)ifhasattr(self,'notify_func'):self.notify_func(self.notify_args)ifreturncode==0andnotself.cmd.is_show_log():self.destroy()self.switch_to(MODE_UPDATING)self.cmd.execute(cmdline,cmd_done)defset_notify_func(self,func,*args):self.notify_func=funcself.notify_args=argsdefrun(ui,*pats,**opts):returnUpdateDialog(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.