changeset 6749:51b0e799352f

manifest: remove execf/linkf methods
author Matt Mackall <mpm@selenic.com>
date Thu, 26 Jun 2008 14:35:50 -0500
parents c6cc35a3d1de
children fb42030d79d6
files hgext/convert/hg.py hgext/keyword.py mercurial/archival.py mercurial/commands.py mercurial/dirstate.py mercurial/manifest.py
diffstat 6 files changed, 17 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/hg.py	Thu Jun 26 14:35:50 2008 -0500
+++ b/hgext/convert/hg.py	Thu Jun 26 14:35:50 2008 -0500
@@ -229,8 +229,7 @@
             raise IOError(err)
 
     def getmode(self, name, rev):
-        m = self.changectx(rev).manifest()
-        return (m.execf(name) and 'x' or '') + (m.linkf(name) and 'l' or '')
+        return self.changectx(rev).manifest().flags(name)
 
     def getchanges(self, rev):
         ctx = self.changectx(rev)
--- a/hgext/keyword.py	Thu Jun 26 14:35:50 2008 -0500
+++ b/hgext/keyword.py	Thu Jun 26 14:35:50 2008 -0500
@@ -163,11 +163,11 @@
             return self.substitute(data, path, changenode, self.re_kw.sub)
         return data
 
-    def iskwfile(self, path, islink):
+    def iskwfile(self, path, flagfunc):
         '''Returns true if path matches [keyword] pattern
         and is not a symbolic link.
         Caveat: localrepository._link fails on Windows.'''
-        return self.matcher(path) and not islink(path)
+        return self.matcher(path) and not 'l' in flagfunc(path)
 
     def overwrite(self, node, expand, files):
         '''Overwrites selected files expanding/shrinking keywords.'''
@@ -178,9 +178,8 @@
             notify = self.ui.debug
         else:                    # kwexpand/kwshrink
             ctx = self.repo['.']
-            mf = ctx.manifest()
             notify = self.ui.note
-        candidates = [f for f in files if self.iskwfile(f, mf.linkf)]
+        candidates = [f for f in files if self.iskwfile(f, ctx.flags)]
         if candidates:
             self.restrict = True # do not expand when reading
             candidates.sort()
@@ -387,8 +386,7 @@
         files += unknown
     files.sort()
     wctx = repo[None]
-    islink = lambda p: 'l' in wctx.flags(p)
-    kwfiles = [f for f in files if kwt.iskwfile(f, islink)]
+    kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
     cwd = pats and repo.getcwd() or ''
     kwfstats = not opts.get('ignore') and (('K', kwfiles),) or ()
     if opts.get('all') or opts.get('ignore'):
--- a/mercurial/archival.py	Thu Jun 26 14:35:50 2008 -0500
+++ b/mercurial/archival.py	Thu Jun 26 14:35:50 2008 -0500
@@ -208,18 +208,17 @@
             data = repo.wwritedata(name, data)
         archiver.addfile(name, mode, islink, data)
 
-    ctx = repo[node]
     if kind not in archivers:
         raise util.Abort(_("unknown archive type '%s'" % kind))
+
+    ctx = repo[node]
     archiver = archivers[kind](dest, prefix, mtime or ctx.date()[0])
-    m = ctx.manifest()
-    items = m.items()
-    items.sort()
+
     if repo.ui.configbool("ui", "archivemeta", True):
         write('.hg_archival.txt', 0644, False,
               lambda: 'repo: %s\nnode: %s\n' % (
                   hex(repo.changelog.node(0)), hex(node)))
-    for filename, filenode in items:
-        write(filename, m.execf(filename) and 0755 or 0644, m.linkf(filename),
-              lambda: repo.file(filename).read(filenode))
+    for f in ctx:
+        ff = ctx.flags(f)
+        write(f, 'x' in ff and 0755 or 0644, 'l' in ff, ctx[f].data)
     archiver.done()
--- a/mercurial/commands.py	Thu Jun 26 14:35:50 2008 -0500
+++ b/mercurial/commands.py	Thu Jun 26 14:35:50 2008 -0500
@@ -1866,17 +1866,13 @@
     if not node:
         node = rev
 
-    m = repo[node].manifest()
-    files = m.keys()
-    files.sort()
-
-    for f in files:
+    decor = {'l':'644 @ ', 'x':'755 * ', '':'644   '}
+    ctx = repo[node]
+    for f in ctx:
         if ui.debugflag:
-            ui.write("%40s " % hex(m[f]))
+            ui.write("%40s " % hex(ctx.manifest()[f]))
         if ui.verbose:
-            type = m.execf(f) and "*" or m.linkf(f) and "@" or " "
-            perm = m.execf(f) and "755" or "644"
-            ui.write("%3s %1s " % (perm, type))
+            ui.write(decor[ctx.flags(f)])
         ui.write("%s\n" % f)
 
 def merge(ui, repo, node=None, force=None, rev=None):
--- a/mercurial/dirstate.py	Thu Jun 26 14:35:50 2008 -0500
+++ b/mercurial/dirstate.py	Thu Jun 26 14:35:50 2008 -0500
@@ -384,7 +384,7 @@
     def rebuild(self, parent, files):
         self.clear()
         for f in files:
-            if files.execf(f):
+            if 'x' in files.flag(f):
                 self._map[f] = ('n', 0777, -1, 0, 0)
             else:
                 self._map[f] = ('n', 0666, -1, 0, 0)
--- a/mercurial/manifest.py	Thu Jun 26 14:35:50 2008 -0500
+++ b/mercurial/manifest.py	Thu Jun 26 14:35:50 2008 -0500
@@ -18,12 +18,6 @@
         self._flags = flags
     def flags(self, f):
         return self._flags.get(f, "")
-    def execf(self, f):
-        "test for executable in manifest flags"
-        return "x" in self.flags(f)
-    def linkf(self, f):
-        "test for symlink in manifest flags"
-        return "l" in self.flags(f)
     def set(self, f, flags):
         self._flags[f] = flags
     def copy(self):