Commit Graph

195 Commits

Author SHA1 Message Date
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
Christian Ebert
924a741c44 keyword: specific regular expressions depending on read mode
More safeguarding against accidental (un)expansion:

Reading filelog: act only on \$(kw1|kw2|..)\$ as keywords are always
                 stored unexpanded.
Reading wdir:    act only on \$(kw1|kw2|..): [^$\n\r]*? \$ as we only
                 are interested in expanded keywords in this situation.
                 Note: we cannot use ..): [^$\n\r]+? \$ because e.g.
                 the {branch} template might be empty.

hg record is a special case as we read from the working directory and
need one regex each for modified and added files. Therefore test
recording an added file.

This way we finally also forbid sequences like $Id:  $ being treated
as keywords.
2010-10-08 18:39:46 +01:00
Christian Ebert
c7f6297b25 keyword: disable expansion in kwfilelog.read() if file renamed in node
Simplifies kwfilelog.cmp() and avoids fiddling with/importing revlog.

Reorder imports alphabetically.
2010-10-08 18:39:46 +01:00
Christian Ebert
05408dc4ec keyword: make iskwfile() a weeding method in lieu of a boolean
Update iskwfile docstring.
2010-10-08 18:39:46 +01:00
Christian Ebert
f6775a8777 keyword: support copy and rename
copy/rename destinations being unversioned and possibly ignored by
the extension should not contain expanded keywords.

Files copied/renamed from an ignored source are not touched.

Add tests covering both of the above cases, plus the corner case of
cp symlink foo; hg cp -A symlink foo (where foo becomes a regular file).
2010-10-08 18:39:46 +01:00
Christian Ebert
6ced1f0e94 keyword: refactor kwtemplater.overwrite()
Make kwexpand, kwshrink restricted commands - i.e. read from
filelog without expansion for substition in kwtemplater.overwrite,
and set/unset restricted mode for overwrite() in in kwcommitctx
and the dorecord wrapper.

Preselect candidates when working on changed files (rollback, record)
outside kwtemplater class, and remove 6th argument from overwrite().

Avoid duplicate substitution/search in overwrite():
Only go into restricted read mode when reading from filelog.
rollback and record read from the working directory, where
restricted mode would already shrink keywords before overwrite()
either expands or shrinks them again.

This ensures that the usual automatic operations on keywords
are turned off during overwrite() and only overwrite() itself
acts on them.

Reduce manifest calculation to the cases where it is needed.

Move helper function for expansion removal outside kwtemplater class.
2010-10-08 18:39:46 +01:00
Christian Ebert
7faf4b3245 keyword: use workingctx to detect modified and added files after rollback 2010-10-01 02:13:31 +02:00
Christian Ebert
8c9ae08c43 keyword: rename variable "cfiles" to "changed" for clarity 2010-10-01 02:13:31 +02:00
Christian Ebert
405806c3f9 keyword: support rollback by restoring expansion to previous values
Prevent spurious differences in the working directory
after a rollback.

Add tests for several rollback situations.
2010-09-26 19:18:41 +02:00
Christian Ebert
9915bf5605 keyword: do not expand at all during diff
Always shrink and never expand keywords during a diff operation.
Avoid user distraction e.g. because of spurious differences
appearing in the commit editor.
2010-09-26 19:18:41 +02:00
Christian Ebert
24b171fdd3 keyword: restore restricted read mode value after overwriting
Even though just enforcing expansion after overwriting files in
the working directory caused no problems that we know of, this avoids
a potential source of problems (e.g. in collaboration other extensions)
at no costs.
2010-09-26 19:18:41 +02:00
Christian Ebert
3fb88c8dbb Use more note admonitions in help texts 2010-09-23 16:31:38 +02:00
Martin Geisler
6335a7f166 merge with stable 2010-09-10 20:19:16 +02:00
Christian Ebert
55548a8056 keyword: explain file-wise expansion in help 2010-09-10 16:58:13 +02:00
Martin Geisler
e9c2a20771 diff: recurse into subrepositories with --subrepos/-S flag 2010-09-03 12:58:51 +02:00
Matt Mackall
42d9b2046b Merge with stable 2010-07-25 21:20:05 -05:00
Christian Ebert
e697dd5558 keyword: move collecting of [keyword] patterns to reposetup (issue2303)
When cloning, prevent [keyword] filename patterns configured locally
in the source directory to persist during the update in the destination.

a) move [keyword] retrieval (back) to reposetup
b) remove the corresponding global kwtools attributes

Add test cases.
2010-07-25 20:01:33 -05:00
Christian Ebert
15f0c93000 keyword: add extra datefilters in a single update call 2010-07-15 10:24:31 +02:00
Christian Ebert
e5d231e804 keyword: postpone manifest calculation in kwtemplater.overwrite
We can check for file existence in the working directory (needed
in case of recording) by simply using the given context and
calculate the manifest only when there are in fact candidates
for expansion/shrinking.
2010-06-15 17:15:31 +02:00
FUJIWARA Katsunori
ce06b102df help: show value requirement and multiple occurrence of options
this helps users to know what kind of option is:

  - no value is required(flag option)
  - value is required
  - value is required, and multiple occurrences are allowed

each kinds are shown as below:

 -f --force              force push
 -e --ssh CMD            specify ssh command to use
 -b --branch BRANCH [+]  a specific branch you would like to push

if one or more 3rd type options are shown, explanation for '[+]' mark
is also shown as footnote.
2010-06-06 17:25:00 +09:00
Christian Ebert
6241cdaae9 keyword: pass context to kwtemplater.overwrite
Now that we have retrieved the context in every calling function
except commit, pass it as argument to kwtemplater.overwrite to
avoid looking it up twice.

Reorder arguments to kwtemplater.overwrite to reflect their
importance.

Turn node argument into a simple boolean and rename it to iswctx.
2010-06-09 12:45:48 +01:00
Dirkjan Ochtman
af6b696f0f move working dir/dirstate methods from localrepo to workingctx 2010-06-07 20:03:32 +02:00
Christian Ebert
9f4630cb27 keyword: use context to detect uncommitted merge 2010-06-03 10:37:31 +01:00
Christian Ebert
8386b76841 keyword: retrieve added and modified files from commitctx 2010-06-01 03:45:10 +02:00
Christian Ebert
a2b0bda630 keyword: force dirstate normal when all changes in a file are recorded
Before this bugfix a file whose changes were entirely recorded was still
considered modified by "hg status".

Note: the test must use hg record -l/--logfile, because this is not
reproducible with hg record -m/--message.
2010-06-01 01:05:45 +02:00
Christian Ebert
e472d468be keyword: offer svn-like default keywordmaps
svn-like default keywords can be set in a new configuration section
called [keywordset] -- thanks to timeless for the name.

Move setup of default keywordmaps into dedicated function used by
kwtemplater.__init__ and demo.

HeadURL/URL is not supported (by default).
2010-05-19 00:45:50 +02:00
Christian Ebert
dfcf923020 keyword: add 2 svn-like date filters
svnisodate yields the format the date in svn's Id keyword expands to.
svnutcdate yields the format svn's Date/LastChangedDate expands to.

http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html
2010-05-18 22:16:38 +02:00