Show More
@@ -80,7 +80,6 b' class shelvedfile(object):' | |||||
80 | the vfs layer""" |
|
80 | the vfs layer""" | |
81 |
|
81 | |||
82 | def __init__(self, repo, name, filetype=None): |
|
82 | def __init__(self, repo, name, filetype=None): | |
83 | self.repo = repo |
|
|||
84 | self.name = name |
|
83 | self.name = name | |
85 | self.vfs = vfsmod.vfs(repo.vfs.join(shelvedir)) |
|
84 | self.vfs = vfsmod.vfs(repo.vfs.join(shelvedir)) | |
86 | self.backupvfs = vfsmod.vfs(repo.vfs.join(backupdir)) |
|
85 | self.backupvfs = vfsmod.vfs(repo.vfs.join(backupdir)) | |
@@ -118,30 +117,6 b' class shelvedfile(object):' | |||||
118 | def opener(self, mode=b'rb'): |
|
117 | def opener(self, mode=b'rb'): | |
119 | return self.vfs(self.fname, mode) |
|
118 | return self.vfs(self.fname, mode) | |
120 |
|
119 | |||
121 | def applybundle(self, tr): |
|
|||
122 | fp = self.opener() |
|
|||
123 | try: |
|
|||
124 | targetphase = phases.internal |
|
|||
125 | if not phases.supportinternal(self.repo): |
|
|||
126 | targetphase = phases.secret |
|
|||
127 | gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs) |
|
|||
128 | pretip = self.repo[b'tip'] |
|
|||
129 | bundle2.applybundle( |
|
|||
130 | self.repo, |
|
|||
131 | gen, |
|
|||
132 | tr, |
|
|||
133 | source=b'unshelve', |
|
|||
134 | url=b'bundle:' + self.vfs.join(self.fname), |
|
|||
135 | targetphase=targetphase, |
|
|||
136 | ) |
|
|||
137 | shelvectx = self.repo[b'tip'] |
|
|||
138 | if pretip == shelvectx: |
|
|||
139 | shelverev = tr.changes[b'revduplicates'][-1] |
|
|||
140 | shelvectx = self.repo[shelverev] |
|
|||
141 | return shelvectx |
|
|||
142 | finally: |
|
|||
143 | fp.close() |
|
|||
144 |
|
||||
145 |
|
120 | |||
146 | class Shelf(object): |
|
121 | class Shelf(object): | |
147 | """Represents a shelf, including possibly multiple files storing it. |
|
122 | """Represents a shelf, including possibly multiple files storing it. | |
@@ -193,6 +168,31 b' class Shelf(object):' | |||||
193 | compression=compression, |
|
168 | compression=compression, | |
194 | ) |
|
169 | ) | |
195 |
|
170 | |||
|
171 | def applybundle(self, tr): | |||
|
172 | filename = self.name + b'.hg' | |||
|
173 | fp = self.vfs(filename) | |||
|
174 | try: | |||
|
175 | targetphase = phases.internal | |||
|
176 | if not phases.supportinternal(self.repo): | |||
|
177 | targetphase = phases.secret | |||
|
178 | gen = exchange.readbundle(self.repo.ui, fp, filename, self.vfs) | |||
|
179 | pretip = self.repo[b'tip'] | |||
|
180 | bundle2.applybundle( | |||
|
181 | self.repo, | |||
|
182 | gen, | |||
|
183 | tr, | |||
|
184 | source=b'unshelve', | |||
|
185 | url=b'bundle:' + self.vfs.join(filename), | |||
|
186 | targetphase=targetphase, | |||
|
187 | ) | |||
|
188 | shelvectx = self.repo[b'tip'] | |||
|
189 | if pretip == shelvectx: | |||
|
190 | shelverev = tr.changes[b'revduplicates'][-1] | |||
|
191 | shelvectx = self.repo[shelverev] | |||
|
192 | return shelvectx | |||
|
193 | finally: | |||
|
194 | fp.close() | |||
|
195 | ||||
196 |
|
196 | |||
197 | class shelvedstate(object): |
|
197 | class shelvedstate(object): | |
198 | """Handle persistence during unshelving operations. |
|
198 | """Handle persistence during unshelving operations. | |
@@ -904,7 +904,7 b' def _unshelverestorecommit(ui, repo, tr,' | |||||
904 | node = Shelf(repo, basename).readinfo()[b'node'] |
|
904 | node = Shelf(repo, basename).readinfo()[b'node'] | |
905 | if node is None or node not in repo: |
|
905 | if node is None or node not in repo: | |
906 | with ui.configoverride({(b'ui', b'quiet'): True}): |
|
906 | with ui.configoverride({(b'ui', b'quiet'): True}): | |
907 |
shelvectx = |
|
907 | shelvectx = Shelf(repo, basename).applybundle(tr) | |
908 | # We might not strip the unbundled changeset, so we should keep track of |
|
908 | # We might not strip the unbundled changeset, so we should keep track of | |
909 | # the unshelve node in case we need to reuse it (eg: unshelve --keep) |
|
909 | # the unshelve node in case we need to reuse it (eg: unshelve --keep) | |
910 | if node is None: |
|
910 | if node is None: |
General Comments 0
You need to be logged in to leave comments.
Login now