files: split reusable implementation into cmdutil for subrepo support
authorMatt Harbison <matt_harbison@yahoo.com>
Sun, 08 Mar 2015 16:50:57 -0400
changeset 24275 e1cb460a3524
parent 24274 9640820bc957
child 24276 2720f967a7b1
files: split reusable implementation into cmdutil for subrepo support
mercurial/cmdutil.py
mercurial/commands.py
--- a/mercurial/cmdutil.py	Sun Mar 08 16:45:29 2015 -0400
+++ b/mercurial/cmdutil.py	Sun Mar 08 16:50:57 2015 -0400
@@ -2219,6 +2219,24 @@
     forgot.extend(f for f in forget if f not in rejected)
     return bad, forgot
 
+def files(ui, ctx, m, fm, fmt):
+    rev = ctx.rev()
+    ret = 1
+    ds = ctx._repo.dirstate
+
+    for f in ctx.matches(m):
+        if rev is None and ds[f] == 'r':
+            continue
+        fm.startitem()
+        if ui.verbose:
+            fc = ctx[f]
+            fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
+        fm.data(abspath=f)
+        fm.write('path', fmt, m.rel(f))
+        ret = 0
+
+    return ret
+
 def remove(ui, repo, m, prefix, after, force, subrepos):
     join = lambda f: os.path.join(prefix, f)
     ret = 0
--- a/mercurial/commands.py	Sun Mar 08 16:45:29 2015 -0400
+++ b/mercurial/commands.py	Sun Mar 08 16:50:57 2015 -0400
@@ -3258,8 +3258,6 @@
 
     """
     ctx = scmutil.revsingle(repo, opts.get('rev'), None)
-    rev = ctx.rev()
-    ret = 1
 
     end = '\n'
     if opts.get('print0'):
@@ -3268,17 +3266,7 @@
     fmt = '%s' + end
 
     m = scmutil.match(ctx, pats, opts)
-    ds = ctx._repo.dirstate
-    for f in ctx.matches(m):
-        if rev is None and ds[f] == 'r':
-            continue
-        fm.startitem()
-        if ui.verbose:
-            fc = ctx[f]
-            fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
-        fm.data(abspath=f)
-        fm.write('path', fmt, m.rel(f))
-        ret = 0
+    ret = cmdutil.files(ui, ctx, m, fm, fmt)
 
     fm.end()