Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/shelve.py (24 lines) | |||
M | tests/test-shelve.t (10 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
ef5bab039326 | dcefb0569f7b | Martin von Zweigbergk | Jan 7 2021, 3:26 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
if suffix in shelvefileextensions: | if suffix in shelvefileextensions: | ||||
shelvedfile(repo, name).movetobackup() | shelvedfile(repo, name).movetobackup() | ||||
cleanupoldbackups(repo) | cleanupoldbackups(repo) | ||||
def deletecmd(ui, repo, pats): | def deletecmd(ui, repo, pats): | ||||
"""subcommand that deletes a specific shelve""" | """subcommand that deletes a specific shelve""" | ||||
if not pats: | if not pats: | ||||
raise error.Abort(_(b'no shelved changes specified!')) | raise error.InputError(_(b'no shelved changes specified!')) | ||||
with repo.wlock(): | with repo.wlock(): | ||||
for name in pats: | for name in pats: | ||||
if not shelvedfile(repo, name, patchextension).exists(): | if not shelvedfile(repo, name, patchextension).exists(): | ||||
raise error.Abort(_(b"shelved change '%s' not found") % name) | raise error.InputError( | ||||
_(b"shelved change '%s' not found") % name | |||||
) | |||||
for suffix in shelvefileextensions: | for suffix in shelvefileextensions: | ||||
shfile = shelvedfile(repo, name, suffix) | shfile = shelvedfile(repo, name, suffix) | ||||
if shfile.exists(): | if shfile.exists(): | ||||
shfile.movetobackup() | shfile.movetobackup() | ||||
cleanupoldbackups(repo) | cleanupoldbackups(repo) | ||||
def listshelves(repo): | def listshelves(repo): | ||||
interactive = opts.get(b'interactive') | interactive = opts.get(b'interactive') | ||||
if not abortf and not continuef: | if not abortf and not continuef: | ||||
cmdutil.checkunfinished(repo) | cmdutil.checkunfinished(repo) | ||||
shelved = list(shelved) | shelved = list(shelved) | ||||
if opts.get(b"name"): | if opts.get(b"name"): | ||||
shelved.append(opts[b"name"]) | shelved.append(opts[b"name"]) | ||||
if interactive and opts.get(b'keep'): | if interactive and opts.get(b'keep'): | ||||
raise error.Abort(_(b'--keep on --interactive is not yet supported')) | raise error.InputError( | ||||
_(b'--keep on --interactive is not yet supported') | |||||
) | |||||
if abortf or continuef: | if abortf or continuef: | ||||
if abortf and continuef: | if abortf and continuef: | ||||
raise error.Abort(_(b'cannot use both abort and continue')) | raise error.InputError(_(b'cannot use both abort and continue')) | ||||
if shelved: | if shelved: | ||||
raise error.Abort( | raise error.InputError( | ||||
_( | _( | ||||
b'cannot combine abort/continue with ' | b'cannot combine abort/continue with ' | ||||
b'naming a shelved change' | b'naming a shelved change' | ||||
) | ) | ||||
) | ) | ||||
if abortf and opts.get(b'tool', False): | if abortf and opts.get(b'tool', False): | ||||
ui.warn(_(b'tool option will be ignored\n')) | ui.warn(_(b'tool option will be ignored\n')) | ||||
state = _loadshelvedstate(ui, repo, opts) | state = _loadshelvedstate(ui, repo, opts) | ||||
if abortf: | if abortf: | ||||
return unshelveabort(ui, repo, state) | return unshelveabort(ui, repo, state) | ||||
elif continuef and interactive: | elif continuef and interactive: | ||||
raise error.Abort(_(b'cannot use both continue and interactive')) | raise error.InputError( | ||||
_(b'cannot use both continue and interactive') | |||||
) | |||||
elif continuef: | elif continuef: | ||||
return unshelvecontinue(ui, repo, state, opts) | return unshelvecontinue(ui, repo, state, opts) | ||||
elif len(shelved) > 1: | elif len(shelved) > 1: | ||||
raise error.Abort(_(b'can only unshelve one change at a time')) | raise error.InputError(_(b'can only unshelve one change at a time')) | ||||
elif not shelved: | elif not shelved: | ||||
shelved = listshelves(repo) | shelved = listshelves(repo) | ||||
if not shelved: | if not shelved: | ||||
raise error.Abort(_(b'no shelved changes to apply!')) | raise error.StateError(_(b'no shelved changes to apply!')) | ||||
basename = util.split(shelved[0][1])[1] | basename = util.split(shelved[0][1])[1] | ||||
ui.status(_(b"unshelving change '%s'\n") % basename) | ui.status(_(b"unshelving change '%s'\n") % basename) | ||||
else: | else: | ||||
basename = shelved[0] | basename = shelved[0] | ||||
if not shelvedfile(repo, basename, patchextension).exists(): | if not shelvedfile(repo, basename, patchextension).exists(): | ||||
raise error.Abort(_(b"shelved change '%s' not found") % basename) | raise error.InputError(_(b"shelved change '%s' not found") % basename) | ||||
return _dounshelve(ui, repo, basename, opts) | return _dounshelve(ui, repo, basename, opts) | ||||
def _dounshelve(ui, repo, basename, opts): | def _dounshelve(ui, repo, basename, opts): | ||||
repo = repo.unfiltered() | repo = repo.unfiltered() | ||||
lock = tr = None | lock = tr = None | ||||
try: | try: |
default-1.patch | default-1.patch | ||||
default-1.shelve | default-1.shelve | ||||
default.hg | default.hg | ||||
default.patch | default.patch | ||||
default.shelve | default.shelve | ||||
$ hg unshelve | $ hg unshelve | ||||
abort: no shelved changes to apply! | abort: no shelved changes to apply! | ||||
[255] | [20] | ||||
$ hg unshelve foo | $ hg unshelve foo | ||||
abort: shelved change 'foo' not found | abort: shelved change 'foo' not found | ||||
[255] | [10] | ||||
named shelves, specific filenames, and "commit messages" should all work | named shelves, specific filenames, and "commit messages" should all work | ||||
(this tests also that editor is invoked, if '--edit' is specified) | (this tests also that editor is invoked, if '--edit' is specified) | ||||
$ hg status -C | $ hg status -C | ||||
M a/a | M a/a | ||||
A b.rename/b | A b.rename/b | ||||
b/b | b/b | ||||
+babar | +babar | ||||
Test shelve --delete | Test shelve --delete | ||||
$ hg shelve --list | $ hg shelve --list | ||||
default (*s ago) changes to: create conflict (glob) | default (*s ago) changes to: create conflict (glob) | ||||
$ hg shelve --delete doesnotexist | $ hg shelve --delete doesnotexist | ||||
abort: shelved change 'doesnotexist' not found | abort: shelved change 'doesnotexist' not found | ||||
[255] | [10] | ||||
$ hg shelve --delete default | $ hg shelve --delete default | ||||
$ cd .. | $ cd .. | ||||
Test visibility of in-memory changes inside transaction to external hook | Test visibility of in-memory changes inside transaction to external hook | ||||
------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ||||
$ cd repo | $ cd repo | ||||
> EOF | > EOF | ||||
$ hg resolve -m bar1 bar2 | $ hg resolve -m bar1 bar2 | ||||
(no more unresolved files) | (no more unresolved files) | ||||
continue: hg unshelve --continue | continue: hg unshelve --continue | ||||
-- using --continue with --interactive should throw an error | -- using --continue with --interactive should throw an error | ||||
$ hg unshelve --continue -i | $ hg unshelve --continue -i | ||||
abort: cannot use both continue and interactive | abort: cannot use both continue and interactive | ||||
[255] | [10] | ||||
$ cat bar1 | $ cat bar1 | ||||
A | A | ||||
B | B | ||||
C | C | ||||
#if stripbased | #if stripbased | ||||
$ hg log -r 3:: -G | $ hg log -r 3:: -G | ||||
+B | +B | ||||
C | C | ||||
record this change to 'bar2'? | record this change to 'bar2'? | ||||
(enter ? for help) [Ynesfdaq?] y | (enter ? for help) [Ynesfdaq?] y | ||||
-- test for --interactive --keep | -- test for --interactive --keep | ||||
$ hg unshelve -i --keep | $ hg unshelve -i --keep | ||||
abort: --keep on --interactive is not yet supported | abort: --keep on --interactive is not yet supported | ||||
[255] | [10] |