Commit Graph

990 Commits

Author SHA1 Message Date
timeless
3502e556ef util: enable getpid to be replaced
This will enable tests to write stable process ids.
2016-02-03 09:11:22 +00:00
Martin von Zweigbergk
c84bb33a89 match: rename "narrowmatcher" to "subdirmatcher" (API)
I keep mistaking "narrowmatcher" for narrowhg's
narrowmatcher. "subdirmatcher" seems more to the point anyway.
2016-02-05 21:09:32 -08:00
liscju
70a7e0a4b4 revert: makes interactive mode ask to forget added files (issue4936)
Before this patch revert interactive mode unconditionally forgets
added files. This patch fixes this by asking user if he wants
to forget added file. If user doesn't want to forget given file,
it is added to matcher_opts exclude list, to not reviewing it
later with other modified files.
2016-02-05 15:18:40 +01:00
Gregory Szorc
5e2a52d9ca exchange: move bundle specification parsing from cmdutil
Clone bundles require a well-defined string to specify the type of
bundle that is listed so clients can filter compatible file types. The
`hg bundle` command and cmdutil.parsebundletype() already establish the
beginnings of a bundle specification format.

As part of formalizing this format specification so it can be used by
clone bundles, we move the specification parsing bits verbatim to
exchange.py, which is a more suitable place than cmdutil.py. A
subsequent patch will refactor this code to make it more appropriate as
a general API.
2015-10-13 11:43:21 -07:00
FUJIWARA Katsunori
af664f3cc0 dirstate: move code paths for backup from dirstateguard to dirstate
This can centralize the logic to write in-memory changes out correctly
according to transaction activity into dirstate.

Passing 'repo' object to newly added functions is needed to examine
current transaction activity in subsequent patches, because 'dirstate'
itself doesn't have direct reference to it.
2015-10-14 02:49:17 +09:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
FUJIWARA Katsunori
05986aa7a1 cmdutil: stop tryimportone from using dirstateguard (BC)
There is no user of 'cmdutil.tryimportone()' other than
'commands.import_()', which can restore dirstate at failure of
applying patches by transaction or dirstateguard.

Therefore, it is reasonable to stop 'tryimportone()' from using
redundant 'dirstateguard', even though it changes behavior of
'tryimportone()'.

After this patch, 3rd party extensions should use 'dirstateguard' or
so explicitly, if they want to restore dirstate at failure of
importing a patch.
2015-10-09 03:53:46 +09:00
FUJIWARA Katsunori
f2187903e7 dirstate: remove meaningless dirstateguard
Previous patch made dirstate changes in a transaction scope "all or
nothing". Therefore, 'dirstateguard' is meaningless, if its scope is
as same as one of the related transaction.

This patch removes such meaningless 'dirstateguard' usage.
2015-10-09 03:53:46 +09:00
Pierre-Yves David
e5e36f8235 import: allow processing of extra part header after import
As we have a way for extension to add more header, we need a way for them to
actually process them. We add a basic hook point to do extra work after the
import have been committed.
2015-10-07 13:05:25 -07:00
Pierre-Yves David
684d4c614d import: allow processing of extra part header during import
As we have a way for extension to add more header, we need a way for them to
actually process them. We add a basic hook points to alter the changeset
(especially extra) before we commit. There would be more to do for a full
featured hooking, but this currently fit my needs.
2015-10-06 09:51:24 -07:00
Pierre-Yves David
ec1d4cc8b3 patch: move 'extract' return to a dictionnary
The final goal here is to be able to parse, return and process arbitrary data
from patch. This mirror the recently added ability to add arbitrary data to
patch headers.

The first step is to return something more flexible, so we return a dict without
changing any other logic.
2015-10-06 02:01:53 -07:00
Pierre-Yves David
d6432f70b8 export: introduce a generic way to add patch header on export
Extensions currently have no easy way to add data to exported
patch. This is now fixed using a generic mechanism in the same fashion
used by bundle2. Tests are coming in the next changeset with its first
user.
2015-10-05 23:17:01 -07:00
Pierre-Yves David
232a6cb371 bundle: use bundle2 if repository uses general delta
As bundle1 does not support generaldelta, this would mean recomputing delta at
bundle time. This is similar to what we do for strip and shelve and was tracked
as issue4865.
2015-10-01 20:31:43 -07:00
Pierre-Yves David
f1e9601240 parsebundletype: add a comment for future generation 2015-10-01 20:21:16 -07:00
Pierre-Yves David
8f390ad0b6 bundle: extend the format of --type to support version and compression
We had some basic undocumented support for uncompressed bundle2 support. We now
have an official extensible syntax to specify both format type and compression
(eg: bzip2-v2).

In practice, this changeset introduce the 'v1' and 'v2' identifier to make it
possible to combine format and compression. The default format is still 'v1'.
We'll care about picking 'v1' or 'v2' in regard with general delta in the next
changesets.
2015-10-01 19:16:00 -07:00
Pierre-Yves David
63b3b90838 bundle: extract the parsing of the bundle type in a function
We are going to introduce significant extensions of the bundle parsing code to
support creation of bundle2 through the bundle command. As an early step, we
extract the logic in its own function.
2015-10-01 18:01:24 -07:00
Yuya Nishihara
dc974fcbf0 templatekw: port implementation of showparents() from changeset_templater
It isn't cool, but we can peek at ui flag via repo.ui. So, it is possible
to implement showparents() in templatekw, and therefore we can eliminate the
dockeywords hack.
2015-09-26 12:38:02 +09:00
Yuya Nishihara
c09856f19f changeset_printer: move _meaningful_parentrevs() to scmutil
It will be used by templatekw.
2015-09-26 12:29:09 +09:00
timeless@mozdev.org
51da91c959 cmdutil: handle multiline translations of HG: messages safely
Before this, if a localizer/localization included a multiline
message, and didn't prefix the intermediate lines with 'HG: ',
then the line would be a candidate for inclusion in the commit
message -- which isn't ideal.
2015-09-30 12:36:30 -04:00
timeless@mozdev.org
2993615080 cmdutil: remove HG: prefix from translation strings 2015-09-25 03:44:15 -04:00
Pierre-Yves David
124b8948d8 addremove: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 01:58:33 -07:00
Matt Harbison
99ffdaafef extdiff: enable -I/-X with --patch
Not sure how useful this really is, but it's trivial to add and ignoring the
existing arguments supported seems like a bad UI.
2015-09-09 22:27:48 -04:00
Matt Mackall
5b498724ca templater: add new docheader/footer components for XML (issue4135)
The existing header/footer components were templated per-changeset,
and thus couldn't be correctly printed for an empty log
2015-08-26 16:27:14 -05:00
Durham Goode
94ca2e4c06 add: pass full=False to dirstate walk
Previously cmdutil.add would call wctx.walk(), which under the hood calls
dirstate.walk with full=True. This means it returns all of the clean files
(which we don't need when computing the add set), as well as the unclean files.
This results in 1) a lot more work being done and 2) this code path
circumventing the hgwatchman extension, resulting in worse performance in
hgwatchman environments ('hg add .' went from 9s to 1.8s).
2015-09-09 09:07:27 -07:00
timeless@mozdev.org
52eae47139 spelling: behaviour -> behavior 2015-08-28 10:53:55 -04:00
Matt Mackall
ca5b5bbb7b templater: move verbosity-to-template matcher to constructor
We're going to reuse this and it's silly for it to be done per-cset anyway.
2015-08-25 13:38:20 -05:00
Matt Mackall
240305489f templater: remove pseudo-ternary 2015-08-25 12:59:08 -05:00
Matt Mackall
9d8dac9846 templater: fix variable name that shadows built-in 2015-08-25 12:57:21 -05:00
Matt Mackall
c43a857672 templater: minor whitespace tweaks 2015-08-25 09:38:06 -05:00
Christian Delahousse
f5b2078fe3 revert: allow configuring the .orig file location 2015-11-12 17:00:08 -06:00
Christian Delahousse
71afd0e97f cmdutil: add origbackuppath helper 2015-11-12 16:56:06 -06:00
Gregory Szorc
a935029795 cmdutil: break import cycle
This was the easiest place to break the chain, as there were only
2 uses of the imported module in the file.
2015-08-08 00:47:19 -07:00
FUJIWARA Katsunori
10e6e169f7 cmdutil: allow callers of cmdutil.dorecord to omit suggestion
Interactive committing under non-interactive mode shows command
suggestion, but sometimes it is meaningless.

  command      suggestion usability
  ------------ ---------- -----------
  record       commit
  commit -i    commit     meaningless
  qrecord      qnew
  qnew -i      qnew       meaningless
  qrefersh -i  qrefresh   meaningless
  shelve -i    commit     incorrect
  ------------ ---------- -----------

This patch allows callers of 'cmdutil.dorecord()' to omit meaningless
suggestion by passing None or so for 'cmdsuggest' argument of it.

This is a preparation for subsequent patches, which fix each
suggestion issues above.
2015-07-15 03:43:16 +09:00
Yuya Nishihara
a88883e3c5 changeset_printer: change flush() to accept ctx instead of rev
Because flush() is the function to write data buffered by show(ctx),
flush(ctx) is more consistent than flush(rev). This makes sure that
buffered header and hunk are always keyed by ctx.rev().

This patch will allow us to give an integer to the wdir while keeping
wctx.rev() -> None.
2015-04-12 21:52:02 +09:00
Yuya Nishihara
0cf602f409 changeset_printer: display wdirrev/wdirnode values for workingctx
Because we want to eliminate "if"s in the default template, it makes sense to
display wdirrev/wdirnode values for now. wdir() is still experimental, so the
output of "log -r'wdir()'" may change in future.
2015-07-04 17:19:49 +09:00
FUJIWARA Katsunori
ec0ec0f1d2 cmdutil: apply dirstate.normallookup on (maybe partially) committed files
To detect change of a file without redundant comparison of file
content, dirstate recognizes a file as certainly clean, if:

  (1) it is already known as "normal",
  (2) dirstate entry for it has valid (= not "-1") timestamp, and
  (3) mode, size and timestamp of it on the filesystem are as same as
      ones expected in dirstate

This works as expected in many cases, but doesn't in the corner case
that changing a file keeps mode, size and timestamp of it on the
filesystem.

The timetable below shows steps in one of typical such situations:

  ---- ----------------------------------- ----------------
                                           timestamp of "f"
                                           ----------------
                                           dirstate   file-
  time          action                     mem  file  system
  ---- ----------------------------------- ---- ----- -----
  N                                              ***   ***
       - change "f"                                     N

       - execute 'hg commit -i'
         - backup "f" with timestamp N
         - revert "f" by 'merge.update()'               N
           with 'partially'
         - apply selected hunks                         N
           by 'patch.patch()'

         - 'repo.commit()'
           - 'dirstate.normal("f")'         N
  N+1
           - 'dirstate.write()'             N    N

         - restore "f"                                  N+1
         - restore timestamp of "f"                     N

       - 'hg status' shows "f" as "clean"   N    N      N
  ---- ----------------------------------- ---- ----- -----

The most important point is that 'dirstate.write()' is executed at N+1
or later. This causes writing dirstate timestamp N of "f" out
successfully. If it is executed at N, 'parsers.pack_dirstate()'
replaces timestamp N with "-1" before actual writing dirstate out.

This issue can occur when 'hg commit -i' satisfies conditions below:

  - the file is committed partially, and
  - mode and size of the file aren't changed before and after committing

The root cause of this issue is that (maybe partially changed) files
are restored with original timestamp but dirstate isn't updated for
them.

To detect changes of files correctly, this patch applies
'dirstate.normallookup()' on restored files. Status check is needed
before 'dirstate.normallookup()', because status other than "n(ormal)"
should be kept at failure of committing.

This patch doesn't examine whether each files are committed fully or
partially, because interactive hunk selection makes it difficult.

After this change, timetable is changed as below:

  ---- ----------------------------------- ----------------
                                           timestamp of "f"
                                           ----------------
                                           dirstate   file-
  time          action                     mem  file  system
  ---- ----------------------------------- ---- ----- -----
  N                                              ***   ***
       - change "f"                                     N

       - execute 'hg commit -i'
         - backup "f" with timestamp N
         - revert "f" by 'merge.update()'               N
           with 'partially'
         - apply selected hunks                         N
           by 'patch.internalpatch()'

         - 'repo.commit()'
           - 'dirstate.normal("f")'         N
  N+1
           - 'dirstate.write()'             N    N

         - restore "f"                                  N+1
         - restore timestamp of "f"                     N
       ----------------------------------- ---- ----- -----
         - normallookup("f")                -1
         - release wlock
           - 'dirstate.write()'             -1   -1     N
       ----------------------------------- ---- ----- -----

       - 'hg status' shows "f" as "clean"   -1   -1     N
  ---- ----------------------------------- ---- ----- -----

To reproduce this issue in tests certainly, this patch emulates some
timing critical actions as below:

  - change "f" at N

    'touch -t 200001010000' before command invocation changes mtime of
    "f" to "2000-01-01 00:00" (= N).

  - apply selected hunks at N

    'patch.internalpatch()' with 'fakepatchtime.py' explicitly changes
    mtime of patched files to "2000-01-01 00:00" (= N).

  - 'dirstate.write()' at N+1 (or "not at N")

    'pack_dirstate()' uses actual timestamp at runtime as "now", and
    it should be different from the "2000-01-01 00:00" of "f".

BTW, in 'test-commit-interactive.t', files are sometimes treated as
modified , even though they are just committed fully via 'hg commit
-i' and 'hg diff' shows nothing for them.

Enabling win32text causes EOL style mismatching below:

  - files are changed in LF style EOL

    => files restored after committing uses LF style EOL (1)

  - 'merge.update()' reverts files in CRLF style EOL
  - 'patch.internalpatch()' changes files in CRLF style EOL

    => 'dirstate.normal()' via 'repo.commit()' uses the size of files
       in CRLF style EOL (2)

Therefore, fully committed files are treated as "modified", because
'lstat()' returns size of (1) restored files in LF style EOL, but
dirstate expects size of (2) committed files in CRLF style EOL.

After this patch, 'dirstate.normallookup()' on committed files forces
subsequent 'hg status' to examine changes exactly, and fully committed
files are treated as clean as expected.

This is reason why this patch also does:

  - add some 'hg status' checking status of fully committed files
  - clear win32text configuration before size/timestamp sensitive examination
2015-07-08 17:07:45 +09:00
FUJIWARA Katsunori
90a70a608d cmdutil: put recordfunc invocation into wlock scope for consistency
Before this patch, 'recordfunc()' for interactive hunk selection does
below outside wlock scope at 'hg commit -i' and so on:

  - backup files, which may be partially changed
  - apply selected hunks on files
  - restore files from backup-ed ones

These should be executed inside wlock scope for consistency.

To put them into wlock scope without largely changing indents in
'recordfunc()', this patch adds another wrapper function.

This patch is also a preparation for subsequent patch fixing the issue
to correctly recognize partially committed files as "modified".
2015-07-08 17:01:09 +09:00
FUJIWARA Katsunori
ad6dc899f9 cmdutil: remove useless dirstate.normallookup() invocation in revert()
Explicit 'dirstate.normallookup()' invocation in 'revert()' is useless
now, because previous patch fixed the relevant issue by writing
in-memory dirstate changes out at the end of dirty check.

'dirstate.normallookup()' invocation was introduced by 1a735e934681 to
avoid occasional test failure (see issue4583 for detail). This is
partial backout of it (added tests are still left).
2015-07-08 17:01:09 +09:00
Yuya Nishihara
0ce55c7cf2 changeset_printer: use node.wdirrev to calculate meaningful parentrevs
Because we defined the working-directory revision is INT_MAX, it makes sense
that "hg log -r 'wdir()'" displays the "parent:" field. This is the same for
two revisions that are semantically contiguous but the intermediate revisions
are hidden.
2015-07-02 22:03:06 +09:00
Pierre-Yves David
47ad450e29 amend: move obsmarkers creation in the "new changeset" conditional
We already check if we created a new changesets right above this piece of code,
so we can just drop the condition and indent the markers creation.
2014-09-28 01:09:16 -07:00
Pierre-Yves David
b721885d3f amend: move createmarkers evaluation earlier
The value is used at multiple points in the function. Retrieving the
value in the middle of the transaction scope gives the false
impression that it has a single user. We move it at the start of the
function to clarify this.
2015-06-30 22:28:40 -07:00
Pierre-Yves David
4daab561bb amend: stop updating the bookmarks twice
There was code to move the bookmarks around both in the 'cmdutil' help and in
the main 'commit' function. We kill the 'commit' version as it is performed
outside the transaction.

The debug note is moved into cmdutil.
2015-06-30 22:39:28 -07:00
Pierre-Yves David
fa60e2bce7 amend: collaborate with the transaction when moving bookmarks
We have code moving bookmarks from the old changeset to the new one within the
transaction scope. Yet this code was still writing to disk instead of
handing the change to the transaction. This changeset fixes this.
2015-06-30 22:36:49 -07:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Laurent Charignon
a48a11f98e revert: change the direction of revert -i
After the discussion on the list about hg revert -i, it seems like we are
satisfied with what we called proposition 2. It shows the changes to revert in
the same direction as hg diff. This patch makes it the default option.
It changes all the + in - and vice versa in the tests for revert -i.
2015-06-23 14:28:15 -07:00
Matt Mackall
8b7c4f2d3a formatter: move most of template option helper to formatter
We want to share this function between formatter and cmdutils. It
doesn't belong in templater because it imports knowledge of ui layers
that shouldn't be there. We'd prefer cmdutil to layer on the formatter
rather than vice-versa. Since the formatter is the handler for -T
options for all non-log commands, let's move the helper there. We
leave the bits specific to the old --style option behind.
2015-06-10 14:29:13 -05:00
Matt Harbison
c16721f6e3 revert: replace match.bad() monkey patching with match.badmatch()
No known issues with the previous code since it immediately overwrote the
patched, locally create matcher.
2015-06-04 22:02:22 -04:00
Matt Harbison
e439cb0dce cat: replace match.bad() monkey patching with match.badmatch()
No known issues with the previous code since it restored the original method,
but this is cleaner.
2015-06-04 21:55:56 -04:00
Matt Harbison
6cb27fae52 forget: replace match.bad() monkey patching with match.badmatch()
The previous code didn't restore the original method, but it looks like the
worst that would happen is junk added to a list that had already been processed
by previous subrepo invocation(s).
2015-06-04 21:53:16 -04:00
Matt Harbison
f7af267a5b add: replace match.bad() monkey patching with match.badmatch()
The previous code didn't restore the original method, but it looks like the
worst that would happen is junk added to a list that had already been processed
by previous subrepo invocation(s).
2015-06-04 21:49:50 -04:00
Laurent Charignon
f9d447f8e4 revert: add an experimental config to use inverted selection
We had a discussion on the list about the interactive ui for revert. This patch
adds a flag to allow people to test the second alternative (referred to as
proposition 2 on the mailing list). It effectively inverts the signs in the
2015-05-29 13:11:52 -07:00
Laurent Charignon
573ba7eac9 record: precise documentation
This patch improves the documentation of the recordfilter function to explain
that we need a translated string for the 'operation' argument.
2015-05-28 16:41:47 -07:00
Laurent Charignon
92c99cc1a7 record: add an operation arguments to customize recording ui
This patch is part of a series of patches to change the recording ui to reflect
the operation currently running (commit, shelve, revert ...).
This patch adds a new argument to the recording function to reflect in the UI
what operation we are running.
2015-05-27 15:49:24 -07:00
Martin von Zweigbergk
bc6ed66a89 _makelogrevset: avoid match.files() in conditions
See 559ee9ecae07 (match: introduce boolean prefix() method,
2014-10-28) for reasons to avoid match.files() in conditions.
2015-05-19 11:35:43 -07:00
Martin von Zweigbergk
bb8cf7edcc walkchangerevs: avoid match.files() in conditions
See 559ee9ecae07 (match: introduce boolean prefix() method,
2014-10-28) for reasons to avoid match.files() in conditions.
2015-05-19 11:34:50 -07:00
Martin von Zweigbergk
94a677214d walkchangerevs: simplify with an 'elif'
Since 'match.files()' is interchangeable with 'not match.files()', we
can simplify with an 'elif' follwoing the 'if match.always()'.
2015-05-21 14:20:24 -07:00
Laurent Charignon
9cd19c7de6 revert: fix edition of newly added file during --interactive
Before this patch: editing hunks of newly added file when performing a revert
--interactive had no effect: the edits were discarded.

After this patch, the edits are taken into account.
2015-05-21 14:34:24 -07:00
Laurent Charignon
301ad40550 revert: make revert --interactive use git style diff
This allows us to use existing code to detect files that are newly added and
modified. In turn, this allows us to make revert --interactive support
editing newly added and modified files.
2015-05-21 14:25:57 -07:00
Laurent Charignon
d7d40148b4 record: extract code to compute newly added and modified files
We want to reuse this logic in revert.
2015-05-21 14:32:14 -07:00
Laurent Charignon
63fddbba5d record: extract ishunk to a function
We extract this code as we want to reuse it in revert -i.
2015-05-21 14:28:02 -07:00
Matt Harbison
f25dcb1c8d files: recurse into subrepos automatically with an explicit path 2015-05-17 22:42:47 -04:00
Pierre-Yves David
d920796811 getlogrevs: rewrite a loop to get read of try/except
Get rid of the 'except StopIteration' abomination.
2015-05-18 12:18:00 -05:00
Pierre-Yves David
f794990267 _makelogrevset: replace try/except with 'next' usage
More readable without the 'except StopIteration' abomination.
2015-05-18 12:17:08 -05:00
Pierre-Yves David
be44b12d03 walkchangerevs: replace try/except with 'next'
Again, this make the code clearer.
2015-05-17 18:11:02 -07:00
Martin von Zweigbergk
decbcc4c31 treemanifest: add --dir option to debug{revlog,data,index}
It should be possible to debug the submanifest revlogs without having
to know where they are stored (in .hg/store/meta/), so let's add a
--dir option for this purpose.
2015-04-12 23:51:06 -07:00
Ryan McElroy
cf22167e56 bookmarks: rename current to active in variables and comments
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-14 12:53:48 -07:00
Durham Goode
769869c6f0 import: use ui.allowemptycommit to allow empty commits
Previously import used force=partial to allow empty commits to be made. Let's
switch it to using the new ui.allowemptycommit option. Tests says we can drop
the 'force' argument in the processs.
2015-05-11 20:15:41 -07:00
FUJIWARA Katsunori
9902feed4d tryimportone: use dirstateguard instead of beginparentchange/endparentchange
To fix the issue that the recent (in memory) dirstate isn't visible to
external process (e.g. "precommit" hook), a subsequent patch makes
"localrepository.commit()" invoke "dirstate.write()" in it.

This change will make "beginparentchange()" and "endparentchange()" on
dirstate in "cmdutil.tryimportone()" meaningless, because:

  - "dirstate.write()" writes changed data into ".hg/dirstate", but

  - aborting between "beginparentchange()" and "endparentchange()"
    doesn't cause any restoring ".hg/dirstate"

    it just discards changes in memory.

This patch uses "dirstateguard" instead of "beginparentchange()" and
"endparentchange()" in "cmdutil.tryimportone()" to restore
".hg/dirstate" during a failure even if "dirstate.write()" is executed
before a failure.

This patch uses "lockmod.release(dsguard)" instead of
"dsguard.release()", because processing may be aborted before
assignment to "dsguard" , and the "if dsguard" examination for safety is
redundant.
2015-05-07 12:07:11 +09:00
FUJIWARA Katsunori
728722d90f amend: use dirstateguard instead of dirstate.invalidate
Before this patch, "cmdutil.amend()" uses "dirstate.invalidate()" as a
kind of "restore .hg/dirstate to the original status" during a failure.

But it just discards changes in memory, and doesn't actually restore
".hg/dirstate". Then, it can't work as expected, if "dirstate.write()"
is executed while processing.

This patch uses "dirstateguard" instead of "dirstate.invalidate()" to
restore ".hg/dirstate" at failure even if "dirstate.write()" is
executed before failure.

This is a part of preparations to fix the issue that the recent (in
memory) dirstate isn't visible to external process (e.g. "precommit"
hook).
2015-05-07 12:07:10 +09:00
FUJIWARA Katsunori
d82146cda6 cmdutil: add class to restore dirstate during unexpected failure
Before this patch, after "dirstate.write()" execution, there was no way to
restore dirstate to the original status before "dirstate.write()".

In some code paths, "dirstate.invalidate()" is used as a kind of "restore
.hg/dirstate to the original status", but it just avoids writing changes in
memory out, and doesn't actually restore the ".hg/dirstate" file.

To fix the issue that the recent (in memory) dirstate isn't visible to external
processes (e.g. "precommit" hooks), "dirstate.write()" should be invoked before
invocation of external processes. But at the same time, ".hg/dirstate" should be
restored to its content before "dirstate.write()" during an unexpected failure
in some cases.

This patch adds the class "dirstateguard" to easily restore ".hg/dirstate"
during unexpected failures. Typical usecase of it is:

    # (1) build dirstate up
    ....

    # (2) write dirstate out, and backup ".hg/dirstate"
    dsguard = dirstateguard(repo, 'scopename')
    try:
        # (3) execute somethig to do:
        #     this may imply making some additional changes on dirstate
        ....

        # (4) unlink backed-up dirstate file at the end of dsguard scope
        dsguard.close()
    finally:
        # (5) if execution is aborted before "dsguard.close()",
        #     ".hg/dirstate" is restored from the backup
        dsguard.release()

For this kind of issue, an "extending transaction" approach (in
https://titanpad.com/mercurial32-sprint) seems to not be suitable, because:

  - transaction nesting occurs in some cases (e.g. "shelve => rebase"), and

  - "dirstate" may be already modified since the beginning of OUTER
    transaction scope, then

  - dirstate should be backed up into the file other than
    "dirstate.journal" at the beginning of INNER transaction scope, but

  - such alternative backup files are useless for transaction itself,
    and increases complication of its implementation

"transaction" and "dirstateguard" differ from each other also in "what
it should do for .hg/dirstate" in cases other than success.

  ============== ======= ======== =============
  type           success fail     "hg rollback"
  ============== ======= ======== =============
  transaction    keep     keep     restore
  dirstateguard  keep     restore  (not implied)
  ============== ======= ======== =============

Some collaboration between transaction and dirstate will probably be introduced
in the future. But this layer is needed in all cases.
2015-05-07 12:07:10 +09:00
Yuya Nishihara
5fa62c1dd9 templater: rename parsestring() to unquotestring() (API)
Since e926f2ef639a, it doesn't parse string escapes.
2015-05-04 10:03:13 +09:00
Yuya Nishihara
71c4aa007f templater: remove noop calls of parsestring(s, quoted=False) (API)
Since e926f2ef639a, parsestring(s, quoted=False) just returns s.
2015-05-04 10:01:03 +09:00
Ryan McElroy
be754988cc bookmarks: simplify iscurrent to isactivewdirparent (API)
Previously this function accepted two optional parameters that were unused by
any callers and complicated the function.

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-14 12:45:15 -07:00
Martin von Zweigbergk
69154b537d remove: use ctx.hasdir(f) instead of 'f in ctx.dirs()'
This speeds up 'hg remove python/README' on the Firefox repo from
2.479s to 0.664s with lazily loaded treemanifests (which is not yet in
core) and has no measurable effect on flat manifests.
2015-04-21 09:29:59 -07:00
Ryan McElroy
7a091e748f bookmarks: rename bookmarkcurrent to activebookmark (API)
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-14 13:17:33 -07:00
Laurent Charignon
a76105b65c record: fix adding new file with record from within a subdir (issue4626)
In my latest change on record (edit newly added file), I forgot the
repo.wjoin() so that record was not computing the paths properly to delete
the backups and was crashing.
2015-04-27 14:02:49 -07:00
FUJIWARA Katsunori
801f00488c cmdutil: avoid wrapping ctx.phasestr() by _()
This wrapping seems meaningless, because:

  - there is no "_()" invocation to prepare for extracting phase names
    to be translated

    "make update-pot" doesn't extract msgids for phase names

  - phase names are kine of reserved keywords like as branch name "default"
2015-04-25 23:44:53 +09:00
Matt Harbison
83f972bb8d revert: restore the ability to revert across case only renames (issue4481)
This regressed in 39be809de631, in what looks like an unrelated change.

It seems sufficient to pass 'ignoremissing=True', but the restored try/except
has been there for six years since 3f24f7324cd8, so this seems safer for now.
Note that renaming directories in the filename doesn't appear to work- not sure
if this would end up throwing a different type of error when that is fixed.
2015-04-25 23:54:31 -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
FUJIWARA Katsunori
2a4f646cd6 revert: apply normallookup on reverted file if size isn't changed (issue4583)
Before this patch, reverting a file to the revision other than the
parent doesn't update dirstate. This seems to expect that timestamp
and/or size will be changed by reverting.

But if (1) dirstate of file "f" is filled with timestamp before
reverting and (2) size and timestamp of file "f" isn't changed at
reverting, file "f" is recognized as CLEAN unexpectedly.

This patch applies "dirstate.normallookup()" on reverted file, if size
isn't changed.

Making "localrepository.wwrite()" return length of written data is
needed to avoid additional (and redundant) "lstat(2)" on the reverted
file. "filectx.size()" can't be used to know it, because data may be
decoded at being written out.

BTW, interactive reverting may cause similar problem, too. But this
patch doesn't focus on fixing it, because (1) interactive (maybe slow)
reverting changes one (or both) of size/timestamp of reverted files in
many usecases, and (2) changes to fix it seems not suitable for stable
branch.
2015-04-24 23:52:41 +09: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
Yuya Nishihara
15789cf528 cat: disable optimization of single file case for workingctx
It crashes because workingctx has no manifest.
2015-04-05 13:16:46 +09:00
Yuya Nishihara
97905d5b99 cat: use ctx.manifestnode() in place of ctx._changeset[0] 2015-04-11 16:01:42 +09:00
Pierre-Yves David
712fee42ec revert: stop marking files clean after interactive revert (issue4592)
The goal of 'hg revert --interactive' is usually to keep some change in the
revert file, so the files -must-not- be marked as clean. We want the status
logic to do its usual job here.

For unclear reasons (probably timing related), I was unable to build an automated
test that reproduced issue4592 but manual testing shows this is fixed.
2015-04-11 11:54:09 -04:00
Drew Gottlieb
901ac5e726 util: move dirs() and finddirs() from scmutil to util
An upcoming commit requires that match.py be able to call scmutil.dirs(), but
when match.py imports scmutil, a dependency cycle is created. This commit
avoids the cycle by moving dirs() and its related finddirs() function from
scmutil to util, which match.py already depends on.
2015-04-06 14:36:08 -07:00
Yuya Nishihara
91233c9b15 jsonchangeset: set manifest node to "null" for workingctx
Unlike changeset_printer, it does not hide the manifest field because JSON
output will be parsed by machine where explicit "null" will be more useful
than nothing.
2015-03-14 20:16:35 +09:00
Yuya Nishihara
8a805d1c6d jsonchangeset: set rev and node to "null" for workingctx 2015-03-14 20:15:40 +09:00
Yuya Nishihara
fcd69a9d8b changeset_printer: hide manifest node for workingctx
Because workingctx has no manifest, it makes sense to hide "manifest:" row
completely.
2015-03-14 17:33:22 +09:00
Yuya Nishihara
f52009fe3b changeset_printer: display p1rev:p1node with "+" suffix for workingctx
Still templater can't handle workingctx, which will be fixed later.
2015-03-14 20:01:30 +09:00
Yuya Nishihara
c5790c61c0 changeset_printer: handle workingctx in _meaningful_parentrevs() 2015-03-14 17:29:48 +09:00
Matt Mackall
b4e070d32e merge with stable 2015-03-31 17:49:46 -05:00
Matt Harbison
cdcba76207 forget: cleanup the output for an inexact case match on icasefs
Previously, specifying a file name but not matching the dirstate case yielded
the following, even though the file was actually removed:

  $ hg forget capsdir1/capsdir/abc.txt
  not removing capsdir\a.txt: file is already untracked
  removing CapsDir\A.txt
  [1]

This change doesn't appear to cause any extra filesystem accesses, even if a
nonexistant file is specified.

If a directory is specified without a case match, it is (and was previously)
still silently ignored.
2015-03-31 17:42:46 -04:00
Martin von Zweigbergk
3e235a01ca log: prefer 'wctx' over 'pctx' for working context 2015-03-18 21:44:25 -07:00
Yuya Nishihara
0e68ae9536 changeset_printer: use changectx to get status tuple
log.parents() can't handle wdir() revision. Because repo.status() creates ctx
objects, there would be no benefit to get parent node from changelog.
2015-03-14 17:40:47 +09:00
Yuya Nishihara
414876e494 changeset_printer: replace _meaningful_parentrevs() by changeset_templater's
Because changeset_printer needs pctx object anyway, there would be no benefit
to avoid creation of pctx in _meaningful_parentrevs().
2015-03-14 17:23:51 +09:00
Yuya Nishihara
a8d2b740f9 changeset_printer: use context objects consistently to show parents
This prepares for merging changeset_printer._maningful_parentrevs() with
changeset_templater's.
2015-03-14 17:19:04 +09:00
Matt Mackall
82e10f2861 cmdutil: remove some excess vertical whitespace 2015-03-27 13:51:21 -05:00
Matt Mackall
61bcacd057 revert: move calculation of targetsubs earlier 2015-03-27 13:48:51 -05:00
Laurent Charignon
0ad4a0efef record: change return value of recording code
It makes it easier to include interactive mode to more commands that
require to get a reference to the newly created node
2015-03-25 15:51:57 -07:00
Laurent Charignon
ce53ca6b37 revert: fix --interactive on local modification (issue4576)
We were moving files during the backup phase and it was incompatible with the
way record/crecord is working
2015-03-25 14:01:14 -07:00
FUJIWARA Katsunori
9592a103f7 cmdutil: allow bailifchanged to ignore merging in progress
In "commands.update()", "cmdutil.bailifchanged()" isn't used for
"abort if the working directory is dirty", because it forcibly
examines about merging in progress.

"workingctx.dirty()" used in "commands.update()" can't detect changes
of largefiles in the working directory without "repo.lfstatus = True"
wrapping. This is only reason of "commands.update()" wrapping by
largefiles extension.

On the other hand, "cmdutil.bailifchanged()" already wrapped by
largefiles extension can detect changes of largefiles.

This patch is a preparations for replacing "workingctx.dirty()" and
raising Abort in "commands.update()" by "cmdutil.bailifchanged()". It
can remove redundant "commands.update()" wrapping.
2015-03-25 13:55:35 +09: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
Matt Harbison
1b58f58b45 revert: evaluate subrepos to revert against the working directory
Reverting to a revision where the subrepo didn't exist will now abort, and
matching subrepos against the working directory is consistent with how filesets
are evaluated since dd1c701aad4d.
2015-03-25 22:20:44 -04:00
Matt Harbison
31c3ab572e revert: handle subrepos missing in the given --rev
The list of subrepos to revert is currently based on the given --rev, so there
is currently no way for this to fail.  Using the --rev context is wrong though,
because if the subrepo doesn't exist in --rev, it is skipped, so it won't be
changed.  This change makes it so that the revert aborts, which is what happens
if a plain file is reverted to -1.  Finding matches based on --rev is also
inconsistent with evaluating files against the working directory (dd1c701aad4d).

This change is made now, so as to not cause breakage when the context is
switched in an upcoming patch.
2015-03-25 21:54:47 -04:00
Sean Farley
a0d78a3107 diff: rename --relative option to --root
The diff output format is unable to express files outside the directory so it
makes sense to name this option --root instead of --relative.
2015-03-25 11:55:15 -07:00
Pierre-Yves David
9d2643c9ed amend: check for directory renames for both merge parents (issue4516)
Before this change, amending a merge would lose the rename information for file
adding in the second parents and implicitly renamed into a new directory.

In case of the merge, we also look for directory rename data from the second
parent. This seems to fix the bug and does not show other issues from the test
suite.
2015-03-02 19:01:00 +00:00
Augie Fackler
69e342baa2 log: fix json-formatted output when file copies are listed (issue4523) 2015-02-02 14:26:47 -05:00
FUJIWARA Katsunori
e42765e252 namespace: introduce logfmt to show l10n-ed messages for hg log correctly
Before this patch, "_()" is used incorrectly for "tag:" and
"bookmark:" fields. "changeset_printer()" looks up keys composed at
runtime, and it prevents "xgettext" command from getting strings to be
translated from source files.

Then, *.po files merged with updated "hg.pot" lose msgids for "tag:"
and "bookmark:".

This patch introduces "logfmt" information into "namespace" to show
l10n-ed messages "hg log" (or "changeset_printer()") correctly.

For similarity to other namespaces, this patch specifies "logfmt" for
"branches" namespace, even though it isn't needed (branch information
is handled in "changeset_printer()" specially).

To find related code paths out easily, this patch adds "i18n: column
positioning ..."  comment to the line composing "logfmt" by default,
even though this line itself doesn't contain any strings to be
translated.
2015-01-28 22:22:59 +09:00
Durham Goode
cb1fb957a4 revert: move prefetch to after the actions logic
The prefetch logic came before the actual population of the actions collection,
so it was always being passed an empty action list. This fixes it by moving it
to after that logic.

The only consumer of this function at the moment is remotefilelog, and I
verified it works with this change.
2015-01-27 19:52:26 -08:00
Yuya Nishihara
4c964d9e78 revert: comment that filesets are always evaluated against workingctx 2015-01-17 14:22:21 +09:00
Martin von Zweigbergk
ce073b0455 revert: take fast path also when not reverting to '.'
This speeds up 'hg revert -r .^ --all --dry-run' on the Mozilla repo
from 4.081s to 0.826s. Note that 'hg revert -r .^ .' does not get any
faster, since '.' does not make match.always() True.

I can't think of a reason it would break anything, and if it does,
it's clearly not covered by tests.
2015-03-24 15:47:57 -07:00
Martin von Zweigbergk
8ef76750bb revert: define 'wctx' a little earlier and use it more 2015-03-24 13:56:51 -07:00
Yuya Nishihara
ed458b9332 log: use rev() to build revset of --follow option from numeric revision
startrev can be -1.
2015-01-10 13:14:00 +09:00
Matt Harbison
8fad1493fa add: pass options via keyword args
The largefiles extensions needs to be able to pass --large, --normal and
--lfsize to subrepos via cmdutil.add() and hgsubrepo.add().  Rather than add
additional special purpose arguments, stop extracting the existing args from the
**opts passed to commands.add() and just pass them along.
2015-01-12 20:59:17 -05:00
Sean Farley
a6610c70d3 log: use namespace logname and colorname
Now that we have the machinary to change the log name and the color label used,
let's use that. Tests have been updated accordingly.
2015-01-14 20:29:47 -08:00
Matt Harbison
85dddfb9c5 forget: don't report rejected files as forgotten as well
It seems like a mistake to report a file as forgotten and rejected.  The
forgotten list doesn't seem to be used by anything in core, so no test changes.
2015-01-11 23:25:23 -05:00
Martin von Zweigbergk
5adcba3667 revert: evaluate filesets against working directory (issue4497)
As the failing revert tests in test-fileset-generated.t show,

Revert currently creates one matcher for matching files in the working
copy and another matcher for matching files in the target
revision. The two matchers are created with different contexts, which
means filesets are evaluated differently. Then the union of the sets
of files matching the matchers in the two contexts are reverted. It
doesn't seem to make sense to use two different matchers; only the
context they're applied to should be different.

It seems very likely that the user wants the filesets to be evaluated
against the working directory, which the tests
test-fileset-generated.t also assume, so let's make it so.

I willingly admit that the largefiles code was modified by trial and
error (according to tests).
2015-03-23 23:04:51 -07:00
Siddharth Agarwal
b48f87449f cmdutil.diffordiffstat: add support for diffs relative to a subdirectory
It's possible that some of the match patterns are outside the relative root. We
warn in that case. In upcoming patches we'll add tests for this.
2015-03-17 15:06:40 -07:00
Matt Harbison
8ef259aa86 cmdutil: drop a duplicate import of crecord
It looks like this crept in with 9819929ec97e.
2015-03-20 21:55:11 -04:00
Sean Farley
5c1d1bb100 log: use new namespaces api to display names
The only caveat here is that branches must be displayed first due to backwards
compatibility. The order of namespaces is defined to be the 'update' order
which, unfortunately, is not the same as log output order.

It's worth mentioning that the log output is still translated the same as
before since we are formating our strings the same way:

  # i18n: column positioning for "hg log"
  _("bookmark:    %s\n") % bookmark

becomes

  tname = _(("%s:" % ns.templatename).ljust(13) + "%s\n") % name

when name == 'bookmark'. The ljust(13) keeps the strings and whitespace equal.
Adding a new namespace is even easier now because the log output code doesn't
need to change. A future programmer would just need to add the string to the
corresponding .po file (which is the same as they would have had to do
previously).
2014-10-17 09:26:37 -07:00
Matt Harbison
3ea5067ed3 subrepo: add basic support to hgsubrepo for the files command
Paths into the subrepo are not yet supported.

The need to use the workingctx in the subrepo will likely be used more in the
future, with the proposed working directory revset symbol.  It is also needed
with archive, if that code is to be reused to support 'extdiff -S'.
Unfortunately, it doesn't seem possible to put the smarts in subrepo.subrepo(),
as it breaks various status and diff tests.

I opted not to pass the desired revision into the subrepo method explicitly,
because the only ones that do pass an explicit revision are methods like status
and diff, which actually operate on two contexts- the subrepo state and the
explicitly passed revision.
2015-03-18 23:03:41 -04:00
Martin von Zweigbergk
5fba048889 walkchangerevs: make followfilter a top-level class
The class only depends on the 'repo' variable in the closure, so let's
move the class out of the function and make it explicit that that (the
repo) is all it needs.
2015-03-19 09:12:21 -07:00
Martin von Zweigbergk
95a9e50c6a walkchangerevs: simplify by using match.always() method
Since "slowpath = match.anypats() or (match.files() and
opts.get('removed'))", we can simplify the condition "not slowpath and
not match.files()" to "not match.anypats() and not match.files()",
which is equivalent to "match.always()".
2014-10-28 22:32:18 -07:00
Durham Goode
724425bff5 obsolete: remove last instance of _enabled
The _enabled bool has been replaced by obsolete.isenabled(...). This removes the
last instance of it so I can remove the _enabled flag entirely shortly.
2015-03-17 14:52:58 -07:00
Yuya Nishihara
53f1e7866c commands: replace "working copy" with "working directory" in help/messages
"working directory" is the standard term, we should use it consistently.

But I didn't touch the hint, "run 'hg update' to get a working copy", because
"get a working directory" sounds a bit odd.
2015-03-17 22:47:08 +09:00
Laurent Charignon
f97eaa8ce4 revert: add flag to make revert interactive 2015-03-16 16:33:59 -07:00
Laurent Charignon
bd121df4b3 record: move ui.write wrapping where it should be
We have to do that for the coloring to work in interactive revert
2015-03-16 15:37:00 -07:00
Laurent Charignon
b53c518d0f record: refactor the filtering code 2015-03-16 15:35:50 -07:00
Laurent Charignon
f58c9907e3 record: consolidate ui.write wrapping in a function 2015-03-16 15:30:33 -07:00
Laurent Charignon
331b4f43db record: minor refactoring of dorecord
It prepares the way for introducing the flag to reverse hunk selection
2015-03-12 17:50:23 -07:00
Laurent Charignon
0502dc3e22 record: enable curses recording logic with experimental flag 2015-03-12 14:24:48 -07:00
Laurent Charignon
62f1f68490 record: change interface of the filtering function
This way filtering functions accept chunks and return chunks
2015-03-12 17:51:37 -07:00
Laurent Charignon
1a368bb039 record: change recording function to work with crecord 2015-03-12 14:20:32 -07:00
Laurent Charignon
8e36c9d449 record: change interface of dorecord to accept new filters
This makes it easier to add different filtering logic (record /crecord ...)
2015-03-11 16:39:38 -07:00
Jordi Gutiérrez Hermoso
8eb132f5ea style: kill ersatz if-else ternary operators
Although Python supports `X = Y if COND else Z`, this was only
introduced in Python 2.5. Since we have to support Python 2.4, it was
a very common thing to write instead `X = COND and Y or Z`, which is a
bit obscure at a glance. It requires some intricate knowledge of
Python to understand how to parse these one-liners.

We change instead all of these one-liners to 4-liners. This was
executed with the following perlism:

    find -name "*.py" -exec perl -pi -e 's,(\s*)([\.\w]+) = \(?(\S+)\s+and\s+(\S*)\)?\s+or\s+(\S*)$,$1if $3:\n$1    $2 = $4\n$1else:\n$1    $2 = $5,' {} \;

I tweaked the following cases from the automatic Perl output:

    prev = (parents and parents[0]) or nullid
    port = (use_ssl and 443 or 80)
    cwd = (pats and repo.getcwd()) or ''
    rename = fctx and webutil.renamelink(fctx) or []
    ctx = fctx and fctx or ctx
    self.base = (mapfile and os.path.dirname(mapfile)) or ''

I also added some newlines wherever they seemd appropriate for readability

There are probably a few ersatz ternary operators still in the code
somewhere, lurking away from the power of a simple regex.
2015-03-13 17:00:06 -04:00
Matt Harbison
d26c34fe51 files: replace 'ctx._repo' with 'ctx.repo()' 2015-03-12 22:55:35 -04:00
Matt Harbison
1a03b7a16d files: split reusable implementation into cmdutil for subrepo support 2015-03-08 16:50:57 -04:00
Laurent Charignon
b5de5559b7 record: move dorecord from record to cmdutil
Part of a serie of patches to move record from hgext to core
2015-03-10 17:14:33 -07:00
Siddharth Agarwal
eb2ddaf931 cmdutil.tryimportone: allow importing relative patches with --bypass 2015-03-10 13:06:38 -07:00
Siddharth Agarwal
3f34a651ac cmdutil.tryimportone: allow importing relative patches into the working dir
This makes hg import --prefix dir/ (without bypass) work.
2015-03-09 18:22:24 -07:00
Augie Fackler
dbd43329ce dispatch: offer suggestions of similar-named commands
When suggestions are available, we show those suggestions instead of
showing some help output.
2015-02-10 15:59:12 -05:00
Jordi Gutiérrez Hermoso
91e31472eb log: display closing-branch nodes as "_" (BC)
In plain `hg log` there is no indication that a commit closes a
branch. You can use hg log --debug, but this is too verbose. A simple
idea copied from thg and other graphical viewers is to display the
node for a closing-branch commit as a horizontal line.

I think this technically is a BC if we consider the graphlog to be
part of the stdout API, but I really can't imagine who the hell is
parsing the graphlog to determine information about commits.
2014-11-24 16:42:49 -05:00
Durham Goode
bd91d1c63e workingctx: use normal dirs() instead of dirstate.dirs()
The workingctx class was using dirstate.dirs() as it's implementation. The
sparse extension maintains a pruned down version of the dirstate, so this
resulted in the workingctx reporting an incorrect listing of directories
during merge calculations (it was detecting directory renames when it
shouldn't have).

The fix is to use the default implementation, which uses workingctx._manifest,
which unions the manifest with the dirstate to produce the correct overall
picture. This also produces more accurate output since it will no longer
return directories that have been entirely deleted in the dirstate.

Tests will be added to the sparse extension to detect regressions for this.
2015-03-05 22:16:28 -08:00
Mads Kiilerich
b2b60414f6 spelling: fixes from proofreading of spell checker issues 2015-01-18 02:38:57 +01:00
Matt Mackall
0c7d82b039 merge with stable 2015-03-02 17:32:37 -06:00
Matt Harbison
ee0eea92e1 revert: display full subrepo output with --dry-run
Since the point of --dry-run is to show what will happen, the output with and
without it should agree.  And since revert wasn't being called on subrepos with
--dry-run before, revert in the subrepo had to be defanged in this case.
2015-02-07 21:47:28 -05:00
Yuya Nishihara
ea398a57c8 log: fix --follow null parent not to include revision 0
If p1 is null, ':.' is translated as '0:null'. But rangeset can't handle null,
only revision 0 was visible.  Because 'null' should not be listed implicitly,
"log --follow" (without -r) should be empty if p1 is null.

Test of "hg grep -f" is added for cmdutil.walkchangerevs().
2015-02-06 21:53:39 +09:00
Yuya Nishihara
f61265845b cmdutil: have walkchangerevs utilize common function to build revs 2015-02-06 00:22:20 +09:00
Yuya Nishihara
97ca3a4dd8 log: extract common part from getgraphlogrevs() and getlogrevs() 2015-02-06 00:15:35 +09:00
Yuya Nishihara
bba83cb128 graphlog: remove useless check for empty repo when --follow is specified
This prepares for extracting common part from getgraphlogrevs() and
getlogrevs(). getlogrevs() does not handle empty repo specially.

When it was added at a98e985d1dd1, revs were build by old-style query, '.:0'.
So I think the purpose of "len(repo) > 0" was to handle the case of . = null.
Currently it isn't necessary for 'reverse(:.)', and it does not work if repo
is not empty but p1 is null.

  $ hg up null
  $ hg glog --follow -T '{rev}:{node|short}\n'
  o  0:0a04b987be5a

The subsequent patch will fix this problem, so drops the wrong version for now.
2015-02-06 00:06:47 +09:00
Yuya Nishihara
454ee6ca93 graphlog: move comment and flag denoting revs might be unsorted
This prepares for extracting common part from getgraphlogrevs() and
getlogrevs().  "possiblyunsorted" exists only in getgraphlogrevs().
2015-02-05 23:49:18 +09:00
Yuya Nishihara
f70a0be178 graphlog: remove too early return from getgraphlogrevs() for empty repo
Even if repository is empty, null revision should exist.
2015-02-05 23:14:44 +09:00
Matt Mackall
80c883c82a merge with stable 2015-01-06 18:18:28 -06:00
Gregory Szorc
73fa937531 cmdutil.jsonchangeset: properly compute added and removed files
jsonchangeset._show() was computing the reverse status of the current
changeset. As a result, added files were showing up as removed and
removed files were showing up as adds.

There were existing tests for this code and they were flat out wrong.
2015-01-05 22:18:55 -08:00
Durham Goode
fd373c16b0 log: fix log revset instability
The log/graphlog revset was not producing stable results since it was
iterating over a dict. Now we sort before iterating to guarantee a fixed order.

This fixes some potential flakiness in the tests.
2014-12-08 15:41:54 -08:00
Durham Goode
74a5156e21 log: fix log -f slow path to actually follow history
The revset created when -f was used with a slow path (for patterns and
directories) did not actually contain any logic to enforce follow. Instead it
was depending on the passed in subset to already be limited (which was limited
to :. but not ::.). This fixes it by adding a '& ::.' to any -f log revset.

hg log -f <file> is still broken, in that it can return results that aren't
actually ancestors of the current file, but fixing that has major perf
implications, so we'll deal with it later.
2014-12-05 14:27:32 -08:00
Siddharth Agarwal
34aea9120f cmdutil.changeset_printer: explicitly honor all diffopts
This is used in hg log -p so the output is expected to be the same as that of
hg diff.
2014-11-21 16:01:55 -08:00
Matt Harbison
21ca967140 narrowmatcher: propagate the rel() method
The full path is propagated to the original match object since this is often
used directly for printing a file name to the user.  This is cleaner than
requiring each caller to join the prefix with the file name prior to calling it,
and will lead to not having to pass the prefix around separately.  It is also
consistent with the bad() and abs() methods in terms of the required input.  The
uipath() method now inherits this path building property.

There is no visible change in path style for rel() because it ultimately calls
util.pathto(), which returns an os.sep based path.  (The previous os.path.join()
was violating the documented usage of util.pathto(), that its third parameter be
'/' separated.)  The doctest needed to be normalized to '/' separators to avoid
test differences on Windows, now that a full path is returned for a short
filename.

The test changes are to drop globs that are no longer necessary when printing an
absolute file in a subrepo, as returned from match.uipath().  Previously when
os.path.join() was used to add the prefix, the absolute path to a file in a
subrepo was printed with a mix of '/' and '\'.  The absolute path for a file not
in a subrepo, as returned from match.uipath(), is still purely '/' based.
2014-11-27 10:16:56 -05:00
Matt Harbison
c2203f42d7 remove: use vfs instead of os.path + match.rel() for filesystem checks 2014-12-25 21:50:35 -05:00
Matt Harbison
5632d06d85 forget: use vfs instead of os.path + match.rel() for filesystem checks 2014-12-25 21:43:45 -05:00
Pierre-Yves David
2d599c1c7d revert: look for copy information for all local modifications
Renaming a file over an existing one marks the file as modified. So we
track rename source in modified file too.
2014-11-25 19:40:54 -08:00
Matt Harbison
9b17eabeab subrepo: drop the 'ui' parameter to revert()
This no longer needs to be explicitly passed because the subrepo object tracks
the 'ui' reference since d4e8aa61370d.  See the change to 'archive' for details
about the differences between the output level in the root repo and subrepo 'ui'
object.

The only use for 'ui' in revert is to emit status and warning messages, and to
check the verbose flag prior to printing the action to be performed on a file.

The local repo's ui was already being used to print a warning message in
wctx.forget() and for 'ui.slash' when walking dirstate in the repo.status()
call.  Unlike other methods where the matcher is passed along and narrowed, a
new matcher is created in each repo, and therefore the bad() method already used
the local repo's ui.
2014-12-13 19:44:55 -05:00
Matt Harbison
616ad7eb66 subrepo: drop the 'ui' parameter to removefiles()
This no longer needs to be explicitly passed because the subrepo object tracks
the 'ui' reference since d4e8aa61370d.  See the change to 'archive' for details
about the differences between the output level in the root repo and subrepo 'ui'
object.

The only use for 'ui' in remove is to emit status and warning messages, and to
check the verbose flag prior to printing files to be removed.  The bad() method
on the matcher still uses the root repo's ui, because narrowing the matcher
doesn't change the ui object.

The local repo's ui was already being used to print a warning message in
wctx.forget() and for 'ui.slash' when walking dirstate in the repo.status()
call.
2014-12-13 19:36:50 -05:00
Matt Harbison
800917e351 subrepo: drop the 'ui' parameter to forget()
This no longer needs to be explicitly passed because the subrepo object tracks
the 'ui' reference since d4e8aa61370d.  See the change to 'archive' for details
about the differences between the output level in the root repo and subrepo 'ui'
object.

The only use for 'ui' in forget is to emit status and warning messages, and to
check the verbose flag prior to printing files to be forgotten.  The bad()
method on the matcher still uses the root repo's ui, because narrowing the
matcher doesn't change the ui object.

The local repo's ui was already being used to print a warning message in
wctx.forget() and for 'ui.slash' when walking dirstate in the repo.status()
call.
2014-12-13 19:23:30 -05:00
Matt Harbison
418c3ff6d6 subrepo: drop the 'ui' parameter to cat()
This no longer needs to be explicitly passed because the subrepo object tracks
a 'ui' reference since d4e8aa61370d.  See the change to 'archive' for details
about the differences between the output level in the root repo and subrepo 'ui'
object.

The only use for 'ui' in cat is to emit a status message when a subrepo is
missing.  The bad() method on the matcher still uses the root repo's ui, because
narrowing the matcher doesn't change the ui object.
2014-12-13 14:26:38 -05:00
Matt Harbison
3c47e94de7 commit: propagate --addremove to subrepos if -S is specified (issue3759)
The recursive addremove operation occurs completely before the first subrepo is
committed.  Only hg subrepos support the addremove operation at the moment- svn
and git subrepos will warn and abort the commit.
2014-11-24 22:27:49 -05:00
Matt Harbison
44b25f2773 commit: abort if --addremove is specified, but fails
This will be required when subrepo support is added, in order to ensure
consistent commits when a subrepo flavor doesn't support addremove.
2014-11-26 15:16:22 -05:00
Matt Harbison
9e4d7cc2d3 scmutil: pass a matcher to scmutil.addremove() instead of a list of patterns
This will make it easier to support subrepository operations.
2014-11-09 19:57:02 -05:00
Matt Mackall
cabaf089d4 merge with stable 2014-12-09 13:32:19 -06:00
John Coomes
310ded0ea2 add: use lexists so that broken symbolic links are added
This restores the add behavior prior to 83750c0d774f and matches the
behavior of addremove.
2014-12-03 14:33:29 -08:00
Siddharth Agarwal
bf23516938 jsonchangeset: don't honor whitespace and format-changing diffopts
JSON is meant to be parsed by computers, and format changes can break them.
2014-11-18 22:13:05 -08:00
Matt Mackall
4abfc94f18 merge with stable 2014-11-27 12:25:01 -06:00
Matt Harbison
6b20f5bf8e add: check for the existence of a file matched inexactly before adding it
The change in 02ecc94fb657 created a problem on Windows and OS X:

    --- /usr/local/mercurial/tests/test-issue660.t
    +++ /usr/local/mercurial/tests/test-issue660.t.err
    @@ -47,6 +47,8 @@
     Should succeed - shadow removed:

       $ hg add b
    +  adding b/b
    +  b/b does not exist!

Prior to the failing 'hg add', the file 'b/b' was added and committed, then 'b'
was recursively deleted from the filesystem, file 'b' was created and the delete
was recorded with 'hg rm --after'.  This add is attempting to record the
existence of file 'b'.

A filesystem that is not case sensitive prevents dirstate.walk() from skipping
its step 3, and step 3 has the effect of inserting removed files into the walk
list.  The Linux code doesn't run through step 3, and didn't exhibit the
problem.  It's not clear why a non case sensitive filesystem triggers step 3,
given that the path normalization occurs in step 2.

Prior to 02ecc94fb657, part of the check here was 'f not in repo.dirstate'
instead of 'f not in wctx'.  Files in the 'r' state are filtered out of
context.__contains__() but not dirstate.__contains__().  Therefore the removed
file name wasn't added to the list of files to add when checking against
dirstate.  That change was to allow removed files to be readded, but adding a
file that doesn't exist is nonsensical.  If the user specifies a missing file,
it will be an exact match and will still fail.
2014-11-19 22:27:55 -05:00
Martin von Zweigbergk
2916dab85b revert: access status fields by name rather than index
For better readability.
2014-11-19 17:07:27 -08:00
Matt Harbison
8766c8079f remove: avoid a bogus warning about no tracked files when removing '.'
Previously, any files relative to the root of the repo that match the -I
patterns would be deleted, but the command exited with 1 after printing a
warning:

   $ hg remove -S -I 're:.*.txt' .
   removing sub1/sub2/folder/test.txt
   removing sub1/sub2/test.txt
   not removing .: no tracked files
2014-11-16 00:24:23 -05:00
Matt Harbison
c0a7d4f5bc remove: support remove with explicit paths in subrepos 2014-11-12 23:15:20 -05:00
Matt Harbison
17e7835237 remove: recurse into subrepositories with --subrepos/-S flag
Like 'forget', git and svn subrepos are currently not supported.  Unfortunately
the name 'remove' is already used in the subrepo classes, so we break the
convention of naming the subrepo function after the command.
2014-11-15 21:36:19 -05:00
Matt Harbison
7fc45849db remove: move most of the implementation into cmdutils.remove()
This will allow access to the reusable parts from subrepos, similar to add(),
forget(), etc.
2014-11-09 12:31:34 -05:00
Martin von Zweigbergk
42c14b3ed1 add: add back forgotten files even when not matching exactly (BC)
I accidentally did 'hg forget .' and tried to undo the operation with
'hg add .'. I expected the files to be reported as either modified or
clean, but they were still reported as removed. It turns out that
forgotten files are only added back if they are listed explicitly, as
shown by the following two invocations. This makes it hard to recover
from the mistake of forgetting a lot of files.

  $ hg forget README && hg add README && hg status -A README
  C README
  $ hg forget README && hg add . && hg status -A README
  R README

The problem lies in cmdutil.add(). That method checks that the file
isn't already tracked before adding it, but it does so by checking the
dirstate, which does have an entry for forgotten files (state 'r'). We
should instead be checking whether the file exists in the
workingctx. The workingctx is also what we later call add() on, and
that method takes care of transforming the add() into a normallookup()
on the dirstate.

Since we're changing repo.dirstate into wctx, let's also change
repo.walk into wctx.walk for consistency (repo.walk calls wctx.walk,
so we're simply inlining the call).
2014-11-10 14:51:18 -08:00
Mads Kiilerich
523c87c1fe spelling: fixes from proofreading of spell checker issues 2014-04-17 22:47:38 +02:00
Matt Harbison
ebc17dec9c amend: abort early if no username is configured with evolve enabled (issue4211)
Amend will reuse the original username if a new one is not provided
with -U, but obsolete.createmarkers() only considers ui.username() for
the obsolete marker's metadata. Allowing the metadata field to be
spoofed seems to defeat the point of the field in the first place.
This covers 'evolve amend' and 'ci --amend' with evolve enabled.

Without this, the transaction aborts but the parent changeset is set to -1.  The
corresponding test will be added to evolve separately.
2014-10-28 23:05:19 -04:00
Durham Goode
18f3737f3a obsolete: add createmarkers option
The basic obsolete option is allowing the creation of obsolete markers. This
does not enable other features, such as allowing unstable commits or exchanging
obsolete markers.
2014-10-14 13:23:52 -07:00
Matt Mackall
f663e5fc01 duplicatecopies: move from cmdutil to copies
This is in preparation for moving its primary caller into merge.py,
which would be a layering violation in the current location.
2014-10-13 14:33:13 -05:00
Pierre-Yves David
b73c13bbd6 getgraphlogrevs: remove user of baseset.append
A `baseset` has multiple cached results and will get even more in the future.
Making it an object "populated once" like the other smartsets makes it both safer
and simpler. The append method will be removed at some point.
2014-10-07 00:20:00 -07:00
Pierre-Yves David
cac69b710e getlogrevs: remove user of baseset.append
A `baseset` has multiple cached results and will get even more in the future.
Making it an object "populated once" like the other smartsets makes it both safer
and simpler. The append method will be removed at some point.
2014-10-07 00:04:16 -07:00
Jordi Gutiérrez Hermoso
a7cc108c20 log: do not hide the public phase in debug mode (BC)
When 62900f2373fa introduced phases to the `hg log --debug` output, it
also disabled outputting public phase. At the same time, it always
shows phases in the default template, `hg log --debug -T default`.
Those two should produce the same output, but they don't.

I think it makes a lot more sense to always show all phases. There's
already loss of backwards compatibility in this case when using a
newer hg on an old hg repo, since draft commits will show up in the
output of `hg log --debug`.

Finally, I just don't think that any sort of information should be
hidden with --debug. This flag should be about showing as much
information as possible.
2014-10-04 16:28:28 -04:00
Jordi Gutiérrez Hermoso
281cec5b64 templater: set the correct phase for parents
Akin to b5baef1e39f6 which did this for `hg log`, the following sets
the correct phase for the {phase} keyword when the context is a parent
of the current cset. This allows templates such as the following to be
defined,

    parent = '{label("log.parent changeset.{phase}",
                      "parent:      {rev}:{node|formatnode}")}\n'

which when called on a parent (e.g. with the `parents` template
keyword), will produce the correct phase.
2014-10-03 22:03:31 -04:00
Pierre-Yves David
bfd39d13a8 revert: properly back up added files with local modification
These files were previously not backed up because the backup mechanism was not
smart enough. This leads to data lose for the user since uncommitted contents
were discarded.

We now properly move the modified version to <filename>.orig before deleting it.

We have to use a small hack to do a different action if "--no-backup" is
specified. This is needed because the backup process is actually a move (not a
copy) so the file is already missing when we backup. The internet kitten is a
bit disapointed about that, but such is life.

This patch concludes the "lets refactor revert" phases. We can now open the
"Lets find stupid bug with renames and merge" phases.

I'm sure that now that the code is clearer we could do it in another simpler
way, but I consider the current improvement good enough for now.
2014-08-31 13:01:00 +02:00
Pierre-Yves David
985e6cc94b revert: track added files with local modifications
Those files need to be backed up but are currently not. We compute the set of
them to be able to use a different backup strategy in the next changeset.
2014-08-30 02:39:08 +02:00
Pierre-Yves David
4b18de4a6a revert: distinguish between "check" and "backup" strategy
"check" behaves as backup did before. We check if the current file differs
from destination and we create a backup if it does. This is used for untracked
files that will be overwritten by formerly-deleted files. We have to do the manual
check since no status output can provide the content comparison.

"backup" is now doing unconditional backup. This can be used for files seen as
modified compared to both the target and the working directory. In such a case, we
know that the file differs from target without actually comparing any content.

This new "backup" strategy will be especially useful in the case of files added
between the target and the working directory -parent- with additional modifications
in the working directory -itself-. In that case we know we need to back it up, but we
cannot run the content check as the files does not exists in target.
2014-08-30 02:30:24 +02:00
Pierre-Yves David
9c3ba8614b revert: small refactoring in the way backup value are handled
The current backup value may have two different values:

  1. Do not try to do backup
  2. Do backup if applicable

We are about to move to:

  1. Do not try to do backup
  2. Do backup if applicable
  3. Do backup in all cases

So we change the current values to make room for the new one.
2014-08-30 02:28:27 +02:00
Matt Mackall
0602ddc218 merge with stable 2014-09-30 18:22:58 -05:00
Yuya Nishihara
525193c247 templater: fix precedence of --style and --template options
Since 266cfa7de44d, --template option is ignored if --style is specified,
which is wrong according to the doc of show_changeset():

    Display format will be the first non-empty hit of:
    1. option 'template'
    2. option 'style'
    ...
2014-09-30 23:15:56 +09:00
Durham Goode
153b05ace7 revert: special case 'hg revert --all'
On large repos, hg revert --all can take over 13 seconds. This is mainly due to
it walking the tree three times: once to find the list of files in the
dirstate, once to find the list of files in the target, and once to compute the
status from the dirstate to the target.

This optimizes the hg revert --all case to only require the final status. This
speeds it up to 1.3 seconds or so (with hgwatchman enabled).

Further optimizations could be done for the -r NODE and pattern cases, but they
are significantly more complex.
2014-09-19 18:43:53 -07:00
Durham Goode
2b47ffae5c revert: move targetsubs calculation down to its use
A future patch will be reorganizing this section of the code into two paths, and
targetsubs complicates this by existing in the middle of one path, but not the
other. We fix that by moving it 200 lines down, to the only place it's used.
2014-09-19 18:40:39 -07:00
FUJIWARA Katsunori
5c74f6bc14 import: show the warning message for failure of merging
Before this patch, no message is shown for failure of merging at "hg
import".

In such case, merging patch is imported as a normal revision silently,
and it may confuse users.

For simplicity, this patch recommends just using "--exact", even
though importing the merging patch itself is possible without it if:

  - the hash of the 1st parent in the patch is equal to one of the
    patch imported just before (or the parent of the working
    directory, for the 1st patch of the series), and

  - the hash of the 2nd parent in the patch is known in the local
    repository
2014-08-27 23:10:06 +09:00
Sean Farley
a5ff857520 log: use correct phase info for parent field (issue4347)
Previously, there was a copy / paste error with using the current changeset's
phase information. We now look up the parent context explicitly.

The line was too long so it is stored into a variable first.
2014-08-23 17:03:08 -05:00
Siddharth Agarwal
f07a4ceb07 cmdutil: add a hook for making custom non-follow log file matchers
This will be used by largefiles (and basically only by largefiles) in an
upcoming patch.
2014-08-13 15:17:03 -07:00
Siddharth Agarwal
b112932fc1 cmdutil: rename _makelogfilematcher to _makefollowlogfilematcher
We're going to add a _makenofollowlogfilematcher in an upcoming patch.
2014-08-13 15:15:13 -07:00
Yuya Nishihara
4d834f9237 log: do not use exact matcher for --patch --follow without file (issue4319)
5d9f39626224 is valid only if file argument is specified.  If no pattern
specified, it can simply fall back to the original matcher.
2014-08-01 21:36:56 +09:00
Matt Mackall
f648f507dd templates: re-add template listing support
We used to have --style nosuch to list templates, but --style is now
merged with --template/-T where random strings are acceptable
templates. So we reserve 'list' to allow listing templates.
2014-07-25 15:35:09 -05: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
Matt Mackall
b221e35cf4 commiteditor: refactor default extramsg 2014-07-18 23:15:28 -05:00
Pierre-Yves David
4a068b03fd revert: add a drop action
This prevents the need for a try except in the `_performrevert` code.
2014-08-30 02:25:23 +02:00
Pierre-Yves David
334a6443f4 revert: explicitly track added but deleted file
Added + deleted file are files that need to be untracked from the dirstate but
that are already missing on disk. The current `_performrevert` code is handling
that with exception catching. We will be able to do better with a dedicated set.
2014-08-30 02:23:25 +02:00
Pierre-Yves David
ed9dd646bd revert: have an explicit action for "forget"
The distinction between "remove" and "forget" used to be in special logic
checking for the state of the file in the dirstate. Now that we have dedicated
filtering, we can stop relying on this logic and have two distinct actions.
2014-09-01 12:36:48 +02:00
Pierre-Yves David
5d71ed07e4 revert: split between newly added file and file added in other changeset
These two kinds of files are handled differently. One is deleted and the other
is just forgotten (the file is untracked but left in place). The distinction is
done in the `_performrevert` code itself and we would like to get ride of this.
2014-08-30 18:20:29 +02:00
Matt Mackall
512fbd2843 import: let --exact 'work' with --no-commit (issue4376) 2014-09-19 14:51:58 -05:00
Matt Mackall
7cc7319641 cmdutil: add json style to log-like commands
Sadly, this can't be done with the normal templater like we do with
XML due to JSON's inter-record comma rules.
2014-09-15 13:11:13 -05:00
Durham Goode
a5a69f0001 dirstate: wrap setparent calls with begin/endparentchange (issue4353)
This wraps all the locations of dirstate.setparent with the appropriate
begin/endparentchange calls. This will prevent exceptions during those calls
from causing incoherent dirstates (issue4353).
2014-09-05 11:36:20 -07:00
Pierre-Yves David
0a99f9c4f9 revert: drop lexist check in the backup logic
We are no longer trying to backup files that do not exist on disk. This check
can be safely dropped.
2014-08-30 02:10:29 +02:00
Pierre-Yves David
2a02a27185 revert: distinguish between deleted file and locally modified
Locally modified needs a backup while a deleted file cannot be backed
up because there is no file to backup.
2014-08-30 02:09:53 +02:00
Pierre-Yves David
a6bc441291 revert: detect unknown files in the same path as files marked as removed
Such unknown files may need to be backed up. Having them identified beforehand
will help simplify the backup logic.

We now use different sets with different backup strategies.
2014-08-30 02:00:20 +02:00
Pierre-Yves David
f77e0eb240 revert: cache working context in a variable
During the silicon age, humans on planet Earth discovered the use of
variables. This marvelous invention let them improve both code
readability and performance.
2014-08-30 01:52:08 +02:00
Martin von Zweigbergk
e95a8f8fb9 cmdutil: avoid the confusing name 'patch' for a matcher 2014-08-31 07:45:50 -07:00
Pierre-Yves David
884e556964 revert: drop now useless conditional in the backup check
Now that we removed the (hopeless) attempt to backup file we knew to be
missing in the target changeset, we can stop checking if the file exists in
the target changeset.
2014-08-30 01:51:02 +02:00
Pierre-Yves David
d51e1ac08b revert: no backup for dsadded set
There is only one case where a backup is required in the `dsadded` set, and the
current backup mechanism fails to handle it. So we stop trying to do backups at
all for now. This will help us to simplify the backup code and finally fix
this backup issue.
2014-08-30 01:49:28 +02:00
Pierre-Yves David
5fca88c509 revert: add more padding in the dispatch list
We are going to add more sets and some of them will have longer names. We add
padding in a standalone patch for readbility purposes.
2014-08-30 16:06:09 +02:00
Pierre-Yves David
b34b8413be revert: add documentation in the dispatch table
More sets are coming so documenting the existing ones will help.
2014-08-30 01:48:58 +02:00
Pierre-Yves David
2554c150e4 revert: add a way for external extensions to prefetch file data
This allow extensions that mess with the storage layer (remotefilelog,
largefile) to prefetch any data that will be accessed during the revert
operation.

We are currently fetching more data than theoretically required because the
backup code is a bit stupid. Future patches will improve that.
2014-08-30 02:47:59 +02:00
Matt Mackall
3ce3f9064f merge with stable 2014-08-27 18:35:34 +02:00
Mads Kiilerich
4dd236da3f convert: use None value for missing files instead of overloading IOError
The internal API used IOError to indicate that a file should be marked as
removed.

There is some correlation between IOError (especially with ENOENT) and files
that should be removed, but using IOErrors to represent file removal internally
required some hacks.

Instead, use the value None to indicate that the file not is present.

Before, spurious IO errors could cause commits that silently removed files.
They will now be reported like all other IO errors so the root cause can be
fixed.
2014-08-26 22:03:32 +02:00
FUJIWARA Katsunori
baa5c6430a import: avoid editor invocation when importing with "--exact" for exact-ness
Before this patch, external editor is invoked when imported patch has
no commit message, even if "--exact" is specified. Then, exact-ness is
broken, because empty commit message causes failure of committing.

This patch avoids editor invocation at importing with "--exact" for
exact-ness, because commit message in the patch should be kept as it
is in such case, even if it is empty.
2014-08-23 23:03:50 +09:00
Pierre-Yves David
1119f2b21b debugobsolete: display parents information from markers
Now that we have a new field, we need a way to visualize it.
2014-08-18 17:17:23 -07:00
FUJIWARA Katsunori
6ff720dff7 import: 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
other in "hg import" without "--bypass" case.

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

    import.normal.normal
    import.normal.merge
    import.bypass.normal
    import.bypass.merge

Unlike other patches in this series, this patch uses "editor.sh"
instead of "checkeditform.sh" for the name of the script to check
"HGEDITFORM", because it has to do more than checking "HGEDITFORM".

To invoke editor forcibly in "test-import-merge.t", this patch creates
the patch not having patch description as "merge.nomsg.diff".
2014-08-16 10:43:59 +09:00
FUJIWARA Katsunori
1d0310bb6c commit: change "editform" to distinguish merge commits from other (--amend)
"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 "amend.normal" and "amend.merge" as ROUTE of
"editform" instead of "amend", to distinguish merge commits from other
in "hg commit --amend" case.
2014-08-16 10:43:59 +09: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
Pierre-Yves David
6fc35a917d revert: drop dead code for untracked files
Untracked files are handled through status now.
2014-06-25 00:02:17 +01:00
Pierre-Yves David
6f03c922f1 revert: handle unknown files through status
This will allow us to drop the code dedicated to this special case.
2014-06-25 00:01:30 +01:00
Pierre-Yves David
aee89be787 revert: drop more dead code
Now that we detect all clean files, we do not need this clause anymore.
2014-06-24 23:55:43 +01:00
Pierre-Yves David
f409864957 revert: add a message to noop action
This prepares for the arrival of a second "not touching file" action:
revert of an untracked file.
2014-08-02 13:07:01 -07:00
Pierre-Yves David
5dc6cf75e9 revert: simplify loop conditional
The two breaks can be joined into one. The code gains one level of indent.
2014-08-01 11:41:56 -07:00
Pierre-Yves David
84467bf1a9 revert: explode the action tuple in the for loop
noop is about to gain a message.
2014-06-24 18:04:13 +01:00
Pierre-Yves David
110f9a614a revert: use actions[...] in all disptable cases
1. Special cases are not special enough

2. There are two cases where nothing is done and a message is displayed. This
   prepares it.
2014-08-02 12:45:34 -07:00
Pierre-Yves David
5b69082d6e revset: factorize backup decision
The conditional controlling the creation of backup is fairly big. We move config
related decisions outside of the loop.
2014-06-24 17:54:33 +01:00
Pierre-Yves David
8af395dddd revert: use a flat dispatch table
Now that the table is simpler, remove one level of depth from it. This
simplifies its usage in the for loop.
2014-06-24 17:44:31 +01:00
Pierre-Yves David
a3e6a74916 debugobsolete: explicitly display date in the output
As the date is becoming a first-class citizen, we are displaying it in an
explicit field. As a bonus it is now readable by humans.
2014-08-13 23:42:36 -07:00
Pierre-Yves David
b1789db911 obsmarker: add a flags method
We introduce a proper method to access the flag information.
2014-08-15 09:41:30 -07:00
Pierre-Yves David
fbb01f1dde revert: add an XXX about rename tracking
We check for rename information in the dirstate. This is probably not enough to
preserve this behavior when using an explicit target rev.

I just spotted this while working on this code, but this is outside the scope
of my series so I'm just adding a comment to highlight this suspicious
situation.
2014-06-24 16:59:40 +01:00
Pierre-Yves David
429f2742a7 revert: inline a now useless closure
Now that a single call site remains, we can just inline its content.
2014-06-24 17:39:43 +01:00
Pierre-Yves David
6088f7f0d0 revert: remove code killed by the double status
All those checks were here to catch cases where files were not modified in
dirstate but were different in the target revision. This is now properly handled
by calling status on the target node too.
2014-06-24 17:37:24 +01:00
Pierre-Yves David
c1c198f25f revert: drop missingmodified set
There cannot be any elements in this set since:

    dsmodified &= modified
2014-06-24 17:36:49 +01:00
Pierre-Yves David
032cc9974f revert: detect files added during a merge
In case of merge, file that are actually added can be reported as modified. This
is currently handled by special-case code. We detect it beforehand instead. This
will lets use remove the special-case code at some point in the future.
2014-06-24 17:28:20 +01:00
Pierre-Yves David
9f80242186 revert: simplify handling of added files
There are multiple possible cases for added files. But it's all handled by magic
much lower in the stack. We document them, simplify the codes and move on.
2014-08-02 11:32:24 -07: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
Pierre-Yves David
ff3290bfea revert: use modified information from both statuses
Using status information against the target ensures we are catching all
files with modifications that need reverting.

We still need to distinguish fresh modifications for backup purpose.

test-largefile is affected because it reverted a file that needs no content
change.
2014-06-24 17:27:18 +01:00
Pierre-Yves David
56e34a196a revert: drop special case handling for file unknown in parent
We had a special case for file not caught by any categories. It was
aimed at files missing in wc and wc's parent but existing in the target
revision. This is now properly handled using status information.
2014-06-24 16:57:16 +01:00
Pierre-Yves David
911e895e66 revert: use "remove" information from both statuses
Using status information against the target to make sure we are catching all
files that need to be re-added.

We still need to distinguish fresh removal because they use a different
message.
2014-06-24 16:53:22 +01:00
Pierre-Yves David
2cc3d88c5b revert: process removed files missing in target as clean
If a file does not exist in target and is marked as removed in the dirstate, we
can mark it as clean. There are no changes needed to revert it.
2014-08-01 18:27:47 -07:00
Pierre-Yves David
708550e527 revert: also track clean files
Tracking clean files is the simplest way to be able to reports files that need
no changes. So we explicitly retrieve them.

This fixes a couple of test outputs where the lack of changes was not reported.
2014-07-31 15:52:56 -07:00