##// END OF EJS Templates
shelve: make listshelves() return shelf names instead of filenames...
Martin von Zweigbergk -
r46999:a34607b6 default
parent child Browse files
Show More
@@ -630,7 +630,7 b' def deletecmd(ui, repo, pats):'
630
630
631
631
632 def listshelves(repo):
632 def listshelves(repo):
633 """return all shelves in repo as list of (time, filename)"""
633 """return all shelves in repo as list of (time, name)"""
634 try:
634 try:
635 names = repo.vfs.readdir(shelvedir)
635 names = repo.vfs.readdir(shelvedir)
636 except OSError as err:
636 except OSError as err:
@@ -643,7 +643,7 b' def listshelves(repo):'
643 if not pfx or sfx != patchextension:
643 if not pfx or sfx != patchextension:
644 continue
644 continue
645 mtime = Shelf(repo, pfx).mtime()
645 mtime = Shelf(repo, pfx).mtime()
646 info.append((mtime, shelvedfile(repo, pfx).filename()))
646 info.append((mtime, pfx))
647 return sorted(info, reverse=True)
647 return sorted(info, reverse=True)
648
648
649
649
@@ -656,22 +656,21 b' def listcmd(ui, repo, pats, opts):'
656 namelabel = b'shelve.newest'
656 namelabel = b'shelve.newest'
657 ui.pager(b'shelve')
657 ui.pager(b'shelve')
658 for mtime, name in listshelves(repo):
658 for mtime, name in listshelves(repo):
659 sname = util.split(name)[1]
659 if pats and name not in pats:
660 if pats and sname not in pats:
661 continue
660 continue
662 ui.write(sname, label=namelabel)
661 ui.write(name, label=namelabel)
663 namelabel = b'shelve.name'
662 namelabel = b'shelve.name'
664 if ui.quiet:
663 if ui.quiet:
665 ui.write(b'\n')
664 ui.write(b'\n')
666 continue
665 continue
667 ui.write(b' ' * (16 - len(sname)))
666 ui.write(b' ' * (16 - len(name)))
668 used = 16
667 used = 16
669 date = dateutil.makedate(mtime)
668 date = dateutil.makedate(mtime)
670 age = b'(%s)' % templatefilters.age(date, abbrev=True)
669 age = b'(%s)' % templatefilters.age(date, abbrev=True)
671 ui.write(age, label=b'shelve.age')
670 ui.write(age, label=b'shelve.age')
672 ui.write(b' ' * (12 - len(age)))
671 ui.write(b' ' * (12 - len(age)))
673 used += 12
672 used += 12
674 with Shelf(repo, sname).open_patch() as fp:
673 with Shelf(repo, name).open_patch() as fp:
675 while True:
674 while True:
676 line = fp.readline()
675 line = fp.readline()
677 if not line:
676 if not line:
@@ -701,8 +700,7 b' def patchcmds(ui, repo, pats, opts):'
701 if not shelves:
700 if not shelves:
702 raise error.Abort(_(b"there are no shelves to show"))
701 raise error.Abort(_(b"there are no shelves to show"))
703 mtime, name = shelves[0]
702 mtime, name = shelves[0]
704 sname = util.split(name)[1]
703 pats = [name]
705 pats = [sname]
706
704
707 for shelfname in pats:
705 for shelfname in pats:
708 if not Shelf(repo, shelfname).exists():
706 if not Shelf(repo, shelfname).exists():
@@ -1122,7 +1120,7 b' def unshelvecmd(ui, repo, *shelved, **op'
1122 shelved = listshelves(repo)
1120 shelved = listshelves(repo)
1123 if not shelved:
1121 if not shelved:
1124 raise error.StateError(_(b'no shelved changes to apply!'))
1122 raise error.StateError(_(b'no shelved changes to apply!'))
1125 basename = util.split(shelved[0][1])[1]
1123 basename = shelved[0][1]
1126 ui.status(_(b"unshelving change '%s'\n") % basename)
1124 ui.status(_(b"unshelving change '%s'\n") % basename)
1127 else:
1125 else:
1128 basename = shelved[0]
1126 basename = shelved[0]
General Comments 0
You need to be logged in to leave comments. Login now