##// END OF EJS Templates
shelve: make --keep option survive user intervention (issue5431)...
Kostia Balytskyi -
r30522:7b3136bc default
parent child Browse files
Show More
@@ -159,6 +159,8 b' class shelvedstate(object):'
159 """
159 """
160 _version = 1
160 _version = 1
161 _filename = 'shelvedstate'
161 _filename = 'shelvedstate'
162 _keep = 'keep'
163 _nokeep = 'nokeep'
162
164
163 @classmethod
165 @classmethod
164 def load(cls, repo):
166 def load(cls, repo):
@@ -175,6 +177,7 b' class shelvedstate(object):'
175 parents = [nodemod.bin(h) for h in fp.readline().split()]
177 parents = [nodemod.bin(h) for h in fp.readline().split()]
176 stripnodes = [nodemod.bin(h) for h in fp.readline().split()]
178 stripnodes = [nodemod.bin(h) for h in fp.readline().split()]
177 branchtorestore = fp.readline().strip()
179 branchtorestore = fp.readline().strip()
180 keep = fp.readline().strip() == cls._keep
178 except (ValueError, TypeError) as err:
181 except (ValueError, TypeError) as err:
179 raise error.CorruptedState(str(err))
182 raise error.CorruptedState(str(err))
180 finally:
183 finally:
@@ -188,6 +191,7 b' class shelvedstate(object):'
188 obj.parents = parents
191 obj.parents = parents
189 obj.stripnodes = stripnodes
192 obj.stripnodes = stripnodes
190 obj.branchtorestore = branchtorestore
193 obj.branchtorestore = branchtorestore
194 obj.keep = keep
191 except error.RepoLookupError as err:
195 except error.RepoLookupError as err:
192 raise error.CorruptedState(str(err))
196 raise error.CorruptedState(str(err))
193
197
@@ -195,7 +199,7 b' class shelvedstate(object):'
195
199
196 @classmethod
200 @classmethod
197 def save(cls, repo, name, originalwctx, pendingctx, stripnodes,
201 def save(cls, repo, name, originalwctx, pendingctx, stripnodes,
198 branchtorestore):
202 branchtorestore, keep=False):
199 fp = repo.vfs(cls._filename, 'wb')
203 fp = repo.vfs(cls._filename, 'wb')
200 fp.write('%i\n' % cls._version)
204 fp.write('%i\n' % cls._version)
201 fp.write('%s\n' % name)
205 fp.write('%s\n' % name)
@@ -206,6 +210,7 b' class shelvedstate(object):'
206 fp.write('%s\n' %
210 fp.write('%s\n' %
207 ' '.join([nodemod.hex(n) for n in stripnodes]))
211 ' '.join([nodemod.hex(n) for n in stripnodes]))
208 fp.write('%s\n' % branchtorestore)
212 fp.write('%s\n' % branchtorestore)
213 fp.write('%s\n' % (cls._keep if keep else cls._nokeep))
209 fp.close()
214 fp.close()
210
215
211 @classmethod
216 @classmethod
@@ -680,7 +685,7 b' def _rebaserestoredcommit(ui, repo, opts'
680 stripnodes = [repo.changelog.node(rev)
685 stripnodes = [repo.changelog.node(rev)
681 for rev in xrange(oldtiprev, len(repo))]
686 for rev in xrange(oldtiprev, len(repo))]
682 shelvedstate.save(repo, basename, pctx, tmpwctx, stripnodes,
687 shelvedstate.save(repo, basename, pctx, tmpwctx, stripnodes,
683 branchtorestore)
688 branchtorestore, opts.get('keep'))
684
689
685 util.rename(repo.join('rebasestate'),
690 util.rename(repo.join('rebasestate'),
686 repo.join('unshelverebasestate'))
691 repo.join('unshelverebasestate'))
@@ -782,6 +787,8 b' def _dounshelve(ui, repo, *shelved, **op'
782
787
783 try:
788 try:
784 state = shelvedstate.load(repo)
789 state = shelvedstate.load(repo)
790 if opts.get('keep') is None:
791 opts['keep'] = state.keep
785 except IOError as err:
792 except IOError as err:
786 if err.errno != errno.ENOENT:
793 if err.errno != errno.ENOENT:
787 raise
794 raise
@@ -1622,3 +1622,31 b' progress'
1622 abort: no unshelve in progress
1622 abort: no unshelve in progress
1623 [255]
1623 [255]
1624 $ cd ..
1624 $ cd ..
1625
1626 Unshelve respects --keep even if user intervention is needed
1627 $ hg init unshelvekeep
1628 $ echo 1 > file && hg ci -Am 1
1629 adding file
1630 $ echo 2 >> file
1631 $ hg shelve
1632 shelved as default
1633 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1634 $ echo 3 >> file && hg ci -Am 13
1635 $ hg shelve --list
1636 default (1s ago) changes to: 1
1637 $ hg unshelve --keep
1638 unshelving change 'default'
1639 rebasing shelved changes
1640 rebasing 3:1d24e58054c8 "changes to: 1" (tip)
1641 merging file
1642 warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
1643 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
1644 [1]
1645 $ hg resolve --mark file
1646 (no more unresolved files)
1647 continue: hg unshelve --continue
1648 $ hg unshelve --continue
1649 rebasing 3:1d24e58054c8 "changes to: 1" (tip)
1650 unshelve of 'default' complete
1651 $ hg shelve --list
1652 default (1s ago) changes to: 1
General Comments 0
You need to be logged in to leave comments. Login now