# HG changeset patch # User Matt Mackall # Date 2012-11-28 22:15:05 # Node ID 83aa4359c49f67bcb98fb9c7d885ed4ac7443239 # Parent 55b367bff8d22666dbd7896e6628140e32f604aa # Parent b3ec0b5fd7771b401392a83f47e0c2360e7f6d90 merge with stable diff --git a/mercurial/hook.py b/mercurial/hook.py --- a/mercurial/hook.py +++ b/mercurial/hook.py @@ -142,25 +142,26 @@ def hook(ui, repo, name, throw=False, ** 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:'): diff --git a/mercurial/phases.py b/mercurial/phases.py --- a/mercurial/phases.py +++ b/mercurial/phases.py @@ -103,7 +103,7 @@ Note: old client behave as a publishing 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) diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -584,14 +584,6 @@ def _descendants(repo, subset, x, follow 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 @@ def roots(repo, subset, x): 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] diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -899,7 +899,7 @@ class chunkbuffer(object): """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 @@ class chunkbuffer(object): 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 diff --git a/tests/test-phases.t b/tests/test-phases.t --- a/tests/test-phases.t +++ b/tests/test-phases.t @@ -337,8 +337,17 @@ test that phase are displayed in log at 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 ===================