Patchwork [2,of,2,V2] files: split reusable implementation into cmdutil for subrepo support

login
register
mail settings
Submitter Matt Harbison
Date March 11, 2015, 12:32 a.m.
Message ID <4b08c3b9200c88908b3f.1426033951@Envy>
Download mbox | patch
Permalink /patch/7985/
State Superseded
Headers show

Comments

Matt Harbison - March 11, 2015, 12:32 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1425847857 14400
#      Sun Mar 08 16:50:57 2015 -0400
# Node ID 4b08c3b9200c88908b3f7a773b337a9376f1be2d
# Parent  a8a49154503c2e7ca4c2ab796a76da42712f780b
files: split reusable implementation into cmdutil for subrepo support
Matt Harbison - March 11, 2015, 12:38 a.m.
On Tue, 10 Mar 2015 20:32:31 -0400, Matt Harbison <mharbison72@gmail.com>  
wrote:

> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1425847857 14400
> #      Sun Mar 08 16:50:57 2015 -0400
> # Node ID 4b08c3b9200c88908b3f7a773b337a9376f1be2d
> # Parent  a8a49154503c2e7ca4c2ab796a76da42712f780b
> files: split reusable implementation into cmdutil for subrepo support

Drop this, I missed an amend

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2047,6 +2047,23 @@ 
     forgot.extend(f for f in forget if f not in rejected)
     return bad, forgot
 
+def files(ui, ctx, matcher, formatter, fmt):
+    rev = ctx.rev()
+    ret = 1
+    ds = ctx._repo.dirstate
+
+    for f in ctx.matches(matcher):
+        if rev is None and ds[f] == 'r':
+            continue
+        formatter.startitem()
+        if ui.verbose:
+            fc = ctx[f]
+            formatter.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
+        formatter.data(abspath=f)
+        formatter.write('path', fmt, matcher.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
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3258,8 +3258,6 @@ 
 
     """
     ctx = scmutil.revsingle(repo, opts.get('rev'), None)
-    rev = ctx.rev()
-    ret = 1
 
     end = '\n'
     if opts.get('print0'):
@@ -3268,19 +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
-
-    fm.end()
+    ret = cmdutil.files(ui, ctx, m, fm, fmt)
 
     return ret