Mercurial > hg
comparison hgext/convert/cvsps.py @ 9031:3b76321aa0de
compat: use open() instead of file() everywhere
author | Alejandro Santos <alejolp@alejolp.com> |
---|---|
date | Sun, 05 Jul 2009 11:01:30 +0200 |
parents | c487719cccef |
children | 1fa80c5428b8 |
comparison
equal
deleted
inserted
replaced
9030:3f56055ff1d7 | 9031:3b76321aa0de |
---|---|
128 if directory is None: | 128 if directory is None: |
129 # Current working directory | 129 # Current working directory |
130 | 130 |
131 # Get the real directory in the repository | 131 # Get the real directory in the repository |
132 try: | 132 try: |
133 prefix = file(os.path.join('CVS','Repository')).read().strip() | 133 prefix = open(os.path.join('CVS','Repository')).read().strip() |
134 if prefix == ".": | 134 if prefix == ".": |
135 prefix = "" | 135 prefix = "" |
136 directory = prefix | 136 directory = prefix |
137 except IOError: | 137 except IOError: |
138 raise logerror('Not a CVS sandbox') | 138 raise logerror('Not a CVS sandbox') |
140 if prefix and not prefix.endswith(os.sep): | 140 if prefix and not prefix.endswith(os.sep): |
141 prefix += os.sep | 141 prefix += os.sep |
142 | 142 |
143 # Use the Root file in the sandbox, if it exists | 143 # Use the Root file in the sandbox, if it exists |
144 try: | 144 try: |
145 root = file(os.path.join('CVS','Root')).read().strip() | 145 root = open(os.path.join('CVS','Root')).read().strip() |
146 except IOError: | 146 except IOError: |
147 pass | 147 pass |
148 | 148 |
149 if not root: | 149 if not root: |
150 root = os.environ.get('CVSROOT', '') | 150 root = os.environ.get('CVSROOT', '') |
173 '.'.join([s for s in cachefile if s])) | 173 '.'.join([s for s in cachefile if s])) |
174 | 174 |
175 if cache == 'update': | 175 if cache == 'update': |
176 try: | 176 try: |
177 ui.note(_('reading cvs log cache %s\n') % cachefile) | 177 ui.note(_('reading cvs log cache %s\n') % cachefile) |
178 oldlog = pickle.load(file(cachefile)) | 178 oldlog = pickle.load(open(cachefile)) |
179 ui.note(_('cache has %d log entries\n') % len(oldlog)) | 179 ui.note(_('cache has %d log entries\n') % len(oldlog)) |
180 except Exception, e: | 180 except Exception, e: |
181 ui.note(_('error reading cache: %r\n') % e) | 181 ui.note(_('error reading cache: %r\n') % e) |
182 | 182 |
183 if oldlog: | 183 if oldlog: |
443 | 443 |
444 log = oldlog + log | 444 log = oldlog + log |
445 | 445 |
446 # write the new cachefile | 446 # write the new cachefile |
447 ui.note(_('writing cvs log cache %s\n') % cachefile) | 447 ui.note(_('writing cvs log cache %s\n') % cachefile) |
448 pickle.dump(log, file(cachefile, 'w')) | 448 pickle.dump(log, open(cachefile, 'w')) |
449 else: | 449 else: |
450 log = oldlog | 450 log = oldlog |
451 | 451 |
452 ui.status(_('%d log entries\n') % len(log)) | 452 ui.status(_('%d log entries\n') % len(log)) |
453 | 453 |