Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/bookmarks.py (19 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Martin von Zweigbergk | May 15 2019, 1:13 PM |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz |
| def _writerepo(self, repo): | def _writerepo(self, repo): | ||||
| """Factored out for extensibility""" | """Factored out for extensibility""" | ||||
| rbm = repo._bookmarks | rbm = repo._bookmarks | ||||
| if rbm.active not in self._refmap: | if rbm.active not in self._refmap: | ||||
| rbm.active = None | rbm.active = None | ||||
| rbm._writeactive() | rbm._writeactive() | ||||
| with repo.wlock(): | with repo.wlock(): | ||||
| file_ = repo.vfs('bookmarks', 'w', atomictemp=True, | with repo.vfs('bookmarks', 'w', atomictemp=True, | ||||
| checkambig=True) | checkambig=True) as f: | ||||
| try: | self._write(f) | ||||
| self._write(file_) | |||||
| except: # re-raises | |||||
| file_.discard() | |||||
| raise | |||||
| finally: | |||||
| file_.close() | |||||
| def _writeactive(self): | def _writeactive(self): | ||||
| if self._aclean: | if self._aclean: | ||||
| return | return | ||||
| with self._repo.wlock(): | with self._repo.wlock(): | ||||
| if self._active is not None: | if self._active is not None: | ||||
| f = self._repo.vfs('bookmarks.current', 'w', atomictemp=True, | with self._repo.vfs('bookmarks.current', 'w', atomictemp=True, | ||||
| checkambig=True) | checkambig=True) as f: | ||||
| try: | |||||
| f.write(encoding.fromlocal(self._active)) | f.write(encoding.fromlocal(self._active)) | ||||
| finally: | |||||
| f.close() | |||||
| else: | else: | ||||
| self._repo.vfs.tryunlink('bookmarks.current') | self._repo.vfs.tryunlink('bookmarks.current') | ||||
| self._aclean = True | self._aclean = True | ||||
| def _write(self, fp): | def _write(self, fp): | ||||
| for name, node in sorted(self._refmap.iteritems()): | for name, node in sorted(self._refmap.iteritems()): | ||||
| fp.write("%s %s\n" % (hex(node), encoding.fromlocal(name))) | fp.write("%s %s\n" % (hex(node), encoding.fromlocal(name))) | ||||
| self._clean = True | self._clean = True | ||||