##// END OF EJS Templates
shelve: teach new shelf class to check if .shelve file exists...
Martin von Zweigbergk -
r47004:3b08f56c default
parent child Browse files
Show More
@@ -72,24 +72,6 b" patchextension = b'patch'"
72 shelveuser = b'shelve@localhost'
72 shelveuser = b'shelve@localhost'
73
73
74
74
75 class shelvedfile(object):
76 """Helper for the file storing a single shelve
77
78 Handles common functions on shelve files (.hg/.patch) using
79 the vfs layer"""
80
81 def __init__(self, repo, name, filetype=None):
82 self.name = name
83 self.vfs = vfsmod.vfs(repo.vfs.join(shelvedir))
84 if filetype:
85 self.fname = name + b'.' + filetype
86 else:
87 self.fname = name
88
89 def exists(self):
90 return self.vfs.exists(self.fname)
91
92
93 class Shelf(object):
75 class Shelf(object):
94 """Represents a shelf, including possibly multiple files storing it.
76 """Represents a shelf, including possibly multiple files storing it.
95
77
@@ -113,6 +95,9 b' class Shelf(object):'
113 def writeinfo(self, info):
95 def writeinfo(self, info):
114 scmutil.simplekeyvaluefile(self.vfs, self.name + b'.shelve').write(info)
96 scmutil.simplekeyvaluefile(self.vfs, self.name + b'.shelve').write(info)
115
97
98 def hasinfo(self):
99 return self.vfs.exists(self.name + b'.shelve')
100
116 def readinfo(self):
101 def readinfo(self):
117 return scmutil.simplekeyvaluefile(
102 return scmutil.simplekeyvaluefile(
118 self.vfs, self.name + b'.shelve'
103 self.vfs, self.name + b'.shelve'
@@ -890,7 +875,7 b' def _unshelverestorecommit(ui, repo, tr,'
890 """Recreate commit in the repository during the unshelve"""
875 """Recreate commit in the repository during the unshelve"""
891 repo = repo.unfiltered()
876 repo = repo.unfiltered()
892 node = None
877 node = None
893 if shelvedfile(repo, basename, b'shelve').exists():
878 if Shelf(repo, basename).hasinfo():
894 node = Shelf(repo, basename).readinfo()[b'node']
879 node = Shelf(repo, basename).readinfo()[b'node']
895 if node is None or node not in repo:
880 if node is None or node not in repo:
896 with ui.configoverride({(b'ui', b'quiet'): True}):
881 with ui.configoverride({(b'ui', b'quiet'): True}):
General Comments 0
You need to be logged in to leave comments. Login now