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 (49 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 |
Handles common functions on shelve files (.hg/.patch) using | Handles common functions on shelve files (.hg/.patch) using | ||||
the vfs layer""" | the vfs layer""" | ||||
def __init__(self, repo, name, filetype=None): | def __init__(self, repo, name, filetype=None): | ||||
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)) | ||||
self.backupvfs = vfsmod.vfs(repo.vfs.join(backupdir)) | self.backupvfs = vfsmod.vfs(repo.vfs.join(backupdir)) | ||||
self.ui = self.repo.ui | |||||
if filetype: | if filetype: | ||||
self.fname = name + b'.' + filetype | self.fname = name + b'.' + filetype | ||||
else: | else: | ||||
self.fname = name | self.fname = name | ||||
def exists(self): | def exists(self): | ||||
return self.vfs.exists(self.fname) | return self.vfs.exists(self.fname) | ||||
shelvectx = self.repo[b'tip'] | shelvectx = self.repo[b'tip'] | ||||
if pretip == shelvectx: | if pretip == shelvectx: | ||||
shelverev = tr.changes[b'revduplicates'][-1] | shelverev = tr.changes[b'revduplicates'][-1] | ||||
shelvectx = self.repo[shelverev] | shelvectx = self.repo[shelverev] | ||||
return shelvectx | return shelvectx | ||||
finally: | finally: | ||||
fp.close() | fp.close() | ||||
def writebundle(self, bases, node): | |||||
cgversion = changegroup.safeversion(self.repo) | |||||
if cgversion == b'01': | |||||
btype = b'HG10BZ' | |||||
compression = None | |||||
else: | |||||
btype = b'HG20' | |||||
compression = b'BZ' | |||||
repo = self.repo.unfiltered() | |||||
outgoing = discovery.outgoing( | |||||
repo, missingroots=bases, ancestorsof=[node] | |||||
) | |||||
cg = changegroup.makechangegroup(repo, outgoing, cgversion, b'shelve') | |||||
bundle2.writebundle( | |||||
self.ui, cg, self.fname, btype, self.vfs, compression=compression | |||||
) | |||||
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 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() | ||||
def writebundle(self, bases, node): | |||||
cgversion = changegroup.safeversion(self.repo) | |||||
if cgversion == b'01': | |||||
btype = b'HG10BZ' | |||||
compression = None | |||||
else: | |||||
btype = b'HG20' | |||||
compression = b'BZ' | |||||
repo = self.repo.unfiltered() | |||||
outgoing = discovery.outgoing( | |||||
repo, missingroots=bases, ancestorsof=[node] | |||||
) | |||||
cg = changegroup.makechangegroup(repo, outgoing, cgversion, b'shelve') | |||||
bundle_filename = self.vfs.join(self.name + b'.hg') | |||||
bundle2.writebundle( | |||||
self.repo.ui, | |||||
cg, | |||||
bundle_filename, | |||||
btype, | |||||
self.vfs, | |||||
compression=compression, | |||||
) | |||||
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. | ||||
""" | """ | ||||
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)} | ||||
Shelf(repo, name).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) | Shelf(repo, name).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 | ||||
) | ) | ||||
def _includeunknownfiles(repo, pats, opts, extra): | def _includeunknownfiles(repo, pats, opts, extra): | ||||
s = repo.status(match=scmutil.match(repo[None], pats, opts), unknown=True) | s = repo.status(match=scmutil.match(repo[None], pats, opts), unknown=True) |