Commit Graph

221 Commits

Author SHA1 Message Date
Christian Ebert
01fcbdd680 keyword: use ui.formatter for kwfiles output 2012-06-28 15:06:41 +01:00
Christian Ebert
840a657147 keyword: update copyleft 2012-05-26 20:49:51 +02:00
Christian Ebert
932da89b94 keyword: wlock cmdutil.copy wrapper
Expanding/shrinking happens outside the wrapped copy function;
therefore write lock the repo.
2012-05-26 20:49:44 +02:00
Christian Ebert
06fe63f255 keyword: support commit --amend (issue3471)
Include a test as well.
2012-05-26 20:46:12 +02:00
Christian Ebert
0ce6a128c9 keyword: rename kwt.record attribute to kwt.postcommit
A more general descriptive name, as the attribute will be used
for commit --amend as well.
2012-05-25 19:32:29 +02:00
Augie Fackler
96d44b39f7 hgext: mark all first-party extensions as such 2012-05-15 14:37:49 -05:00
Christian Ebert
7b42c28269 keyword: intentionally ignore check-code warning about unwrapped ui message 2012-05-13 14:26:26 +01:00
Brodie Rao
a7ef0a0cc5 cleanup: "not x in y" -> "x not in y" 2012-05-12 16:00:57 +02:00
Christian Ebert
12742c63ce keyword: update filectx.cmp monkeypatch to handle '\1\n' at start of file
Analogous to fe250fe8487d.
2012-01-15 13:37:33 +01:00
Matt Mackall
2988d59e97 keyword: backout realpath change (issue3071) 2011-10-30 12:10:11 -05:00
Thomas Arendsen Hein
8d8608054c keyword: use util.realpath instead of os.path.realpath
This makes test-keyword.t pass on Python 2.4.1 (e.g. Debian sarge)
2011-10-24 13:54:59 +02:00
Christian Ebert
81060c2149 keyword: correct grammar in iskwfile docstring 2011-10-21 12:07:27 +01:00
Greg Ward
3e3c1d99c8 rollback: avoid unsafe rollback when not at tip (issue2998)
You can get into trouble if you commit, update back to an older
changeset, and then rollback. The update removes your valuable changes
from the working dir, then rollback removes them history. Oops: you've
just irretrievably lost data running nothing but core Mercurial
commands. (More subtly: rollback from a shared clone that was already
at an older changeset -- no update required, just rollback from the
wrong directory.)

The fix assumes that only "commit" transactions have irreplaceable
data, and allows rolling back non-commit transactions as always. But
when rolling back a commit, check that the working dir is checked out
to tip, i.e. the changeset we're about to destroy. If not, abort. You
can get back the old (dangerous) behaviour with --force.
2011-09-30 21:58:54 -04:00
Christian Ebert
9260ab613b keyword: use wopener(..., atomictemp=True) to overwrite 2011-09-11 12:20:39 +01:00
Matt Mackall
416842428c merge with stable 2011-09-08 18:30:44 -05:00
Christian Ebert
5496330943 keyword: preserve file mode when overwriting 2011-09-08 19:30:25 +01:00
Christian Ebert
58df2bcfcf keyword: avoid x = a and b or c 2011-08-08 11:34:52 +01:00
Matt Mackall
5ab97592f7 scmutil: switch match users to supplying contexts
The most appropriate context is not always clearly defined. The obvious cases:

For working directory commands, we use None
For commands (eg annotate) with single revs, we use that revision

The less obvious cases:

For commands (eg status, diff) with a pair of revs, we use the second revision
For commands that take a range (like log), we use None
2011-06-18 16:52:51 -05:00
Patrick Mezard
3680e66462 patch: generalize the use of patchmeta in applydiff()
- Add patchmeta.copy() and emit copies from iterhunks. Modifying patchmeta
  instances in applydiff() makes things simpler.
- Rename selectfile() into makepatchmeta(). It is responsible for creating
  patchmeta for regular patches.
- Pass patchmeta objects to patchfile() directly

patchmeta instances were associated with git patches, for regular patches we
had to pass additional variables to tell the patch intent to patchfile().
Instead, we generate patchmeta for regular patches and pass them. This will
also help with patch filtering by matcher objects.
2011-06-11 14:17:25 +02:00
Christian Ebert
f79ff6d290 keyword: reuse already present working contexts for match
Shortens overlong line as side-effect.
2011-07-03 12:58:03 +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
Patrick Mezard
514ff73602 patch: set desired mode when patching, not in updatedir()
This patch and the following aim at merging _updatedir() actions into
_applydiff().
2011-05-18 23:48:13 +02:00
Patrick Mezard
431a9d156a patch: extract fs access from patchfile into fsbackend
Most filesystem calls are already isolated in patchfile but this is not enough:
renames are performed before patchfile is available and some chmod calls are
even done outside of the applydiff call. Once all these calls are extracted
into a backend class, we can provide cleaner APIs to write to a working
directory context directly into the repository.
2011-05-17 23:46:15 +02:00
Matt Mackall
0832007f60 scmutil: drop aliases in cmdutil for match functions 2011-05-13 14:58:24 -05:00
Martin Geisler
249808f0a8 keyword: use cmdutil.command decorator 2011-05-12 14:31:07 +02:00
Dan Villiom Podlaski Christiansen
511c941422 prevent transient leaks of file handle by using new helper functions
These leaks may occur in environments that don't employ a reference
counting GC, i.e. PyPy.

This implies:
 - changing opener(...).read() calls to opener.read(...)
 - changing opener(...).write() calls to opener.write(...)
 - changing open(...).read(...) to util.readfile(...)
 - changing open(...).write(...) to util.writefile(...)
2011-05-02 10:11:18 +02:00
Adrian Buehlmann
f3e8eae526 move canonpath from util to scmutil 2011-04-20 21:41:41 +02:00
Martin Geisler
722384a5f7 keyword: convert a verbatim block to a field list 2011-04-05 11:07:25 +02:00
Christian Ebert
d7bf092ada keyword: offer additional datefilters when the extension is enabled
Before the additional datefilters (utcdate, svnisodate, svnutcdate)
were used when kwtemplater was initialized. Now they always be used
once the extension is enabled.
2011-03-14 12:26:50 +01:00
Christian Ebert
538e3f9097 keyword: docstrings for additional date filters 2011-03-14 12:19:59 +01:00
Patrick Mezard
3a56f6a3b1 templates: document missing keywords or filters
Keywords keywords are not documented yet but are turned into function
definitions to avoid lambda docstring weirdness.
2011-03-12 12:46:31 +01:00
Christian Ebert
95a7f264b7 keyword: move repo.__class__ assignment out of monkeypatch context
A cosmetic change to improve readability.
2011-01-23 03:15:44 +01:00
Christian Ebert
36f93ec22a keyword: inform user about current keywordset in kwdemo
The kwdemo --default output now looks roughly like this:

      configuration using default cvs keywordset
[extensions]
keyword =
[keyword]
demo.txt =
[keywordset] * section added with this change
svn = False
[keywordmaps]
...
2011-01-23 03:15:39 +01:00
Christian Ebert
87f97c3b31 keyword: update documentation for kwshrink
* remove obsolete reference to potential problems with merge and import
* emphasize that running kwshrink before configuration changes which
  affect active/expanded keywords is mandatory
2011-01-16 15:45:26 +01:00
Christian Ebert
3482ce6068 keyword: make kwfiles show deleted files configured for expansion 2010-12-04 14:44:05 +01:00
Christian Ebert
04b255ebb4 keyword: colorize hg kwfiles output 2010-12-04 14:22:12 +01:00
Matt Mackall
15ad3a76d6 merge with stable 2010-12-01 18:47:40 -06:00
Christian Ebert
7130ab35da keyword: copy: when copied source is a symlink, follow it
1) hg cp symlink copy -> copy is a symlink.
2) cp symlink copy; hg cp -A symlink copy -> copy is a regular file.

In the second case we have to follow the symlink to its target
to find out whether we have to unexpand keywords in the copy.

Add test covering the case where the copied link's target is ignored
by keyword but has content which would match the regex for expanded
keywords to check whether we indeed leave the destination alone.
2010-12-01 10:51:49 +01:00
Martin Geisler
59192feb36 merge with stable 2010-11-22 17:39:46 +01:00
Christian Ebert
0a8e9b8d50 keyword: s/config/configuration/ in help 2010-11-22 16:05:31 +01:00
Christian Ebert
df0bc30259 keyword: turn regexes and escaped keywords into a propertycache 2010-11-04 22:56:38 +00:00
Christian Ebert
8d43aa49f8 keyword: function to look up changectx for expansion
Similarly rename variable in kwtemplater.overwrite().
2010-11-03 14:37:41 +01:00
Christian Ebert
baf94f43b9 keyword: fix regressions introduced in 1416551b9299
- dirstate of overwritten files must be forced to normal
  with kwexpand/kwshrink, not commit.
- recorded files must be weeded before overwriting.
- add test cases.
2010-10-24 15:11:41 +01:00
Christian Ebert
89ad77f3b8 keyword: only use expensive fctx.cmp when needed
Restrict expensive cmp to cases when:

- comparing against working directory
and
  - encode filters active
  or
  - path is configured for keyword expansion
2010-10-14 22:53:17 +02:00
Christian Ebert
94017a6ef9 keyword: code cleanup
- move preselection of expansion candidates for rollback
  and record into helper function
- same overwrite order in rollback and record:
  1. modified, 2. added
- self.wlock() inside kwrepo class instead of repo.wlock()
2010-10-12 12:49:23 +01:00
Nicolas Dumazet
04cf1f6b57 filectx: use ctx.size comparisons to speed up ctx.cmp
Comparing sizes is cheaper than comparing file contents, as it does not
involve reading the file on disk or from the filelog.

It is however not always possible: some extensions, or encode filters,
change data when extracting it to the working directory.
2010-07-27 23:07:30 +09:00
Christian Ebert
090eecd7fd keyword: enforce subn method via boolean switch
There are only 2 patterns to choose, and so far only 1 case
where kwtemplater.re_kw.subn is applied on data read from
the working directory: when recording added files.

With this change the code reflects more closely the boolean
character of the switch and underlines the special case.
2010-10-10 00:38:57 +01:00
Christian Ebert
f2c0019bd0 keyword: fix weeding of expansion candidates when recording
Rearrange tests to check this, i.e. that there are changes
in other files, not only the recorded one.
2010-10-10 00:30:09 +01:00
Christian Ebert
cdefb1362f keyword: switch kwtemplater.record in kw_dorecord()
Obsoletes the need for a global recordcommands variable.
2010-10-08 18:39:46 +01:00