comparison hgext/shelve.py @ 39889:d9ba836fc234

shelve: find shelvedctx from bundle even if they are already in the repo We use the new "duplicates" node tracking to find the tip of the bundle even if it already exists in the repository. Such logic is not supposed to be needed in theory. If the shelve was made using internal-phase, we already know its node. Otherwise, the bundle content should have been stripped. However, handling it makes the shelve code more robust and provide a good example of "revduplicates" usage.
author Boris Feld <boris.feld@octobus.net>
date Thu, 20 Sep 2018 17:47:05 +0200
parents 42a6b228dd2e
children e2697acd9381
comparison
equal deleted inserted replaced
39888:42a6b228dd2e 39889:d9ba836fc234
142 try: 142 try:
143 targetphase = phases.internal 143 targetphase = phases.internal
144 if not phases.supportinternal(self.repo): 144 if not phases.supportinternal(self.repo):
145 targetphase = phases.secret 145 targetphase = phases.secret
146 gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs) 146 gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs)
147 bundle2.applybundle(self.repo, gen, self.repo.currenttransaction(), 147 pretip = self.repo['tip']
148 tr = self.repo.currenttransaction()
149 bundle2.applybundle(self.repo, gen, tr,
148 source='unshelve', 150 source='unshelve',
149 url='bundle:' + self.vfs.join(self.fname), 151 url='bundle:' + self.vfs.join(self.fname),
150 targetphase=targetphase) 152 targetphase=targetphase)
151 return self.repo['tip'] 153 shelvectx = self.repo['tip']
154 if pretip == shelvectx:
155 shelverev = tr.changes['revduplicates'][-1]
156 shelvectx = self.repo[shelverev]
157 return shelvectx
152 finally: 158 finally:
153 fp.close() 159 fp.close()
154 160
155 def bundlerepo(self): 161 def bundlerepo(self):
156 path = self.vfs.join(self.fname) 162 path = self.vfs.join(self.fname)