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.
# visdiff.py - launch external visual diff tools## Copyright 2009 Steve Borho## Based on extdiff extension for Mercurial## This software may be used and distributed according to the terms# of the GNU General Public License, incorporated herein by reference.importgtkimportgobjectimportosimportshleximportsubprocessimportshutilimporttempfilefrommercurialimporthg,ui,cmdutil,utilfromthgutil.i18nimport_fromthgutilimporthglib,settings,pathsfromhggtkimportgdialog,gtklibtry:importwin32conopenflags=win32con.CREATE_NO_WINDOWexceptImportError:openflags=0defsnapshot_node(repo,files,node,tmproot):'''snapshot files as of some revision'''dirname=os.path.basename(repo.root)ifdirname=="":dirname="root"dirname='%s.%s'%(dirname,str(repo[node]))base=os.path.join(tmproot,dirname)os.mkdir(base)ctx=repo[node]forfninfiles:wfn=util.pconvert(fn)ifnotwfninctx:# skipping new file after a merge ?continuedest=os.path.join(base,wfn)destdir=os.path.dirname(dest)ifnotos.path.isdir(destdir):os.makedirs(destdir)data=repo.wwritedata(wfn,ctx[wfn].data())open(dest,'wb').write(data)returndirnameclassFileSelectionDialog(gtk.Dialog):'Dialog for selecting visual diff candidates'def__init__(self,canonpats,opts):'Initialize the Dialog'gtk.Dialog.__init__(self)gtklib.set_tortoise_icon(self,'menushowchanged.ico')gtklib.set_tortoise_keys(self)self.set_title(_('Visual Diffs'))self.set_default_size(400,150)lbl=gtk.Label(_('Temporary files are removed when this dialog'' is closed'))self.vbox.pack_start(lbl,False,False,2)scroller=gtk.ScrolledWindow()scroller.set_shadow_type(gtk.SHADOW_IN)scroller.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)model=gtk.ListStore(str,str)treeview=gtk.TreeView(model)treeview.get_selection().set_mode(gtk.SELECTION_SINGLE)treeview.set_search_equal_func(self.search_filelist)scroller.add(treeview)self.vbox.pack_start(scroller,True,True,2)hbox=gtk.HBox()self.vbox.pack_start(hbox,False,False,2)vsettings=settings.Settings('visdiff')single=vsettings.get_value('launchsingle',False)check=gtk.CheckButton(_('Always launch single files'))check.set_active(single)hbox.pack_start(check,True,True,2)self.singlecheck=checktreeview.connect('row-activated',self.rowactivated)treeview.set_headers_visible(False)treeview.set_property('enable-grid-lines',True)treeview.set_enable_search(False)cell=gtk.CellRendererText()stcol=gtk.TreeViewColumn('Status',cell)stcol.set_resizable(True)stcol.add_attribute(cell,'text',0)treeview.append_column(stcol)cell=gtk.CellRendererText()fcol=gtk.TreeViewColumn('Filename',cell)fcol.set_resizable(True)fcol.add_attribute(cell,'text',1)treeview.append_column(fcol)try:repo=hg.repository(ui.ui(),path=paths.find_root())excepthglib.RepoError:# hgtk should catch this earliergdialog.Prompt(_('No repository'),_('No repository found here'),None).run()returntools=readtools(repo.ui)preferred=repo.ui.config('tortoisehg','vdiff','vdiff')ifpreferredandpreferredintools:iflen(tools)>1:lbl=gtk.Label(_('Select diff tool'))combo=gtk.combo_box_new_text()fori,nameinenumerate(tools.iterkeys()):combo.append_text(name)ifname==preferred:defrow=icombo.connect('changed',self.toolselect,tools)combo.set_active(defrow)hbox.pack_start(lbl,False,False,2)hbox.pack_start(combo,False,False,2)else:self.diffpath,self.diffopts=tools[preferred]cwd=os.getcwd()try:os.chdir(repo.root)self.find_files(repo,canonpats,opts,model)finally:os.chdir(cwd)else:gdialog.Prompt(_('No visual diff tool'),_('No visual diff tool has been configured'),None).run()defsearch_filelist(self,model,column,key,iter):'case insensitive filename search'key=key.lower()ifkeyinmodel.get_value(iter,1).lower():returnFalsereturnTruedeftoolselect(self,combo,tools):sel=combo.get_active_text()ifselintools:self.diffpath,self.diffopts=tools[sel]deffind_files(self,repo,pats,opts,model):revs=opts.get('rev')change=opts.get('change')ifchange:title=_('changeset ')+str(change)node2=repo.lookup(change)node1=repo[node2].parents()[0].node()else:ifrevs:title=_('revision(s) ')+' to '.join(revs)else:title=_('working changes')node1,node2=cmdutil.revpair(repo,revs)title=_('Visual Diffs - ')+titleifpats:title+=' filtered'self.set_title(title)matcher=cmdutil.match(repo,pats,opts)modified,added,removed=repo.status(node1,node2,matcher)[:3]ifnot(modifiedoraddedorremoved):gdialog.Prompt(_('No file changes'),_('There are no file changes to view'),self).run()# GTK+ locks up if this is done immediately heregobject.idle_add(self.destroy)returntmproot=tempfile.mkdtemp(prefix='extdiff.')self.connect('destroy',self.delete_tmproot,tmproot)dir2=''dir2root=''# Always make a copy of node1dir1=snapshot_node(repo,modified+removed,node1,tmproot)# If node2 in not the wc or there is >1 change, copy itifnode2:dir2=snapshot_node(repo,modified+added,node2,tmproot)else:# This lets the diff tool open the changed file directlydir2root=repo.rootself.dirs=(dir1,dir2,dir2root,tmproot)forminmodified:model.append(['M',hglib.toutf(m)])forainadded:model.append(['A',hglib.toutf(a)])forrinremoved:model.append(['R',hglib.toutf(r)])iflen(model)==1andself.singlecheck.get_active():self.launch(*model[0])defdelete_tmproot(self,_,tmproot):vsettings=settings.Settings('visdiff')vsettings.set_value('launchsingle',self.singlecheck.get_active())vsettings.write()shutil.rmtree(tmproot)defrowactivated(self,tree,path,column):selection=tree.get_selection()ifselection.count_selected_rows()!=1:returnFalsemodel,paths=selection.get_selected_rows()self.launch(*model[paths[0]])deflaunch(self,st,fname):fname=hglib.fromutf(fname)dir1,dir2,dir2root,tmproot=self.dirsifst=='A':dir1=os.devnulldir2=os.path.join(dir2root,dir2,util.localpath(fname))elifst=='R':dir1=os.path.join(dir1,util.localpath(fname))dir2=os.devnullelse:dir1=os.path.join(dir1,util.localpath(fname))dir2=os.path.join(dir2root,dir2,util.localpath(fname))ifos.name=='nt':cmdline=('%s%s%s%s'%(util.shellquote(self.diffpath),' '.join(self.diffopts),util.shellquote(dir1),util.shellquote(dir2)))else:cmdline=[self.diffpath]+self.diffopts+[dir1,dir2]try:subprocess.Popen(cmdline,shell=False,cwd=tmproot,creationflags=openflags, stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE)
- except Exception, e:
+ except (OSError, EnvironmentError), e:
gdialog.Prompt(_('Tool launch failure'),
_('%s : %s') % (self.diffpath, str(e)), None).run()
defreadtools(ui):tools={}forcmd,pathinui.configitems('extdiff'):ifcmd.startswith('cmd.'):cmd=cmd[4:]ifnotpath:path=cmddiffopts=ui.config('extdiff','opts.'+cmd,'')diffopts=diffoptsand[diffopts]or[]tools[cmd]=[path,diffopts]elifcmd.startswith('opts.'):continueelse:# command = path optsifpath:diffopts=shlex.split(path)path=diffopts.pop(0)else:path,diffopts=cmd,[]tools[cmd]=[path,diffopts]returntoolsdefrun(ui,*pats,**opts):root=paths.find_root()canonpats=[]forfinpats:canonpats.append(util.canonpath(root,os.getcwd(),f))returnFileSelectionDialog(canonpats,opts)
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.