hgweb: fix errors and warnings found by pychecker
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Sun, 04 Jun 2006 12:19:51 +0200
changeset 2394 a8f1049d1d2d
parent 2393 5083cba2a777
child 2395 8ed45fb1053a
child 2396 8d44649df03b
hgweb: fix errors and warnings found by pychecker - fix missing import - use type_ instead of type - remove unused variable
mercurial/hgweb/hgweb_mod.py
mercurial/hgweb/request.py
--- a/mercurial/hgweb/hgweb_mod.py	Sun Jun 04 02:25:27 2006 +0200
+++ b/mercurial/hgweb/hgweb_mod.py	Sun Jun 04 12:19:51 2006 +0200
@@ -591,7 +591,6 @@
         count = cl.count()
         start = max(0, count - self.maxchanges)
         end = min(count, start + self.maxchanges)
-        pos = end - 1
 
         yield self.t("summary",
                  desc = self.repo.ui.config("web", "description", "unknown"),
@@ -629,10 +628,10 @@
         'zip': ('application/zip', 'zip', '.zip', None),
         }
 
-    def archive(self, req, cnode, type):
+    def archive(self, req, cnode, type_):
         reponame = re.sub(r"\W+", "-", os.path.basename(self.reponame))
         name = "%s-%s" % (reponame, short(cnode))
-        mimetype, artype, extension, encoding = self.archive_specs[type]
+        mimetype, artype, extension, encoding = self.archive_specs[type_]
         headers = [('Content-type', mimetype),
                    ('Content-disposition', 'attachment; filename=%s%s' %
                     (name, extension))]
@@ -649,7 +648,7 @@
         def clean(path):
             p = util.normpath(path)
             if p[:2] == "..":
-                raise "suspicious path"
+                raise Exception("suspicious path")
             return p
 
         def header(**map):
@@ -804,11 +803,11 @@
 
         elif cmd == 'archive':
             changeset = self.repo.lookup(req.form['node'][0])
-            type = req.form['type'][0]
+            type_ = req.form['type'][0]
             allowed = self.repo.ui.config("web", "allow_archive", "").split()
-            if (type in self.archives and (type in allowed or
-                self.repo.ui.configbool("web", "allow" + type, False))):
-                self.archive(req, changeset, type)
+            if (type_ in self.archives and (type_ in allowed or
+                self.repo.ui.configbool("web", "allow" + type_, False))):
+                self.archive(req, changeset, type_)
                 return
 
             req.write(self.t("error"))
--- a/mercurial/hgweb/request.py	Sun Jun 04 02:25:27 2006 +0200
+++ b/mercurial/hgweb/request.py	Sun Jun 04 12:19:51 2006 +0200
@@ -7,7 +7,7 @@
 # of the GNU General Public License, incorporated herein by reference.
 
 from mercurial.demandload import demandload
-demandload(globals(), "socket sys cgi os")
+demandload(globals(), "socket sys cgi os errno")
 from mercurial.i18n import gettext as _
 
 class hgrequest(object):