Package PyFoam :: Package Basics :: Module HgInterface
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Basics.HgInterface

 1  #  ICE Revision: $Id: /local/openfoam/Python/PyFoam/PyFoam/Basics/HgInterface.py 7224 2011-02-14T21:24:21.439959Z bgschaid  $  
 2  """A VCS-interface to Mercurial""" 
 3   
 4  from PyFoam.Error import warning,error 
 5   
 6  from GeneralVCSInterface import GeneralVCSInterface 
 7   
 8  from os import uname 
 9  from os import path as opath 
10  from mercurial import commands,ui,hg 
11   
12 -class HgInterface(GeneralVCSInterface):
13 """The interface class to mercurial""" 14
15 - def __init__(self, 16 path, 17 init=False):
18 19 GeneralVCSInterface.__init__(self,path,init) 20 self.ui=ui.ui() 21 if init: 22 commands.init(self.ui,path) 23 open(opath.join(path,".hgignore"),"w").write("syntax: re\n\n") 24 25 self.repo=hg.repository(self.ui,path) 26 27 if init: 28 self.addPath(opath.join(self.repo.root,".hgignore")) 29 self.addStandardIgnores()
30
31 - def addPath(self, 32 path, 33 rules=[]):
34 include=[] 35 exclude=[] 36 if rules!=[]: 37 for inclQ,patt in rules: 38 if inclQ: 39 include.append("re:"+patt) 40 else: 41 exclude.append("re:"+patt) 42 43 commands.add(self.ui, 44 self.repo, 45 path, 46 include=include, 47 exclude=exclude)
48
49 - def clone(self, 50 dest):
51 commands.clone(self.ui, 52 self.repo, 53 dest)
54
55 - def commit(self, 56 msg):
57 commands.commit(self.ui, 58 self.repo, 59 message=msg)
60
61 - def addGlobToIgnore(self,expr):
62 self.addToHgIgnore("glob:"+expr)
63
64 - def addRegexpToIgnore(self,expr):
65 self.addToHgIgnore("re:"+expr)
66
67 - def addToHgIgnore(self,expr):
68 open(opath.join(self.repo.root,".hgignore"),"a").write(expr+"\n")
69