Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
( )
| Automatic diff as part of commit; lint not applicable. |
| Automatic diff as part of commit; unit tests not applicable. |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/shelve.py (10 lines) |
| 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 |
| repo, missingroots=bases, ancestorsof=[node] | repo, missingroots=bases, ancestorsof=[node] | ||||
| ) | ) | ||||
| cg = changegroup.makechangegroup(repo, outgoing, cgversion, b'shelve') | cg = changegroup.makechangegroup(repo, outgoing, cgversion, b'shelve') | ||||
| bundle2.writebundle( | bundle2.writebundle( | ||||
| self.ui, cg, self.fname, btype, self.vfs, compression=compression | self.ui, cg, self.fname, btype, self.vfs, compression=compression | ||||
| ) | ) | ||||
| def readinfo(self): | |||||
| return scmutil.simplekeyvaluefile(self.vfs, self.fname).read() | |||||
| 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 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): | |||||
| return scmutil.simplekeyvaluefile( | |||||
| self.vfs, self.name + b'.shelve' | |||||
| ).read() | |||||
| class shelvedstate(object): | class shelvedstate(object): | ||||
| """Handle persistence during unshelving operations. | """Handle persistence during unshelving operations. | ||||
| Handles saving and restoring a shelved state. Ensures that different | Handles saving and restoring a shelved state. Ensures that different | ||||
| versions of a shelved state are possible and handles them appropriately. | versions of a shelved state are possible and handles them appropriately. | ||||
| """ | """ | ||||
| return tmpwctx, addedbefore | return tmpwctx, addedbefore | ||||
| def _unshelverestorecommit(ui, repo, tr, basename): | def _unshelverestorecommit(ui, repo, tr, basename): | ||||
| """Recreate commit in the repository during the unshelve""" | """Recreate commit in the repository during the unshelve""" | ||||
| repo = repo.unfiltered() | repo = repo.unfiltered() | ||||
| node = None | node = None | ||||
| if shelvedfile(repo, basename, b'shelve').exists(): | if shelvedfile(repo, basename, b'shelve').exists(): | ||||
| node = shelvedfile(repo, basename, b'shelve').readinfo()[b'node'] | node = Shelf(repo, basename).readinfo()[b'node'] | ||||
| if node is None or node not in repo: | if node is None or node not in repo: | ||||
| with ui.configoverride({(b'ui', b'quiet'): True}): | with ui.configoverride({(b'ui', b'quiet'): True}): | ||||
| shelvectx = shelvedfile(repo, basename, b'hg').applybundle(tr) | shelvectx = shelvedfile(repo, basename, b'hg').applybundle(tr) | ||||
| # We might not strip the unbundled changeset, so we should keep track of | # We might not strip the unbundled changeset, so we should keep track of | ||||
| # the unshelve node in case we need to reuse it (eg: unshelve --keep) | # the unshelve node in case we need to reuse it (eg: unshelve --keep) | ||||
| if node is None: | if node is None: | ||||
| info = {b'node': hex(shelvectx.node())} | info = {b'node': hex(shelvectx.node())} | ||||
| Shelf(repo, basename).writeinfo(info) | Shelf(repo, basename).writeinfo(info) | ||||