Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG6bd9f18d31a8: progress: use context manager for lock
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/progress.py (5 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Martin von Zweigbergk | Jun 20 2018, 1:06 AM |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz |
| # smoother. | # smoother. | ||||
| if newdelta < 0.1: | if newdelta < 0.1: | ||||
| return | return | ||||
| self.startvals[topic] = pos - newdelta | self.startvals[topic] = pos - newdelta | ||||
| self.starttimes[topic] = now - interval | self.starttimes[topic] = now - interval | ||||
| def progress(self, topic, pos, item='', unit='', total=None): | def progress(self, topic, pos, item='', unit='', total=None): | ||||
| now = time.time() | now = time.time() | ||||
| self._refreshlock.acquire() | with self._refreshlock: | ||||
| try: | |||||
| if pos is None: | if pos is None: | ||||
| self.starttimes.pop(topic, None) | self.starttimes.pop(topic, None) | ||||
| self.startvals.pop(topic, None) | self.startvals.pop(topic, None) | ||||
| self.topicstates.pop(topic, None) | self.topicstates.pop(topic, None) | ||||
| # reset the progress bar if this is the outermost topic | # reset the progress bar if this is the outermost topic | ||||
| if self.topics and self.topics[0] == topic and self.printed: | if self.topics and self.topics[0] == topic and self.printed: | ||||
| self.complete() | self.complete() | ||||
| self.resetstate() | self.resetstate() | ||||
| self.topics.append(topic) | self.topics.append(topic) | ||||
| self.topicstates[topic] = pos, item, unit, total | self.topicstates[topic] = pos, item, unit, total | ||||
| self.curtopic = topic | self.curtopic = topic | ||||
| self._calibrateestimate(topic, now, pos) | self._calibrateestimate(topic, now, pos) | ||||
| if now - self.lastprint >= self.refresh and self.topics: | if now - self.lastprint >= self.refresh and self.topics: | ||||
| if self._oktoprint(now): | if self._oktoprint(now): | ||||
| self.lastprint = now | self.lastprint = now | ||||
| self.show(now, topic, *self.topicstates[topic]) | self.show(now, topic, *self.topicstates[topic]) | ||||
| finally: | |||||
| self._refreshlock.release() | |||||