Martin von Zweigbergk <martinvonz@google.com> [Mon, 11 Jan 2021 10:35:52 -0800] rev 46290
shelve: use listdir() instead of readdir() when we don't need stat information
Differential Revision: https://phab.mercurial-scm.org/D9737
Martin von Zweigbergk <martinvonz@google.com> [Fri, 08 Jan 2021 23:08:37 -0800] rev 46289
shelve: don't crash on file with unexpected extension in .hg/shelved/
We assumed that the files in the `.hg/shelved/` directory have an
extension. That's a valid assumption except that users may put garbage
in the directory. This patch fixes the crash by simply not assuming
that the result of splittin a string at '.' yields an extension. We
don't use the extension since the previous patch anyway.
Differential Revision: https://phab.mercurial-scm.org/D9720
Martin von Zweigbergk <martinvonz@google.com> [Mon, 11 Jan 2021 09:26:48 -0800] rev 46288
shelve: don't include invalid shelves in `hg shelve --list`
Before this patch, if a shelved change is missing its `.hg` file, we
still list it in `hg shelve --list`, but then `hg unshelve`
crashes. This patch makes it so we only list valid shelved changes.
This patch means that users who do `touch .hg/shelve/buy-milk.patch`
as a form of TODO list will no longer see their TODO items in `hg
shelve --list`.
Differential Revision: https://phab.mercurial-scm.org/D9719
Martin von Zweigbergk <martinvonz@google.com> [Thu, 07 Jan 2021 23:32:19 -0800] rev 46287
shelve: extract some repeated creation of shelf instances to variables
This just looks cleaner to me; I'd be surprised if there's any
measurable performance improvement.
Differential Revision: https://phab.mercurial-scm.org/D9714
Martin von Zweigbergk <martinvonz@google.com> [Thu, 07 Jan 2021 23:18:24 -0800] rev 46286
shelve: teach new shelf class to check if .shelve file exists
This removes the only remaining use for `shelvedfile`, so the class
now goes away.
Differential Revision: https://phab.mercurial-scm.org/D9713
Martin von Zweigbergk <martinvonz@google.com> [Thu, 07 Jan 2021 22:45:17 -0800] rev 46285
shelve: move method for creating backup to new shelf class
Differential Revision: https://phab.mercurial-scm.org/D9712
Martin von Zweigbergk <martinvonz@google.com> [Thu, 07 Jan 2021 23:09:04 -0800] rev 46284
shelve: make gennames() helper generate relative backup paths
When I saw `gennames()`, I thought it was meant to take a relative
filename as argument. Maybe it was or maybe it wasn't, but it seems
simpler to pass it a relative path anyway, so that's what this patch
does. That also makes the call to backupvfs.exists() more natural (I
expect a relative path to be passed there too).
Differential Revision: https://phab.mercurial-scm.org/D9711
Martin von Zweigbergk <martinvonz@google.com> [Thu, 07 Jan 2021 22:38:19 -0800] rev 46283
shelve: use listshelves() in cleanup function
The point of this patch is to make it so all the callers of
`shelvedfile.movetobackup()` look the same, so I can move it over to
the new `Shelf` class next.
Differential Revision: https://phab.mercurial-scm.org/D9710