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.
"""hglib.py Copyright (C) 2007 Steve Borho <steve@borho.org>This software may be used and distributed according to the termsof the GNU General Public License, incorporated herein by reference.
"""
-import gtkimport os
import sys
import traceback
-import Queueimport shlib
from mercurial import hg, ui, util, extensions, commands, hook
fromi18nimport_importpathstry:frommercurial.errorimportRepoError,ParseError,LookupErrorfrommercurial.errorimportUnknownCommand,AmbiguousCommandexceptImportError:frommercurial.cmdutilimportUnknownCommand,AmbiguousCommandfrommercurial.repoimportRepoErrorfrommercurial.dispatchimportParseErrorfrommercurial.revlogimportLookupErrorfrommercurialimportdispatchtry:frommercurialimportencoding_encoding=encoding.encoding_encodingmode=encoding.encodingmode_fallbackencoding=encoding.fallbackencodingexceptImportError:_encoding=util._encoding_encodingmode=util._encodingmode_fallbackencoding=util._fallbackencodingtry:# post 1.1.2frommercurialimportutilhgversion=util.version()exceptAttributeError:# <= 1.1.2frommercurialimportversionhgversion=version.get_version()deftoutf(s):""" Convert a string to UTF-8 encoding Based on mercurial.util.tolocal() """forein('utf-8',_encoding):try:returns.decode(e,'strict').encode('utf-8')exceptUnicodeDecodeError:passreturns.decode(_fallbackencoding,'replace').encode('utf-8')deffromutf(s):""" Convert UTF-8 encoded string to local. It's primarily used on strings converted to UTF-8 by toutf(). """try:returns.decode('utf-8').encode(_encoding)exceptUnicodeDecodeError:passexceptUnicodeEncodeError:passreturns.decode('utf-8').encode(_fallbackencoding)_tabwidth=Nonedefgettabwidth(ui):global_tabwidthtabwidth=ui.config('tortoisehg','tabwidth')try:tabwidth=int(tabwidth)iftabwidth<1ortabwidth>16:tabwidth=0except(ValueError,TypeError):tabwidth=0_tabwidth=tabwidthreturntabwidthdefdiffexpand(line):'Expand tabs in a line of diff/patch text'if_tabwidthisNone:gettabwidth(ui.ui())ifnot_tabwidthorlen(line)<2:returnlinereturnline[0]+line[1:].expandtabs(_tabwidth)defuiwrite(u,args):''' write args if there are buffers returns True if the caller shall handle writing '''buffers=getattr(u,'_buffers',None)ifbuffers==None:buffers=u.buffersifbuffers:ui.ui.write(u,*args)returnFalsereturnTruedefcalliffunc(f):returnhasattr(f,'__call__')andf()orfdefinvalidaterepo(repo):repo.invalidate()repo.dirstate.invalidate()ifhasattr(repo,'mq'):mq=repo.mqmqclass=mq.__class__repo.mq=mqclass(mq.ui,mq.basepath,mq.path)defhgcmd_toq(path,q,*args):''' Run an hg command in a background thread, pipe all output to a Queue object. Assumes command is completely noninteractive. '''classQui(ui.ui):def__init__(self,src=None):super(Qui,self).__init__(src)self.setconfig('ui','interactive','off')defwrite(self,*args):ifuiwrite(self,args):forainargs:q.put(str(a))u=Qui()ifhasattr(ui.ui,'copy'):# Mercurial 1.3returndispatch._dispatch(u,list(args))else:returnthgdispatch(u,path,list(args))defdisplaytime(date):returnutil.datestr(date,'%Y-%m-%d %H:%M:%S %1%2')# the remaining functions are only needed for Mercurial versions < 1.3def_earlygetopt(aliases,args):"""Return list of values for an option (or aliases). The values are listed in the order they appear in args. The options and values are removed from args. """try:argcount=args.index("--")exceptValueError:argcount=len(args)shortopts=[optforoptinaliasesiflen(opt)==2]values=[]pos=0whilepos<argcount:ifargs[pos]inaliases:ifpos+1>=argcount:# ignore and let getopt report an error if there is no valuebreakdelargs[pos]values.append(args.pop(pos))argcount-=2elifargs[pos][:2]inshortopts:# short option can have no following space, e.g. hg log -Rfoovalues.append(args.pop(pos)[2:])argcount-=1else:pos+=1returnvalues_loaded={}defthgdispatch(ui,path=None,args=[],nodefaults=True):''' Replicate functionality of mercurial dispatch but force the use of the passed in ui for all purposes '''# clear all user-defined command defaultsifnodefaults:fork,vinui.configitems('defaults'):ui.setconfig('defaults',k,'')# read --config before doing anything else# (e.g. to change trust settings for reading .hg/hgrc)config=_earlygetopt(['--config'],args)ifconfig:forsection,name,valueindispatch._parseconfig(config):ui.setconfig(section,name,value)# check for cwdcwd=_earlygetopt(['--cwd'],args)ifcwd:os.chdir(cwd[-1])# read the local repository .hgrc into a local ui objectpath=paths.find_root(path)or""ifpath:try:ui.readconfig(os.path.join(path,".hg","hgrc"))exceptIOError:pass# now we can expand paths, even ones in .hg/hgrcrpath=_earlygetopt(["-R","--repository","--repo"],args)ifrpath:path=ui.expandpath(rpath[-1])extensions.loadall(ui)ifnothasattr(extensions,'extensions'):extensions.extensions=lambda:()# pre-0.9.5, loadall did belowforname,moduleinextensions.extensions():ifnamein_loaded:continue# setup extensionsextsetup=getattr(module,'extsetup',None)ifextsetup:extsetup()cmdtable=getattr(module,'cmdtable',{})overrides=[cmdforcmdincmdtableifcmdincommands.table]ifoverrides:ui.warn(_("extension '%s' overrides commands: %s\n")%(name," ".join(overrides)))commands.table.update(cmdtable)_loaded[name]=1# check for fallback encodingfallback=ui.config('ui','fallbackencoding')iffallback:_fallbackencoding=fallbackfullargs=argscmd,func,args,options,cmdoptions=dispatch._parse(ui,args)ifoptions["encoding"]:_encoding=options["encoding"]ifoptions["encodingmode"]:_encodingmode=options["encodingmode"]ifoptions['verbose']oroptions['debug']oroptions['quiet']:ui.setconfig('ui','verbose',str(bool(options['verbose'])))ui.setconfig('ui','debug',str(bool(options['debug'])))ui.setconfig('ui','quiet',str(bool(options['quiet'])))ifoptions['traceback']:ui.setconfig('ui','traceback','on')ifoptions['noninteractive']:ui.setconfig('ui','interactive','off')ifoptions['help']:returncommands.help_(ui,cmd,options['version'])elifoptions['version']:returncommands.version_(ui)elifnotcmd:returncommands.help_(ui,'shortlist')repo=Noneifcmdnotincommands.norepo.split():try:repo=hg.repository(ui,path=path)repo.ui=uiui.setconfig("bundle","mainreporoot",repo.root)ifnotrepo.local():raiseutil.Abort(_("repository '%s' is not local")%path)exceptRepoError:ifcmdnotincommands.optionalrepo.split():ifnotpath:raiseRepoError(_('There is no Mercurial repository here'' (.hg not found)'))raised=lambda:func(ui,repo,*args,**cmdoptions)else:d=lambda:func(ui,*args,**cmdoptions)# run pre-hook, and abort if it failsret=hook.hook(ui,repo,"pre-%s"%cmd,False,args=" ".join(fullargs))ifret:returnret# Run actual commandtry:ret=d()exceptTypeError:# was this an argument error?tb=traceback.extract_tb(sys.exc_info()[2])iflen(tb)!=2:# noraiseraiseParseError(cmd,_('invalid arguments'))# run post-hook, passing command resulthook.hook(ui,repo,"post-%s"%cmd,False,args=" ".join(fullargs),result=ret)ifrepo:shlib.update_thgstatus(repo.ui,repo.root,wait=True)returnret
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.