[PATCH 8 of 8] largefiles: align the output messages for an added file with core methods

Matt Harbison mharbison72 at gmail.com
Tue Dec 23 14:56:20 CST 2014


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1417229081 18000
#      Fri Nov 28 21:44:41 2014 -0500
# Node ID a376ad84f4a0cc2667caac55941567576851886a
# Parent  0fb59e8c02c8e55d947b951e90ded7317d85bd4a
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.

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 (glob)
   adding subrepo/normal.txt (glob)
   adding subrepo/renamed-large.txt (glob)
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.
 


More information about the Mercurial-devel mailing list