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

login
register
mail settings
Submitter Matt Harbison
Date March 10, 2015, 2:34 a.m.
Message ID <207a9764b3fa80c949d0.1425954856@Envy>
Download mbox | patch
Permalink /patch/7959/
State Superseded
Commit e1cb460a35245edfa3d3b216352923ffe1be8566
Delegated to: Pierre-Yves David
Headers show

Comments

Matt Harbison - March 10, 2015, 2:34 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 207a9764b3fa80c949d08527a2635c255429f764
# Parent  988cae9297fd5c61bf0a592cbb049f0a9277e210
files: split reusable implementation into cmdutil for subrepo support
Pierre-Yves David - March 10, 2015, 2:55 a.m.
On 03/09/2015 07:34 PM, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1425847857 14400
> #      Sun Mar 08 16:50:57 2015 -0400
> # Node ID 207a9764b3fa80c949d08527a2635c255429f764
> # Parent  988cae9297fd5c61bf0a592cbb049f0a9277e210
> files: split reusable implementation into cmdutil for subrepo support

nom nom nom.
Pushed to the clowncopter.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2047,6 +2047,21 @@ 
     forgot.extend(f for f in forget if f not in rejected)
     return bad, forgot
 
+def files(ui, ctx, matcher, formatter, fmt):
+    ret = 1
+    ds = ctx._repo.dirstate
+    for f in ctx.matches(matcher):
+        if ctx.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,7 +3258,6 @@ 
 
     """
     ctx = scmutil.revsingle(repo, opts.get('rev'), None)
-    ret = 1
 
     end = '\n'
     if opts.get('print0'):
@@ -3267,17 +3266,7 @@ 
     fmt = '%s' + end
 
     matcher = scmutil.match(ctx, pats, opts)
-    ds = ctx._repo.dirstate
-    for f in ctx.matches(matcher):
-        if ctx.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
+    ret = cmdutil.files(ui, ctx, matcher, formatter, fmt)
 
     formatter.end()