##// END OF EJS Templates
shelve: don't include invalid shelves in `hg shelve --list`...
Martin von Zweigbergk -
r46914:680cc423 default draft
parent child Browse files
Show More
@@ -87,7 +87,9 b' class Shelf(object):'
87 87 self.backupvfs = vfsmod.vfs(repo.vfs.join(backupdir))
88 88
89 89 def exists(self):
90 return self.vfs.exists(self.name + b'.' + patchextension)
90 return self.vfs.exists(
91 self.name + b'.' + patchextension
92 ) and self.vfs.exists(self.name + b'.hg')
91 93
92 94 def mtime(self):
93 95 return self.vfs.stat(self.name + b'.' + patchextension)[stat.ST_MTIME]
@@ -621,12 +623,17 b' def listshelves(repo):'
621 623 raise
622 624 return []
623 625 info = []
624 for (name, _type) in names:
625 pfx, sfx = name.rsplit(b'.', 1)
626 if not pfx or sfx != patchextension:
626 seen = set()
627 for (filename, _type) in names:
628 name, ext = filename.rsplit(b'.', 1)
629 if name in seen:
627 630 continue
628 mtime = Shelf(repo, pfx).mtime()
629 info.append((mtime, pfx))
631 seen.add(name)
632 shelf = Shelf(repo, name)
633 if not shelf.exists():
634 continue
635 mtime = shelf.mtime()
636 info.append((mtime, name))
630 637 return sorted(info, reverse=True)
631 638
632 639
@@ -753,16 +753,15 b' Test corrupt shelves (in .hg/shelved/, n'
753 753 # A (corrupt) .patch file without a .hg file
754 754 $ touch .hg/shelved/junk1.patch
755 755 $ hg shelve -l
756 junk1 (* ago) (glob)
757 756 $ hg unshelve
758 unshelving change 'junk1'
759 abort: $ENOENT$: '$TESTTMP/corrupt-shelves/.hg/shelved/junk1.hg'
760 [255]
757 abort: no shelved changes to apply!
758 [20]
761 759 $ hg shelve -d junk1
760 abort: shelved change 'junk1' not found
761 [10]
762 762 $ find .hg/shelve*
763 .hg/shelve-backup
764 .hg/shelve-backup/junk1.patch
765 763 .hg/shelved
764 .hg/shelved/junk1.patch
766 765
767 766 # A .hg file without a .patch file
768 767 $ touch .hg/shelved/junk2.hg
@@ -774,9 +773,8 b' Test corrupt shelves (in .hg/shelved/, n'
774 773 abort: shelved change 'junk2' not found
775 774 [10]
776 775 $ find .hg/shelve*
777 .hg/shelve-backup
778 .hg/shelve-backup/junk1.patch
779 776 .hg/shelved
777 .hg/shelved/junk1.patch
780 778 .hg/shelved/junk2.hg
781 779
782 780 # A file with an unexpected extension
@@ -789,9 +787,8 b' Test corrupt shelves (in .hg/shelved/, n'
789 787 abort: shelved change 'junk3' not found
790 788 [10]
791 789 $ find .hg/shelve*
792 .hg/shelve-backup
793 .hg/shelve-backup/junk1.patch
794 790 .hg/shelved
791 .hg/shelved/junk1.patch
795 792 .hg/shelved/junk3
796 793 .hg/shelved/junk2.hg
797 794
General Comments 0
You need to be logged in to leave comments. Login now