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