1
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 from mercurial.node import short
12
14 """The interface class to mercurial"""
15
16 - def __init__(self,
17 path,
18 init=False):
32
35
36 - def addPath(self,
37 path,
38 rules=[]):
39 try:
40 if not opath.exists(path):
41 error("Path",path,"does not exist")
42 except TypeError:
43 error(path,"is not a path name")
44
45 include=[]
46 exclude=[]
47 if rules!=[]:
48 for inclQ,patt in rules:
49 if inclQ:
50 include.append("re:"+patt)
51 else:
52 exclude.append("re:"+patt)
53
54 commands.add(self.ui,
55 self.repo,
56 path,
57 include=include,
58 exclude=exclude)
59
60 - def clone(self,
61 dest):
62 commands.clone(self.ui,
63 self.repo,
64 dest)
65
67 return self.repo.dirstate.branch()
68
70 ctx = self.repo[None]
71 parents = ctx.parents()
72 return '+'.join([short(p.node()) for p in parents])
73
79
80 - def update(self,
81 timeout=None):
82 ok=True
83 if timeout:
84 self.ui.setconfig("ui","timeout",timeout);
85
86 try:
87 if commands.pull(self.ui,
88 self.repo):
89 ok=False
90 if commands.update(self.ui,
91 self.repo):
92 ok=False
93 except IndexError,e:
94
95 raise e
96 return False
97
98 return ok
99
102
105
107 open(opath.join(self.repo.root,".hgignore"),"a").write(expr+"\n")
108