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 writeinfo(self, info): | |||||
| scmutil.simplekeyvaluefile(self.vfs, self.fname).write(info) | |||||
| def readinfo(self): | def readinfo(self): | ||||
| return scmutil.simplekeyvaluefile(self.vfs, self.fname).read() | 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): | |||||
| scmutil.simplekeyvaluefile(self.vfs, self.name + b'.shelve').write(info) | |||||
| 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. | ||||
| """ | """ | ||||
| % len(stat.deleted) | % len(stat.deleted) | ||||
| ) | ) | ||||
| else: | else: | ||||
| ui.status(_(b"nothing changed\n")) | ui.status(_(b"nothing changed\n")) | ||||
| def _shelvecreatedcommit(repo, node, name, match): | def _shelvecreatedcommit(repo, node, name, match): | ||||
| info = {b'node': hex(node)} | info = {b'node': hex(node)} | ||||
| shelvedfile(repo, name, b'shelve').writeinfo(info) | Shelf(repo, name).writeinfo(info) | ||||
| bases = list(mutableancestors(repo[node])) | bases = list(mutableancestors(repo[node])) | ||||
| shelvedfile(repo, name, b'hg').writebundle(bases, node) | shelvedfile(repo, name, b'hg').writebundle(bases, node) | ||||
| with shelvedfile(repo, name, patchextension).opener(b'wb') as fp: | with shelvedfile(repo, name, patchextension).opener(b'wb') as fp: | ||||
| cmdutil.exportfile( | cmdutil.exportfile( | ||||
| repo, [node], fp, opts=mdiff.diffopts(git=True), match=match | repo, [node], fp, opts=mdiff.diffopts(git=True), match=match | ||||
| ) | ) | ||||
| node = shelvedfile(repo, basename, b'shelve').readinfo()[b'node'] | node = shelvedfile(repo, basename, b'shelve').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())} | ||||
| shelvedfile(repo, basename, b'shelve').writeinfo(info) | Shelf(repo, basename).writeinfo(info) | ||||
| else: | else: | ||||
| shelvectx = repo[node] | shelvectx = repo[node] | ||||
| return repo, shelvectx | return repo, shelvectx | ||||
| def _createunshelvectx(ui, repo, shelvectx, basename, interactive, opts): | def _createunshelvectx(ui, repo, shelvectx, basename, interactive, opts): | ||||
| """Handles the creation of unshelve commit and updates the shelve if it | """Handles the creation of unshelve commit and updates the shelve if it | ||||