Commit Graph

88 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
2ad325e10a merge: mark .hgsubstate as possibly dirty before submerge for consistency
Before this patch, failure of updating subrepos may cause inconsistent
".hgsubstate". For example:

  1. dirstate entry for ".hgsubstate" of the parent repo is filled
     with valid size/date (via "hg state" or so)

  2. "hg update" is invoked at the parent repo

  3. ".hgsubstate" of the parent repo is updated on the filesystem as
     a part of "g"(et) action in "merge.applyupdates"

  4. it is assumed that size/date of ".hgsubstate" on the filesystem
     aren't changed from ones at (1)

     this is not so difficult condition, because just changing hash
     ids (every ids are same in length) in ".hgsubstate" doesn't
     change the file size of it

  5. "subrepo.submerge()" is invoked to update subrepos

  6. failure of updating in one of subrepos raises exception
     (e.g. "untracked file differs")

  7. "hg update" is aborted without updating dirstate of the parent repo

     dirstate entry for ".hgsubstate" still holds size/date at (1)

Then, ".hgsubstate" of the parent repo is treated as "CLEAN"
unexpectedly, because updating ".hgsubstate" at (3) doesn't change
size/date of it on the filesystem: see assumption at (4).

This inconsistent ".hgsubstate" status causes unexpected behavior, for
example:

  - "hg revert" forgets to revert ".hgsubstate"

  - "hg update" misunderstands that (not yet updated) subrepos diverge
    (then, it shows the prompt to confirm user's decision)

To avoid inconsistent ".hgsubstate" status above, this patch marks
".hgsubstate" as possibly dirty before "submerge" invocation.
"normallookup"-ed (= dirty) dirstate should be written out, even if
processing is aborted by failure.

This patch marks ".hgsubstate" as possibly dirty before "submerge",
also when it is removed or merged while merging, for safety. This
should prevent Mercurial from misunderstanding inconsistent
".hgsubstate" as clean.

To satisfy conditions at (1) and (4) above, this patch uses "hg status
--config debug.dirstate.delaywrite=2" (to fill valid size/date into
dirstate) and "touch" (to fix date of the file).
2015-01-30 04:59:05 +09:00
Matt Harbison
d1e1ea0e07 tests: fix globs for Windows
test-largefiles-update.t, test-subrepo.t, test-tag.t, and
test-rename-dir-merge.t still warn about no result returned because of
unnecessary globs that test-check-code-hg.t wants, relating to output for
pushing to, pulling from and moving X to Y.
2014-11-16 16:26:15 -05:00
Mads Kiilerich
3a64b6d7ed subrepo: remove superfluous newline from subrepo prompt 2014-10-01 01:08:17 +02:00
FUJIWARA Katsunori
f09e7bc4c8 templatekw: add 'subrepos' keyword to show updated subrepositories
'subrepos' template keyword newly added by this patch shows updated
subrepositories.

For the compatibility with the list of subrepositories shown in the
editor at commit:

  - 'subrepos' is empty, at revisions removing '.hgsub' itself

  - 'subrepos' is calculated between the revision and the first parent
    of it, at merge revisions

To avoid silent regression, this patch also confirms "hg diff" of
".hgsubstate" and parents for each target revisions in the test.
2014-07-15 23:34:13 +09:00
FUJIWARA Katsunori
a9d25c900f subrepo: add test whether "[paths]" is configured correctly at subrepo creation
This test is added for changes in the subsequent patch.

This test doesn't use "(glob)" for expected output, because "[paths]"
is configured at subrepo creation by "_abssource()" using
"posixpath.join()" to join path components.
2014-06-20 00:41:31 +09:00
Pierre-Yves David
21bb02d08f merge: drop the quotes around commit description
We already have a ":" after the user name to denote the start of the
description. The current usage of quotes around the description is
problematic as the truncation to 80 chars is likely to drop the
closing quote. This may confuse syntax coloration in some editors.
2014-05-26 11:44:58 -07:00
Durham Goode
bcc0ea1fe2 merge: add conflict marker formatter (BC)
Adds a conflict marker formatter that can produce custom conflict marker
descriptions. It can be set via ui.mergemarkertemplate. The old behavior
can be used still by setting ui.mergemarkers=basic.

The default format is similar to:

  {node|short} {tag} {branch} {bookmarks} - {author}: "{desc|firstline}"

And renders as:

  contextblahblah
  <<<<<<< local: c7fdd7ce4652 - durham: "Fix broken stuff in my feature branch"
  line from my changes
  =======
  line from the other changes
  >>>>>>> other: a3e55d7f4d38  master - sid0: "This is a commit to master th...
  morecontextblahblah
2014-05-08 16:50:22 -07:00
Mads Kiilerich
473137c772 merge: change debug logging - test output changes but no real changes
Preparing for action list split-up, making sure the final change don't have any
test changes.

The patch moves debug statements around without really changing anything.
Arguably, it temporarily makes the code worse. The only justification is that
it makes it easier to review the test changes ... and in the end the big change
will not change test output at all.

The changes to test output are due to changes in the ordering of debug output.
That is mainly because we now do the debug logging for files when we actually
process them. Files are also processed in a slightly different but still
correct order. It is now primarily ordered by action type, secondarily by
filename.

The patch introduces some redundancy. Some of it will be removed again, some of
it will in the end help code readability and efficiency. It is possible that we
later on could introduce a "process this action list and do some logging and
progress reporting and apply this function".

The "preserving X for resolve" debug statements will only have single space
indentation. It will no longer have a leading single space indented "f: msg ->
m" message. Having this message double indented would thus no longer make
sense.

The bid actions will temporarily be sorted using a custom sort key that happens
to match the sort order the simplified code will have in the end.
2014-04-22 02:10:25 +02:00
Matt Harbison
615b124547 cat: support cat with explicit paths in subrepos
The cat command with an explicit path into a subrepo is now handled by invoking
cat on the file, from that subrepo.  The previous behavior was to complain that
the file didn't exist in the revision (of the top most repo).  Now when the file
is actually missing, the revision of the subrepo is named instead (though it is
probably desirable to continue naming the top level repo).

The documented output formatters %d and %p reflect the path from the top level
repo, since the purpose of this is to give the illusion of a unified repository.
Support for the undocumented (for cat) formatters %H, %R, %h, %m and %r was
added long ago (I tested back as far as 0.5), but unfortunately these will
reflect the subrepo node instead of the parent context.

The previous implementation was a bit loose with the return value, i.e. it would
return 0 if _any_ file requested was cat'd successfully.  This maintains that
behavior.
2014-03-14 21:32:05 -04:00
Mads Kiilerich
0e8795ccd6 spelling: fixes from spell checker 2014-04-13 19:01:00 +02:00
FUJIWARA Katsunori
ccc7916e45 localrepo: omit ".hgsubstate" also from "added" files
Before this patch, "localrepository.commit()" omits ".hgsubstate" from
"modified" (changes[0]) and "removed" (changes[2]) file list before
checking subrepositories, but leaves one in "added" (changes[1]) as it
is.

Then, "localrepository.commit()" adds ".hgsubstate" into "modified" or
"removed" list forcibly, according to subrepository statuses.

If "added" contains ".hgsubstate", the committed context will contain
two ".hgsubstate" in its "files": one from "added" (not omitted one),
and another from "modified" or "removed" (newly added one).

How many times ".hgsubstate" appears in "files" changes node hash,
even though revision content is same, because node hash calculation
uses the specified "files" directly (without duplication check or so).

This means that node hash of committed revision changes according to
existence of ".hgsubstate" in "added" at "localrepository.commit()".

".hgsubstate" is treated as "added", not only in accidental cases, but
also in the case of "qpush" for the patch adding ".hgsubstate".

This patch omits ".hgsubstate" also from "added" files before checking
subrepositories. This patch also omits ".hgsubstate" exclusion in
"qnew"/"qrefresh" introduced by changeset bbb8109a634f, because this
patch makes them meaningless.

"hg parents --template '{files}\n'" newly added to "test-mq-subrepo.t"
enhances checking unexpected multiple appearances of ".hgsubstate" in
"files" of created/refreshed MQ revisions.
2014-03-22 23:39:51 +09:00
Jordi Gutiérrez Hermoso
19098ea63d commit: propagate --secret option to subrepos (issue4182)
Before this patch, `hg commit --secret` was not getting propagated
correctly, and subrepos were not getting the commit in the secret
phase. The problem is that subrepos get their ui from the base repo's
baseui object and ignore the ui object passed on to them. This sets
and restores both ui objects with the appropriate option.
2014-03-17 14:57:13 -04:00
Pierre-Yves David
605b367f84 backout: add a message after backout that need manual commit
In some case Backout silently succeeded to back out but left all the change
uncommitted. This may be confusing for user so this changeset  add a note
reminding to commit. Other backout case already actively informs the user about
created commit.
2014-01-08 17:23:26 -08:00
Pierre-Yves David
75c6a1c8fa backout: avoid update on simple case.
Before the changeset the backout process was:
1) go to <target>
2) revert to <target> parent
3) update back to changeset we came from

The two update steps can takes a very long time to move back and forth unrelated
file change between <target> and current working directory.

The new process is just merging current working directory with the parent of
<target> using <target> as ancestor. This give the very same result but skip
the two updates. On big repo with a lot of files and changes that save a lots of
time (x20 for one week window).

The "merge" version (hg backout --merge) is still done with upgrades. We could
imagine using in memory commit to speed it up but this is another fish.
2014-01-08 14:53:46 -08:00
FUJIWARA Katsunori
bcc53deece subrepo: check phase of state in each subrepositories before committing
Before this patch, phase of newly created commit is determined by
"phases.new-commit" configuration regardless of phase of state in each
subrepositories.

For example, this may cause the "public" revision in the parent
repository referring the "secret" one in subrepository.

This patch checks phase of state in each subrepositories before
committing in the parent, and aborts or changes phase of newly created
commit if subrepositories have more restricted phase than the parent.

This patch uses "follow" as default value of "phases.checksubrepos"
configuration, because it can keep consistency between phases of the
parent and subrepositories without breaking existing tool chains.
2013-11-13 15:55:30 +09:00
FUJIWARA Katsunori
3198fa3830 push: hide description about "-f" in the hint to prevent from using it easily
"use push -f to force" in the hint at abortion of "hg push" may cause
novice users to execute "push -f" easily without understanding about
problems of multiple branch heads in the repository.

This patch hides description about "-f" in the hint, and leads into
seeing "hg help push" for details about pushing new heads.
2013-10-03 23:16:06 +09:00
Angel Ezquerra
65d42d2870 merge: let the user choose to merge, keep local or keep remote subrepo revisions
When a subrepo has changed on the local and remote revisions, prompt the user
whether it wants to merge those subrepo revisions, keep the local revision or
keep the remote revision.

Up until now mercurial would always perform a merge on a subrepo that had
changed on the local and the remote revisions. This is often inconvenient. For
example:

- You may want to perform the actual subrepo merge after you have merged the
parent subrepo files.
- Some subrepos may be considered "read only", in the sense that you are not
supposed to add new revisions to them. In those cases "merging a subrepo" means
choosing which _existing_ revision you want to use on the merged revision. This
is often the case for subrepos that contain binary dependencies (such as DLLs,
etc).

This new prompt makes mercurial better cope with those common scenarios.

Notes:

- The default behavior (which is the one that is used when ui is not
interactive) remains unchanged (i.e. merge is the default action).
- This prompt will be shown even if the ui --tool flag is set.
- I don't know of a way to test the "keep local" and "keep remote" options (i.e.
to force the test to choose those options).


# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1378420708 -7200
#      Fri Sep 06 00:38:28 2013 +0200
# Node ID 2fb9cb0c7b26303ac3178b7739975e663075857d
# Parent  796d34e1b749b79834321ef1181ed8433a5515d9
merge: let the user choose to merge, keep local or keep remote subrepo revisions

When a subrepo has changed on the local and remote revisions, prompt the user
whether it wants to merge those subrepo revisions, keep the local revision or
keep the remote revision.

Up until now mercurial would always perform a merge on a subrepo that had
changed on the local and the remote revisions. This is often inconvenient. For
example:

- You may want to perform the actual subrepo merge after you have merged the
parent subrepo files.
- Some subrepos may be considered "read only", in the sense that you are not
supposed to add new revisions to them. In those cases "merging a subrepo" means
choosing which _existing_ revision you want to use on the merged revision. This
is often the case for subrepos that contain binary dependencies (such as DLLs,
etc).

This new prompt makes mercurial better cope with those common scenarios.

Notes:

- The default behavior (which is the one that is used when ui is not
interactive) remains unchanged (i.e. merge is the default action).
- This prompt will be shown even if the ui --tool flag is set.
- I don't know of a way to test the "keep local" and "keep remote" options (i.e.
to force the test to choose those options).
2013-09-06 00:38:28 +02:00
Matt Mackall
15d52a5074 merge with stable 2013-05-09 15:22:21 -05:00
Matt Mackall
d2d6316f27 tests: fix another Windows path issue 2013-05-09 15:09:36 -05:00
Brendan Cully
5fda2ba23f tests: sprinkle globs over largefiles/subrepo tests for Windows 2013-05-02 11:26:43 -07:00
Matt Mackall
2d6d229def check-code: add more path sep glob checks 2013-05-02 15:21:47 -05:00
Matt Harbison
8ab43e8c5a ui: add support for fully printing chained exception stacks in ui.traceback()
Currently, only SubrepoAbort has a cause chained to it.
2013-02-09 14:15:34 -05:00
Yuya Nishihara
56f8539ba6 subrepo: fix exception on revert when "all" option is omitted
Since 0f22f83473ea, backout does not set opts['all'], which causes KeyError
at hgsubrepo.revert.
2013-04-15 23:52:57 +09:00
Angel Ezquerra
eab5413a57 test-subrepo: add tests for subrepo "storeclean" checks
These tests verify that subrepos are not pushed when their store is clean versus
a given target repository.
2013-03-08 21:50:27 +01:00
Simon Heimberg
09ff06d669 tests: remove glob lines which unnecessary match / for \ on windows
This lines were reported as unnecessary when running the tests on windows
because the path was already printed with a slash and not a backslash.
2013-02-23 22:54:57 +01:00
Bryan O'Sullivan
948134e159 tests: update test output (will be folded into parent) 2013-02-09 15:22:04 -08:00
Bryan O'Sullivan
88fa66b36f merge: don't call copies.mergecopies unless we need to
This reduces the amount of time we spend calculating when doing a clean
non-merge update. In a large repo, the time dropped from 10.1 seconds
to 3.4.
2013-02-09 21:24:36 +00:00
Siddharth Agarwal
ace5cac25b manifestmerge: pass in branchmerge and force separately
This will be used in an upcoming patch.
2013-02-08 15:23:23 +00:00
Mads Kiilerich
4260e671c6 merge with stable 2013-02-04 23:53:37 +01:00
Mads Kiilerich
59596219f0 tests: fix windows test failure in test-subrepo.t 2013-02-04 23:41:11 +01:00
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
Mads Kiilerich
ee476759ff merge: delay debug messages for merge actions
Show messages at a point where the actions have been sorted, thus preparing for
backout of 14f4258e3526.

This makes manifestmerge more of a silent operation, just like 'copies' is.

Indent 'preserving' messages to make them subordinate to the action logging so
they fit in the new context. (The 'preserving' messages are quite redundant and
could also be removed completely.)
2013-01-24 23:57:44 +01:00
Matt Harbison
b344797c5f share: backout f48752441ca0, except the test
Locating the share source when no default path is available is now handled in
subrepo._abssource(), so unconditionally setting a default path (and the
associated problems) can be avoided.

The test change reflects the fact that a default path is no longer set on the
resulting share.
2012-11-27 21:31:59 -05: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
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
simon@laptop-tosh
b228b696db share: always set default path to work with subrepos (issue3518)
set the default path in any case because creating subrepo looks this up.
Subrepos are cloned, not shared.
2012-10-27 12:38:59 +02:00
Adrian Buehlmann
c700586a1f test-subrepo: adapt for Windows after 6e587aaeb4ef
Fixes

  @@ -606,7 +606,7 @@
     issue3276_ok
     $ rm repo/s/b
     $ hg -R repo revert --all
  -  reverting repo/.hgsubstate
  +  reverting repo\.hgsubstate
     reverting subrepo s
     $ hg -R repo update
     1 files updated, 0 files merged, 0 files removed, 0 files unresolved

on Windows
2012-11-02 20:47:03 +01: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
Mads Kiilerich
9cddfd19ab check-code: fix check for trailing whitespace on sh command lines
The $ has been without necessary escaping since introduced in c4ecbbd282fe.
2012-08-08 18:10:16 +02:00
Patrick Mezard
2e04c51661 identity: show trailing '+' for dirty subrepos (issue2839) 2012-07-27 13:56:19 +02:00
Mads Kiilerich
9355854f8a tests: cleanup of tests that got lost in their own nested directories
Some tests ended up in a directory several directories deeper than $TESTTMP,
usually because some 'cd ..' had been forgotten between different test cases.

Add 'cd ..' where they are missing so the tests get back where they started.
2012-06-11 01:38:32 +02:00
Mads Kiilerich
d94d866bcb tests: add missing accept of native pathname separator 2012-04-28 01:55:39 +02:00
Angel Ezquerra
d9ec5798ba tests: add test for fileset 'subrepo' keyword 2012-04-17 07:22:44 +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
bd7d3adcb4 merge with stable 2012-02-10 17:09:23 -06:00
Matt Mackall
31ad230c52 pull: backout change to return code
This bit a number of people.
2012-02-10 16:09:30 -06:00
Matt Mackall
a17b10a14b subrepo: rewrite handling of subrepo state at commit (issue2403)
When the contents of .hgsubstate are stale (either because they've
manually been tweaked or partial updates have confused it), we get
confused about whether it actually needs committing.

So instead, we actively consult the parent's substate and compare it
the actual current state when deciding whether it needs committing.

Side effect: lots of "committing subrepo" messages that didn't
correspond with real commits disappear.

This change is fairly invasive for a fairly obscure condition, so it's
kept on the default branch.
2012-02-06 15:10:01 -06:00
Matt Mackall
902bee47a8 pull: return 1 when no changes found (BC)
Currently we have the following return codes if nothing is found:

                commit   incoming    outgoing      pull     push
intended           1        1           1            1       1
documented         1        1           1            0       1
actual             1        1           1            0       1

This makes pull agree with the rest of the table and makes it easy to
detect "nothing was pulled" in scripts.
2012-01-30 16:01:54 -06:00
Martin Geisler
d6b9b24fa1 merge with stable 2011-12-15 16:26:33 +01:00