Patchwork [4,of,4,V2] largefiles: align the output messages for an added file with core methods

login
register
mail settings
Submitter Matt Harbison
Date Dec. 31, 2014, 12:55 a.m.
Message ID <436e298e3bc338907f47.1419987348@Envy>
Download mbox | patch
Permalink /patch/7276/
State Superseded
Commit 749dc66e932901f2f5dcdbfa960315c191105096
Headers show

Comments

Matt Harbison - Dec. 31, 2014, 12:55 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1417229081 18000
#      Fri Nov 28 21:44:41 2014 -0500
# Node ID 436e298e3bc338907f47180171c6bd85498a1ee7
# Parent  48b36666cb054ffe50d9d4fe74fe211a1d8a159e
largefiles: align the output messages for an added file with core methods

Core addremove prints the file relative to cwd only if patterns are provided to
the command.  Core add always prints relative to cwd.  Also, both methods print
the subrepo prefix when needed.  The 'already a largefile' doesn't have an
analog in core, but follows the same rules for consistency.
Matt Mackall - Jan. 2, 2015, 9:09 p.m.
On Tue, 2014-12-30 at 19:55 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1417229081 18000
> #      Fri Nov 28 21:44:41 2014 -0500
> # Node ID 436e298e3bc338907f47180171c6bd85498a1ee7
> # Parent  48b36666cb054ffe50d9d4fe74fe211a1d8a159e
> largefiles: align the output messages for an added file with core methods

These are queued for default, thanks.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -85,7 +85,7 @@ 
     scmutil.matchandpats = getattr(scmutil.matchandpats, 'oldmatchandpats',
             scmutil.matchandpats)
 
-def addlargefiles(ui, repo, matcher, **opts):
+def addlargefiles(ui, repo, isaddremove, matcher, **opts):
     large = opts.pop('large', None)
     lfsize = lfutil.getminsize(
         ui, lfutil.islfilesrepo(repo), opts.pop('lfsize', None))
@@ -106,11 +106,17 @@ 
         nfile = f in wctx
         exists = lfile or nfile
 
+        # addremove in core gets fancy with the name, add doesn't
+        if isaddremove:
+            name = m.uipath(f)
+        else:
+            name = m.rel(f)
+
         # Don't warn the user when they attempt to add a normal tracked file.
         # The normal add code will do that for us.
         if exact and exists:
             if lfile:
-                ui.warn(_('%s already a largefile\n') % f)
+                ui.warn(_('%s already a largefile\n') % name)
             continue
 
         if (exact or not exists) and not lfutil.isstandin(f):
@@ -126,7 +132,7 @@ 
             if large or abovemin or (lfmatcher and lfmatcher(f)):
                 lfnames.append(f)
                 if ui.verbose or not exact:
-                    ui.status(_('adding %s as a largefile\n') % m.rel(f))
+                    ui.status(_('adding %s as a largefile\n') % name)
 
     bad = []
 
@@ -239,7 +245,7 @@ 
             raise util.Abort(_('--normal cannot be used with --large'))
         return orig(ui, repo, *pats, **opts)
     matcher = scmutil.match(repo[None], pats, opts)
-    bad = addlargefiles(ui, repo, matcher, **opts)
+    bad = addlargefiles(ui, repo, False, matcher, **opts)
     installnormalfilesmatchfn(repo[None].manifest())
     result = orig(ui, repo, *pats, **opts)
     restorematchfn()
@@ -1118,7 +1124,7 @@ 
         removelargefiles(repo.ui, repo, True, m, **opts)
     # Call into the normal add code, and any files that *should* be added as
     # largefiles will be
-    addlargefiles(repo.ui, repo, matcher, **opts)
+    addlargefiles(repo.ui, repo, True, matcher, **opts)
     # Now that we've handled largefiles, hand off to the original addremove
     # function to take care of the rest.  Make sure it doesn't do anything with
     # largefiles by passing a matcher that will ignore them.
diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t
--- a/tests/test-largefiles-misc.t
+++ b/tests/test-largefiles-misc.t
@@ -291,7 +291,7 @@ 
   ? subrepo/renamed-large.txt
 
   $ hg -R statusmatch addremove --dry-run -S
-  adding statusmatch/large.dat as a largefile (glob)
+  adding large.dat as a largefile
   removing subrepo/large.txt
   adding subrepo/normal.txt
   adding subrepo/renamed-large.txt
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -493,7 +493,7 @@ 
   $ cd ..
   $ hg -R a -v addremove
   removing sub/large4
-  adding a/testaddremove.dat as a largefile (glob)
+  adding testaddremove.dat as a largefile
   removing normal3
   adding normaladdremove
   $ cd a
@@ -1720,7 +1720,7 @@ 
   $ rm sub2/large7
   $ echo "largeasnormal" > sub2/large7
   $ hg add sub2/large7
-  sub2/large7 already a largefile
+  sub2/large7 already a largefile (glob)
 
 Test that transplanting a largefile change works correctly.