replace various uses of list.reverse()
authorMatt Mackall <mpm@selenic.com>
Sun, 26 Apr 2009 16:50:44 -0500
changeset 8210 344751cd8cb8
parent 8209 a1a5a57efe90
child 8211 5b4ff21c74e4
replace various uses of list.reverse()
hgext/convert/subversion.py
hgext/gpg.py
hgext/graphlog.py
hgext/rebase.py
mercurial/cmdutil.py
mercurial/commands.py
mercurial/localrepo.py
mercurial/sshrepo.py
mercurial/store.py
--- a/hgext/convert/subversion.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/convert/subversion.py	Sun Apr 26 16:50:44 2009 -0500
@@ -437,9 +437,8 @@
                 origpaths, revnum, author, date, message = entry
                 copies = [(e.copyfrom_path, e.copyfrom_rev, p) for p, e
                           in origpaths.iteritems() if e.copyfrom_path]
-                copies.sort()
                 # Apply moves/copies from more specific to general
-                copies.reverse()
+                copies.sort(reverse=True)
 
                 srctagspath = tagspath
                 if copies and copies[-1][2] == tagspath:
--- a/hgext/gpg.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/gpg.py	Sun Apr 26 16:50:44 2009 -0500
@@ -90,11 +90,9 @@
             yield (l.split(" ", 2), (context, ln))
             ln +=1
 
+    # read the heads
     fl = repo.file(".hgsigs")
-    h = fl.heads()
-    h.reverse()
-    # read the heads
-    for r in h:
+    for r in reversed(fl.heads()):
         fn = ".hgsigs|%s" % hgnode.short(r)
         for item in parsefile(fl.read(r).splitlines(), fn):
             yield item
@@ -154,9 +152,7 @@
             continue
         revs.setdefault(r, [])
         revs[r].extend(keys)
-    nodes = list(revs)
-    nodes.reverse()
-    for rev in nodes:
+    for rev in reversed(revs):
         for k in revs[rev]:
             r = "%5d:%s" % (rev, hgnode.hex(repo.changelog.node(rev)))
             ui.write("%-30s %s\n" % (keystr(ui, k), r))
--- a/hgext/graphlog.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/graphlog.py	Sun Apr 26 16:50:44 2009 -0500
@@ -285,11 +285,10 @@
     ascii(ui, grapher(graphdag))
 
 def graphrevs(repo, nodes, opts):
-    nodes.reverse()
     include = set(nodes)
     limit = cmdutil.loglimit(opts)
     count = 0
-    for node in nodes:
+    for node in reversed(nodes):
         if count >= limit:
             break
         ctx = repo[node]
--- a/hgext/rebase.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/rebase.py	Sun Apr 26 16:50:44 2009 -0500
@@ -286,10 +286,7 @@
         repo.mq.finish(repo, mqrebase.keys())
 
         # We must start import from the newest revision
-        mq = mqrebase.keys()
-        mq.sort()
-        mq.reverse()
-        for rev in mq:
+        for rev in sorted(mqrebase, reverse=True):
             if rev not in skipped:
                 repo.ui.debug(_('import mq patch %d (%s)\n')
                               % (state[rev], mqrebase[rev][0]))
--- a/mercurial/cmdutil.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/cmdutil.py	Sun Apr 26 16:50:44 2009 -0500
@@ -1052,8 +1052,7 @@
                     n = filelog.node(j)
                     revs.append((filelog.linkrev(j),
                                  follow and filelog.renamed(n)))
-                revs.reverse()
-                for rev in revs:
+                for rev in reversed(revs):
                     # only yield rev for which we have the changelog, it can
                     # happen while doing "hg log" during a pull or commit
                     if rev[0] < cl_count:
--- a/mercurial/commands.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/commands.py	Sun Apr 26 16:50:44 2009 -0500
@@ -447,8 +447,8 @@
     activebranches = [encoding.tolocal(repo[n].branch())
                             for n in repo.heads(closed=False)]
     branches = sorted([(tag in activebranches, repo.changelog.rev(node), tag)
-                          for tag, node in repo.branchtags().items()])
-    branches.reverse()
+                          for tag, node in repo.branchtags().items()],
+                      reverse=True)
 
     for isactive, node, tag in branches:
         if (not active) or isactive:
@@ -2870,12 +2870,10 @@
     switch is used, a third column "local" is printed for local tags.
     """
 
-    l = repo.tagslist()
-    l.reverse()
     hexfunc = ui.debugflag and hex or short
     tagtype = ""
 
-    for t, n in l:
+    for t, n in reversed(repo.tagslist()):
         if ui.quiet:
             ui.write("%s\n" % t)
             continue
--- a/mercurial/localrepo.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/localrepo.py	Sun Apr 26 16:50:44 2009 -0500
@@ -331,11 +331,9 @@
         return self._tagstypecache.get(tagname)
 
     def _hgtagsnodes(self):
-        heads = self.heads()
-        heads.reverse()
         last = {}
         ret = []
-        for node in heads:
+        for node in reversed(self.heads()):
             c = self[node]
             rev = c.rev()
             try:
--- a/mercurial/sshrepo.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/sshrepo.py	Sun Apr 26 16:50:44 2009 -0500
@@ -81,8 +81,7 @@
             self.abort(error.RepoError(_("no suitable response from remote hg")))
 
         self.capabilities = set()
-        lines.reverse()
-        for l in lines:
+        for l in reversed(lines):
             if l.startswith("capabilities:"):
                 self.capabilities.update(l[:-1].split(":")[1].split())
                 break
--- a/mercurial/store.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/store.py	Sun Apr 26 16:50:44 2009 -0500
@@ -183,9 +183,7 @@
         for x in self.datafiles():
             yield x
         # yield manifest before changelog
-        meta = self._walk('', False)
-        meta.reverse()
-        for x in meta:
+        for x in reversed(self._walk('', False)):
             yield x
 
     def copylist(self):