D2153: py3: open patches.queue in binary mode
This revision was automatically updated to reflect the committed changes. Closed by commit rHGbff95b002e33: py3: open patches.queue in binary mode (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2153?vs=5454=5578 REVISION DETAIL https://phab.mercurial-scm.org/D2153 AFFECTED FILES hgext/mq.py CHANGE DETAILS diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -445,9 +445,9 @@ def __init__(self, ui, baseui, path, patchdir=None): self.basepath = path try: -fh = open(os.path.join(path, 'patches.queue')) -cur = fh.read().rstrip() -fh.close() +with open(os.path.join(path, 'patches.queue'), r'rb') as fh: +cur = fh.read().rstrip() + if not cur: curpath = os.path.join(path, 'patches') else: To: indygreg, #hg-reviewers, pulkit, durin42 Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2153: py3: open patches.queue in binary mode
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY And switch to using the context manager form of open() while we're here. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2153 AFFECTED FILES hgext/mq.py CHANGE DETAILS diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -445,9 +445,9 @@ def __init__(self, ui, baseui, path, patchdir=None): self.basepath = path try: -fh = open(os.path.join(path, 'patches.queue')) -cur = fh.read().rstrip() -fh.close() +with open(os.path.join(path, 'patches.queue'), r'rb') as fh: +cur = fh.read().rstrip() + if not cur: curpath = os.path.join(path, 'patches') else: To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel