##// END OF EJS Templates
shelve: permit shelves to contain unknown files...
Simon Farnsworth -
r27908:d73a5ab1 default
parent child Browse files
Show More
@@ -301,6 +301,16 b' def _docreatecmd(ui, repo, pats, opts):'
301 if name.startswith('.'):
301 if name.startswith('.'):
302 raise error.Abort(_("shelved change names may not start with '.'"))
302 raise error.Abort(_("shelved change names may not start with '.'"))
303 interactive = opts.get('interactive', False)
303 interactive = opts.get('interactive', False)
304 includeunknown = (opts.get('unknown', False) and
305 not opts.get('addremove', False))
306
307 extra={}
308 if includeunknown:
309 s = repo.status(match=scmutil.match(repo[None], pats, opts),
310 unknown=True)
311 if s.unknown:
312 extra['shelve_unknown'] = '\0'.join(s.unknown)
313 repo[None].add(s.unknown)
304
314
305 def commitfunc(ui, repo, message, match, opts):
315 def commitfunc(ui, repo, message, match, opts):
306 hasmq = util.safehasattr(repo, 'mq')
316 hasmq = util.safehasattr(repo, 'mq')
@@ -312,7 +322,7 b' def _docreatecmd(ui, repo, pats, opts):'
312 editor = cmdutil.getcommiteditor(editform='shelve.shelve',
322 editor = cmdutil.getcommiteditor(editform='shelve.shelve',
313 **opts)
323 **opts)
314 return repo.commit(message, user, opts.get('date'), match,
324 return repo.commit(message, user, opts.get('date'), match,
315 editor=editor)
325 editor=editor, extra=extra)
316 finally:
326 finally:
317 repo.ui.restoreconfig(backup)
327 repo.ui.restoreconfig(backup)
318 if hasmq:
328 if hasmq:
@@ -656,8 +666,10 b' def _dounshelve(ui, repo, *shelved, **op'
656 # and shelvectx is the unshelved changes. Then we merge it all down
666 # and shelvectx is the unshelved changes. Then we merge it all down
657 # to the original pctx.
667 # to the original pctx.
658
668
659 # Store pending changes in a commit
669 # Store pending changes in a commit and remember added in case a shelve
670 # contains unknown files that are part of the pending change
660 s = repo.status()
671 s = repo.status()
672 addedbefore = frozenset(s.added)
661 if s.modified or s.added or s.removed or s.deleted:
673 if s.modified or s.added or s.removed or s.deleted:
662 ui.status(_("temporarily committing pending changes "
674 ui.status(_("temporarily committing pending changes "
663 "(restore with 'hg unshelve --abort')\n"))
675 "(restore with 'hg unshelve --abort')\n"))
@@ -722,6 +734,16 b' def _dounshelve(ui, repo, *shelved, **op'
722 shelvectx = tmpwctx
734 shelvectx = tmpwctx
723
735
724 mergefiles(ui, repo, pctx, shelvectx)
736 mergefiles(ui, repo, pctx, shelvectx)
737
738 # Forget any files that were unknown before the shelve, unknown before
739 # unshelve started, but are now added.
740 shelveunknown = shelvectx.extra().get('shelve_unknown')
741 if shelveunknown:
742 shelveunknown = frozenset(shelveunknown.split('\0'))
743 addedafter = frozenset(repo.status().added)
744 toforget = (addedafter & shelveunknown) - addedbefore
745 repo[None].forget(toforget)
746
725 shelvedstate.clear(repo)
747 shelvedstate.clear(repo)
726
748
727 # The transaction aborting will strip all the commits for us,
749 # The transaction aborting will strip all the commits for us,
@@ -743,6 +765,8 b' def _dounshelve(ui, repo, *shelved, **op'
743 @command('shelve',
765 @command('shelve',
744 [('A', 'addremove', None,
766 [('A', 'addremove', None,
745 _('mark new/missing files as added/removed before shelving')),
767 _('mark new/missing files as added/removed before shelving')),
768 ('u', 'unknown', None,
769 _('Store unknown files in the shelve')),
746 ('', 'cleanup', None,
770 ('', 'cleanup', None,
747 _('delete all shelved changes')),
771 _('delete all shelved changes')),
748 ('', 'date', '',
772 ('', 'date', '',
@@ -793,6 +817,7 b' def shelvecmd(ui, repo, *pats, **opts):'
793 '''
817 '''
794 allowables = [
818 allowables = [
795 ('addremove', set(['create'])), # 'create' is pseudo action
819 ('addremove', set(['create'])), # 'create' is pseudo action
820 ('unknown', set(['create'])),
796 ('cleanup', set(['cleanup'])),
821 ('cleanup', set(['cleanup'])),
797 # ('date', set(['create'])), # ignored for passing '--date "0 0"' in tests
822 # ('date', set(['create'])), # ignored for passing '--date "0 0"' in tests
798 ('delete', set(['delete'])),
823 ('delete', set(['delete'])),
@@ -54,6 +54,7 b' shelve has a help message'
54
54
55 -A --addremove mark new/missing files as added/removed before
55 -A --addremove mark new/missing files as added/removed before
56 shelving
56 shelving
57 -u --unknown Store unknown files in the shelve
57 --cleanup delete all shelved changes
58 --cleanup delete all shelved changes
58 --date DATE shelve with the specified commit date
59 --date DATE shelve with the specified commit date
59 -d --delete delete the named shelved change(s)
60 -d --delete delete the named shelved change(s)
@@ -1245,3 +1246,71 b' Keep active bookmark while (un)shelving '
1245 test 4:33f7f61e6c5e
1246 test 4:33f7f61e6c5e
1246
1247
1247 $ cd ..
1248 $ cd ..
1249
1250 Shelve and unshelve unknown files. For the purposes of unshelve, a shelved
1251 unknown file is the same as a shelved added file, except that it will be in
1252 unknown state after unshelve if and only if it was either absent or unknown
1253 before the unshelve operation.
1254
1255 $ hg init unknowns
1256 $ cd unknowns
1257
1258 The simplest case is if I simply have an unknown file that I shelve and unshelve
1259
1260 $ echo unknown > unknown
1261 $ hg status
1262 ? unknown
1263 $ hg shelve --unknown
1264 shelved as default
1265 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1266 $ hg status
1267 $ hg unshelve
1268 unshelving change 'default'
1269 $ hg status
1270 ? unknown
1271 $ rm unknown
1272
1273 If I shelve, add the file, and unshelve, does it stay added?
1274
1275 $ echo unknown > unknown
1276 $ hg shelve -u
1277 shelved as default
1278 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1279 $ hg status
1280 $ touch unknown
1281 $ hg add unknown
1282 $ hg status
1283 A unknown
1284 $ hg unshelve
1285 unshelving change 'default'
1286 temporarily committing pending changes (restore with 'hg unshelve --abort')
1287 rebasing shelved changes
1288 rebasing 1:098df96e7410 "(changes in empty repository)" (tip)
1289 merging unknown
1290 $ hg status
1291 A unknown
1292 $ hg forget unknown
1293 $ rm unknown
1294
1295 And if I shelve, commit, then unshelve, does it become modified?
1296
1297 $ echo unknown > unknown
1298 $ hg shelve -u
1299 shelved as default
1300 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1301 $ hg status
1302 $ touch unknown
1303 $ hg add unknown
1304 $ hg commit -qm "Add unknown"
1305 $ hg status
1306 $ hg unshelve
1307 unshelving change 'default'
1308 rebasing shelved changes
1309 rebasing 1:098df96e7410 "(changes in empty repository)" (tip)
1310 merging unknown
1311 $ hg status
1312 M unknown
1313 $ hg remove --force unknown
1314 $ hg commit -qm "Remove unknown"
1315
1316 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now