[pypy-commit] pypy stdlib-unification/py3k: merge from stdlib-unification

RonnyPfannschmidt noreply at buildbot.pypy.org
Sat Apr 14 14:32:22 CEST 2012


Author: Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
Branch: stdlib-unification/py3k
Changeset: r54363:4e795faa4933
Date: 2012-04-14 12:05 +0200
http://bitbucket.org/pypy/pypy/changeset/4e795faa4933/

Log:	merge from stdlib-unification

diff --git a/pypy/tool/clean_old_branches.py b/pypy/tool/clean_old_branches.py
--- a/pypy/tool/clean_old_branches.py
+++ b/pypy/tool/clean_old_branches.py
@@ -4,30 +4,28 @@
 called 'closed-branch'.  It reduces the number of heads.
 """
 
-import os, sys
+import os
+import sys
+import commands
 
-if not os.listdir('.hg'):
+if not os.path.isdir('.hg'):
     print 'Must run this script from the top-level directory.'
     sys.exit(1)
 
-def heads(args):
-    g = os.popen(r"hg heads --topo %s --template '{node|short}:{branches}\n'"
-                 % args, 'r')
-    result = g.read()
-    g.close()
+def heads():
+    result = commands.getoutput(
+        "hg heads --topo --closed --template '{node|short}:{branches}:{extras}\n'")
     result = result.splitlines(False)
+    result = [s.split(':', 2) for s in result]
     for line in result:
-        if len(line.split(':', 1)) != 2:
+        if len(line) != 3:
             raise ValueError("'result' contains: %r" % line)
-    result = [s.split(':', 1) for s in result]
-    result = [(head, branch) for (head, branch) in result
-                if branch not in ['', 'closed-branches']]
+    result = [(head, branch) for (head, branch, extra) in result
+                if branch not in ['', 'closed-branches'] and 'close' in extra]
     return result
 
-all_heads = heads("--closed")
-opened_heads = heads("")
 
-closed_heads = [s for s in all_heads if s not in opened_heads]
+closed_heads = heads()
 
 if not closed_heads:
     print >> sys.stderr, 'no dangling closed heads.'
@@ -56,16 +54,14 @@
         print '*** error %r' % (err,)
         sys.exit(1)
 
+print '*** switching to closed branches *** '
+do("hg up --clean closed-branches")
+do("hg --config extensions.purge= purge --all")
+
 for head, branch in closed_heads:
     print
     print '***** %s ***** %s *****' % (branch, head)
-    do("hg up --clean closed-branches")
-    do("hg --config extensions.purge= purge --all")
-    do("hg merge -y %s" % head)
-    for fn in os.listdir('.'):
-        if fn.lower() != '.hg':
-            do("rm -fr -- '%s'" % fn)
-            do("hg rm --after -- '%s' || true" % fn)
+    do("hg debugsetparents closed-branches %s" % head)
     do("hg ci -m'Merge closed head %s on branch %s'" % (head, branch))
 
 print
diff --git a/pypy/tool/test/test_udir.py b/pypy/tool/test/test_udir.py
--- a/pypy/tool/test/test_udir.py
+++ b/pypy/tool/test/test_udir.py
@@ -13,6 +13,8 @@
 def test_make_udir_with_basename():
     root = str(udir.udir.ensure('make_udir2', dir=1))
     p1 = udir.make_udir(dir=root, basename='foobar')
+    def assert_relto(path, root, expected):
+        assert path.relto(root) == expected, path.relto(root)
     assert p1.relto(root) == 'usession-foobar-0'
     p1 = udir.make_udir(dir=root, basename='-foobar')
     assert p1.relto(root) == 'usession-foobar-1'
@@ -24,3 +26,5 @@
     assert p1.relto(root) == 'usession-0'
     p1 = udir.make_udir(dir=root, basename='-')
     assert p1.relto(root) == 'usession-1'
+    p1 = udir.make_udir(dir=root, basename='fun/bar')
+    assert p1.relto(root) == 'usession-fun--bar-0'
diff --git a/pypy/tool/udir.py b/pypy/tool/udir.py
--- a/pypy/tool/udir.py
+++ b/pypy/tool/udir.py
@@ -41,6 +41,7 @@
                 basename = basename.encode(sys.getdefaultencoding())
         else:
             basename = ''
+    basename = basename.replace('/', '--')
     if not basename.startswith('-'):
         basename = '-' + basename
     if not basename.endswith('-'):
diff --git a/pypy/translator/driver.py b/pypy/translator/driver.py
--- a/pypy/translator/driver.py
+++ b/pypy/translator/driver.py
@@ -115,12 +115,10 @@
         backend, ts = self.get_backend_and_type_system()
         for task in self.tasks:
             explicit_task = task
-            parts = task.split('_')
-            if len(parts) == 1:
-                if task in ('annotate',):
-                    expose_task(task)
+            if task == 'annotate':
+                expose_task(task)
             else:
-                task, postfix = parts
+                task, postfix = task.split('_')
                 if task in ('rtype', 'backendopt', 'llinterpret',
                             'pyjitpl'):
                     if ts:


More information about the pypy-commit mailing list