Only the mtime was needed, so I made it restricted to that in the
move.
The new Shelf class expects its argument to be a shelf name (not a
arbitrary filename like shelvedfile would accept), so only the
shelf name is now passed in.
( )
Only the mtime was needed, so I made it restricted to that in the
move.
The new Shelf class expects its argument to be a shelf name (not a
arbitrary filename like shelvedfile would accept), so only the
shelf name is now passed in.
| No Linters Available |
| No Unit Test Coverage |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/shelve.py (10 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| 0d9da4521d9c | a4ab5e961fa5 | Martin von Zweigbergk | Jan 7 2021, 5:54 PM |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz |
| if not self.backupvfs.exists(n): | if not self.backupvfs.exists(n): | ||||
| return n | return n | ||||
| def movetobackup(self): | def movetobackup(self): | ||||
| if not self.backupvfs.isdir(): | if not self.backupvfs.isdir(): | ||||
| self.backupvfs.makedir() | self.backupvfs.makedir() | ||||
| util.rename(self.filename(), self.backupfilename()) | util.rename(self.filename(), self.backupfilename()) | ||||
| def stat(self): | |||||
| return self.vfs.stat(self.fname) | |||||
| class Shelf(object): | class Shelf(object): | ||||
| """Represents a shelf, including possibly multiple files storing it. | """Represents a shelf, including possibly multiple files storing it. | ||||
| Old shelves will have a .patch and a .hg file. Newer shelves will | Old shelves will have a .patch and a .hg file. Newer shelves will | ||||
| also have a .shelve file. This class abstracts away some of the | also have a .shelve file. This class abstracts away some of the | ||||
| differences and lets you work with the shelf as a whole. | differences and lets you work with the shelf as a whole. | ||||
| """ | """ | ||||
| def __init__(self, repo, name): | def __init__(self, repo, name): | ||||
| self.repo = repo | self.repo = repo | ||||
| self.name = name | self.name = name | ||||
| self.vfs = vfsmod.vfs(repo.vfs.join(shelvedir)) | self.vfs = vfsmod.vfs(repo.vfs.join(shelvedir)) | ||||
| def exists(self): | def exists(self): | ||||
| return self.vfs.exists(self.name + b'.' + patchextension) | return self.vfs.exists(self.name + b'.' + patchextension) | ||||
| def mtime(self): | |||||
| return self.vfs.stat(self.name + b'.' + patchextension)[stat.ST_MTIME] | |||||
| def writeinfo(self, info): | def writeinfo(self, info): | ||||
| scmutil.simplekeyvaluefile(self.vfs, self.name + b'.shelve').write(info) | scmutil.simplekeyvaluefile(self.vfs, self.name + b'.shelve').write(info) | ||||
| def readinfo(self): | def readinfo(self): | ||||
| return scmutil.simplekeyvaluefile( | return scmutil.simplekeyvaluefile( | ||||
| self.vfs, self.name + b'.shelve' | self.vfs, self.name + b'.shelve' | ||||
| ).read() | ).read() | ||||
| if err.errno != errno.ENOENT: | if err.errno != errno.ENOENT: | ||||
| raise | raise | ||||
| return [] | return [] | ||||
| info = [] | info = [] | ||||
| for (name, _type) in names: | for (name, _type) in names: | ||||
| pfx, sfx = name.rsplit(b'.', 1) | pfx, sfx = name.rsplit(b'.', 1) | ||||
| if not pfx or sfx != patchextension: | if not pfx or sfx != patchextension: | ||||
| continue | continue | ||||
| st = shelvedfile(repo, name).stat() | mtime = Shelf(repo, pfx).mtime() | ||||
| info.append((st[stat.ST_MTIME], shelvedfile(repo, pfx).filename())) | info.append((mtime, shelvedfile(repo, pfx).filename())) | ||||
| return sorted(info, reverse=True) | return sorted(info, reverse=True) | ||||
| def listcmd(ui, repo, pats, opts): | def listcmd(ui, repo, pats, opts): | ||||
| """subcommand that displays the list of shelves""" | """subcommand that displays the list of shelves""" | ||||
| pats = set(pats) | pats = set(pats) | ||||
| width = 80 | width = 80 | ||||
| if not ui.plain(): | if not ui.plain(): | ||||