Commit Graph

264 Commits

Author SHA1 Message Date
Pierre-Yves David
271a03e73f subrepo: allows to drop courtesy phase sync (issue3781)
Publishing server may contains draft changeset when they are created locally. As
publishing is the default, it is actually fairly common. Because of this
"inconsistency" phases synchronization may be done even to publishing server.

This may cause severe issues for subrepo. It is possible to reference read-only
repository as subrepo. Push in a super repo recursively push subrepo. Those
pushes to potential read only repo are not optional, they are "suffered" not
"choosed". This does not break because as the repo is untouched the push is
supposed to be empty. If the reference repo locally contains draft changesets, a
courtesy push is triggered to turn them public. As the repo is read only, the
push fails (after possible prompt asking for credential). Failure of the
sub-push aborts the whole subrepo push. This force the user to define a custom
default-push for such subrepo.

This changeset introduce a prevention of this error client side by skipping the
courtesy phase synchronisation in problematic situation. The phases
synchronisation is skipped when four conditions are gathered:
- this is a subrepo push, (normal push to read-only repo)
- and remote support phase
- and remote is publishing
- and no changesets was pushed (if we pushed changesets, repo is not read only)

The internal config option used in this version is not definitive. It is here to
demonstrate a working fix to the issue.

In the future we probably wants to track subrepo changes and avoid pushing to
untouched one. That will prevent any attempt to push to read-only or unreachable
subrepo.

Another fix to prevent courtesy push from older clients to push to newer server
is also still needed.
2013-01-31 01:44:29 +01:00
Matt Harbison
90844b4729 subrepo: use sharepath if available when locating the source repo
This is an alternative fix for issue3518, enabling sharing of repositories with
subrepos, without unconditionally setting the default path in the resulting
repo's hgrc file.  Better test coverage is added here, but won't prove this code
is working until f48752441ca0 is backed out.

The problem with the original fix is, if a default path is not available to be
copied over from the share source, the default path on the resulting repo is set
to the source location.  Since that's where the actual repository is stored, the
path is essentially self-referential, so push, pull, incoming and outgoing
effectively operate on itself.  While incoming and outgoing make it look like
nothing was changed, push currently hangs (see issue3657).  In this case where
there is not a real default path, these operations should abort with
"default(-push) not found", like the source repo would.  Note this problem with
the original fix affected repos without subrepos too.
2012-11-27 20:56:27 -05:00
Mads Kiilerich
2d6545f8b6 subrepos: process subrepos in sorted order
Add sorted() in places found by testing with PYTHONHASHSEED=random and code
inspection.

An alternative to sprinkling sorted() all over would be to change substate to a
custom dict with sorted iterators...
2012-12-12 02:38:14 +01:00
Angel Ezquerra
e70892baf4 subrepo: make 'in subrepo' string easier to find by external tools
This patch is meant to make it easier for tools that wrap the mercurial
output (such as TortoiseHg) to find the "in subrepo MYSUBREPO" string that
(since 6c419dfc848c) is appended after subrepo error messages, particularly when
the mercurial output is translated to a non-English language.

The message remains the same but the '%s' that was used to prepend the original
error message in front of the 'in subrepo' string has been moved out of the
translatable string.

As an example of the usefulness of making it easy to look for "in subrepo
MYSUBREPO" strings, TortoiseHg looks for these strings in error messages in
order to "linkify them" (i.e. convert "MYSUBREPO" into alink to the
corresponding subrepo).

The original string made it hard for a tool such as TortoiseHg to look for the
translated string on mercurial's output because the translated string contained
the error message itself. This meant that a regular expression was required to
ignore the error message part. With this change TortoiseHg can just get the
translated "(in subrepo %s)" string, substitute %s for the subrepo path (which
it gets from the subrepo exception) and simply search for the resulting string
(no regular expression needed, or at least a much simpler regular expression
could be used).

Additionaly, the existing string could lead a translator mistakenly assume that
it was possible invert the order of the %s (error and subrepo path) fields,
which would not work because the string interpolation was position based.
2013-01-03 17:42:25 +01:00
Brendan Cully
31cab25274 subrepo: fix python2.4 compatibility after e9ad4d8804d3
super(SubrepoAbort, self).__init__(*args, **kw) raises
  TypeError: super() argument 1 must be type, not classobj
2013-01-10 10:35:37 -08:00
Angel Ezquerra
58223810c5 subrepo: add subrepo property to SubrepoAbort exceptions
This new property contains the path of the subrepo that generated the exception.
This information can then be used by GUI tools such as TortoiseHg.
2013-01-03 17:35:58 +01:00
Angel Ezquerra
586f53ce9d subrepo: append subrepo path to subrepo error messages
This change appends the subrepo path to subrepo errors. That is, when there
is an error performing an operation a subrepo, rather than displaying a message
such as:

pushing subrepo MYSUBREPO to PATH
searching for changes
abort: push creates new remote head HEADHASH!
hint: did you forget to merge? use push -f to force

mercurial will show:

pushing subrepo MYSUBREPO to PATH
searching for changes
abort: push creates new remote head HEADHASH! (in subrepo MYSUBREPO)
hint: did you forget to merge? use push -f to force

The rationale for this change is that the current error messages make it hard
for TortoiseHg (and similar tools) to tell the user which subrepo caused the
push failure.

The "(in subrepo MYSUBREPO)" message has been added to those subrepo methods
were it made sense (by using a decorator). We avoid appending "(in subrepo XXX)"
multiple times when subrepos are nexted by throwing a "SubrepoAbort" exception
after the extra message is appended. The decorator will then "ignore" (i.e. just
re-raise) the exception and never add the message again.

A small drawback of this method is that part of the exception trace is lost when
the exception is catched and re-raised by the annotatesubrepoerror decorator.

Also, because the state() function already printed the subrepo path when it
threw an error, that error has been changed to avoid duplicating the subrepo
path in the error message.

Note that I have also updated several subrepo related tests to reflect these
changes.
2012-12-13 23:37:53 +01:00
Kevin Bullock
e8ece086e3 merge with stable 2012-12-04 11:19:32 -06:00
FUJIWARA Katsunori
b81a7802fd subrepo: add argument to "diff()" to pass "ui" of caller side (issue3712) (API)
Color extension achieves colorization by overriding the class of
"ui" object just before command execution.

Before this patch, "diff()" of abstractsubrepo and classes
derived from it has no "ui" argument, so "diff()" of hgsubrepo
uses "self._repo.ui" to invoke "cmdutil.diffordiffstat()".

For separation of configuration between repositories, revision
1498948ee815 changed the initialization source of "self._repo.ui"
from "ui"(overridden) to "baseui"(plain) of parent repository.
And this caused break of colorization.

This patch adds "ui" argument to "diff()" of abstractsubrepo and
classes derived from it to pass "ui" object of caller side.
2012-11-30 00:43:55 +09:00
Simon Heimberg
b731b379ec subrepo: only do clean update when overwrite is set (issue3276)
Files in a subrepo were overwritten on update. But this should only happen on a
clean update (example: -C is specified).
Use the overwrite parameter introduced for svn subrepos in e3640daa4703 to
decide whether to merge changes (as update) or remove them (as clean).

The new function hg.updaterepo is intruduced to keep all update calls in hg.

test-subrepo.t is extended to test if an untracked file is overwritten
(issue3276). (Update -C is already tested in many places.)
The first two chunks are debugging output which has changed. (Because overwrite
is not always true anymore for subrepos)
All other tests still pass without any change.
2012-10-24 18:45:22 +02:00
Simon Heimberg
57e96e0b1f subrepo: subrepo isolation, pass baseui when cloning a new subrepo (issue2904)
Create the repo with baseui because it should only get the global configuration.

After this patch issue2904 is finally fixed.
2012-10-10 01:18:06 +02:00
Bryan O'Sullivan
0dc2115da0 subrepo: use posixpath when diffing, for consistent paths
This fixes a Windows failure in test-subrepo-recursion.t introduced
by c9345d017402.
2012-11-27 14:58:00 -08:00
Simon Heimberg
6523213f0e peer: subrepo isolation, pass repo instead of repo.ui to hg.peer
Do not pass ui because it contains the configuration of the repo. It is the
same object as repo.ui.
When a repo is passed to hg.peer, the global configuration is read from
repo.baseui.
2012-07-28 23:28:36 +02:00
FUJIWARA Katsunori
1168611426 subrepo: isolate configuration between each repositories in subrepo tree
Before this patch, repository local configurations are not isolated
between repositories in subrepo tree, because "localrepository"
objects for each subrepositories are created with "ui" instance of the
parent of each ones.

So, local configuration of the parent or higher repositories are
visible also in children or lower ones.

This patch uses "baseui" instead of "ui" to create repository object:
the former contains only global configuration.

This patch also copies 'ui.commitsubrepos' configuration to commit
recursively in subrepo tree, because it may be set in not
"repo.baseui" but "repo.ui".
2012-09-29 20:11:24 +09:00
Thomas Arendsen Hein
024d25472d subrepo, hghave: use "svn --version --quiet" to determine version number
svn --version --quiet is implemented since svn 0.14.1 (August 2002)
and prints just the version number, not the long output (21 lines)
of "svn --version".

Additionally I expect this output format to be more stable, at least
it is not changed with different translations.
2012-10-04 16:52:20 +02:00
Thomas Arendsen Hein
b722606b41 merge with crew-stable 2012-10-04 16:44:28 +02:00
Thomas Arendsen Hein
42db02b2a5 subrepo: setting LC_MESSAGES only works if LC_ALL is empty or unset
For example LC_ALL=de_DE.utf-8 would cause the version check to fail,
because "svn, Version 1.6.12 (r955767)" with a capital "V" will be printed.
Using "svn --version --quiet" would only print the version number, but then
matching other messages, e.g. "Committed revision" would fail.
2012-10-04 16:30:40 +02:00
Bryan O'Sullivan
fa1f3c0da0 Merge with crew-stable 2012-09-04 15:50:42 -07:00
Bryan O'Sullivan
bccd757a71 subrepo: encode unicode path names (issue3610)
Subversion 1.7 changes its XML output to include an explicit encoding tag:

  <?xml version="1.0" encoding="UTF-8"?>

This triggers xml.dom.minidom to always return unicode strings, causing
other parts of the code to explode.

We unconditionally encode path names before handing them back, which
works with both str (actually a no-op) and unicode values.
2012-09-04 15:46:04 -07:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Sune Foldager
ffe56435bf peer: introduce peer methods to prepare for peer classes
This introduces a peer method into all repository classes, which currently
simply returns self. It also changes hg.repository so it now raises an
exception if the supplied paths does not resolve to a localrepo or descendant.

Finally, all call sites are changed to use the peer and local methods as
appropriate, where peer is used whenever the code is dealing with a remote
repository (even if it's on local disk).
2012-07-13 21:46:53 +02:00
Martin Geisler
0a036ffb67 merge with crew-stable 2012-07-12 10:41:56 +02:00
Martin Geisler
37556a7588 subrepo: add missing newline in Git warning message 2012-07-12 09:58:40 +02:00
Matt Harbison
63a46b018b subrepo: propagate matcher to subrepos when archiving
Add a match object to subrepo.archive(). This will allow the -X and -I
options to be honored inside subrepos when archiving. They formerly
only affect the top level repo.
2012-06-16 22:34:06 -04:00
Thomas Arendsen Hein
cc4d20e368 subrepo/svn: make rev number retrieval compatible with svn 1.5 (issue2968)
dbc9f6aea991 introduced "svn info TARGET@REV" to determine if a certain
path exists in the specified revision, but in svn 1.5 the error message
"Not a valid URL" yields exit code 0 so the error is not caught.
Use "svn list TARGET@REV" instead which works with svn 1.5 and is even
faster in some situations.
2012-06-26 14:27:33 +02:00
Benjamin Pollack
8e9d7031f8 subrepo: support Git being named "git.cmd" on Windows (issue3173)
Popen does not consider "foo.cmd" equivalent to "foo" on Windows.
Unfortunately, the default MSYS Git installation installs only "git.cmd" into
the path by default.  This patch probes for both possible names on Windows.
2012-06-12 09:31:04 -04:00
Benjamin Pollack
b47c23a368 subrepo: warn user if Git is not version 1.6.0 or higher 2012-06-12 09:28:55 -04:00
Thomas Arendsen Hein
bbd22fd92b merge with crew-stable 2012-06-26 14:32:20 +02:00
Martin Geisler
d22efb8f52 merge with stable 2012-06-21 15:10:01 +02:00
Dov Feldstern
bc4eac4b26 subrepo: make subrepo.subrepo(<not a subrepo path>) fail
Until now, when calling subrepo.subrepo with a path at which there is no
subrepo, a "nullstate" tuple would be returned. However, this is not very
useful (the tuple can't really be used for creating a subrepo), so we'd just as
soon have the function just fail, and leave it up to the caller to decide what
to do.

The motivation for doing this now is to simplify the solution for (issue3056).
2012-05-20 21:11:34 +03:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Patrick Mezard
f49c9eec1a subrepo: do not traceback on .hgsubstate parsing errors
Note that aborting in subrepo.state() prevents "repairing" commands like revert
to be issued. The user will have to edit the .hgsubstate manually (but he
probably had already otherwise this would not be failing). The same behaviour
already happens with invalid .hgsub entries.
2012-05-04 14:19:55 +02:00
Patrick Mezard
a124dced40 subrepo: ignore blank lines in .hgsubstate (issue3424)
Reported by Sebastian Krysmanski <infomail@lordb.de>
2012-05-04 14:19:52 +02:00
Patrick Mezard
ac389a393c subrepo/svn: cache _wcrev() value in merge() 2012-04-30 17:05:19 +02:00
Patrick Mezard
5e78cfbfbb subrepo/svn: fix checked out rev number retrieval (issue2968)
The initial version was to take the "Revision" field from svn info. It works
but produces false positive when parent paths are being moved or unrelated
changes are being committed, causing it to change while the svn checkout itself
remains the same. To avoid spurious commit, we took "Revision" and "Last
Changed Rev" for general comparison and kept the latter to answer "what is your
revision?" question. This is better but fails when the subrepo path exists at
"Revision" but not at "Last Changed Rev". This patch adds a check for this, and
returns "Revision" if the path does not exist. We try to avoid doing this as
much as possible at it implies an extra, *remote* call.
2012-04-30 17:03:15 +02:00
Patrick Mezard
cb57bc8bda subrepo/svn: improve error message on missing files
From:

  abort: failed to commit svn changes

to:

  abort: cannot commit missing svn entries
2012-04-26 12:13:20 +02:00
Patrick Mezard
ed26ff342c subrepo/svn: abort on commit with missing file (issue3029)
Previous code was printing a traceback because it expected some error output
from svn. But sometimes our definition of "changed" differs with the subversion
one. For instance, subversion ignores missing files when committing. And when
there are only missing files, svn commit will be a successful no-op with no
output. Still, we should stick to our definition including missing files in
changes as doing otherwise could cause surprising behaviour for the user.
2012-04-26 11:55:07 +02:00
Patrick Mezard
f98c45e1c6 subrepo: fix default implementation of forget() (issue3404) 2012-04-27 11:02:16 +02:00
Angel Ezquerra
60d6e7877d revert: show warning when reverting subrepos that do not support revert
The warning is similar to the warning that was shown before hgsubrepo revert
support was added, with the exception that now the subrepo type is shown.

For example, when trying to revert a git subrepo located in "include/mygitsub",
the warning message would be:

include/mygitsub: reverting git subrepos is unsupported
2012-04-19 23:36:42 +02:00
Matt Mackall
1ca3f6721a merge with stable 2012-04-16 16:50:25 -05:00
Patrick Mezard
4539c8fa89 archive: make it work with svn subrepos (issue3308)
- _svncommand() in files() returns a tuple since 1ca3bbcf0c2a not a string.
- _svncommand() in filedata() returns a tuple not a string.
- "svn list" returns files but also directories.
- "svn list" is not recursive by default.

I have no idea what happens to svn:externals possibly embedded in the svn
subrepository.
2012-04-16 11:48:15 +02:00
Angel Ezquerra
5089e1299f revert: add support for reverting subrepos without --no-backup and/or --all
When a subrepo is reverted but --no-backup is not set, call revert on the
subrepo that is being reverted prior to updating it to the revision specified
in the parent repo's .hgsubstate file.

The --all flag is passed down to the subrepo when it is being reverted. If the
--all flag is not set, all files that are modified on the subrepo will be
reverted.
2012-03-28 11:42:17 +02:00
Angel Ezquerra
3e2b4220e7 revert: add support for reverting subrepos
Reverting a subrepo is done by updating it to the revision that is selected on
the parent repo .hgsubstate file.

* ISSUES/TODO:

- reverting added and removed subrepos is not supported yet.
- reverting subrepos is only supported if the --no-backup flag is used (this
limitation will be removed on another patch).
- The behavior of the --all flag has been changed. It now reverts subrepos as
well. Note that this may lead to data loss if the user has a dirty subrepo.
2012-03-28 11:42:17 +02:00
Matt Mackall
45a83fbf05 merge with stable 2012-02-29 17:27:24 -06:00
Friedrich Kastner-Masilko
b4d42dc703 subrepo: fix for merge inconsistencies
Merging ancestors with children is allowed if they are on different
named branches. This did not work for subrepo merges before. To fix
this inconsistency, the mergefunc() will now use the simple update
path only if both versions are on the same named branch. If not, they
get merged into a new changeset, just as if you did the merge from the
subrepo's root directly.
2012-02-29 14:24:57 +01:00
Matt Mackall
79aca17050 push: more precise failure check on subrepo push
This will let us distinguish between nothing to push and push failed
2012-01-30 11:26:20 -06:00
Matt Mackall
5db4edab96 subrepo: add basestate method
This will allow us to sort out what's going on with state .hgsubstate
files more precisely.
2012-02-06 15:00:08 -06:00
David M. Carr
560a2fff89 forget: fix subrepo recursion for explicit path handling
When support for handling explicit paths in subrepos was added to the forget
command (155b89136ae7), subrepo recursion wasn't taken into account.  This
change fixes that by pulling the majority of the logic of commands.forget into
cmdutil.forget, which can then be called from both there and subrepo.forget.
2012-01-17 19:10:59 -05:00
David M. Carr
375e0ca3cf add: fix subrepo recursion for explicit path handling
When support for handling explicit paths in subrepos was added to the add
command (825c4cefde4b), subrepo recursion wasn't taken into account.  This
change adds an explicitonly argument to cmdutil.add to allow controlling which
levels of recursion should include only explicit paths versus all matched
paths.
2012-01-17 19:10:58 -05:00
Matt Mackall
36343a23b2 subrepo: avoid syncing bookmarks twice on clone (issue3191)
Clone internally handles bookmark synchronization.

(Fix spotted by Eric Blood)
2012-01-10 13:48:42 -06:00