Commit Graph

46 Commits

Author SHA1 Message Date
Tony Tung
4c1f5709e1 commit: abort when a committemplate is not changed
If a committemplate is provided and no message is provided on the
command line, and no edits are made to the commit template, then abort
the commit.
2015-10-09 21:44:54 -07:00
Matt Mackall
5e1b4ad958 urls: bulk-change primary website URLs 2015-09-30 15:43:49 -05:00
Matt Mackall
f0c000187c merge with stable 2015-06-01 14:47:02 -05:00
FUJIWARA Katsunori
1d5cc643a1 templatekw: compare target context and its parent exactly (issue4690)
Before this patch, template keywords `{file_mods}`, `{file_adds}` and
`{file_dels}` use values gotten by `repo.status(ctx.p1().node(),
ctx.node())`.

But this doesn't work as expected if `ctx` is `memctx` or
`workingcommitctx`. Typical case of templating with these contexts is
customization of the text shown in the commit message editor by
`[committemplate]` configuration.

In this case, `ctx.node()` returns None and it causes comparison
between `ctx.p1()` and `workingctx`. `workingctx` lists up all changed
files in the working directory even at selective committing.

BTW, `{files}` uses `ctx.files()` and it works as expected.

To compare target context and its parent exactly, this patch passes
`ctx.p1()` and `ctx` without `node()`-nize. This avoids unexpected
comparison with `workingctx`.

This patch uses a little redundant template configurations in
`test-commit.t`, but they are needed to avoid regression around
problems fixed by 17e2fda16f58 and 2b999bc2d89a: accessing on `ctx`
may break `ctx._status` field.
2015-06-02 02:28:33 +09:00
Durham Goode
54f9c89eae commit: add ui.allowemptycommit config option
This adds a config flag that enables a user to make empty commits.
This is useful in a number of cases.

For instance, automation that creates release branches via
bookmarks may want to make empty commits to that release bookmark so that it
can't be fast-forwarded and so it can record information about the release
bookmark's creation. This is already possible with named branches, so making it
possible for bookmarks makes sense.

Another case we've wanted it is for mirroring repositories into Mercurial. We
have automation that syncs commits into hg by running things from the command
line. The ability to produce empty commits is useful for syncing unusual commits
from other VCS's.

In general, allowing the user to create the DAG as they see fit seems useful,
and when I mentioned this in IRC more than one person piped up and said they
were already hacking around this limitation by using mq, import, and
commit-dummy-change-then-amend-the-content-away style solutions.
2015-05-11 16:18:28 -07:00
Ryan McElroy
1729fe1e93 templatekw: replace currentbookmark with activebookmark keyword
Today, the terms 'active' and 'current' are interchangeably used throughout the
codebase in reference to the active bookmark (the bookmark that will be updated
with the next commit). This leads to confusion among developers and users.
This patch is part of a series to standardize the usage to 'active' throughout
the mercurial codebase and user interface.
2015-04-15 08:19:36 -07:00
Mads Kiilerich
7167031347 localrepo: show headline notes in commitctx before showing filenames
commitctx already showed notes with filenames but didn't provide any context.
It is just as relevant to know when manifest or changelog is committed.

So, in addition to filenames, also show headlines 'committing files:',
'committing manifest' and 'committing changelog'.
2014-04-18 13:33:20 +02:00
FUJIWARA Katsunori
851e75b58e context: override _dirstatestatus in workingcommitctx for correct matching
Before this patch, the result of "status()" on "workingcommitctx" may
incorrectly contain files other than ones to be committed, because
"workingctx._dirstatestatus()" returns the result of
"dirstate.status()" directly.

For correct matching, this patch overrides "_dirstatestatus" in
"workingcommitctx" and makes it return matched files only in
"self._status".

This patch uses empty list for "deleted", "unknown" and "ignored" of
status, because status between "changectx"s also makes them empty.
2014-12-31 17:55:43 +09:00
FUJIWARA Katsunori
7b31cd3a28 context: avoid breaking already fixed self._status at ctx.status()
Before this patch, "status()" on "workingcommitctx" with "always
match" object causes breaking "self._status" in
"workingctx._buildstatus()", because "workingctx._buildstatus()"
caches the result of "dirstate.status()" into "self._status" for
efficiency, even though it should be fixed at construction for
committing.

For example, template function "diff()" without any patterns in
"committemplate" implies "status()" on "workingcommitctx" with "always
match" object, via "basectx.diff()" and "patch.diff()".

Then, broken "self._status" causes committing unexpected files.

To avoid breaking already fixed "self._status" at "ctx.status()", this
patch overrides "_buildstatus" in "workingcommitctx".

This patch doesn't write out the result of template function "diff()"
in "committemplate" in "test-commit.t", because matching against files
to be committed still has an issue fixed in subsequent patch.
2014-12-31 17:55:43 +09:00
Matt Harbison
8080f9baf5 tests: add missing globs for Windows
I couldn't figure out how to glob the first chunk for Windows, so it's been
conditionalized.
2014-12-10 22:09:46 -05:00
FUJIWARA Katsunori
9eb07e5515 memctx: remove redundant test for issue4470 from test-commit.t
Because:

  - the test to avoid regression for issue4470 was already added to
    test-commit-amend.t by previous patch

    It is also a part of test series about manifest calculation issues
    of memctx in test-commit-amend.t.

  - this is the only test using "commit --amend" in test-commit.t
2014-12-19 00:11:56 +09:00
Matt Mackall
0826b8e884 merge with stable 2014-12-18 16:41:59 -06:00
Matt Mackall
8b83dfc480 pathauditor: check for Windows shortname aliases 2014-12-18 14:18:28 -06:00
Augie Fackler
13206234f4 pathauditor: check for codepoints ignored on OS X 2014-12-16 13:08:17 -05:00
Augie Fackler
a029bf7fdb memctx: fix manifest for removed files (issue4470)
filectxfn returns None for removed files, so we have to check for None
before computing the new file content hash for the manifest.

Includes a test that proves this works, by demonstrating that we can
show the diff of an amended commit in the committemplate.
2014-12-15 15:00:54 -05:00
FUJIWARA Katsunori
df8f4a6663 commit: change "editform" to distinguish merge commits from others
"editform" argument for "getcommiteditor" is decided according to the
format below:

  COMMAND[.ROUTE]

  - COMMAND: name of command
  - ROUTE: name of route, if there are two or more routes in COMMAND

This patch uses "normal.normal" and "normal.merge" as ROUTE of
"editform" instead of "normal", to distinguish merge commits from
others in "hg commit" without "--amend" case.

This patch assumes "editform" variations for "hg commit" below:

    commit.normal.normal
    commit.normal.merge
    commit.amend.normal
    commit.amend.merge

"mergeeditform" is factored out for subsequent patches. It takes
"ctxorbool" argument, because context object can't be passed in some
cases.
2014-08-16 10:43:59 +09:00
FUJIWARA Katsunori
e8856bc78d ui: invoke editor for committing with HGEDITFORM environment variable
At the external editor invocation for committing, the value specified
as "editform" for "cmdutil.getcommiteditor" is in "HGEDITFORM".

This enables external editor to do own customization according to
commit types.
2014-08-15 23:05:53 +09:00
FUJIWARA Katsunori
ec97822d35 cmdutil: look commit template definition up by specified 'editform'
Before this patch, '[committemplate] changeset' definition is shared
between all actions invoking 'commitforceeditor()'.

This prevents template definition from showing action specific
messages: for example, 'hg tag --remove' may need specific
message to call attention, but showing it may be redundant for
other actions.

This patch looks commit template definition up by specified
'editform' introduced by prior patches. 'editform' are
dot-separated list of names, and treated as hierarchical one.
2014-08-02 21:46:27 +09:00
FUJIWARA Katsunori
f9743bb802 cmdutil: make commit message shown in text editor customizable by template
This patch makes commit message shown in text editor customizable by
template. For example, this can advertise:

  - sample commit messages for routine works,
  - points to call attention before commit,
  - message of the day, and so on

To show commit message correctly even in problematic encoding, this
patch chooses the latter below:

  - replace "buildcommittext" with "buildcommittemplate" completely

  - invoke "buildcommittemplate" only if '[committemplate] changeset'
    is configured explicitly

For example, if multibyte character ending with backslash (0x5c) is
followed by ASCII character 'n' in the customized template, sequence
of backslash and 'n' is treated as line-feed unexpectedly (and
multibyte character is broken, too).

This corruption occurs in 'decode("string-escape")' while parsing
template string.
2014-07-15 23:34:13 +09:00
Bradley M. Kuhn
4cd8c219ba commit: --edit/-e to force edit of otherwise-supplied commit message
The --edit/-e option for the 'commit' command forces editor, even when a
commit message has been provided already by other means, such as by the -m or
-l options.
2013-09-08 19:02:08 -04:00
Kevin Bullock
c63d1fcf68 merge with stable
This should correct an earlier couple of bad merges (5433856b2558 and
596960a4ad0d, now pruned) that accidentally brought in a change that had
been marked obsolete (244ac996a821).
2014-03-31 10:12:07 -05:00
Sean Farley
04ea4eb32d tests: use TESTTMP instead of TESTDIR
In d87f1c1d18fa, be4d37a43992, 394118f2cf71, and 7594c2ea371e, new tests were
added that used TESTDIR instead of TESTTMP thereby leading to polluting the
working directory with these temporary files. Now, we use TESTTMP so that they
will be cleaned up properly.
2014-03-28 14:33:27 -05:00
FUJIWARA Katsunori
51bca8f3b4 localrepo: save manually edited commit message as soon as possible
Before this patch, "localrepository.commit()" invokes specified
"editor" to edit commit message manually, and saves it after checking
sub-repositories.

This may lose manually edited commit message, if unexpected exception
is raised while checking (or commiting recursively) sub-repositories.

This patch saves manually edited commit message as soon as possible.
2014-03-19 01:07:41 +09:00
Mads Kiilerich
914cc822c9 repo: rephrase the "missing requirement" error message
Unknown requirements will now be reported as:
  abort: repository requires features unknown to this Mercurial: largefiles!
  (see http://mercurial.selenic.com/wiki/MissingRequirement for more information)

Some features of this phrasing:
* avoid double ':' in abort message
* make it more clear who requires and knows what
* don't quote the requirement names - it is not something the user entered or
  need the exact spelling of ... and it is "identifiers" that are unambiguous
  anyway
* remove double hint by removing "(upgrade Mercurial)" comment
* don't mention upgrading Mercurial without mentioning enabling the feature -
  instead, just refer to wiki page for both
* don't just talk about "details", talk about "more information"
2014-03-19 00:18:30 +01:00
Matt Mackall
ea6ffc9a80 merge with stable 2014-03-18 14:25:28 -05:00
Antonio Zanardo
a6143a0b42 commit: show active bookmark in commit editor helper text
If there is an active bookmark while committing, the bookmark name
will be visible inside the commit message helper, below the branch
name.

This should make easier for the user to detect a mistaken commit
parent, while working for example with a bookmark centric workflow
like topic branches.

The active bookmark is checked to be in the working directory, as
pointed by Kevin Bullock, because otherwise committing would not
advance it. In other words, this would not show the active
bookmark name if the user changed the working tree parents with
'hg debugsetparents', for example.
2013-02-02 15:37:17 -02:00
Bryan O'Sullivan
158df87946 tests: reduce spurious failures when run with generaldelta
Quite a few tests fail in noisy but meaningless ways when the test suite
is run with generaldelta enabled:

  ./run-tests.py --extra-config-opt=format.generaldelta=1

This reduces the amount of noise introduced by the debugindex command,
the main source of differences.  In my environment, when testing with
generaldelta enabled, this change reduces the number of completely
failing tests from 21 to 8.
2012-07-11 15:03:10 -07: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
Adrian Buehlmann
a98fa3a65d test-commit: remove extra cd ..
This specific cd .. leaves the base directory of the test ($TESTTMP).

Removing it avoids that test artifacts (e.g. files) are created
outside of the base directory.
2012-06-09 14:20:25 +02:00
Adrian Buehlmann
6949570f9b tests: roll test-commit-copy.t into test-commit.t 2012-06-04 18:40:31 +02:00
Mads Kiilerich
7d411da706 tests: introduce c-style conditional sections in .t tests
This makes it possible to have conditional sections like:

#if windows
  $ echo foo
  foo
#else
  $ echo bar
  bar
#endif

The directives and skipped sections are treated like comments, so don't
interleave them with commands and their output.

The parameters to #if are evaluated while preparing the test by passing them
over to hghave. Requirements can thus be negated with 'no-' prefix, and
multiple requirements must all be true to return true.
2012-06-01 02:25:12 +02:00
Mads Kiilerich
637e2ecde2 tests: hide 'No such file or directory' messages
Windows will use a different and localized message.
2011-11-16 03:45:14 +01:00
Mads Kiilerich
8c22a0ec28 tests: make (glob) on windows accept \ instead of /
Globbing is usually used for filenames, so on windows it is reasonable and very
convenient that glob patterns accepts '\' or '/' when the pattern specifies
'/'.
2011-11-07 03:25:10 +01:00
Mads Kiilerich
4838bfb2c4 tests: use 'hghave symlink' for tests using symlinks 2011-11-07 03:14:54 +01:00
Pierre-Yves David
4b1a4196e2 require: provide a link to a wiki page in addition of suggesting upgrade
The wiki page is intended to describe several solution to the requirement issue.
Some of those solutions does not involve upgrading mercurial. That is very
useful for people that can't easily upgrade they Mercurial in some place.
2011-06-25 02:46:23 +02:00
Pierre-Yves David
2ebc0660c3 requirements: show all missing features in the error message.
Displaying all missing featureis help people to solve the issue (choosing the
right version, creation the right repo)
2011-06-25 02:30:24 +02:00
Adrian Buehlmann
cfc4484960 readrequires: provide easier to understand error message
NEW:

  $ hg id
  abort: unknown repository format: requires feature 'foo' (upgrade Mercurial)!

OLD:

  $ hg id
  abort: requirement 'foo' not supported!
2011-05-31 19:16:25 +02:00
Martin Geisler
43d795e497 commit: note when files are missing
Before, you could experience the following strange interaction:

  $ hg commit
  nothing changed
  $ hg merge
  abort: outstanding uncommitted changes

which confused at least one user in #mercurial.
2011-04-06 16:21:12 +02:00
Adrian Buehlmann
a8a418601f introduce new RequirementError (issue2649)
This improves the misleading error message

  $ hg identify
  abort: there is no Mercurial repository here (.hg not found)!

to the more explicit

  $ hg identify
  abort: requirement 'fake' not supported!

for all commands in commands.optionalrepo, which includes the identify
and serve commands in particular.

This is for the case when a new entry in .hg/requires will be defined
in a future Mercurial release.
2011-02-18 20:25:25 +01:00
Adrian Buehlmann
9817658bbd parsedate: abort on negative dates (issue2513)
catches "hg commit -d '-7654321 3600'" (example)
2010-11-24 19:31:43 +01:00
Martin Geisler
3d112b3042 tests: added a short description to issue numbers
Many tests already had a short line to describe what IssueXXX is
about. I find that quite useful when reading a test.
2010-09-24 10:13:49 +02:00
Matt Mackall
bf9417da11 tests: exit 0 no longer needed on unified tests 2010-09-17 17:03:04 -05:00
Matt Mackall
08439e0f2d tests: add exit codes to unified tests 2010-09-16 17:51:32 -05:00
Martin Geisler
cc612c476f tests: remove unneeded -d flags
Many tests fixed the commit date of their changesets at '1000000 0' or
similar. However testing with "Mon Jan 12 13:46:40 1970 +0000" is not
better than testing with "Thu Jan 01 00:00:00 1970 +0000", which is
the default run-tests.py installs.

Removing the unnecessary flag removes some clutter and will hopefully
make it clearer what the tests are really trying to test. Some tests
did not even change their output when the dates were changed, in which
case the -d flag was truly irrelevant.

Dates used in sequence (such as '0 0', '1 0', etc...) were left alone
since they may make the test easier to understand.
2010-09-02 23:22:51 +02:00
Nicolas Dumazet
90787c08f9 util: get rid of extra trailing whitespace in parsedate abort message 2010-08-30 13:29:44 +09:00
Nicolas Dumazet
557c241888 tests: unify test-commit 2010-08-12 22:22:17 +09:00