Commit Graph

7529 Commits

Author SHA1 Message Date
Patrick Mezard
ab82a700d3 patch: do not patch unknown files (issue752) 2011-05-27 21:50:11 +02:00
Patrick Mezard
d4b7db6294 patch: use temporary files to handle intermediate copies
git patches may require copies to be handled out-of-order. For instance, take
the following sequence:

  * modify a
  * copy a into b

Here, we have to generate b from a before its modification. To do so,
applydiff() was scanning for copy metadata and performing the copies before
processing the other changes in-order. While smart and efficient, this approach
complicates things by handling file copies and file creations at different
places and times. While a new file must not exist before being patched a copied
file already exists before applying the first hunk.

Instead of copying the files at their final destination before patching, we
store them in a temporary file location and retrieve them when patching. The
filestore always stores file content in real files but nothing prevents adding
a cache layer. The filestore class was kept separate from fsbackend for at
least two reasons:

- This class is likely to be reused as a temporary result store for a future
  repository patching call (entries just have to be extended to contain copy
  sources).

- Delegating this role to backends might be more efficient in a repository
  backend case: the source files are already available in the repository itself
  and do not need to be copied again. It also means that third-parties backend
  would have to implement two other methods. If we ever decide to merge the
  filestore feature into backend, a minimalistic approach would be to compose
  with filestore directly. Keep in mind this copy overhead only applies for
  copy/rename sources, and may even be reduced to copy sources which have to
  handled ahead of time.
2011-05-27 21:50:10 +02:00
Patrick Mezard
e6f284be06 patch: refactor file creation/removal detection
The patcher has to know if a file is being created or removed to check if the
target already exists, or to actually unlink the file when a hunk emptying it
is applied. This was done by embedding the creation/removal information in the
first (and only) hunk attached to the file.

There are two problems with this approach:

- creation/removal is really a property of the file being patched and not its
  hunk.

- for regular patches, file creation cannot be deduced at parsing time: there
  are case where the *stripped* file paths must be compared. Modifying hunks
  after their creation is clumsy and prevent further refactorings related to
  copies handling.

Instead, we delegate this job to selectfile() which has all the relevant
information, and remove the hunk createfile() and rmfile() methods.
2011-05-27 21:50:09 +02:00
Adrian Buehlmann
5e0e57cb94 commands.remove: don't use workingctx.remove(list, unlink=True)
workingctx.remove(list, unlink=True) is unsuited here, because it does too
much: it also unlinks added files. But the command 'hg remove' is specified
to *never* unlink added files.

Instead, we now unlink the files at the commands.remove level (if --after was
not specified) and use workingctx.forget for all files.

As an added bonus, this happens to eliminate a wlock acquire/release pair,
since the previous implementation caused

   acquire wlock
   release wlock
   acquire wlock
   release wlock

where the first pair of acquire/release was caused by the workingctx.forget
call, and the second by the workingctx.remove call.
2011-05-27 15:59:52 +02:00
Matt Mackall
fd5cc95a4a coal: use preformatted text for descriptions (issue2835)
The coal style was broken here by an earlier change to paper, which
shares files.
2011-05-27 08:50:27 -05:00
Martin Geisler
2edabc4530 subrepo: refactor writestate for clarity 2011-05-27 11:01:44 +02:00
Matt Mackall
5f2364be24 cmdutil: make private copies of option lists to avoid sharing monkeypatches 2011-05-26 17:15:35 -05:00
Paul Molodowitch
dfc345d9b5 subrepo: bare git repos considered dirty
Currently, if there is a bare git subrepo, but it is at the "right"
revision, calling dirty() will error because diff-index does not work
on bare repos. This patch makes it so bare subrepos are always
considered dirty.
2011-05-25 08:38:58 -07:00
Idan Kamara
b9dc5b5bf7 dispatch: use the request to store the ui object
and check if we got one before creating.

note that the contents of the ui object might change after
dispatch() returns (by options passed through --config for example),
to ensure it doesn't, pass a copy() of it.
2011-05-26 00:53:23 +03:00
Idan Kamara
5544ef8f07 dispatch: wrap dispatch related information in a request class
currently only stores the arguments.
2011-05-26 00:44:11 +03:00
Steven Brown
b13eee65a4 patch: restore the previous output of 'diff --stat'
Restore the previous diffstat behaviour of scaling by the maximum number of
changes to a single file. Changeset 7bb0e22a7988 modified the diffstat to be
scaled by the total number of changes. This seems to have been unintentional.
2011-05-26 22:51:02 +08:00
Peter Arrenbrecht
8761d1fa87 wireproto: enable optional args for known() for future extensibility
Firstly, I think we should do this for all new wire commands, just
to be on the safe side. So I want to get this into the 1.9 release.

Secondly, there actually is potential here that sometimes the server
can know that the number of its nodes which can possibly still be
undecided on the client is small. It might then just send them along
directly (cutting short the end game). This, however, requires
walking the graph on the server, which can be expensive, so for the
moment we're not actually doing it.
2011-05-24 17:48:16 +02:00
Matt Mackall
c6e850b04b context: make forget work like commands.forget
Switch users of wctx.delete(..., False) to forget.
2011-05-26 17:15:35 -05:00
Matt Mackall
97c6e7b48d dirstate: rename forget to drop
It has substantially different semantics from forget at the command
layer, so change it to avoid confusion.

We can't simply combine it with remove because we need to explicitly
drop non-added files in some cases like commit.
2011-05-26 17:15:35 -05:00
Martin Geisler
ce8ced9777 minirst: read test input from stdin 2011-05-26 10:46:34 +02:00
Matt Mackall
a8dec32fed httprepo: handle large lengths by bypassing the len() operator 2011-05-24 17:30:00 -05:00
Adrian Buehlmann
5872a76fa2 workingctx.remove: don't stat files again after unlinking
we already know at this point that they have been unlinked
2011-05-24 14:52:23 +02:00
Matt Mackall
438f823709 httprepo: send URL redirection notices to stderr (issue2828) 2011-05-24 17:16:31 -05:00
Augie Fackler
14a08e5514 pure parsers: properly detect corrupt index files
This new Python code should be equivalent in behavior to the if
statement at line 312 of parsers.c. Without this, the pure-python
parsers improperly ignore truncated revlogs as created in
test-verify.t.
2011-05-24 13:30:10 -05:00
Adrian Buehlmann
2fa6cdd315 workingctx: unlink paths while holding the wlock 2011-05-24 14:08:20 +02:00
Martin Geisler
34dddcd6fe wireproto: do not hash when heads == ['force']
Changeset 20b319765bcf introduced the unbundlehash capability and
unconditionally hashed the heads on the client side. By mistake, the
heads were also cased in the heads == ['force'] case.
2011-05-24 16:12:01 +02:00
Patrick Mezard
32250cd067 patch: remove EOL support from linereader class
This was only used when reading patched files which is now done by backends.
2011-05-24 14:21:04 +02:00
Matt Mackall
db4e14bfa3 subrepo: handle local added subrepo case correctly 2011-05-23 22:49:10 -05:00
Idan Kamara
d5c206ffa2 extensions: raise when trying to find an extension that failed to load
extensions that depend on other extensions (such as record) use this pattern
to check if the dependant extension is available:

    try:
        mq = extensions.find('mq')
    except KeyError:
        return

but since if an error occurs while loading an extension it leaves its entry
in the _extensions map as None, we want to raise in that situation too.

(rather than adding another check if the return value is None)
2011-05-23 23:09:00 +03:00
Adrian Buehlmann
f559c2bcbb remove: clarify help text about added files never being deleted from disk 2011-05-23 15:56:31 +02:00
Adrian Buehlmann
8728d73db7 pure: provide more correct implementation of posixfile for Windows
requires ctypes

Why is posixfile a class?

Because the implementation needs to use the Python library call os.fdopen [1],
which sets the 'name' attribute on the Python file object it creates to the
mostly meaningless string '<fdopen>', since file descriptors don't have a name.

But users of posixfile depend on the name attribute [2] being set to a proper
value, like Python's built-in 'open' function sets it on file objects.

Python file's name attribute is read-only, so we can't just assign to it after
the file object has alrady been created.

To solve this problem, we save the name of the file on a wrapper object,
and delegate the file function calls to the wrapped (private) file object
using __getattr__.

[1] http://docs.python.org/library/os.html#os.fdopen
[2] http://docs.python.org/library/stdtypes.html#file.name
2011-05-18 09:12:27 +02:00
Peter Arrenbrecht
fedeff28a1 bundlerepo: make getremotechanges support filtering of incoming
Extensions can hook discovery.findcommonincoming to filter out unwanted remote
changesets. This patch makes getremotechanges respect the changed remote heads
returned by such extensions.
2011-05-23 20:35:10 +02:00
Adrian Buehlmann
a11d19c5ad applyupdates: audit merged files
protects changing flags on merged files (util.setflags call on line 341)
2011-05-22 11:03:15 +02:00
Adrian Buehlmann
18e5c7b1c9 applyupdates: audit path on flag changes
we're using the auditor of the repo wopener, since this is a path that belongs
to the tree we're updating to
2011-05-21 23:21:12 +02:00
Adrian Buehlmann
60c5ff105b opener: add audit function 2011-05-21 23:13:59 +02:00
Matt Mackall
0842cf2d1e templatekw: use diffstatsum in diffstat keyword 2011-05-21 15:09:15 -05:00
Matt Mackall
6af03bc2e8 patch: use diffstatsum in diffstat 2011-05-21 15:06:38 -05:00
Matt Mackall
7560e9a576 patch: add diffstatsum helper 2011-05-21 15:06:36 -05:00
Matt Mackall
898e0ce783 diffstatdata: no longer a generator
This produces a smallish amount of data and all consumers needed to
buffer it anyway.
2011-05-21 15:01:28 -05:00
Adrian Buehlmann
9e0713e79c add new option --all to manifest command
prints a list of all files in all revisions of the repo

obsoletes the cifiles extension
2011-05-18 21:31:40 +02:00
Adrian Buehlmann
4c8d0e46fa applyupdates: audit unlinking of renamed files and directories 2011-05-21 02:05:00 +02:00
Matt Mackall
66805ccfed revlog: stop exporting node.short 2011-05-21 15:01:28 -05:00
Patrick Mezard
272081b65d patch: fast-path git case in selectfile()
We avoid a lot of complicated heuristics in git cases, where these heurestics
may even be broken when copies are involved.
2011-05-19 22:55:13 +02:00
Patrick Mezard
a09607c9ee patch: unify backend file access interface
- Rename readlines() into getfile(), return data and mode
- Make setfile() write a data buffer instead of lines, make mode mandatory.
2011-05-19 22:49:43 +02:00
Patrick Mezard
701e9571f9 patch: merge backend setmode() into writelines()
Copy handling will be easier to handle in a single method.
2011-05-19 22:44:01 +02:00
Patrick Mezard
15861c0232 patch: stop modifying gitpatch objects
gitpatch objects emitted by iterhunks() were referencing file paths unmodified
from the input patch. _applydif() made them usable by modifying the gitpatch
objects in-place with specified path strip level. The same modified objects
were then reused by iterhunks() generator. _applydiff() now copies and update
the paths which completely decouples both routines.

As a side effect, the "git" event now receives only metadata about
copies/renames to perform the necessary copies ahead of time. Other actions are
handled in the "file" event.
2011-05-19 22:44:01 +02:00
Patrick Mezard
3246b5c773 patch: stop handling hunkless git blocks out of stream
Patch changes are emitted by iterhunks() in two separate events: 'file' when
hunks have to be applied and 'git' to describe other modifications like copies
or mode changes. Note that a file which mode is changed and which content is
modified by the same patch will be emitted in both events. It is more
convenient to handle all file modifications in a single event. This patch
"zips" git actions with regular changes so both kinds can be emitted at the
same place.
2011-05-19 22:44:01 +02:00
Patrick Mezard
ac0634bc33 patch: reindent code 2011-05-19 22:44:01 +02:00
Patrick Mezard
ac6f56515a patch: unify iterhunks() afile/bfile handling
git afile/bfile are extracted twice, once when reading a 'diff --git', and
again when reading a unified hunk. The problem is not all git blocks have
unified hunks (renames just have metadata) and they were not extracted the same
way. This is what this patch unifies.
2011-05-19 22:44:01 +02:00
Patrick Mezard
f8df1dcc42 patch: git metadata was ignored if strip > 1
gitpatch objects emitted by iterhunks() are modified in place by applydiff().
Processing them earlier improves iterhunks() isolation. applydiff() modifying
them should still be fixed though.
2011-05-19 22:44:01 +02:00
Patrick Mezard
68fd0dcbe7 patch: construct and parse binary hunks at the same time 2011-05-19 22:44:01 +02:00
Patrick Mezard
452fad17b8 patch: refactor iterhunks() regular and binary files emission 2011-05-19 22:44:01 +02:00
Patrick Mezard
78738c3822 patch: remove patch.patch() cwd argument 2011-05-19 22:44:01 +02:00
Patrick Mezard
6d4d079b0e patch: merge _updatedir() into externalpatch() 2011-05-19 22:44:01 +02:00
Martin Geisler
0eaeed4412 merge with stable 2011-05-19 18:10:03 +02:00