Mercurial > hg-stable
comparison hgext/histedit.py @ 22978:d4e764521249
histedit: add clear method to remove state
Encapsulate the unlinking histedit-state and use the vfs layer instead of
os.unlink.
author | David Soria Parra <davidsp@fb.com> |
---|---|
date | Wed, 15 Oct 2014 17:30:57 -0700 |
parents | 29ae3b190ec5 |
children | bb22cd700e0a |
comparison
equal
deleted
inserted
replaced
22977:29ae3b190ec5 | 22978:d4e764521249 |
---|---|
204 def write(self): | 204 def write(self): |
205 fp = self.repo.vfs('histedit-state', 'w') | 205 fp = self.repo.vfs('histedit-state', 'w') |
206 pickle.dump((self.parentctxnode, self.rules, self.keep, | 206 pickle.dump((self.parentctxnode, self.rules, self.keep, |
207 self.topmost, self.replacements), fp) | 207 self.topmost, self.replacements), fp) |
208 fp.close() | 208 fp.close() |
209 | |
210 def clear(self): | |
211 self.repo.vfs.unlink('histedit-state') | |
209 | 212 |
210 def commitfuncfor(repo, src): | 213 def commitfuncfor(repo, src): |
211 """Build a commit function for the replacement of <src> | 214 """Build a commit function for the replacement of <src> |
212 | 215 |
213 This function ensure we apply the same treatment to all changesets. | 216 This function ensure we apply the same treatment to all changesets. |
584 break | 587 break |
585 else: | 588 else: |
586 pass | 589 pass |
587 cleanupnode(ui, repo, 'created', tmpnodes) | 590 cleanupnode(ui, repo, 'created', tmpnodes) |
588 cleanupnode(ui, repo, 'temp', leafs) | 591 cleanupnode(ui, repo, 'temp', leafs) |
589 os.unlink(os.path.join(repo.path, 'histedit-state')) | 592 state.clear() |
590 return | 593 return |
591 else: | 594 else: |
592 cmdutil.checkunfinished(repo) | 595 cmdutil.checkunfinished(repo) |
593 cmdutil.bailifchanged(repo) | 596 cmdutil.bailifchanged(repo) |
594 | 597 |
681 obsolete.createmarkers(repo, markers) | 684 obsolete.createmarkers(repo, markers) |
682 else: | 685 else: |
683 cleanupnode(ui, repo, 'replaced', mapping) | 686 cleanupnode(ui, repo, 'replaced', mapping) |
684 | 687 |
685 cleanupnode(ui, repo, 'temp', tmpnodes) | 688 cleanupnode(ui, repo, 'temp', tmpnodes) |
686 os.unlink(os.path.join(repo.path, 'histedit-state')) | 689 state.clear() |
687 if os.path.exists(repo.sjoin('undo')): | 690 if os.path.exists(repo.sjoin('undo')): |
688 os.unlink(repo.sjoin('undo')) | 691 os.unlink(repo.sjoin('undo')) |
689 | 692 |
690 def gatherchildren(repo, ctx): | 693 def gatherchildren(repo, ctx): |
691 # is there any new commit between the expected parent and "." | 694 # is there any new commit between the expected parent and "." |