comparison hgsubversion/maps.py @ 1555:cff81f35b31e

cleanup: reference Abort from mercurial.error instead of mercurial.util It's been there since hg 1.7 or so, which lets us avoid any need for compat shims.
author Augie Fackler <raf@durin42.com>
date Sat, 24 Mar 2018 16:39:30 -0400
parents 67b28d657f62
children ae572c9be4e6
comparison
equal deleted inserted replaced
1554:258fb67fb956 1555:cff81f35b31e
253 process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) 253 process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
254 output, err = process.communicate() 254 output, err = process.communicate()
255 retcode = process.poll() 255 retcode = process.poll()
256 if retcode: 256 if retcode:
257 msg = 'map author command "%s" exited with error' 257 msg = 'map author command "%s" exited with error'
258 raise hgutil.Abort(msg % cmd) 258 raise error.Abort(msg % cmd)
259 self[author] = result = output.strip() 259 self[author] = result = output.strip()
260 if not result: 260 if not result:
261 if self._defaultauthors: 261 if self._defaultauthors:
262 self[author] = result = '%s%s' % (author, self.defaulthost) 262 self[author] = result = '%s%s' % (author, self.defaulthost)
263 msg = 'substituting author "%s" for default "%s"\n' 263 msg = 'substituting author "%s" for default "%s"\n'
264 self._ui.debug(msg % (author, result)) 264 self._ui.debug(msg % (author, result))
265 else: 265 else:
266 msg = 'author %s has no entry in the author map!' 266 msg = 'author %s has no entry in the author map!'
267 raise hgutil.Abort(msg % author) 267 raise error.Abort(msg % author)
268 self._ui.debug('mapping author "%s" to "%s"\n' % (author, result)) 268 self._ui.debug('mapping author "%s" to "%s"\n' % (author, result))
269 return result 269 return result
270 270
271 def reverselookup(self, author): 271 def reverselookup(self, author):
272 for svnauthor, hgauthor in self.iteritems(): 272 for svnauthor, hgauthor in self.iteritems():
300 ver = int(f.readline()) 300 ver = int(f.readline())
301 if ver < self.VERSION: 301 if ver < self.VERSION:
302 raise error.Abort( 302 raise error.Abort(
303 'tag map outdated, please run `hg svn rebuildmeta`') 303 'tag map outdated, please run `hg svn rebuildmeta`')
304 elif ver != self.VERSION: 304 elif ver != self.VERSION:
305 raise hgutil.Abort('tagmap too new -- please upgrade') 305 raise error.Abort('tagmap too new -- please upgrade')
306 for l in f: 306 for l in f:
307 ha, revision, tag = l.split(' ', 2) 307 ha, revision, tag = l.split(' ', 2)
308 revision = int(revision) 308 revision = int(revision)
309 tag = tag[:-1] 309 tag = tag[:-1]
310 if self.endrev is not None and revision > self.endrev: 310 if self.endrev is not None and revision > self.endrev:
333 return dict.__getitem__(self, tag) 333 return dict.__getitem__(self, tag)
334 raise KeyError() 334 raise KeyError()
335 335
336 def __setitem__(self, tag, info): 336 def __setitem__(self, tag, info):
337 if not tag: 337 if not tag:
338 raise hgutil.Abort('tag cannot be empty') 338 raise error.Abort('tag cannot be empty')
339 ha, revision = info 339 ha, revision = info
340 f = open(self._filepath, 'a') 340 f = open(self._filepath, 'a')
341 f.write('%s %s %s\n' % (hex(ha), revision, tag)) 341 f.write('%s %s %s\n' % (hex(ha), revision, tag))
342 f.close() 342 f.close()
343 dict.__setitem__(self, tag, ha) 343 dict.__setitem__(self, tag, ha)
427 os.rename(tmppath, self._filepath) 427 os.rename(tmppath, self._filepath)
428 hgutil.unlinkpath(revmap._dbpath) 428 hgutil.unlinkpath(revmap._dbpath)
429 hgutil.unlinkpath(revmap._rowcountpath, ignoremissing=True) 429 hgutil.unlinkpath(revmap._rowcountpath, ignoremissing=True)
430 return self._readmapfile() 430 return self._readmapfile()
431 if ver != self.VERSION: 431 if ver != self.VERSION:
432 raise hgutil.Abort('revmap too new -- please upgrade') 432 raise error.Abort('revmap too new -- please upgrade')
433 return f 433 return f
434 434
435 @util.gcdisable 435 @util.gcdisable
436 def _load(self): 436 def _load(self):
437 lastpulled = self.lastpulled 437 lastpulled = self.lastpulled
885 def _load(self): 885 def _load(self):
886 self._ui.debug('reading in-repo file map from %s\n' % self._filename) 886 self._ui.debug('reading in-repo file map from %s\n' % self._filename)
887 with open(self._filename) as f: 887 with open(self._filename) as f:
888 ver = int(f.readline()) 888 ver = int(f.readline())
889 if ver != self.VERSION: 889 if ver != self.VERSION:
890 raise hgutil.Abort('filemap too new -- please upgrade') 890 raise error.Abort('filemap too new -- please upgrade')
891 self.load_fd(f, self._filename) 891 self.load_fd(f, self._filename)
892 892
893 def _write(self): 893 def _write(self):
894 with open(self._filename, 'w') as f: 894 with open(self._filename, 'w') as f:
895 f.write('%s\n' % self.VERSION) 895 f.write('%s\n' % self.VERSION)