Commit Graph

152 Commits

Author SHA1 Message Date
Kostia Balytskyi
85168fc2a2 shelve: move ui.quiet manipulations to configoverride 2017-03-29 05:31:31 -07:00
Kostia Balytskyi
1bf23671ce shelve: add logic to preserve active bookmarks
This adds an explicit active-bookmark-handling logic
to shelve. Traditional shelve handles it by transaction aborts,
but it is a bit ugly and having an explicit functionality
seems better.
2017-03-26 16:51:19 -07:00
Kostia Balytskyi
57c52e7771 shelve: rename stripnodes to nodestoprune
Since we are introducing obs-based shelve, we are no longer
stripping temporary nodes, we are obsoleting them. Therefore
it looks like stipnodes would be a misleading name, while
prune has a connotaion of "strip but with obsolescense", so
nodestoprune seems like a good rename.
2017-03-10 16:18:43 -08:00
Kostia Balytskyi
83f829a40a shelve: add an ability to write key-val data to a new type of shelve files
Obsolescense-based shelve only needs metadata stored in .hg/shelved
and if feels that this metadata should be stored in a
simplekeyvaluefile format for potential extensibility purposes.
I want to avoid storing it in an unstructured text file where
order of lines determines their semantical meanings (as now
happens in .hg/shelvedstate. .hg/rebasestate and I suspect other
state files as well).

Not included in this series, I have ~30 commits, doubling test-shelve.t
in size and testing almost every tested shelve usecase for obs-shelve.
Here's the series for the curious now: http://pastebin.com/tGJKx0vM
I would like to send it to the mailing list and get accepted as well,
but:
1. it's big, so should I send like 6 patches a time or so?
2. instead of having a commit per test case, it more like
   a commit per some amount of copy-pasted code. I tried to keep
   it meaningful and named commits somewhat properly, but it is
   far from this list standards IMO. Any advice on how to get it
   in without turning it into a 100 commits and spending many
   days writing descriptions?
3. it makes test-shelve.t run for twice as long (and it is already
   a slow test). Newest test-shelve.r runs for ~1 minute.
2017-03-10 15:03:09 -08:00
Ryan McElroy
37206f8f83 shelve: use tryunlink 2017-03-21 06:50:28 -07:00
Jun Wu
9ab84eb3ce shelve: get rid of ui.backupconfig 2017-03-16 14:27:41 -07:00
Pierre-Yves David
58d5f4561c shelve: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2017-03-08 16:52:42 -08:00
Mads Kiilerich
30045d0a29 vfs: use repo.vfs.rename 2017-03-11 11:04:14 -08:00
Mads Kiilerich
975c19c195 vfs: use repo.vfs.unlinkpath 2017-03-11 11:02:25 -08:00
Pierre-Yves David
1be66dee7d vfs: use 'vfs' module directly in 'hgext.shelve'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:31:32 +01:00
Pulkit Goyal
fb4eebbc96 pager: add support to --patch, --list and --stat options of hg shelve 2017-02-25 03:42:43 +05:30
liscju
f5ef66440e shelve: add -n/--name option to unshelve (issue5475)
This makes using shelve/unshelve more consistent because
shelving can be done using name option and unshelving as
well. Author of the idea of this improvement and solution is
joshgold.
2017-02-19 10:56:08 +01:00
Kostia Balytskyi
bc104f588e shelve: make unshelve not crash when there are missing files (issue4176)
This patch makes it possible to unshelve while having missing files
in your repo as long as shelved changes don't touch those missing files.
It also makes error message better otherwise.
2017-01-19 09:48:40 -08:00
Pulkit Goyal
d9c78356f5 shelve: allow multiple shelves with --patch and --stat
Before this patch, there was a single way to see multiple shelves using
`--patch --list` which show all the shelves. Doing `--patch s1 s2` returns an
error. This patch allows to show multiple shelves using `--patch` and `--stat`.
2017-01-14 01:23:07 +05:30
Pulkit Goyal
b94e592b62 shelve: choose a legal shelve name when no name is passed (issue5112)
Currently if our branch name contains '\' or starts with '.', shelve chooses
an illegal shelve name. This behaviour is not good as it itself is choosing
something which it won't accept further. We can raise errors if user passes
a name which is illegal.
After this patch, if '\' is contained in branch name or bookmark name, it will
be replaced by '_' while choosing a shelve name and if they starts with '.',
the first '.' is replaced by '_'.
2016-12-22 19:35:30 +05:30
Kostia Balytskyi
9b01b1d353 shelve: move patch extension to a string constant
We are using 'name + ".patch"' pattern throughout the shelve code to
identify the existence of a shelve with a particular name. In two
cases however we use 'name + ".hg"' instead. This commit makes
'patch' be used in all places and "emphasizes" it by moving
'patch' to live in a constant. Also, this allows to extract file
name without extension like this:
    f[:-(1 + len(patchextension))]
instead of:
    f[:-6]
which is good IMO.

This is a first patch from this initial "obsshelve" series. This
series does not include tests, although locally I have all of
test-shelve.t ported to test obs-shelve as well. I will send tests
later as a separate series.
2016-11-29 07:20:03 -08:00
Augie Fackler
f37a723203 merge with stable 2016-11-27 20:44:52 -05:00
Mads Kiilerich
9c5f48e630 shelve: add missing space in help text
The change is trivial and unlikely to have been translated so we update
translation files too.
2016-11-14 22:43:25 +01:00
Kostia Balytskyi
c89c84d317 shelve: make --keep option survive user intervention (issue5431)
Currently if user runs 'hg unshelve --keep' and merge conflicts
occur, the information about --keep provided by user is lost and
shelf is deleted after 'hg unshelve --continue'. This is obviously
not desired, so this patch fixes it.
2016-11-23 14:58:52 -08:00
Kostia Balytskyi
1e0814b20b shelve: move unshelve-finishing logic to a separate function
Finishing unshelve involves two steps now:
- stripping a changelog
- aborting a transaction
Obs-based shelve will not require these things, so isolating this logic
into a separate function where the normal/obs-shelve branching is
going to be implemented seems to be like a nice idea.

Behavior-wise this change moves 'unshelvecleanup' from being between
changelog stripping and transaction abortion to being after them.
I don't think this has any negative effects.
2016-11-11 07:01:27 -08:00
Kostia Balytskyi
ca69665116 shelve: move file-forgetting logic to a separate function
This is just a readability improvement.
2016-11-10 11:02:39 -08:00
Kostia Balytskyi
f2453996da shelve: move rebasing logic to a separate function
Rebasing restored shelved commit onto the right destination is done
differently in traditional and obs-based unshelve:
- for traditional, we just rebase it
- for obs-based, we need to check whether a successor of
  the restored commit already exists in the destination (this
  might happen when unshelving twice on the same destination)
This is the reason why this piece of logic should be in its own
function: to not have excessive complexity in the main function.
2016-11-10 10:57:10 -08:00
Kostia Balytskyi
634c961418 shelve: move commit restoration logic to a separate function 2016-11-10 10:51:06 -08:00
Kostia Balytskyi
6240b21e34 shelve: move temporary commit creation to a separate function
Committing working copy changes before rebasing a shelved commit
on top of them is an independent piece of behavior, which fits
into its own function.

Similar to the previous series, this and a couple of following
patches are for unshelve refactoring.
2016-11-13 03:35:52 -08:00
Augie Fackler
4e1c384d0a extensions: change magic "shipped with hg" string
I've caught multiple extensions in the wild lying about being
'internal', so it's time to move the goalposts on people. Goalpost
moving will continue until third party extensions stop trying to
defeat the system.
2016-08-23 11:26:08 -04:00
Kostia Balytskyi
e27abece5f shelve: make unshelve be able to abort in any case 2016-07-13 16:16:18 +01:00
Mateusz Kwapich
717823e3f5 shelve: use backup functions instead of manually copying dirstate
This increases encapsulation of dirstate: the dirstate file is private
to the dirstate module and shouldn't be touched by extensions directly.
2016-05-24 13:29:53 -07:00
Yuya Nishihara
a5c934df3c py3: move up symbol imports to enforce import-checker rules
Since (b) is banned, we should do the same for (a) for consistency.

 a) from mercurial import hg
    from mercurial.i18n import _

 b) from . import hg
    from .i18n import _
2016-05-14 14:03:12 +09:00
Henning Schild
9ed7d6b8f2 patch: remove unused git parameter from patch.diffstat()
Since 5997ebdd67f0 the parameter is not used anymore.
2016-11-12 13:36:17 +01:00
Kostia Balytskyi
20f84ae643 shelve: move shelve-finishing logic to a separate function
With future obs-based shelve, finishing shelve will be different
from just aborting a transaction and I would like to keep both
variants of this functionality in a separate function.
2016-11-10 03:15:41 -08:00
Kostia Balytskyi
082c8bc2de shelve: move unknown files handling to a separate function
This change has nothing to do with future obsshelve introduction,
it is done just for readability purposes.
2016-11-10 03:20:28 -08:00
Kostia Balytskyi
0796e063c2 shelve: move actual created commit shelving to a separate function
Currently, this code does not have any branching, it just bundles
a commit and saves a patch file. Later, obsolescence-based shelve
will be added, so this code will also create some obsmarkers and
will be one of the few places where obsshelve will be different
from traditional shelve.
2016-11-10 03:07:20 -08:00
Kostia Balytskyi
78a4c1c0bd shelve: move 'nothing changed' messaging to a separate function
This has nothing to do with the future obsshelve implementation, I just
thought that moving this messaging to a separate function will improve
shelve code readability.
2016-11-10 03:33:01 -08:00
Kostia Balytskyi
739f37c1cd shelve: move commitfunc creation to a separate function
Special commitfuncs are created as closures at least twice in shelve's
code and one time special commitfunc is used within another closure.
They all serve very specific purposes like temporarily tweak some
configuration or enable editor, etc. This is not immediately important
to someone reading shelve code, so I think moving this logic to a separate
function is a good idea.
2016-11-10 03:26:31 -08:00
Kostia Balytskyi
406f14ba4a shelve: move mutableancestors to not be a closure
There's no value in it being a closure and everyone who tries to read
the outer function code will be distracted by it. IMO moving it out
significantly improves readability, especially given how clear it is
what mutableancestors function does from its name.
2016-11-10 03:24:07 -08:00
Kostia Balytskyi
3f100ab127 shelve: move shelve name generation to a separate function
This has nothing to do with future obsshelve introduction, done just
for readability purposes.
2016-11-10 03:22:55 -08:00
Kostia Balytskyi
96bd77e21a shelve: move possible shelve file extensions to a single place
This and a couple of following patches are a preparation to
implementing obsolescense-enabled shelve which was discussed
on a Sprint. If this refactoring is not done, shelve is going
to look even more hackish than now.

This particular commit introduces a slight behavior change. Previously,
if only .hg/shelve/name.patch file exists, but .hg/name.hg does not,
'hg shelve -d name' would fail saying "shelve not found". Now deletion
will only fail if .patch file does not exist (since .patch is used
as an indicator of an existing shelve). Other shelve files being absent
are skipped silently to accommodate for future introduction of obs-based
shelve, which will mean that for some shelves .hg and .patch files exist,
while for others .hg and .oshelve.
2016-11-10 03:07:20 -08:00
Oleg Afanasyev
2f8e102f8e shelve: refactor directory name into constant
Shelve directory name extracted into constant to avoid typos/duplication.
2016-04-08 23:33:28 -07:00
Martin von Zweigbergk
4cc86f7b27 bundle: move writebundle() from changegroup.py to bundle2.py (API)
writebundle() writes a bundle2 bundle or a plain changegroup1. Imagine
away the "2" in "bundle2.py" for a moment and this change should makes
sense. The bundle wraps the changegroup, so it makes sense that it
knows about it. Another sign that this is correct is that the delayed
import of bundle2 in changegroup goes away.

I'll leave it for another time to remove the "2" in "bundle2.py"
(alternatively, extract a new bundle.py from it).
2016-03-28 14:41:29 -07:00
liscju
22355da162 shelve: adds restoring newly created branch (issue5048) (BC)
Before this patch shelve never preserved branch information,
so after applying unshelve branch was the same as it was
on working copy no matter in which branch shelve took place.

This patch makes bare shelving(with no files specified, without
interactive,include and exclude option) remembers information if
the working directory was on newly created branch ,in other words
working directory was on different branch than its first parent.
In this situation unshelving restores branch information to the working
directory.
2016-02-10 02:23:27 +01:00
liscju
eefc583bbc shelve: make non bare shelve not saving branch information in bundle
This patch prepares for restoring newly created branch only on
bare shelve later because information about new-branch will be
preserved only when shelve was bare and working copy branch
was different than branch of its parent. In other case information
about new-branch will be gone, so unshelve will not recognise that
shelve was made on new-branch and it will not restore branch
information from the bundle to the working directory.
2016-03-07 22:58:11 +01:00
liscju
251de74ab8 shelve: preserve newly created branch on non-bare shelve in wctx (BC)
Before this patch current branch in working context wasnt preserved
after shelve, this patch makes it restore after update.
2016-03-12 18:36:31 +01:00
liscju
5a50693a7e shelve: changes getting opts values by get method
When shelve is used by another extension that doesn't
provide all necessary values in opts shelve raises
KeyError exception. This patch fixes this by getting
values from opts dictionary with get method.
2016-03-09 08:21:57 +01:00
timeless
067d78e42f shelve: use absolute_import 2016-03-02 21:30:51 +00:00
timeless
9a9c421b30 shelve: suggest the correct tool to continue (not unshelve)
Suggest committing (or whatever the current activity is), via
wrongtooltocontinue which uses howtocontinue.
2016-02-04 03:47:38 +00:00
Martin von Zweigbergk
c28812c552 shelve: use cg3 for treemanifests
Similar to previous change, this teaches shelve to pick the right
changegroup version for repos that use treemanifests.
2016-01-19 15:37:07 -08:00
timeless
8d9186074f shelve: lowercase flag description
The help for --unknown is the *only* command that started with a capital letter
2016-01-21 00:20:19 +00:00
Simon Farnsworth
bbec8fe980 shelve: permit shelves to contain unknown files
If an emergency comes in while you're in the middle of an experimental
change, it can be useful to shelve not just files hg already tracks but
also your unknown files while you handle the emergency. This is
especially true if you have hooks intended to prevent you from
forgetting to add new code before you push.

Teach "hg shelve" to optionally shelve unknown files, not just tracked
files. This is functionally similar to --addremove, but with two
differences:

 1) Deleted files are not removed.
 2) Files added during shelve creation are tracked in extra so that they
    can be forgotten by "hg unshelve".

When unshelving, we take care to only forget files if they've been
created during the unshelve operation; if you add a file that's being
tracked in a shelve as an unknown file, it should not become unknown
again when the shelve is unshelved.
2016-01-14 10:03:31 -08:00
Simon Farnsworth
1d446c79cb shelve: move commitfunc closer to use site
Supporting shelving of unknown files needs this code motion.

No functional changes.
2016-01-14 12:52:59 -08:00
Bryan O'Sullivan
9c8b627124 with: use context manager in unshelveabort 2016-01-15 13:14:50 -08:00