Show More
@@ -86,7 +86,7 b' from mercurial import commands, context,' | |||
|
86 | 86 | from mercurial import localrepo, match, patch, templatefilters, templater, util |
|
87 | 87 | from mercurial.hgweb import webcommands |
|
88 | 88 | from mercurial.i18n import _ |
|
89 | import re, shutil, tempfile | |
|
89 | import os, re, shutil, tempfile | |
|
90 | 90 | |
|
91 | 91 | commands.optionalrepo += ' kwdemo' |
|
92 | 92 | |
@@ -555,17 +555,31 b' def reposetup(ui, repo):' | |||
|
555 | 555 | def kw_copy(orig, ui, repo, pats, opts, rename=False): |
|
556 | 556 | '''Wraps cmdutil.copy so that copy/rename destinations do not |
|
557 | 557 | contain expanded keywords. |
|
558 |
Note that the source may also be a |
|
|
558 | Note that the source of a regular file destination may also be a | |
|
559 | symlink: | |
|
559 | 560 | hg cp sym x -> x is symlink |
|
560 | 561 | cp sym x; hg cp -A sym x -> x is file (maybe expanded keywords) |
|
561 | ''' | |
|
562 | For the latter we have to follow the symlink to find out whether its | |
|
563 | target is configured for expansion and we therefore must unexpand the | |
|
564 | keywords in the destination.''' | |
|
562 | 565 | orig(ui, repo, pats, opts, rename) |
|
563 | 566 | if opts.get('dry_run'): |
|
564 | 567 | return |
|
565 | 568 | wctx = repo[None] |
|
569 | cwd = repo.getcwd() | |
|
570 | ||
|
571 | def haskwsource(dest): | |
|
572 | '''Returns true if dest is a regular file and configured for | |
|
573 | expansion or a symlink which points to a file configured for | |
|
574 | expansion. ''' | |
|
575 | source = repo.dirstate.copied(dest) | |
|
576 | if 'l' in wctx.flags(source): | |
|
577 | source = util.canonpath(repo.root, cwd, | |
|
578 | os.path.realpath(source)) | |
|
579 | return kwt.match(source) | |
|
580 | ||
|
566 | 581 | candidates = [f for f in repo.dirstate.copies() if |
|
567 | kwt.match(repo.dirstate.copied(f)) and | |
|
568 | not 'l' in wctx.flags(f)] | |
|
582 | not 'l' in wctx.flags(f) and haskwsource(f)] | |
|
569 | 583 | kwt.overwrite(wctx, candidates, False, False) |
|
570 | 584 | |
|
571 | 585 | def kw_dorecord(orig, ui, repo, commitfunc, *pats, **opts): |
@@ -553,7 +553,8 b' Copy ignored file to ignored file: no ov' | |||
|
553 | 553 | $ hg forget i |
|
554 | 554 | $ rm i |
|
555 | 555 | |
|
556 | cp symlink (becomes regular file), and hg copy after | |
|
556 | cp symlink file; hg cp -A symlink file (part1) | |
|
557 | - copied symlink points to kwfile: overwrite | |
|
557 | 558 | |
|
558 | 559 | $ cp sym i |
|
559 | 560 | $ ls -l i |
@@ -602,6 +603,26 b' Status after rollback:' | |||
|
602 | 603 | $ hg update --clean |
|
603 | 604 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
604 | 605 | |
|
606 | cp symlink file; hg cp -A symlink file (part2) | |
|
607 | - copied symlink points to kw ignored file: do not overwrite | |
|
608 | ||
|
609 | $ cat a > i | |
|
610 | $ ln -s i symignored | |
|
611 | $ hg commit -Am 'fake expansion in ignored and symlink' i symignored | |
|
612 | $ cp symignored x | |
|
613 | $ hg copy --after --verbose symignored x | |
|
614 | copying symignored to x | |
|
615 | $ head -n 1 x | |
|
616 | expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $ | |
|
617 | $ hg forget x | |
|
618 | $ rm x | |
|
619 | ||
|
620 | $ hg rollback | |
|
621 | rolling back to revision 1 (undo commit) | |
|
622 | $ hg update --clean | |
|
623 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
624 | $ rm i symignored | |
|
625 | ||
|
605 | 626 | Custom keywordmaps as argument to kwdemo |
|
606 | 627 | |
|
607 | 628 | $ hg --quiet kwdemo "Xinfo = {author}: {desc}" |
General Comments 0
You need to be logged in to leave comments.
Login now