merge with stable
authorMatt Mackall <mpm@selenic.com>
Wed, 28 Nov 2012 16:15:05 -0600
changeset 17980 83aa4359c49f
parent 17978 55b367bff8d2 (current diff)
parent 17979 b3ec0b5fd777 (diff)
child 17982 e06e9fd2d99f
merge with stable
mercurial/revset.py
--- a/mercurial/hook.py	Thu Nov 08 11:54:08 2012 +0100
+++ b/mercurial/hook.py	Wed Nov 28 16:15:05 2012 -0600
@@ -142,25 +142,26 @@
         return False
 
     r = False
-
     oldstdout = -1
-    if _redirect:
-        try:
-            stdoutno = sys.__stdout__.fileno()
-            stderrno = sys.__stderr__.fileno()
-            # temporarily redirect stdout to stderr, if possible
-            if stdoutno >= 0 and stderrno >= 0:
-                sys.__stdout__.flush()
-                oldstdout = os.dup(stdoutno)
-                os.dup2(stderrno, stdoutno)
-        except AttributeError:
-            # __stdout__/__stderr__ doesn't have fileno(), it's not a real file
-            pass
 
     try:
         for hname, cmd in _allhooks(ui):
             if hname.split('.')[0] != name or not cmd:
                 continue
+
+            if oldstdout == -1 and _redirect:
+                try:
+                    stdoutno = sys.__stdout__.fileno()
+                    stderrno = sys.__stderr__.fileno()
+                    # temporarily redirect stdout to stderr, if possible
+                    if stdoutno >= 0 and stderrno >= 0:
+                        sys.__stdout__.flush()
+                        oldstdout = os.dup(stdoutno)
+                        os.dup2(stderrno, stdoutno)
+                except (OSError, AttributeError):
+                    # files seem to be bogus, give up on redirecting (WSGI, etc)
+                    pass
+
             if util.safehasattr(cmd, '__call__'):
                 r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r
             elif cmd.startswith('python:'):
--- a/mercurial/phases.py	Thu Nov 08 11:54:08 2012 +0100
+++ b/mercurial/phases.py	Wed Nov 28 16:15:05 2012 -0600
@@ -103,7 +103,7 @@
 import errno
 from node import nullid, nullrev, bin, hex, short
 from i18n import _
-import util
+import util, error
 import obsolete
 
 allphases = public, draft, secret = range(3)
--- a/mercurial/revset.py	Thu Nov 08 11:54:08 2012 +0100
+++ b/mercurial/revset.py	Wed Nov 28 16:15:05 2012 -0600
@@ -584,14 +584,6 @@
     if not args:
         return []
     s = set(_revdescendants(repo, args, followfirst)) | set(args)
-
-    if len(subset) == len(repo):
-        # the passed in revisions may not exist, -1 for example
-        for arg in args:
-            if arg not in subset:
-                s.remove(arg)
-        return list(s)
-
     return [r for r in subset if r in s]
 
 def descendants(repo, subset, x):
@@ -1349,10 +1341,7 @@
     Changesets in set with no parent changeset in set.
     """
     s = set(getset(repo, repo.changelog, x))
-    if len(subset) == len(repo):
-        subset = s
-    else:
-        subset = [r for r in subset if r in s]
+    subset = [r for r in subset if r in s]
     cs = _children(repo, subset, s)
     return [r for r in subset if r not in cs]
 
--- a/mercurial/util.py	Thu Nov 08 11:54:08 2012 +0100
+++ b/mercurial/util.py	Wed Nov 28 16:15:05 2012 -0600
@@ -899,7 +899,7 @@
         """Read L bytes of data from the iterator of chunks of data.
         Returns less than L bytes if the iterator runs dry."""
         left = l
-        buf = ''
+        buf = []
         queue = self._queue
         while left > 0:
             # refill the queue
@@ -917,11 +917,11 @@
             left -= len(chunk)
             if left < 0:
                 queue.appendleft(chunk[left:])
-                buf += chunk[:left]
+                buf.append(chunk[:left])
             else:
-                buf += chunk
+                buf.append(chunk)
 
-        return buf
+        return ''.join(buf)
 
 def filechunkiter(f, size=65536, limit=None):
     """Create a generator that produces the data in the file size
--- a/tests/test-phases.t	Thu Nov 08 11:54:08 2012 +0100
+++ b/tests/test-phases.t	Wed Nov 28 16:15:05 2012 -0600
@@ -337,8 +337,17 @@
   description:
   A
   
+
+
+(Issue3707)
+test invalid phase name
+
+  $ mkcommit I --config phases.new-commit='babar'
+  transaction abort!
+  rollback completed
+  abort: phases.new-commit: not a valid phase name ('babar')
+  [255]
   
-
 Test phase command
 ===================