diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1554,6 +1554,8 @@ def init(ui, repo, **opts):
if r:
if not os.path.exists(r.wjoin('.hgignore')):
fp = r.wopener('.hgignore', 'w')
+ fp.write('^\\.hg\n')
+ fp.write('^\\.mq\n')
fp.write('syntax: glob\n')
fp.write('status\n')
fp.write('guards\n')
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -225,6 +225,7 @@ def backout(ui, repo, node=None, rev=Non
revert_opts['date'] = None
revert_opts['all'] = True
revert_opts['rev'] = hex(parent)
+ revert_opts['no_backup'] = None
revert(ui, repo, **revert_opts)
commit_opts = opts.copy()
commit_opts['addremove'] = False
@@ -2196,7 +2197,6 @@ def revert(ui, repo, *pats, **opts):
# but not other.
names = {}
- target_only = {}
wlock = repo.wlock()
try:
@@ -2204,8 +2204,6 @@ def revert(ui, repo, *pats, **opts):
for src, abs, rel, exact in cmdutil.walk(repo, pats, opts,
badmatch=mf.has_key):
names[abs] = (rel, exact)
- if src == 'b':
- target_only[abs] = True
# walk target manifest.
@@ -2223,10 +2221,9 @@ def revert(ui, repo, *pats, **opts):
if abs in names or src == 'b':
continue
names[abs] = (rel, exact)
- target_only[abs] = True
-
- changes = repo.status(match=names.has_key)[:5]
- modified, added, removed, deleted, unknown = map(dict.fromkeys, changes)
+
+ changes = repo.status(match=names.has_key)[:4]
+ modified, added, removed, deleted = map(dict.fromkeys, changes)
# if f is a rename, also revert the source
cwd = repo.getcwd()
@@ -2254,8 +2251,6 @@ def revert(ui, repo, *pats, **opts):
(added, revert, forget, True, False),
(removed, undelete, None, False, False),
(deleted, revert, remove, False, False),
- (unknown, add, None, True, False),
- (target_only, add, None, False, False),
)
entries = names.items()
@@ -2282,10 +2277,14 @@ def revert(ui, repo, *pats, **opts):
handle(hitlist, backuphit)
elif misslist is not None:
handle(misslist, backupmiss)
- else:
- if exact: ui.warn(_('file not managed: %s\n') % rel)
break
else:
+ if abs not in repo.dirstate:
+ if mfentry:
+ handle(add, True)
+ elif exact:
+ ui.warn(_('file not managed: %s\n') % rel)
+ continue
# file has not changed in dirstate
if node == parent:
if exact: ui.warn(_('no changes needed to %s\n') % rel)
@@ -2298,7 +2297,8 @@ def revert(ui, repo, *pats, **opts):
if mfentry:
# if version of file is same in parent and target
# manifests, do nothing
- if pmf[abs] != mfentry:
+ if (pmf[abs] != mfentry or
+ pmf.flags(abs) != mf.flags(abs)):
handle(revert, False)
else:
handle(remove, False)
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -369,6 +369,14 @@ class dirstate(object):
% (self.pathto(f), kind))
return False
+ def _dirignore(self, f):
+ if self._ignore(f):
+ return True
+ for c in strutil.findall(f, '/'):
+ if self._ignore(f[:c]):
+ return True
+ return False
+
def walk(self, files=None, match=util.always, badmatch=None):
# filter out the stat
for src, f, st in self.statwalk(files, match, badmatch=badmatch):
@@ -404,9 +412,11 @@ class dirstate(object):
return match(file_)
ignore = self._ignore
+ dirignore = self._dirignore
if ignored:
imatch = match
ignore = util.never
+ dirignore = util.never
# self._root may end with a path separator when self._root == '/'
common_prefix_len = len(self._root)
@@ -492,8 +502,9 @@ class dirstate(object):
yield 'b', ff, None
continue
if s_isdir(st.st_mode):
- for f, src, st in findfiles(f):
- yield src, f, st
+ if not dirignore(nf):
+ for f, src, st in findfiles(f):
+ yield src, f, st
else:
if nf in known:
continue
@@ -519,6 +530,7 @@ class dirstate(object):
lookup, modified, added, unknown, ignored = [], [], [], [], []
removed, deleted, clean = [], [], []
+ files = files or []
_join = self._join
lstat = os.lstat
cmap = self._copymap
@@ -536,8 +548,9 @@ class dirstate(object):
if fn in dmap:
type_, mode, size, time, foo = dmap[fn]
else:
- if list_ignored and self._ignore(fn):
- iadd(fn)
+ if (list_ignored or fn in files) and self._dirignore(fn):
+ if list_ignored:
+ iadd(fn)
else:
uadd(fn)
continue
diff --git a/templates/header.tmpl b/templates/header.tmpl
--- a/templates/header.tmpl
+++ b/templates/header.tmpl
@@ -1,6 +1,6 @@
-
+
diff --git a/templates/old/header.tmpl b/templates/old/header.tmpl
--- a/templates/old/header.tmpl
+++ b/templates/old/header.tmpl
@@ -1,6 +1,6 @@
-
+
diff --git a/tests/test-hgweb-commands.out b/tests/test-hgweb-commands.out
index 684b3e91d0dd961c12354408a2906d90d327a5b0..326d8df07cad7af2196b263febeb5b826bf1fdc8
GIT binary patch
literal 15005
zc%1E9>2ljR63+fy)jkA@cX+u+
zeo1B-p|MZAIgMv5>kVw1TzWiA1xc17T?!zKqGXlzdXuL&i-=q^o`p$#W;lJ@AT0J0
zWOruJ%nL)~>9jWq81o5`#@U%M7a|>7mNPi++wjk^fd8TOTqFx)+9Q*%Op}~T$x$*R
zripE#KV2I&v7imdYl_Z{j75P#=9~pBLMZSzfumv72hm6{9#g?Kj#MK=C?Yl$
zEEDDICYEZ2?q%u&4}a>6j&0L+;C*G=WBGm}KPQ$Z=>a*51;2%Hn(uSp2L%Z_BcMW1
zFW1Tkvkh2aQ}1{l5Bx!rHXuZ=zW&*39)JjN3UnTMH3`0b|)%n$qLVgKBSAOxe@-vP_E<>_%Af-a-{sH(>^jBC61+9cn2)G)<$>
zqo@tJzn_4;3^YnEzrbunGCMOczz`XSFjt~PV|xia%bEh9smA~9<>fkiD>sar_|hZL
z4ZVnF;D+u}h$POCifW!1qa0)El^~H;yCK;FJ$^Pif-qt=WMvuC1&zZ%?punIX~(LX
zOPa!kmT>o|tu&29ily2!;If0MHh4h?`Wj##+%E|AgiI=yoD#IAXfNur2yv1BI@g)wfj+?Cn2K|;SIulS)svhY7}eP9Fsm|ll7F#niLvIUJIZ71DsOiO+1
ziPr+FG5yy54%bLp2qE);<-%0;TT%il1J`8Xa^+^AZp5_Q42E4`Bq1r~p}4hWb`&a<
z3SX1K29~zICAY9ZFq`n36fy!Ec@SUgjuXGOwkAm51!>Z0Eqbu1v0I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@Dk>KYSXccW
zK9z%Eb;P*KI_ns?QNNpn(u}fPmAS1yV|MMHd=z`tPI7?qfleM6L$wh?@mb_
zr6)6WX05floW|Z94-q;>`7EHzNZ_GDUgUVb&I|@r$CQ<}oK}68XSY&S7``EDBr8tS
zjzeI(rPL9c{7UY(RZGuVv#0af>{+$Sx;<4{b~{@&l#bX)VXfbz^p5G>q4bWC?Mkoi
zq6iaSuJZ)<8f2@Xu}O~`_HV!6Z%SAT2(9s;BM*GeKyY6tkw$hmTlQ0!v{_m2&Z(c>
z7Y;W1LW}M0>j#gGsfvG}KL^}5-q%ZEbss1r^xZyjuh`nGI_~BZI|t_Bf*DViX|{9`94upZ8T(*^pMG@gAOE$FUq7g?
zcdzyco@zQ7Z~c5}kEl6xF|)}xAK2|TK&$uPrx3mM6D?wI`P!NgEmW$!YcV(f_5S_r
z(W6IydGx0}I0SM=7w>_lYls8fFXbVf;Ku6K75PZeb4{Ol371FVah$~Ll>FA~gLgys
zY90z^%HR8p6(o?ISO(hME2|0^ShCGDc~k@fmwF#i6R~f?)=l`BJoe?QLg%#8G5L~o
zs;-RkLSM|srpwrmD$x
z4r_wp6h11nqqDVzkHYb%NLZGIbb<=&7r#>}cAH}ZE4dAImyREK|6!wB%(bWM3C0Nr
zZ*O(=YsMj-(MUIoByDm-ar>m!5`;X{8*W_{&GA+0HO=Z}gz=m~IFc>`TDsJ~)2b>b
z>(EZNK|Lq=<}LdH$84b=HMvddsdDS92OU+5D4Dp9D_UCuK0dg}Z$A
-
+
diff --git a/tests/test-mq.out b/tests/test-mq.out
--- a/tests/test-mq.out
+++ b/tests/test-mq.out
@@ -70,6 +70,8 @@ A series
A test.patch
% qinit; qinit -c
.hgignore:
+^\.hg
+^\.mq
syntax: glob
status
guards
diff --git a/tests/test-revert b/tests/test-revert
--- a/tests/test-revert
+++ b/tests/test-revert
@@ -1,6 +1,7 @@
#!/bin/sh
-hg init
+hg init repo
+cd repo
echo 123 > a
echo 123 > c
echo 123 > e
@@ -40,19 +41,26 @@ hg revert q
rm q
echo %% should say file not found
hg revert notfound
+touch d
+hg add d
hg rm a
hg commit -m "second" -d "1000000 0"
echo z > z
hg add z
hg st
-echo %% should add a, forget z
+echo %% should add a, remove d, forget z
hg revert --all -r0
-echo %% should forget a
+echo %% should forget a, undelete d
hg revert --all -rtip
rm a *.orig
echo %% should silently add a
hg revert -r0 a
hg st a
+hg rm d
+hg st d
+echo %% should silently keep d removed
+hg revert -r0 d
+hg st d
hg update -C
chmod +x c
@@ -68,6 +76,8 @@ hg revert --all
echo %% should print executable
test -x c && echo executable
+cd ..
+
echo %% issue 241
hg init a
cd a
@@ -100,3 +110,33 @@ hg mv a newa
hg revert newa
hg st a newa
+cd ..
+
+hg init ignored
+cd ignored
+echo '^ignored$' > .hgignore
+echo '^ignoreddir$' >> .hgignore
+echo '^removed$' >> .hgignore
+
+mkdir ignoreddir
+touch ignoreddir/file
+touch ignoreddir/removed
+touch ignored
+touch removed
+echo '%% 4 ignored files (we will add/commit everything)'
+hg st -A -X .hgignore
+hg ci -qAm 'add files' ignored ignoreddir/file ignoreddir/removed removed
+
+echo >> ignored
+echo >> ignoreddir/file
+hg rm removed ignoreddir/removed
+echo '%% should revert ignored* and undelete *removed'
+hg revert -a --no-backup
+hg st -mardi
+
+hg up -qC
+echo >> ignored
+hg rm removed
+echo %% should silently revert the named files
+hg revert --no-backup ignored removed
+hg st -mardi
diff --git a/tests/test-revert-flags b/tests/test-revert-flags
new file mode 100755
--- /dev/null
+++ b/tests/test-revert-flags
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+"$TESTDIR/hghave" execbit || exit 80
+
+hg init repo
+cd repo
+echo foo > foo
+chmod 644 foo
+hg ci -qAm '644'
+
+chmod 755 foo
+hg ci -qAm '755'
+
+echo '% reverting to rev 0'
+hg revert -a -r 0
+hg st
+hg diff --git
diff --git a/tests/test-revert-flags.out b/tests/test-revert-flags.out
new file mode 100644
--- /dev/null
+++ b/tests/test-revert-flags.out
@@ -0,0 +1,6 @@
+% reverting to rev 0
+reverting foo
+M foo
+diff --git a/foo b/foo
+old mode 100755
+new mode 100644
diff --git a/tests/test-revert.out b/tests/test-revert.out
--- a/tests/test-revert.out
+++ b/tests/test-revert.out
@@ -37,14 +37,19 @@ notfound: No such file in rev 095eacd0c0
A z
? b
? e.orig
-%% should add a, forget z
+%% should add a, remove d, forget z
adding a
+removing d
forgetting z
-%% should forget a
+%% should forget a, undelete d
forgetting a
+undeleting d
%% should silently add a
A a
-0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+R d
+%% should silently keep d removed
+R d
+1 files updated, 0 files merged, 1 files removed, 0 files unresolved
reverting c
%% should print non-executable
non-executable
@@ -65,3 +70,14 @@ forgetting newdir/newfile
reverting b/b
% reverting a rename target should revert the source
? newa
+%% 4 ignored files (we will add/commit everything)
+I ignored
+I ignoreddir/file
+I ignoreddir/removed
+I removed
+%% should revert ignored* and undelete *removed
+reverting ignored
+reverting ignoreddir/file
+undeleting ignoreddir/removed
+undeleting removed
+%% should silently revert the named files
diff --git a/tests/test-status b/tests/test-status
--- a/tests/test-status
+++ b/tests/test-status
@@ -21,7 +21,7 @@ cd ..
hg init repo2
cd repo2
touch modified removed deleted ignored
-echo "ignored" > .hgignore
+echo "^ignored$" > .hgignore
hg ci -A -m 'initial checkin' -d "1000000 0"
sleep 1 # make sure mtime is changed
touch modified added unknown ignored
@@ -37,3 +37,10 @@ echo "hg status -C:"
hg status -C
echo "hg status -A:"
hg status -A
+echo "^ignoreddir$" > .hgignore
+mkdir ignoreddir
+touch ignoreddir/file
+echo "hg status ignoreddir/file:"
+hg status ignoreddir/file
+echo "hg status -i ignoreddir/file:"
+hg status -i ignoreddir/file
diff --git a/tests/test-status.out b/tests/test-status.out
--- a/tests/test-status.out
+++ b/tests/test-status.out
@@ -99,7 +99,6 @@ never-existed: No such file or directory
A added
R removed
! deleted
-? ignored
? unknown
hg status -C:
A added
@@ -118,3 +117,6 @@ R removed
I ignored
C .hgignore
C modified
+hg status ignoreddir/file:
+hg status -i ignoreddir/file:
+I ignoreddir/file
diff --git a/tests/test-walk b/tests/test-walk
--- a/tests/test-walk
+++ b/tests/test-walk
@@ -93,6 +93,13 @@ hg rm fenugreek
debugwalk fenugreek
touch new
debugwalk new
+
+mkdir ignored
+touch ignored/file
+echo '^ignored$' > .hgignore
+debugwalk ignored
+debugwalk ignored/file
+
chdir ..
debugwalk -R t t/mammals/skunk
mkdir t2
diff --git a/tests/test-walk.out b/tests/test-walk.out
--- a/tests/test-walk.out
+++ b/tests/test-walk.out
@@ -283,6 +283,11 @@ m fenugreek fenugreek exact
hg debugwalk new
f new new exact
+hg debugwalk ignored
+
+hg debugwalk ignored/file
+f ignored/file ignored/file exact
+
cd ..
hg debugwalk -R t t/mammals/skunk