Mercurial > hg
comparison mercurial/localrepo.py @ 10882:f0bfe42c7b1f
rollback: add dry-run argument, emit transaction description
author | Steve Borho <steve@borho.org> |
---|---|
date | Fri, 09 Apr 2010 17:23:37 -0500 |
parents | a685011ed38e |
children | 38f2ef9c134b |
comparison
equal
deleted
inserted
replaced
10881:a685011ed38e | 10882:f0bfe42c7b1f |
---|---|
597 self.ui.warn(_("no interrupted transaction available\n")) | 597 self.ui.warn(_("no interrupted transaction available\n")) |
598 return False | 598 return False |
599 finally: | 599 finally: |
600 lock.release() | 600 lock.release() |
601 | 601 |
602 def rollback(self): | 602 def rollback(self, dryrun=False): |
603 wlock = lock = None | 603 wlock = lock = None |
604 try: | 604 try: |
605 wlock = self.wlock() | 605 wlock = self.wlock() |
606 lock = self.lock() | 606 lock = self.lock() |
607 if os.path.exists(self.sjoin("undo")): | 607 if os.path.exists(self.sjoin("undo")): |
608 self.ui.status(_("rolling back last transaction\n")) | 608 try: |
609 args = self.opener("undo.desc", "r").read().split(",") | |
610 if len(args) == 3 and self.ui.verbose: | |
611 desc = _("rolling back %s (%s) to revision %s\n") % ( | |
612 args[1], args[2], args[0]) | |
613 else: | |
614 desc = _("rolling back %s to revision %s\n") % ( | |
615 args[1], args[0]) | |
616 except (IOError, IndexError): | |
617 desc = _("rolling back unknown transaction\n") | |
618 self.ui.status(desc) | |
619 if dryrun: | |
620 return | |
609 transaction.rollback(self.sopener, self.sjoin("undo"), | 621 transaction.rollback(self.sopener, self.sjoin("undo"), |
610 self.ui.warn) | 622 self.ui.warn) |
611 util.rename(self.join("undo.dirstate"), self.join("dirstate")) | 623 util.rename(self.join("undo.dirstate"), self.join("dirstate")) |
612 try: | 624 try: |
613 branch = self.opener("undo.branch").read() | 625 branch = self.opener("undo.branch").read() |