Reduce use of kwrepo methods kwmap-templates
authorChristian Ebert <blacktrash@gmx.net>
Wed, 27 Jun 2007 13:50:06 +0200
branchkwmap-templates
changeset 168 368fbd5b054c
parent 167 b0a5c3535727
child 169 6df702b4601e
Reduce use of kwrepo methods Use repo and ui arguments from reposetup where possible. kwfmatcher doesn't need to be an attribute to repo.
hgkw/keyword.py
--- a/hgkw/keyword.py	Wed Jun 27 13:33:57 2007 +0200
+++ b/hgkw/keyword.py	Wed Jun 27 13:50:06 2007 +0200
@@ -228,18 +228,18 @@
     if not inc:
         return
 
-    repo.kwfmatcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
+    kwfmatcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
 
     class kwrepo(repo.__class__):
         def file(self, f):
             if f[0] == '/':
                 f = f[1:]
             # only use kwfilelog when needed
-            if self.kwfmatcher(f):
-                kwt = kwtemplater(self.ui, self, path=f)
-                return kwfilelog(self.sopener, f, kwt)
+            if kwfmatcher(f):
+                kwt = kwtemplater(repo.ui, repo, path=f)
+                return kwfilelog(repo.sopener, f, kwt)
             else:
-                return filelog.filelog(self.sopener, f)
+                return filelog.filelog(repo.sopener, f)
 
         def commit(self, files=None, text="", user=None, date=None,
                    match=util.always, force=False, lock=None, wlock=None,
@@ -248,10 +248,11 @@
             configured files in working directory.'''
             wrelease = False
             if not wlock:
-                wlock = self.wlock()
+                wlock = repo.wlock()
                 wrelease = True
             try:
-                removed = self.status()[2]
+                removed = repo.status(node1=p1, node2=p2, files=files,
+                                      match=match, wlock=wlock)[2]
 
                 node = super(kwrepo,
                              self).commit(files=files, text=text, user=user,
@@ -262,14 +263,14 @@
                 if node is None:
                     return node
 
-                candidates = self.changelog.read(node)[3]
-                candidates = [f for f in candidates if self.kwfmatcher(f)
+                candidates = repo.changelog.read(node)[3]
+                candidates = [f for f in candidates if kwfmatcher(f)
                               and f not in removed
                               and not os.path.islink(self.wjoin(f))]
                 if not candidates:
                     return node
 
-                kwt = kwtemplater(self.ui, self, node=node)
+                kwt = kwtemplater(repo.ui, repo, node=node)
                 kwt.overwrite(candidates)
                 return node
             finally: