(0.9.2compat) incorporate changes from default branch
_iskwfile used by 2 functions again.
--- a/hgkw/keyword.py Sat Feb 09 09:31:13 2008 +0100
+++ b/hgkw/keyword.py Sun Feb 10 01:28:16 2008 +0100
@@ -89,7 +89,7 @@
from mercurial import filelog, localrepo, revlog, templater, util
from mercurial.node import *
from mercurial.i18n import gettext as _
-import getopt, os.path, re, shutil, tempfile, time
+import getopt, os, re, shutil, tempfile, time
commands.optionalrepo += ' kwdemo'
@@ -106,7 +106,7 @@
return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(date[0]))
-_kwtemplater, _cmd, _cmdoptions = None, None, None
+_kwtemplater = _cmd = _cmdoptions = None
# backwards compatibility hacks
@@ -265,11 +265,11 @@
'Header': '{root}/{file},v {node|short} {date|utcdate} {author|user}',
}
- def __init__(self, ui, repo, inc, exc, restrict):
+ def __init__(self, ui, repo, inc, exc, hgcmd):
self.ui = ui
self.repo = repo
self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
- self.restrict = restrict
+ self.restrict = hgcmd in restricted.split()
self.commitnode = None
self.path = ''
@@ -523,9 +523,13 @@
if opts.get('untracked'):
files += unknown
files.sort()
- # use the full definition of repo._link for backwards compatibility
- kwfiles = [f for f in files if _kwtemplater.matcher(f)
- and not os.path.islink(repo.wjoin(f))]
+ wctx = repo.workingctx()
+ if hasattr(wctx, 'fileflags'):
+ islink = lambda p: 'l' in wctx.fileflags(p)
+ else:
+ mf = wctx.manifest()
+ islink = mf.linkf
+ kwfiles = [f for f in files if _iskwfile(f, islink)]
cwd = pats and repo.getcwd() or ''
kwfstats = not opts.get('ignore') and (('K', kwfiles),) or ()
if opts.get('all') or opts.get('ignore'):
@@ -561,7 +565,7 @@
try:
if (not repo.local() or hgcmd in nokwcommands.split()
- or '.hg' in repo.root.split('/')
+ or '.hg' in repo.root.split(os.sep)
or repo._url.startswith('bundle:')):
return
except AttributeError:
@@ -585,8 +589,7 @@
if node1 is not None and node1 != repo.changectx().node():
hgcmd = 'diff1'
- restrict = hgcmd in restricted.split()
- _kwtemplater = kwtemplater(ui, repo, inc, exc, restrict)
+ _kwtemplater = kwtemplater(ui, repo, inc, exc, hgcmd)
class kwrepo(repo.__class__):
def file(self, f, kwmatch=False):
@@ -598,7 +601,7 @@
def wread(self, filename):
data = super(kwrepo, self).wread(filename)
- if restrict and _kwtemplater.matcher(filename):
+ if _kwtemplater.restrict and _kwtemplater.matcher(filename):
return _kwtemplater.shrink(data)
return data
--- a/tests/test-keyword Sat Feb 09 09:31:13 2008 +0100
+++ b/tests/test-keyword Sun Feb 10 01:28:16 2008 +0100
@@ -32,6 +32,19 @@
echo % kwshrink should exit silently in empty/invalid repo
hg kwshrink
+# Symlinks cannot be created on Windows. The bundle was made with:
+#
+# hg init t
+# cd t
+# echo a > a
+# ln -s a sym
+# hg add sym
+# hg ci -m addsym -u mercurial
+# hg bundle --base null ../test-keyword.hg
+#
+hg pull -u "$TESTDIR/test-keyword.hg" \
+ | sed 's/pulling from.*test-keyword.hg/pulling from test-keyword.hg/'
+
echo 'expand $Id$' > a
echo 'do not process $Id:' >> a
echo 'xxx $' >> a
@@ -138,7 +151,7 @@
hg kwfiles
echo % diff --rev
-hg diff --rev 0 | grep -v 'b/c'
+hg diff --rev 1 | grep -v 'b/c'
echo % rollback
hg rollback
@@ -200,7 +213,7 @@
echo % clone to test incoming
cd ..
-hg clone -r0 Test Test-a
+hg clone -r1 Test Test-a
cd Test-a
cat <<EOF >> .hg/hgrc
[paths]
Binary file tests/test-keyword.hg has changed
--- a/tests/test-keyword.out Sat Feb 09 09:31:13 2008 +0100
+++ b/tests/test-keyword.out Sun Feb 10 01:28:16 2008 +0100
@@ -70,6 +70,13 @@
Branch = {branches}
$Branch: demobranch $
% kwshrink should exit silently in empty/invalid repo
+pulling from test-keyword.hg
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
% cat
expand $Id$
do not process $Id:
@@ -90,14 +97,14 @@
% status
? hooktest
% identify
-7f0665a496fd
+475643d17242
% cat
-expand $Id: a,v 7f0665a496fd 1970/01/01 00:00:00 user $
+expand $Id: a,v 475643d17242 1970/01/01 00:00:00 user $
do not process $Id:
xxx $
ignore $Id$
% hg cat
-expand $Id: a,v 7f0665a496fd 1970/01/01 00:00:00 user $
+expand $Id: a,v 475643d17242 1970/01/01 00:00:00 user $
do not process $Id:
xxx $
ignore $Id$
@@ -111,14 +118,14 @@
adding changesets
adding manifests
adding file changes
-added 1 changesets with 2 changes to 2 files
-2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+added 2 changesets with 3 changes to 3 files
+3 files updated, 0 files merged, 0 files removed, 0 files unresolved
% touch
% status
% update
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
% cat
-expand $Id: a,v 7f0665a496fd 1970/01/01 00:00:00 user $
+expand $Id: a,v 475643d17242 1970/01/01 00:00:00 user $
do not process $Id:
xxx $
ignore $Id$
@@ -129,10 +136,10 @@
overwriting a expanding keywords
overwriting c expanding keywords
% compare changenodes in a c
-expand $Id: a,v 7f0665a496fd 1970/01/01 00:00:00 user $
+expand $Id: a,v 475643d17242 1970/01/01 00:00:00 user $
do not process $Id:
xxx $
-$Id: c,v 7fefeeacf359 1970/01/01 00:00:01 user $
+$Id: c,v c08ff8b9d54e 1970/01/01 00:00:01 user $
tests for different changenodes
% qinit -c
% qimport
@@ -141,11 +148,11 @@
# HG changeset patch
# User User Name <user@example.com>
# Date 1 0
-# Node ID 7fefeeacf3596ca401a248c183c2314cbf4661ee
-# Parent 7f0665a496fd37c3627191bd02e26a1e230f2aa2
+# Node ID c08ff8b9d54ebf87b428631bd34b3d8b69cbf72f
+# Parent 475643d17242703d20c30af0fc52b30fd231c6f6
cndiff
-diff -r 7f0665a496fd -r 7fefeeacf359 c
+diff -r 475643d17242 -r c08ff8b9d54e c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/c Thu Jan 01 00:00:01 1970 +0000
@@ -0,0 +1,2 @@
@@ -157,7 +164,7 @@
applying mqtest.diff
Now at: mqtest.diff
% cat
-$Id: c,v 7fefeeacf359 1970/01/01 00:00:01 user $
+$Id: c,v c08ff8b9d54e 1970/01/01 00:00:01 user $
tests for different changenodes
% qpop and move on
Patch queue now empty
@@ -170,10 +177,10 @@
c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
overwriting c expanding keywords
% cat a c
-expand $Id: a,v 7f0665a496fd 1970/01/01 00:00:00 user $
+expand $Id: a,v 475643d17242 1970/01/01 00:00:00 user $
do not process $Id:
xxx $
-expand $Id: c,v 6a127771f5db 1970/01/01 00:00:01 user $
+expand $Id: c,v 1acf8f3ab611 1970/01/01 00:00:01 user $
do not process $Id:
xxx $
% touch copied c after 1 second
@@ -182,7 +189,7 @@
a
c
% diff --rev
-diff -r 7f0665a496fd c
+diff -r 475643d17242 c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,3 @@
+expand $Id$
@@ -206,12 +213,12 @@
Xinfo = {author}: {desc}
$Xinfo: test: hg keyword config and expansion example $
% cat
-expand $Id: a,v 7f0665a496fd 1970/01/01 00:00:00 user $
+expand $Id: a,v 475643d17242 1970/01/01 00:00:00 user $
do not process $Id:
xxx $
ignore $Id$
% hg cat
-expand $Id: a 7f0665a496fd Thu, 01 Jan 1970 00:00:00 +0000 user $
+expand $Id: a 475643d17242 Thu, 01 Jan 1970 00:00:00 +0000 user $
do not process $Id:
xxx $
ignore $Id$
@@ -220,13 +227,13 @@
overwriting a expanding keywords
% status
% cat
-expand $Id: a 576a35651b0a Thu, 01 Jan 1970 00:00:02 +0000 user $
+expand $Id: a 9ea11ce3ca13 Thu, 01 Jan 1970 00:00:02 +0000 user $
do not process $Id:
xxx $
$Xinfo: User Name <user@example.com>: firstline $
ignore $Id$
% hg cat
-expand $Id: a 576a35651b0a Thu, 01 Jan 1970 00:00:02 +0000 user $
+expand $Id: a 9ea11ce3ca13 Thu, 01 Jan 1970 00:00:02 +0000 user $
do not process $Id:
xxx $
$Xinfo: User Name <user@example.com>: firstline $
@@ -239,7 +246,7 @@
R a
% revert a
% cat a
-expand $Id: a 576a35651b0a Thu, 01 Jan 1970 00:00:02 +0000 user $
+expand $Id: a 9ea11ce3ca13 Thu, 01 Jan 1970 00:00:02 +0000 user $
do not process $Id:
xxx $
$Xinfo: User Name <user@example.com>: firstline $
@@ -248,11 +255,11 @@
adding changesets
adding manifests
adding file changes
-added 1 changesets with 2 changes to 2 files
-2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+added 2 changesets with 3 changes to 3 files
+3 files updated, 0 files merged, 0 files removed, 0 files unresolved
% incoming
searching for changes
-changeset: 1:576a35651b0a
+changeset: 2:9ea11ce3ca13
tag: tip
user: User Name <user@example.com>
date: Thu Jan 01 00:00:02 1970 +0000
@@ -268,7 +275,7 @@
x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
overwriting x/a expanding keywords
% cat a
-expand $Id: x/a 2d19a72f00da Thu, 01 Jan 1970 00:00:03 +0000 user $
+expand $Id: x/a 93c8b61c99cd Thu, 01 Jan 1970 00:00:03 +0000 user $
do not process $Id:
xxx $
$Xinfo: User Name <user@example.com>: xa $
@@ -292,7 +299,7 @@
$Xinfo$
ignore $Id$
% hg cat
-expand $Id: a 576a35651b0a Thu, 01 Jan 1970 00:00:02 +0000 user $
+expand $Id: a 9ea11ce3ca13 Thu, 01 Jan 1970 00:00:02 +0000 user $
do not process $Id:
xxx $
$Xinfo: User Name <user@example.com>: firstline $