changeset 4579:4500fbe3a432

Merge with crew
author Brendan Cully <brendan@kublai.com>
date Wed, 13 Jun 2007 19:11:20 -0700
parents b1716a8b32d3 (current diff) e7d4ed543de5 (diff)
children 7de7a80e7422
files
diffstat 6 files changed, 30 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -438,11 +438,14 @@ class queue:
     def apply(self, repo, series, list=False, update_status=True,
               strict=False, patchdir=None, merge=None, wlock=None,
               all_files={}):
+        if not wlock:
+            wlock = repo.wlock()
+        lock = repo.lock()
         tr = repo.transaction()
         try:
             ret = self._apply(tr, repo, series, list, update_status,
                               strict, patchdir, merge, wlock,
-                              all_files=all_files)
+                              lock=lock, all_files=all_files)
             tr.close()
             self.save_dirty()
             return ret
@@ -456,14 +459,11 @@ class queue:
 
     def _apply(self, tr, repo, series, list=False, update_status=True,
                strict=False, patchdir=None, merge=None, wlock=None,
-               all_files={}):
+               lock=None, all_files={}):
         # TODO unify with commands.py
         if not patchdir:
             patchdir = self.path
         err = 0
-        if not wlock:
-            wlock = repo.wlock()
-        lock = repo.lock()
         n = None
         for patchname in series:
             pushable, reason = self.pushable(patchname)
@@ -1057,9 +1057,11 @@ class queue:
             aaa = aa[:]
             if opts.get('short'):
                 filelist = mm + aa + dd
+                match = dict.fromkeys(filelist).__contains__
             else:
                 filelist = None
-            m, a, r, d, u = repo.status(files=filelist)[:5]
+                match = util.always
+            m, a, r, d, u = repo.status(files=filelist, match=match)[:5]
 
             # we might end up with files that were added between tip and
             # the dirstate parent, but then changed in the local dirstate.
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -574,9 +574,7 @@ def addremove(repo, pats=[], opts={}, wl
             mapping[abs] = rel, exact
             if repo.ui.verbose or not exact:
                 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs))
-        islink = os.path.islink(target)
-        if (repo.dirstate.state(abs) != 'r' and not islink
-            and not os.path.exists(target)):
+        if repo.dirstate.state(abs) != 'r' and not util.lexists(target):
             remove.append(abs)
             mapping[abs] = rel, exact
             if repo.ui.verbose or not exact:
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -404,8 +404,6 @@ def commit(ui, repo, *pats, **opts):
                 continue
             if f not in files:
                 rf = repo.wjoin(f)
-                if f in unknown:
-                    raise util.Abort(_("file %s not tracked!") % rf)
                 try:
                     mode = os.lstat(rf)[stat.ST_MODE]
                 except OSError:
@@ -419,9 +417,11 @@ def commit(ui, repo, *pats, **opts):
                     if i >= len(slist) or not slist[i].startswith(name):
                         raise util.Abort(_("no match under directory %s!")
                                          % rf)
-                elif not stat.S_ISREG(mode):
+                elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)):
                     raise util.Abort(_("can't commit %s: "
                                        "unsupported file type!") % rf)
+                elif repo.dirstate.state(f) == '?':
+                    raise util.Abort(_("file %s not tracked!") % rf)
     else:
         files = []
     try:
@@ -2099,7 +2099,7 @@ def remove(ui, repo, *pats, **opts):
                 forget.append(abs)
                 continue
             reason = _('has been marked for add (use -f to force removal)')
-        elif abs in unknown:
+        elif repo.dirstate.state(abs) == '?':
             reason = _('is not managed')
         elif opts['after'] and not exact and abs not in deleted:
             continue
@@ -2261,8 +2261,7 @@ def revert(ui, repo, *pats, **opts):
         def handle(xlist, dobackup):
             xlist[0].append(abs)
             update[abs] = 1
-            if (dobackup and not opts['no_backup'] and
-                (os.path.islink(target) or os.path.exists(target))):
+            if dobackup and not opts['no_backup'] and util.lexists(target):
                 bakname = "%s.orig" % rel
                 ui.note(_('saving current version of %s as %s\n') %
                         (rel, bakname))
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -951,7 +951,8 @@ class localrepository(repo.repository):
                         if fcmp(f, getnode):
                             modified.append(f)
                         else:
-                            clean.append(f)
+                            if list_clean:
+                                clean.append(f)
                             if not wlock and not mywlock:
                                 mywlock = True
                                 try:
@@ -1013,16 +1014,17 @@ class localrepository(repo.repository):
             wlock = self.wlock()
         for f in list:
             p = self.wjoin(f)
-            islink = os.path.islink(p)
-            size = os.lstat(p).st_size
-            if size > 10000000:
+            try:
+                st = os.lstat(p)
+            except:
+                self.ui.warn(_("%s does not exist!\n") % f)
+                continue
+            if st.st_size > 10000000:
                 self.ui.warn(_("%s: files over 10MB may cause memory and"
                                " performance problems\n"
                                "(use 'hg revert %s' to unadd the file)\n")
                                % (f, f))
-            if not islink and not os.path.exists(p):
-                self.ui.warn(_("%s does not exist!\n") % f)
-            elif not islink and not os.path.isfile(p):
+            if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
                 self.ui.warn(_("%s not added: only files and symlinks "
                                "supported currently\n") % f)
             elif self.dirstate.state(f) in 'an':
--- a/tests/test-symlink-basic
+++ b/tests/test-symlink-basic
@@ -1,5 +1,10 @@
 #!/bin/sh
 
+cleanpath()
+{
+    sed -e "s:/.*\(/test-symlink-basic/.*\):...\1:"
+}
+
 cat >> readlink.py <<EOF
 import os
 import sys
@@ -11,6 +16,7 @@ EOF
 hg init a
 cd a
 ln -s nothing dangling
+hg commit -m 'commit symlink without adding' -d '0 0' dangling 2>&1 | cleanpath
 hg add dangling
 hg commit -m 'add symlink' -d '0 0'
 
--- a/tests/test-symlink-basic.out
+++ b/tests/test-symlink-basic.out
@@ -1,3 +1,4 @@
+abort: file .../test-symlink-basic/a/dangling not tracked!
 changeset:   0:cabd88b706fc
 tag:         tip
 user:        test