Patchwork D6984: cvsps: switch a file open to a with statement

login
register
mail settings
Submitter phabricator
Date Oct. 5, 2019, 5:45 p.m.
Message ID <differential-rev-PHID-DREV-b4d5udbrosu4tnbbhba5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/41985/
State Superseded
Headers show

Comments

phabricator - Oct. 5, 2019, 5:45 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  For some reason this only showed up in check-code after running
  black. Puzzling.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6984

AFFECTED FILES
  hgext/convert/cvsps.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/convert/cvsps.py b/hgext/convert/cvsps.py
--- a/hgext/convert/cvsps.py
+++ b/hgext/convert/cvsps.py
@@ -138,7 +138,8 @@ 
 
         # Get the real directory in the repository
         try:
-            prefix = open(os.path.join('CVS','Repository'), 'rb').read().strip()
+            with open(os.path.join(b'CVS', b'Repository'), 'rb') as f:
+                prefix = f.read().strip()
             directory = prefix
             if prefix == ".":
                 prefix = ""