Commit Graph

38 Commits

Author SHA1 Message Date
Matt Harbison
86a2e6550a subrepo: make the output references to subrepositories consistent
Well, mostly.  The annotation on subrepo functions tacks on a parenthetical to
the abort message, which seems reasonable for a generic mechanism.  But now all
messages consistently spell out 'subrepository', and double quote the name of
the repo.  I noticed the inconsistency in the change for the last commit.
2017-07-09 16:13:30 -04:00
Gábor Stefanik
a47c5119e6 update: enable copy tracing for backwards and non-linear updates
As a followup to the issue4028 series, this fixes a variant of the issue
that can occur when updating with uncommited local changes.

The duplicated .hgsub warning is coming from wc.dirty(). We would previously
skip this call because it's only relevant when we're going to perform copy
tracing, which we didn't do before.

The change to the update summary line is because we now treat the rename as a
proper rename (which counts as a change), rather than an add+delete pair
(which counts as a change and a delete).
2016-08-25 22:02:26 +02:00
timeless@mozdev.org
ff22eee5cd mq: consistently use qrefresh 2015-10-14 03:30:27 -04:00
Mads Kiilerich
ccf61891e6 mq: generate patch names from first line of description
Avoid the pointless numeric rev.diff patch names.

Instead, do like mbox extension does and create meaningful patch names.
2015-03-10 13:19:17 +01:00
Matt Harbison
d7353508b0 scmutil: consistently return subrepos relative to ctx1 from itersubrepos()
Previously, if a subrepo was added in ctx2 and then compared to another without
it (ctx1), the subrepo for ctx2 was returned amongst all of the ctx1 based
subrepos, since no subrepo exists in ctx1 to replace it in the 'subpaths' dict.
The two callers of this, basectx.status() and cmdutil.diffordiffstat(), both
compare the yielded subrepo against ctx2, and thus saw no changes when ctx2's
subrepo was returned.  The tests here previously didn't mention 's/a' for the
'p1()' case.

This appears to have been a known issue, because some diffordiffstat() comments
mention that the subpath disappeared, and "the best we can do is ignore it".  I
originally ran into the issue with some custom convert code to flatten a tree of
subrepos causing hg.putcommit() to abort, but this new behavior seems like the
correct status and diff behavior regardless.  (The abort in convert isn't
something users will see, because convert doesn't currently support subrepos in
the official repo.)
2015-06-03 14:21:15 -04:00
Laurent Charignon
6fc9e8be66 record: edit patch of newly added files (issue4304)
I tried to fix this issue in the past and had to revert the fix. This is a
second attempt without the regression we found with the first one.

record defines special headers (of file) as headers whose hunk are not shown
to the user for editing, they are used to represent deleted, moved and new
files. Since we want to authorize editing the patch of newly added file we
make the newly added file with some content not special anymore. This entails
that we have to save their content before applying the backup to be able to
revert it if the patch does not apply properly.
We reintroduce the test showing that newly added files can be edited and that
their content is shown to the user.
2015-04-23 14:27:26 -07:00
Laurent Charignon
4fc3c4c465 record: fix record with change on moved file crashes (issue4619)
reverting fe807064739c, add a test to prevent the issue from coming back.
2015-04-22 13:56:30 -07:00
Matt Harbison
a941ba77e5 subrepo: precisely identify the missing subrepo spec file
It isn't obvious which file is the problem with deep subrepos, so provide the
path.  Since the parsing is done with a ctx and not a subrepo object, it isn't
possible to display a path from the root subrepo.  Therefore, the path shown is
relative to cwd.

There's no test coverage for the first abort, and I couldn't figure out how to
trigger it, but it is changed for consistency.
2015-04-05 15:08:55 -04:00
FUJIWARA Katsunori
e269967115 subrepo: add bailifchanged to centralize raising Abort if subrepo is dirty
This patch also centralizes composing dirty reason message like
"uncommitted changes in subrepository 'xxxx'".
2015-03-25 13:55:35 +09:00
Laurent Charignon
e0bce75a1d record: allow editing new files (issue4304)
While using the record extension to select changes, the user couldn't see the
content of newly added files and had to select/reject them based on filename.
The test is changed accordingly in two places.
2015-03-06 15:57:43 -08: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
Yuya Nishihara
ed7051c6c7 tests: write hgrc of more than two lines by using shell heredoc
Here document should be readable than repeating echo commands.
2014-11-04 23:41:46 +09:00
Mads Kiilerich
29285eb86d ui: show prompt choice if input is not a tty but is forced to be interactive
The tests often set ui.interactive to control normally interactive prompts from
stdin. That gave an output where it was non-obvious what prompts got which
which response, and the output lacked the newline users would see after input.

Instead, if the input not is a tty, write the selection and a newline.
2014-10-01 01:04:18 +02:00
Mads Kiilerich
44bd94dc4e mq: refactor patchheader header ordering to match export (BC)
The refactoring also gives more robust and extendable handling of other HG
headers.
2014-09-24 02:41:11 +02:00
Mads Kiilerich
600dadebda mq: write '# Parent ' lines with two spaces like export does (BC)
This aligns "Parent" node IDs with "Node ID" node IDs.
2014-09-24 01:36:44 +02:00
Mads Kiilerich
3ed8837146 mq: write headers for new HG patches in the same order as export (BC) 2014-09-20 17:06:56 +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
FUJIWARA Katsunori
e280ea2008 mq: omit ".hgsubstate" from qnew/qrefresh target list for consistent node hash
Before this patch, even if specified file patterns and -I/-X options
cause listing ".hgsubstate" up in the target list, qnew/qrefresh put
".hgsubstate" into the target list individually and forcibly.

This changes how many times ".hgsubstate" appear in the target list
according to run-time conditions, and causes inconsistent node hash,
even though revision content is same, because node hash calculation
uses the specified target list directly (without duplication check or
so).

This patch always omits ".hgsubstate" from qnew/qrefresh target list
for consistent node hash.

This omitting doesn't miss including ".hgsubstate" changes, because:

  - "localrepository.commit()" puts ".hgsubstate" into the target list
    for "commitctx()" forcibly if needed

  - "mq.putsubstate2changes()" puts ".hgsubstate" into the target list
    for "patch.diff()" if it is not yet listed up
2014-03-20 00:10:45 +09:00
FUJIWARA Katsunori
ff356918e1 qnew: omit meaningless and harmful putting subrepositories into target list
Before this patch, qnew puts updated subrepositories into target list
forcibly, if any of -I, -X or patterns are specified.

But this is meaningless and harmful, because:

  - putting subrepositories into target list doesn't affect the result
    of "localrepository.status()"

    "dirstate.status()" invoked via "localrepository.status()" always
    omits subrepositories from the result of it

  - any -I/-X opts and empty "pats" causes unexpected failure

    when any -I/-X opts are specified, "inclsubs" are always added to
    "pats", even if "pats" is empty.

    but this changes meaning of "pats" from "including all to be
    included" to "including only listed subrepositories"

    this may exclude ".hgsub" and cause unexpected exception raising
    ("can't commit subrepos without .hgsub" ).

  - qnew at other than repository root (with -I, -X or any patterns)
    causes unexpected failure

    "scmutil.match()" treats pattern without syntax type as 'relpath'
    type (= one rooted at cwd).

    but qnew puts subrepository paths rooted at the repository root,
    and it causes unexpected exception raising ("SUBREPO not under
    root ROOT" in "pathutil.canonpath()"), if "hg qnew" is executed at
    other than repository root with -I, -X or any patterns.

This patch omits meaningless and harmful putting subrepositories into
target list.

This omitting doesn't miss including updated subrepositories, because
subrepositories are specified to "scmutil.matchfiles()" directly, to
get "match" object for "localrepository.commit()".
2014-03-20 00:10:45 +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
Angel Ezquerra
98ae79f962 mq: update subrepos when applying / unapplying patches that change .hgsubstate
Up until now applying or unapplying a patch that modified .hgsubstate would not
work as expected because it would not update the subrepos according to the
.hgsubstate change. This made it very easy to lose subrepo changes when using
mq.

This revision also changes the test-mq-subrepo test so that on the qpop / qpush
tests. We no longer use the debugsub command to check the state of the subrepos
after the qpop and qpush operations. Instead we directly run the id command on
the subrepos that we want to check. The reason is that using the debugsub
command is misleading because it does not really check the state of the subrepos
on the working directory (it just returns what the change that is specified on a
given revision). Because of this the tests did not detect the problem that this
revision fixes (i.e. that applying a patch did not update the subrepos to the
corresponding revisions).


# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1376350710 -7200
#      Tue Aug 13 01:38:30 2013 +0200
# Node ID 60897e264858cdcd46f89e27a702086f08adca02
# Parent  2defb5453f223c3027eb2f7788fbddd52bbb3352
mq: update subrepos when applying / unapplying patches that change .hgsubstate

Up until now applying or unapplying a patch that modified .hgsubstate would not
work as expected because it would not update the subrepos according to the
.hgsubstate change. This made it very easy to lose subrepo changes when using
mq.

This revision also changes the test-mq-subrepo test so that on the qpop / qpush
tests. We no longer use the debugsub command to check the state of the subrepos
after the qpop and qpush operations. Instead we directly run the id command on
the subrepos that we want to check. The reason is that using the debugsub
command is misleading because it does not really check the state of the subrepos
on the working directory (it just returns what the change that is specified on a
given revision). Because of this the tests did not detect the problem that this
revision fixes (i.e. that applying a patch did not update the subrepos to the
corresponding revisions).
2013-08-13 01:38:30 +02:00
Angel Ezquerra
d278e5fc26 mq: look for modified subrepos when checking for local changes
It was possible to apply, unapply, fold, patches (etc) with modified subrepos,
which resulted in surprising behavior. For example it was easy to apply a patch
with a modified subrepo, and then the refresh it and accidentally end up
including the modified subrepo on the refreshed patch.

A test has been added to verify this new check.


# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1375742979 -7200
#      Tue Aug 06 00:49:39 2013 +0200
# Node ID a5c90acff5e61aae714ba6c9457d766c54b4f124
# Parent  bacc55ce64d5de9d1eb7fcefccd3829161d5dcf7
mq: look for modified subrepos when checking for local changes

It was possible to apply, unapply, fold, patches (etc) with modified subrepos,
which resulted in surprising behavior. For example it was easy to apply a patch
with a modified subrepo, and then the refresh it and accidentally end up
including the modified subrepo on the refreshed patch.

A test has been added to verify this new check.
2013-08-06 00:49:39 +02:00
Bryan O'Sullivan
dc9ede17dc Merge spelling fixes 2012-09-11 08:36:09 -07:00
timeless@mozdev.org
aba5d4b292 grammar: rolled-back 2012-08-17 13:58:19 -07:00
FUJIWARA Katsunori
54911ad11a mq: check subrepo synchronizations against parent of workdir or other appropriate context
Before this patch, MQ checks each subrepo synchronizations against the
working directory context, so ".hgsubstate" updating is not imported
into MQ revision correctly in cases below:

  - qrefresh when current ".hgsubstate" is already synchronized with
    each subrepos: you can reproduce this easily by just twice or more
    qrefresh invocations

  - qnew just after rollback of commit which updates ".hgsubstate"

This patch resolves this by checking subrepo states against:

  - the parent of "qtop" for qrefresh, or
  - the parent of working context otherwise
2012-06-27 22:03:27 +09:00
FUJIWARA Katsunori
8ecc1d9d04 mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
Even though the committed revision contains diff of ".hgsubstate", the
patch file created by qrefresh doesn't contain it, because:

  - ".hgsubstate" is not listed up as one of target files of the patch
    for reasons below, so diff of ".hgsubstate" is not imported into
    patch file

      - status of ".hgsubstate" in working directory is usually "clean"
      - ".hgsubstate" is not specified explicitly by users

  - the patch file is created before commit processing which updates
    or creates ".hgsubstate" automatically, so there is no diff for it
    at that time

This patch resolves this problem by:

  - putting ".hgsubstate" into target list of the patch, if needed:
    this allows "patch.diff()" to import diff of ".hgsubstate" into
    patch file.

  - creating the patch file after commit processing:
    this updates ".hgsubstate" before "patch.diff()" invocation.

For the former fixing, this patch introduces "putsubstate2changes()"
to share same implementation with qnew. This is invoked only once per
qnew/qrefresh at most, so there is less performance impact.

This patch also omits "match" argument for "patch.diff()" invocation,
because "patch.diff()" ignores "match" if "changes" is specified.
2012-06-27 22:03:27 +09:00
FUJIWARA Katsunori
fba032044a mq: add ".hgsubstate" to patch target list only if it is not listed up yet
If ".hgsubstate" is already listed up as one of commit targets, qnew
put diff of ".hgsubstate" twice into the patch file stored under
".hg/patches".

It causes rejections at applying such patches.

Other than the case like in added test script, this can also occur
when qnew is executed just after rolling back the committing updated
".hgsubstate".

This patch checks whether ".hgsubstate" is already listed up as one of
commit targets, and put it into the appropriate list only if it is not
listed up yet.
2012-06-27 22:03:22 +09:00
Mads Kiilerich
fa1c4e5ebe tests: add missing trailing 'cd ..'
Many tests didn't change back from subdirectories at the end of the tests ...
and they don't have to. The missing 'cd ..' could always be added when another
test case is added to the test file.

This change do that tests (99.5%) consistently end up in $TESTDIR where they
started, thus making it simpler to extend them or move them around.
2012-06-11 01:40:51 +02:00
A. S. Budden
285680e0f0 record: allow splitting of hunks by manually editing patches
It is possible that unrelated changes in a file are on sequential lines.  The
current record extension does not allow these to be committed independently.

An example use case for this is in software development for deeply embedded
real-time systems.  In these environments, it is not always possible to use a
debugger (due to time-constraints) and hence inline UART-based printing is
often used.  When fixing a bug in a module, it is often convenient to add a
large number of 'printf's (linked to the UART via a custom fputc) to the module
in order to work out what is going wrong.  printf is a very slow function (and
also variadic so somewhat frowned upon by the MISRA standard) and hence it is
highly undesirable to commit these lines to the repository.  If only a partial
fix is implemented, however, it is desirable to commit the fix without deleting
all of the printf lines.  This is also simplifies removal of the printf lines
as once the final fix is committed, 'hg revert' does the rest.  It is likely
that the printf lines will be very near the actual fix, so being able to split
the hunk is very useful in this case.

There were two alternatives I considered for the user interface.  One was to
manually edit the patch, the other to allow a hunk to be split into individual
lines for consideration.  The latter option would require a significant
refactor of the record module and is less flexible.  While the former is
potentially more complicated to use, this is a feature that is likely to only
be used in certain exceptional cases (such as the use case proposed above) and
hence I felt that the complexity would not be a considerable issue.

I've also written a follow-up patch that refactors the 'prompt' code to base
everything on the choices variable.  This tidies up and clarifies the code a
bit (removes constructs like 'if ret == 7' and removes the 'e' option from the
file scope options as it's not relevant there.  It's not really a necessity, so
I've excluded it from this submission for now, but I can send it separately if
there's a desire and it's on bitbucket (see below) in the meantime.

Possible future improvements include:

* Tidying up the 'prompt' code to base everything on the choices variable.
  This would allow entries to be removed from the prompt as currently 'e' is
  offered even for entire file patches, which is currently unsupported.
* Allowing the entire file (or even multi-file) patch to be edited manually:
  this would require quite a large refactor without much benefit, so I decided
  to exclude it from the initial submission.
* Allow the option to retry if a patch fails to apply (this is what Git does).
  This would require quite a bit of refactoring given the current 'hg record'
  implementation, so it's debatable whether it's worth it.

Output is similar to existing record user interface except that an additional
option ('e') exists to allow manual editing of the patch.  This opens the
user's configured editor with the patch.  A comment is added to the bottom of
the patch explaining what to do (based on Git's one).

A large proportion of the changeset is test-case changes to update the options
reported by record (Ynesfdaq? instead of Ynsfdaq?).  Functional changes are in
record.py and there are some new test cases in test-record.t.
2012-03-30 22:08:46 +01: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
Martin Geisler
acfa971cf1 subrepos: abort commit by default if a subrepo is dirty (BC)
This changeset flips the default value of ui.commitsubrepos setting
from True to False and adds a --subrepos flag to commit.

The commit, status, and diff commands behave like this with regard to
recusion and the ui.commitsubrepos setting:

          | recurses      | recurses
          | by default    | with --subrepos
  --------+---------------+----------------
  commit: | commitsubrepo | True
  status: | False         | True
  diff:   | False         | True

By changing the default from True to False, the table becomes
consistent in the two columns:

* without --subrepos on the command line, commit will abort if a
  subrepo is dirty and status/diff wont show changes inside subrepos.

* with --subrepos, all three commands will recurse.

A --subrepos flag on the command line overrides the config settin.g
2011-10-21 00:33:08 +02:00
Kevin Bullock
e4deb92563 subrepo: don't commit in subrepo if it's clean
If a subrepo has changed relative to the outer repo's substate, but the
subrepo itself is clean, we don't need to commit in the subrepo.
2011-07-19 13:43:53 -05:00
Mads Kiilerich
eb342250cc tests: test-mq-subrepo.t Solaris 10 sh compliance
Solaris 10 sh do apparently not like temporary environment variable assignment
before a function call. There is no problem with commands.
2011-03-01 02:54:16 +01:00
Kevin Bullock
e55c355bcb subrepo: separate out mq+svn subrepo tests
Having the mq+subrepo+svn tests in a separate file lets them be skipped
without skipping the other mq+subrepo tests.
2011-01-10 16:02:41 -05:00
Adrian Buehlmann
8c0b1e047c test-mq-subrepo.t: skip test if svn not installed 2011-01-07 19:15:21 +01:00
Kevin Bullock
e69254e948 subrepo: fix svnsubrepo.dirty() checking of ignoreupdate (issue2499)
The ignoreupdate flag to subrepo.dirty(), introduced in 55e4073493fc, is
correctly checked with this change.
2011-01-04 11:33:47 -06:00
Patrick Mezard
e0cbee9100 test-mq-subrepo.t: correctly forward stdin to test functions
- stdin was not forwarded in testrm1 and testrm2
- Forwarding content with EOL using command substitution (`foo`) does not work
  correctly, the lines are joined together which breaks the prompt readline.
- EOFError is raised in ui.prompt() if the input is too short on Linux while
  OSX treats it as an empty line.
2011-01-07 17:44:23 +01:00
Kevin Bullock
5c61f5f136 mq: update .hgsubstate if subrepos are clean (issue2499)
This patch prevents MQ from creating an inconsistent subrepo state. If
the .hgsub file has been changed, and none of the subrepos have
uncommitted changes, creating or updating a patch (using qnew, qrefresh,
or qrecord) will update .hgsubstate accordingly.

If any subrepos _do_ have uncommitted changes, qnew/qrefresh/qrecord
will abort.

Thanks to pmezard for proposing this solution.
2010-12-07 22:14:43 -06:00