changeset 1560:2cf2fb2e2d15 default tip

merged crew or orig repo
author twaldmann@thinkmo.de
date Sat, 26 Nov 2005 12:54:48 +0100
parents 98398a6ddd75 (diff) 68ec7b9e09a4 (current diff)
children
files mercurial/commands.py mercurial/hgweb.py mercurial/localrepo.py
diffstat 8 files changed, 106 insertions(+), 102 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changelog.py	Thu Nov 17 19:38:57 2005 +0100
+++ b/mercurial/changelog.py	Sat Nov 26 12:54:48 2005 +0100
@@ -23,14 +23,14 @@
         manifest = bin(l[0])
         user = l[1]
         date = l[2].split(' ')
-        time = float(date.pop(0))
+        time_ = float(date.pop(0))
         try:
             # various tools did silly things with the time zone field.
             timezone = int(date[0])
         except:
             timezone = 0
         files = l[3:]
-        return (manifest, user, (time, timezone), files, desc)
+        return (manifest, user, (time_, timezone), files, desc)
 
     def read(self, node):
         return self.extract(self.revision(node))
--- a/mercurial/commands.py	Thu Nov 17 19:38:57 2005 +0100
+++ b/mercurial/commands.py	Sat Nov 26 12:54:48 2005 +0100
@@ -13,6 +13,8 @@
 demandload(globals(), "fnmatch hgweb mdiff random signal time traceback")
 demandload(globals(), "errno socket version struct atexit sets bz2")
 
+# XXX TODO: commands.py:(misc lines): Local variable (ui) shadows global defined on line (12)
+
 class UnknownCommand(Exception):
     """Exception raised if command is not in the command table."""
 class AmbiguousCommand(Exception):
@@ -115,8 +117,8 @@
                     yield rev
 
         minrev, maxrev = min(revs), max(revs)
-        for file in files:
-            filelog = repo.file(file)
+        for file_ in files:
+            filelog = repo.file(file_)
             # A zero count may be a directory or deleted file, so
             # try to find matching entries on the slow path.
             if filelog.count() == 0:
@@ -127,7 +129,7 @@
                     if rev < minrev:
                         break
                     fncache.setdefault(rev, [])
-                    fncache[rev].append(file)
+                    fncache[rev].append(file_)
                     wanted[rev] = 1
     if slowpath:
         # The slow path checks files modified in every changeset.
@@ -488,13 +490,13 @@
     """
 
     names = []
-    for src, abs, rel, exact in walk(repo, pats, opts):
+    for src, abs_, rel, exact in walk(repo, pats, opts):
         if exact:
             if ui.verbose: ui.status(_('adding %s\n') % rel)
-            names.append(abs)
-        elif repo.dirstate.state(abs) == '?':
+            names.append(abs_)
+        elif repo.dirstate.state(abs_) == '?':
             ui.status(_('adding %s\n') % rel)
-            names.append(abs)
+            names.append(abs_)
     repo.add(names)
 
 def addremove(ui, repo, *pats, **opts):
@@ -506,13 +508,13 @@
     with add, these changes take effect at the next commit.
     """
     add, remove = [], []
-    for src, abs, rel, exact in walk(repo, pats, opts):
-        if src == 'f' and repo.dirstate.state(abs) == '?':
-            add.append(abs)
+    for src, abs_, rel, exact in walk(repo, pats, opts):
+        if src == 'f' and repo.dirstate.state(abs_) == '?':
+            add.append(abs_)
             if ui.verbose or not exact:
                 ui.status(_('adding %s\n') % rel)
-        if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel):
-            remove.append(abs)
+        if repo.dirstate.state(abs_) != 'r' and not os.path.exists(rel):
+            remove.append(abs_)
             if ui.verbose or not exact:
                 ui.status(_('removing %s\n') % rel)
     repo.add(add)
@@ -561,17 +563,17 @@
     change = repo.changelog.read(node)
     mmap = repo.manifest.read(change[0])
 
-    for src, abs, rel, exact in walk(repo, pats, opts):
-        if abs not in mmap:
+    for src, abs_, rel, exact in walk(repo, pats, opts):
+        if abs_ not in mmap:
             ui.warn(_("warning: %s is not in the repository!\n") % rel)
             continue
 
-        f = repo.file(abs)
-        if not opts['text'] and util.binary(f.read(mmap[abs])):
+        f = repo.file(abs_)
+        if not opts['text'] and util.binary(f.read(mmap[abs_])):
             ui.write(_("%s: binary file\n") % rel)
             continue
 
-        lines = f.annotate(mmap[abs])
+        lines = f.annotate(mmap[abs_])
         pieces = []
 
         for o, f in opmap:
@@ -638,11 +640,11 @@
     if rev:
         change = repo.changelog.read(repo.lookup(rev))
         mf = repo.manifest.read(change[0])
-    for src, abs, rel, exact in walk(repo, (file1,) + pats, opts):
-        r = repo.file(abs)
+    for src, abs_, rel, exact in walk(repo, (file1,) + pats, opts):
+        r = repo.file(abs_)
         if rev:
             try:
-                n = mf[abs]
+                n = mf[abs_]
             except (hg.RepoError, KeyError):
                 try:
                     n = r.lookup(rev)
@@ -650,7 +652,7 @@
                     raise util.Abort(_('cannot find file %s in rev %s'), rel, rev)
         else:
             n = r.tip()
-        fp = make_file(repo, r, opts['output'], node=n, pathname=abs)
+        fp = make_file(repo, r, opts['output'], node=n, pathname=abs_)
         fp.write(r.read(n))
 
 def clone(ui, source, dest=None, **opts):
@@ -804,10 +806,10 @@
     copied = []
     targets = {}
 
-    def okaytocopy(abs, rel, exact):
+    def okaytocopy(abs_, rel, exact):
         reasons = {'?': _('is not managed'),
                    'a': _('has been marked for add')}
-        reason = reasons.get(repo.dirstate.state(abs))
+        reason = reasons.get(repo.dirstate.state(abs_))
         if reason:
             if exact: ui.warn(_('%s: not copying - file %s\n') % (rel, reason))
         else:
@@ -1008,16 +1010,16 @@
             ui.write("\t%d -> %d\n" % (r.rev(e[5]), i))
     ui.write("}\n")
 
-def debugrename(ui, repo, file, rev=None):
+def debugrename(ui, repo, file_, rev=None):
     """dump rename information"""
-    r = repo.file(relpath(repo, [file])[0])
+    r = repo.file(relpath(repo, [file_])[0])
     if rev:
         try:
             # assume all revision numbers are for changesets
             n = repo.lookup(rev)
             change = repo.changelog.read(n)
             m = repo.manifest.read(change[0])
-            n = m[relpath(repo, [file])[0]]
+            n = m[relpath(repo, [file_])[0]]
         except (hg.RepoError, KeyError):
             n = r.lookup(rev)
     else:
@@ -1034,10 +1036,10 @@
     if not items:
         return
     fmt = '%%s  %%-%ds  %%-%ds  %%s' % (
-        max([len(abs) for (src, abs, rel, exact) in items]),
-        max([len(rel) for (src, abs, rel, exact) in items]))
-    for src, abs, rel, exact in items:
-        line = fmt % (src, abs, rel, exact and 'exact' or '')
+        max([len(abs_) for (src, abs_, rel, exact) in items]),
+        max([len(rel) for (src, abs_, rel, exact) in items]))
+    for src, abs_, rel, exact in items:
+        line = fmt % (src, abs_, rel, exact and 'exact' or '')
         ui.write("%s\n" % line.rstrip())
 
 def diff(ui, repo, *pats, **opts):
@@ -1137,9 +1139,9 @@
     Undo an 'hg add' scheduled for the next commit.
     """
     forget = []
-    for src, abs, rel, exact in walk(repo, pats, opts):
-        if repo.dirstate.state(abs) == 'a':
-            forget.append(abs)
+    for src, abs_, rel, exact in walk(repo, pats, opts):
+        if repo.dirstate.state(abs_) == 'a':
+            forget.append(abs_)
             if ui.verbose or not exact:
                 ui.status(_('forgetting %s\n') % rel)
     repo.forget(forget)
@@ -1461,11 +1463,11 @@
     """
     end = opts['print0'] and '\0' or '\n'
 
-    for src, abs, rel, exact in walk(repo, pats, opts, '(?:.*/|)'):
-        if repo.dirstate.state(abs) == '?':
+    for src, abs_, rel, exact in walk(repo, pats, opts, '(?:.*/|)'):
+        if repo.dirstate.state(abs_) == '?':
             continue
         if opts['fullpath']:
-            ui.write(os.path.join(repo.root, abs), end)
+            ui.write(os.path.join(repo.root, abs_), end)
         else:
             ui.write(rel, end)
 
@@ -1762,8 +1764,8 @@
     directory, they will be deleted from it.
     """
     names = []
-    def okaytoremove(abs, rel, exact):
-        c, a, d, u = repo.changes(files = [abs])
+    def okaytoremove(abs_, rel, exact):
+        c, a, d, u = repo.changes(files = [abs_])
         reason = None
         if c: reason = _('is modified')
         elif a: reason = _('has been marked for add')
@@ -1772,10 +1774,10 @@
             if exact: ui.warn(_('not removing %s: file %s\n') % (rel, reason))
         else:
             return True
-    for src, abs, rel, exact in walk(repo, (pat,) + pats, opts):
-        if okaytoremove(abs, rel, exact):
+    for src, abs_, rel, exact in walk(repo, (pat,) + pats, opts):
+        if okaytoremove(abs_, rel, exact):
             if ui.verbose or not exact: ui.status(_('removing %s\n') % rel)
-            names.append(abs)
+            names.append(abs_)
     repo.remove(names, unlink=True)
 
 def rename(ui, repo, *pats, **opts):
@@ -1797,9 +1799,9 @@
     """
     errs, copied = docopy(ui, repo, pats, opts)
     names = []
-    for abs, rel, exact in copied:
+    for abs_, rel, exact in copied:
         if ui.verbose or not exact: ui.status(_('removing %s\n') % rel)
-        names.append(abs)
+        names.append(abs_)
     repo.remove(names, unlink=True)
     return errs
 
@@ -1862,7 +1864,7 @@
             fout.write(v)
             fout.flush()
 
-        lock = None
+        lock_ = None
 
         while 1:
             cmd = fin.readline()[:-1]
@@ -1872,12 +1874,12 @@
                 h = repo.heads()
                 respond(" ".join(map(hex, h)) + "\n")
             if cmd == "lock":
-                lock = repo.lock()
+                lock_ = repo.lock()
                 respond("")
             if cmd == "unlock":
-                if lock:
-                    lock.release()
-                lock = None
+                if lock_:
+                    lock_.release()
+                lock_ = None
                 respond("")
             elif cmd == "branches":
                 arg, nodes = getarg()
@@ -1908,7 +1910,7 @@
                 fout.flush()
 
             elif cmd == "addchangegroup":
-                if not lock:
+                if not lock_:
                     respond("not locked")
                     continue
                 respond("")
--- a/mercurial/dirstate.py	Thu Nov 17 19:38:57 2005 +0100
+++ b/mercurial/dirstate.py	Sat Nov 26 12:54:48 2005 +0100
@@ -158,8 +158,8 @@
         self.markdirty()
         self.copies[dest] = source
 
-    def copied(self, file):
-        return self.copies.get(file, None)
+    def copied(self, file_):
+        return self.copies.get(file_, None)
 
     def update(self, files, state, **kw):
         ''' current states:
@@ -268,11 +268,11 @@
         elif not dc:
             dc = self.filterfiles(files)
 
-        def statmatch(file, stat):
-            file = util.pconvert(file)
-            if file not in dc and self.ignore(file):
+        def statmatch(file_, stat):
+            file_ = util.pconvert(file_)
+            if file_ not in dc and self.ignore(file_):
                 return False
-            return match(file)
+            return match(file_)
 
         return self.walkhelper(files=files, statmatch=statmatch, dc=dc)
 
@@ -371,7 +371,7 @@
 
         for src, fn, st in self.statwalk(files, match):
             try:
-                type, mode, size, time = self[fn]
+                type_, mode, size, time_ = self[fn]
             except KeyError:
                 unknown.append(fn)
                 continue
@@ -390,22 +390,23 @@
                         nonexistent = False
                 # XXX: what to do with file no longer present in the fs
                 # who are not removed in the dirstate ?
-                if nonexistent and type in "nm":
+                if nonexistent and type_ in "nm":
                     deleted.append(fn)
                     continue
             # check the common case first
-            if type == 'n':
+            if type_ == 'n':
                 if not st:
                     st = os.stat(fn)
                 if size != st.st_size or (mode ^ st.st_mode) & 0100:
                     modified.append(fn)
-                elif time != st.st_mtime:
+                elif time_ != st.st_mtime:
                     lookup.append(fn)
-            elif type == 'm':
+            elif type_ == 'm':
                 modified.append(fn)
-            elif type == 'a':
+            elif type_ == 'a':
                 added.append(fn)
-            elif type == 'r':
+            elif type_ == 'r':
                 removed.append(fn)
 
         return (lookup, modified, added, removed + deleted, unknown)
+
--- a/mercurial/fancyopts.py	Thu Nov 17 19:38:57 2005 +0100
+++ b/mercurial/fancyopts.py	Sat Nov 26 12:54:48 2005 +0100
@@ -1,30 +1,30 @@
 import getopt
 
 def fancyopts(args, options, state):
-    long = []
+    long_ = []
     short = ''
-    map = {}
+    map_ = {}
     dt = {}
 
     for s, l, d, c in options:
         pl = l.replace('-', '_')
-        map['-'+s] = map['--'+l] = pl
+        map_['-'+s] = map_['--'+l] = pl
         state[pl] = d
         dt[pl] = type(d)
         if not d is None and not callable(d):
             if s: s += ':'
             if l: l += '='
         if s: short = short + s
-        if l: long.append(l)
+        if l: long_.append(l)
 
-    opts, args = getopt.getopt(args, short, long)
+    opts, args = getopt.getopt(args, short, long_)
 
     for opt, arg in opts:
-        if dt[map[opt]] is type(fancyopts): state[map[opt]](state,map[opt],arg)
-        elif dt[map[opt]] is type(1): state[map[opt]] = int(arg)
-        elif dt[map[opt]] is type(''): state[map[opt]] = arg
-        elif dt[map[opt]] is type([]): state[map[opt]].append(arg)
-        elif dt[map[opt]] is type(None): state[map[opt]] = 1
+        if dt[map_[opt]] is type(fancyopts): state[map_[opt]](state,map_[opt],arg)
+        elif dt[map_[opt]] is type(1): state[map_[opt]] = int(arg)
+        elif dt[map_[opt]] is type(''): state[map_[opt]] = arg
+        elif dt[map_[opt]] is type([]): state[map_[opt]].append(arg)
+        elif dt[map_[opt]] is type(None): state[map_[opt]] = 1
 
     return args
 
--- a/mercurial/hgweb.py	Thu Nov 17 19:38:57 2005 +0100
+++ b/mercurial/hgweb.py	Sat Nov 26 12:54:48 2005 +0100
@@ -95,9 +95,9 @@
             self.out.write("%s: %s\r\n" % header)
         self.out.write("\r\n")
 
-    def httphdr(self, type, file="", size=0):
+    def httphdr(self, type_, file="", size=0):
 
-        headers = [('Content-type', type)]
+        headers = [('Content-type', type_)]
         if file:
             headers.append(('Content-disposition', 'attachment; filename=%s' % file))
         if size > 0:
@@ -658,7 +658,7 @@
                      parent=self.parents(n, cl.parents(n), cl.rev),
                      diff=diff)
 
-    def archive(self, req, cnode, type):
+    def archive(self, req, cnode, type_):
         cs = self.repo.changelog.read(cnode)
         mnode = cs[0]
         mf = self.repo.manifest.read(mnode)
@@ -669,7 +669,7 @@
         files = mf.keys()
         files.sort()
 
-        if type == 'zip':
+        if type_ == 'zip':
             tmp = tempfile.mkstemp()[1]
             try:
                 zf = zipfile.ZipFile(tmp, "w", zipfile.ZIP_DEFLATED)
@@ -687,17 +687,17 @@
                 os.unlink(tmp)
 
         else:
-            tf = tarfile.TarFile.open(mode='w|' + type, fileobj=req.out)
+            tf = tarfile.TarFile.open(mode='w|' + type_, fileobj=req.out)
             mff = self.repo.manifest.readflags(mnode)
             mtime = int(time.time())
 
-            if type == "gz":
+            if type_ == "gz":
                 encoding = "gzip"
             else:
                 encoding = "x-bzip2"
             req.header([('Content-type', 'application/x-tar'),
                     ('Content-disposition', 'attachment; filename=%s%s%s' %
-                        (name[:-1], '.tar.', type)),
+                        (name[:-1], '.tar.', type_)),
                     ('Content-encoding', encoding)])
             for fname in files:
                 rcont = self.repo.file(fname).read(mf[fname])
@@ -853,10 +853,10 @@
 
         elif req.form['cmd'][0] == 'archive':
             changeset = self.repo.lookup(req.form['node'][0])
-            type = req.form['type'][0]
-            if (type in self.archives and
-                self.repo.ui.configbool("web", "allow" + type, False)):
-                self.archive(req, changeset, type)
+            type_ = req.form['type'][0]
+            if (type_ in self.archives and
+                self.repo.ui.configbool("web", "allow" + type_, False)):
+                self.archive(req, changeset, type_)
                 return
 
             req.write(self.t("error"))
--- a/mercurial/localrepo.py	Thu Nov 17 19:38:57 2005 +0100
+++ b/mercurial/localrepo.py	Sat Nov 26 12:54:48 2005 +0100
@@ -222,7 +222,7 @@
                                        self.join("journal"), after)
 
     def recover(self):
-        lock = self.lock()
+        lock_ = self.lock()
         if os.path.exists(self.join("journal")):
             self.ui.status(_("rolling back interrupted transaction\n"))
             transaction.rollback(self.opener, self.join("journal"))
@@ -233,7 +233,7 @@
 
     def undo(self):
         wlock = self.wlock()
-        lock = self.lock()
+        lock_ = self.lock()
         if os.path.exists(self.join("undo")):
             self.ui.status(_("rolling back last transaction\n"))
             transaction.rollback(self.opener, self.join("undo"))
@@ -279,7 +279,7 @@
             update_dirstate = 0
 
         wlock = self.wlock()
-        lock = self.lock()
+        lock_ = self.lock()
         tr = self.transaction()
         mm = m1.copy()
         mfm = mf1.copy()
@@ -369,7 +369,7 @@
             return None
 
         wlock = self.wlock()
-        lock = self.lock()
+        lock_ = self.lock()
         tr = self.transaction()
 
         # check in files
@@ -909,7 +909,7 @@
         return subset
 
     def pull(self, remote, heads = None):
-        lock = self.lock()
+        lock_ = self.lock()
 
         # if we have an empty repo, fetch everything
         if self.changelog.tip() == nullid:
@@ -929,7 +929,7 @@
         return self.addchangegroup(cg)
 
     def push(self, remote, force=False):
-        lock = remote.lock()
+        lock_ = remote.lock()
 
         base = {}
         heads = remote.heads()
--- a/mercurial/manifest.py	Thu Nov 17 19:38:57 2005 +0100
+++ b/mercurial/manifest.py	Sat Nov 26 12:54:48 2005 +0100
@@ -22,16 +22,16 @@
         if self.mapcache and self.mapcache[0] == node:
             return self.mapcache[1]
         text = self.revision(node)
-        map = {}
+        map_ = {}
         flag = {}
         self.listcache = array.array('c', text)
         lines = text.splitlines(1)
         for l in lines:
             (f, n) = l.split('\0')
-            map[f] = bin(n[:40])
+            map_[f] = bin(n[:40])
             flag[f] = (n[40:-1] == "x")
-        self.mapcache = (node, map, flag)
-        return map
+        self.mapcache = (node, map_, flag)
+        return map_
 
     def readflags(self, node):
         if node == nullid: return {} # don't upset local cache
@@ -42,7 +42,7 @@
     def diff(self, a, b):
         return mdiff.textdiff(str(a), str(b))
 
-    def add(self, map, flags, transaction, link, p1=None, p2=None,
+    def add(self, map_, flags, transaction, link, p1=None, p2=None,
             changed=None):
 
         # returns a tuple (start, end).  If the string is found
@@ -105,11 +105,11 @@
         # parented by the same node we're diffing against
         if not changed or not self.listcache or not p1 or \
                self.mapcache[0] != p1:
-            files = map.keys()
+            files = map_.keys()
             files.sort()
 
             text = ["%s\000%s%s\n" %
-                            (f, hex(map[f]), flags[f] and "x" or '')
+                            (f, hex(map_[f]), flags[f] and "x" or '')
                             for f in files]
             self.listcache = array.array('c', "".join(text))
             cachedelta = None
@@ -136,7 +136,7 @@
                 # bs will either be the index of the item or the insert point
                 start, end = manifestsearch(addbuf, f, start)
                 if w[1] == 0:
-                    l = "%s\000%s%s\n" % (f, hex(map[f]),
+                    l = "%s\000%s%s\n" % (f, hex(map_[f]),
                                           flags[f] and "x" or '')
                 else:
                     l = ""
@@ -168,6 +168,6 @@
 
         n = self.addrevision(buffer(self.listcache), transaction, link, p1,  \
                              p2, cachedelta)
-        self.mapcache = (n, map, flags)
+        self.mapcache = (n, map_, flags)
 
         return n
--- a/mercurial/packagescan.py	Thu Nov 17 19:38:57 2005 +0100
+++ b/mercurial/packagescan.py	Sat Nov 26 12:54:48 2005 +0100
@@ -65,10 +65,11 @@
     It does not check on sys.modules or includes the module in the scope.
     """
     loader = ihooks.BasicModuleLoader()
-    path, file = os.path.split(filename)
-    name, ext  = os.path.splitext(file)
+    path, file_ = os.path.split(filename)
+    name, ext  = os.path.splitext(file_)
     m = loader.find_module_in_dir(name, path)
     if not m:
         raise ImportError, name
     m = loader.load_module(name, m)
     return m
+