Commit Graph

2912 Commits

Author SHA1 Message Date
Gregory Szorc
68fc062c6f commands: unify argument handling for revlog debug commands
The same 3 options are used in a few locations and I'm about to
add another. Might as well consolidate the pattern.
2015-12-05 21:47:39 -08:00
Yuya Nishihara
3e4bbbe974 commit: fix rest syntax of examples
This fixes the formatting of help/commit page and silence test-gendoc.t.
2015-12-06 17:16:37 +09:00
Matt Harbison
378739c9cd commit: adjust the quoting in the examples to be Windows friendly
We should probably avoid strong quotes around command line args in the examples,
since cmd.exe doesn't recognize them, and it will surprise a user who cargo
cults them.  I don't see a way to make a rule for this, since strong quoting is
OK inside command line args, like within revsets.
2015-12-05 22:19:48 -05:00
Augie Fackler
31fc3d117c commit: add some help examples (issue4963)
Includes documenting --date now, which resolves the above issue.
2015-12-04 15:24:05 -05:00
Yuya Nishihara
78ebbc20b2 graphlog: move creation of workingdir-parent nodes to displaygraph()
Future patches will make a node symbol templatable. Because arguments of a
templatekw function are repo and ctx, "showparents" list will have to be
built from a repo object by that function.
2015-11-14 16:45:15 +09:00
FUJIWARA Katsunori
f8fa1a1ece commands: execute checkunfinished and bailifchanged inside wlock scope
Before this patch, "hg import" executes below before acquisition of
wlock:

  - cmdutil.checkunfinished()
  - cmdutil.bailifchanged()

It may cause unintentional result, if another command runs parallelly
(see also issue4368).

To avoid this issue, this patch executes 'cmdutil.checkunfinished()'
and 'cmdutil.bailifchanged()' inside wlock scope of "hg import".
2015-12-02 03:12:08 +09:00
FUJIWARA Katsunori
3aef0e6f75 commands: widen wlock scope of graft for consitency while processing
Before this patch, "hg graft" executes below before acquisition of
wlock.

  - cmdutil.checkunfinished()
  - cmdutil.bailifchanged()
  - repo.dirstate.parents() via 'repo["."]'
  - unlinking '.hg/graftstate'

It may cause unintentional result, if another command runs parallelly
(see also issue4368).

This patch widens wlock scope of "hg graft" for consitency while
processing.
2015-12-02 03:12:07 +09:00
FUJIWARA Katsunori
9b4fb6e7f8 commands: make backout acquire locks before processing
Before this patch, "hg backout" executes below before acquisition of
wlock.

  - cmdutil.checkunfinished()
  - cmdutil.bailifchanged()
  - repo.dirstate.parents()

It may cause unintentional result, if another command runs parallelly
(see also issue4368).

In addition to it, "hg backout" refers changelog for purposes below
without acquisition of store lock (slock), and it may cause
unintentional result, if store is updated parallelly.

  - show and update to the revision by 'repo.changelog.tip()'

  - examine for "created new head" by 'repo.branchheads()' and
    'cmdutil.commitstatus()'

To avoid this issue, this patch makes "hg backout" acquire wlock and
slock before processing.
2015-12-02 03:12:07 +09:00
FUJIWARA Katsunori
401c1d7800 commands: make commit acquire locks before processing (issue4368)
Before this patch, "hg commit" (process A) executes steps below:

  1. get current branch heads via 'repo.branchheads()'
     - cache 'repo.changelog'
  2. invoke 'repo.commit()'
  3. acquire wlock
     - invalidate 'repo.dirstate'
  4. access 'repo.dirstate'
     - re-read '.hg/dirstate'
     - check validity of parent revisions with 'repo.changelog'
  5. invoke 'repo.commitctx()'
  6. acquire store lock (slock)
     - invalidate 'repo.changelog'
  7. do committing
  8. release slock
  9. release wlock
 10. check new branch head (via 'cmdutil.commitstatus()')

If acquisition of wlock at (3) above waits for another "hg commit"
(process B) or so running parallelly to release wlock, process A
causes creating orphan revision, because:

  - '.hg/dirstate' refers the revision, which is newly added by
    process B, as its parent

  - but already cached 'repo.changelog' doesn't contain such revision

  - therefore, validating parents of '.hg/dirstate' at (4) above
    replaces such revision with 'nullid'

Then, process A creates "orphan" revision, of which parent is "null"
revision.

In addition to it, "created new head" may be shown at the end of
process A unintentionally, if store is updated parallelly, because
both getting branch heads (1) and checking new branch head (10) are
executed outside slock scope.

To avoid this issue, this patch makes "hg commit" acquire wlock and
slock before processing.

This patch resolves the issue between "hg commit" processes, but not
one between "hg commit" and other commands. Subsequent patches resolve
the latter.

Even after this patch, there are still corner case problems below:

  - filecache may overlook changes of '.hg/dirstate', and it causes
    similar issue (see below for detail)

    https://bz.mercurial-scm.org/show_bug.cgi?id=4368#c10

  - 3rd party extension may cause similar issue, if it directly uses
    'repo.commit()' without acquisition of wlock and slock

    This can be fixed by acquisition of slock at the beginning of
    'repo.commit()', but it seems suitable for "default" branch

    In fact, acquisition of slock itself is already introduced at
    "default" branch by ec227b188932, but acquisition is not at the
    beginning of 'repo.commit()'.

This patch also changes some tests:

  - test-fncache.t needs this tricky wrapping, to release (= forced
    failure of) wlock certainly

  - order of "hg commit" output is changed by widening scope of locks,
    because some hooks are fired after releasing wlock
2015-12-02 03:12:07 +09:00
Christian Delahousse
2a005d816a dirstate: change debugrebuilddirstate --minimal to use dirstate.rebuild
When debugrebuilddirstate --minimal is called, rebuilding the dirstate was done
outside of the appropriate rebuild function. This patch makes
debugrebuilddirstate use dirstate.rebuild.

This was done to allow our extension to become aware debugrebuilddirstate
--minimal
2015-11-30 11:23:15 -08:00
timeless
3d618fe024 graft: improve --continue abort message
before, if you ran hg graft --user ... --date ... --log ... revs,
and if it failed, it would suggest "hg graft --continue",
but if you did that, your --user / --date / --log options
were lost, because they were not persisted anywhere...
2015-12-02 06:33:52 +00:00
timeless
9742970292 summary: mention graft 2015-12-02 06:31:12 +00:00
Augie Fackler
840125d439 commands: inline definition of localrepo.parents() and drop the method (API)
localrepo.parents() has relatively few users, and most of those were
actually implicitly looking at the wctx, which is now made explicit
via repo[None].
2015-11-11 20:07:15 -05:00
Mike Edgar
8e7be9d666 commit: preserve extra when amending with commit --amend
The new extra propagation needs to be accounted for in cmdutil.amend,
when checking for a no-changes fast-path.
2015-11-28 04:11:57 -05:00
Mike Edgar
35c5515acc graft: copy extra (except branch) when copying changesets 2015-11-28 04:11:38 -05:00
Mathias De Maré
d20ed7b157 commands: add examples for 'addremove' 2015-11-25 18:10:59 +01:00
Mathias De Maré
ef88a42655 commands: add example for 'hg add' 2015-11-25 18:10:31 +01:00
Yuya Nishihara
8b17e38d89 serve: unify cmdutil.service() calls of commandserver and hgweb 2015-10-31 22:17:05 +09:00
Yuya Nishihara
c64bc024c8 hgweb: extract factory function of httpservice object
The next patch will merge the cmdutil.service() calls of both commandserver
and hgweb. Before doing it, this patch wipes out the code specific to hgweb
from commands.serve().
2015-10-31 22:15:16 +09:00
Yuya Nishihara
4fb8995ece hgweb: move httpservice object from commands module
This avoids the deep import of hgweb.server at the commands module.
2015-10-31 21:57:45 +09:00
Siddharth Agarwal
298e8f0bd3 debugmergestate: also recognize change/delete conflicts in the merge state
We're going to use this for tests in upcoming patches.
2015-11-24 18:26:21 -08:00
Siddharth Agarwal
6bdb690f9a debugmergestate: print out null nodes as 'null'
This is so much easier to read than a long string of zeroes, and we're going to
have a lot more of these nodes once change/delete conflicts are part of the
merge state.
2015-11-30 10:26:37 -08:00
Mathias De Maré
b4c9b11d12 identify: refer to log to be able to view full hashes 2015-11-27 20:23:23 +01:00
Mathias De Maré
2bc22a2b60 log: add 'hg log' example for full hashes 2015-11-27 20:23:02 +01:00
Mathias De Maré
f15b803069 backout: add examples to clarify basic usage 2015-10-02 07:48:23 +02:00
Siddharth Agarwal
2071a98a25 resolve: record dirstate actions after performing resolutions
Some resolutions might lead to pending actions we need to perform in the
dirstate -- so perform them.
2015-11-15 21:27:22 -08:00
Siddharth Agarwal
5380ac35da resolve: fix incorrect merge
The merge from stable into default was semantically incomplete -- a couple of
changes in preceding code had to be rewritten here.

This code only triggers for change/delete conflicts, so we can't test it yet.
We will soon be able to do it, though.
2015-11-18 23:43:18 -08:00
Matt Mackall
a20ef0162d merge with stable 2015-11-18 20:59:17 -06:00
Siddharth Agarwal
4e11ac7ea5 resolve: restore .orig only after merge is fully complete (issue4952)
Previously, we'd restore the .orig file after the premerge is complete but
before the merge was complete. This would lead to the .orig file potentially
containing merge conflict markers in it, as a leftover from the last merge
attempt.
2015-11-13 15:56:02 -08:00
Siddharth Agarwal
61e8a89dd2 debugmergestate: explain why we create mergestate objects directly
We would normally use the read() constructor, but in this case it's fine
because
- we implement our own reading layer, so the extra parsing done by
   read() is unnecessary
- read() can raise an exception for unsupported merge state records,
   but here we'd like to handle that separately
- debugmergestate needs to be privy to mergestate internals anyway
2015-11-17 14:22:30 -08:00
Christian Delahousse
b71632a839 debugdirstate: convert keyword parameters to **opts
Removes the named arguments and replaces them by accessing opts. This will be
used in the next patch in the series because we'll be adding more flags to
debugdirstate
2015-11-11 13:28:00 -08:00
Siddharth Agarwal
2204a499bc commands.summary: switch to mergestate.read()
See previous patch for why we're doing this.

We do this with a bit of care -- it would be bad form for 'hg summary' to abort
completely if we encounter an unsupported merge record. Instead just warn about
that and continue with the rest of the summary.
2015-11-17 14:20:55 -08:00
Siddharth Agarwal
88c48784e2 commands.resolve: switch to mergestate.read()
See previous patches for why we're doing this.
2015-11-17 13:56:46 -08:00
Siddharth Agarwal
c7aefbc8d6 debugmergestate: print out record type for files
We're going to add a separate record type for change/delete conflicts soon. We
need to make sure they get stored with the correct record type so that older
versions of Mercurial correctly abort when they see change/delete records.
2015-11-13 23:01:36 -08:00
Augie Fackler
8501cbfa05 debugrevlog: cope with empty revlog files
I have no idea where it came from, but my clone of Mercurial has an
empty filelog for `contrib/hgfixes/__init__.py` - it's *valid*, just
contains no nodes. Without this change, debugrevlog crashes with a
zero division error.
2015-10-23 11:04:53 -04:00
timeless
ca55452b0c commands: fix help for debugobsolete 2015-10-20 18:46:00 -04:00
Sean Farley
68f4554f78 pull: all pass along extra opargs
Wihtout this patch, commands.pull silently drops opargs defeating the whole
purpose of the argument.
2015-10-19 15:47:40 -07:00
Sean Farley
4c9db86a8b push: all pass along opargs
Wihtout this patch, commands.push silently drops opargs defeating the whole
purpose of the argument.
2015-10-19 15:43:35 -07:00
Pierre-Yves David
5c189f7c9b unbundle: use 'url' argument with applybundle
This will let the hook get access to the 'url' value.
2015-10-20 15:56:22 +02:00
Pierre-Yves David
921847dc20 unbundle: use 'source' argument with applybundle
This will let the hook get access to the 'source' value.
2015-10-20 15:53:07 +02:00
Pierre-Yves David
d58db8692b unbundle: use 'bundle2.applybundle'
This is one such place.
2015-10-20 15:47:20 +02:00
Siddharth Agarwal
700ac1613d commands.resolve: conclude merge driver if no unresolved files are left
This can happen when either 'hg resolve --all' is called or a driver-resolved
file is explicitly requested.

This is done as part of 'hg resolve --all' so that users still have a chance to
test their changes before committing them.

The exact semantics here are still to be decided. This does not impact any
non-experimental features.

Thanks to Pierre-Yves David for some advice about this behavior in particular,
and merge drivers in general.
2015-10-15 01:31:04 -07:00
Siddharth Agarwal
2dafef1c48 commands.resolve: call driverpreprocess if we haven't run it yet
We need to be careful about allowing --mark and --unmark to keep working -- we
don't want the user to be stuck in a weird state. The exact behavior here is
still to be decided, though.
2015-10-15 01:27:06 -07:00
Siddharth Agarwal
3465e76062 commands.resolve: don't allow users to mark or unmark driver-resolved files
Users will often be in the habit of running 'hg resolve --mark --all' after
resolving merge conflicts in source files. We need to make sure this doesn't
cause driver-resolved files to be marked.

'hg resolve --all' will resolve driver-resolved files, though.

The weird conditional structure is to accommodate an upcoming patch.
2015-10-15 01:15:22 -07:00
Siddharth Agarwal
1bbadeb63f resolve: only create wctx once
This allows for status and other results on the wctx to be cached between iterations.
2015-10-15 01:11:50 -07:00
Siddharth Agarwal
e78d354b3c commands.resolve: print out warning when only driver-resolved files remain
'hg resolve --all' will be the canonical way to run the 'conclude' step of the
merge driver.
2015-10-15 01:09:58 -07:00
Siddharth Agarwal
b6455eb8c6 commands.resolve: support printing out driver-resolved files
There's no user-visible way to mark files as driver-resolved, so this status
won't be visible.
2015-10-15 00:45:20 -07:00
Gregory Szorc
ddb0256917 exchange: support parameters in bundle specification strings
Sometimes a basic type string is not sufficient for representing the
contents of a bundle. Take bundle2 for example: future bundle2 files may
contain parts that today's bundle2 parser can't read. Another example is
stream clone data. These require clients to support specific
repository formats or they won't be able to read the written files. In
both scenarios, we need to describe additional metadata beyond the outer
container type. Furthermore, this metadata behaves more like an
unordered set, so an order-based declaration format (such as static
strings) is not sufficient.

We introduce support for "parameters" into the bundle specification
string. These are essentially key-value pairs that can be used to encode
additional metadata about the bundle.

Semicolons are used as the delimiter partially to increase similarity to
MIME parameter values (see RFC 2231) and because they are relatively
safe from the command line (although values will need quotes to avoid
interpretation as multiple shell commands). Alternatives considered were
spaces (a bit annoying to encode) and '&' (similar to URL query strings)
(which will do bad things in a shell if unquoted).

The parsing function now returns a dict of parsed parameters and
consumers have been updated accordingly.
2015-10-14 17:00:34 -07:00
Gregory Szorc
ae85c846e7 commands: support consuming stream clone bundles
For the same reasons that we don't produce stream clone bundles with `hg
bundle`, we don't support consuming stream clone bundles with `hg
unbundle`. We introduce a complementary debug command for applying
stream clone bundles. This command is mostly to facilitate testing.
Although it may be used to manually apply stream clone bundles until a
more formal mechanism is (possibly) adopted.
2015-10-15 13:43:18 -07:00
Gregory Szorc
e52d35ae6b commands: support creating stream clone bundles
Now that we have support for recognizing the streaming clone bundle
type, add a debug command for creating them.

I decided to create a new debug command instead of adding support to `hg
bundle` because stream clone bundles are not exactly used the same way
as normal bundle files and I don't want to commit to supporting them
through the official `hg bundle` command forever. A debug command,
however, can be changed without as much concern for backwards
compatibility.

As part of this, `hg bundle` will explicitly reject requests to produce
stream bundles.

This command will be required by server operators using stream clone
bundles with the clone bundles feature.
2015-10-17 11:40:29 -07:00