mharbison72 edited the summary of this revision.
mharbison72 updated this revision to Diff 20293.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8145?vs=20290&id=20293

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8145/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8145

AFFECTED FILES
  hgext/largefiles/lfutil.py
  tests/test-lfs-bundle.t

CHANGE DETAILS

diff --git a/tests/test-lfs-bundle.t b/tests/test-lfs-bundle.t
--- a/tests/test-lfs-bundle.t
+++ b/tests/test-lfs-bundle.t
@@ -95,3 +95,27 @@
   OK
   ---- Applying src-lfs.bundle to dst-lfs ----
   OK
+
+Hint if the cache location cannot be inferred from the environment
+
+#if windows
+  $ env -u HOME -u LOCALAPPDATA -u APPDATA HGRCPATH= hg config lfs --debug
+  abort: unknown lfs usercache location
+  (define LOCALAPPDATA or APPDATA in the environment, or set lfs.usercache)
+  [255]
+#endif
+
+#if osx
+  $ env -u HOME HGRCPATH= hg config lfs --debug
+  abort: unknown lfs usercache location
+  (define HOME in the environment, or set lfs.usercache)
+  [255]
+#endif
+
+#if no-windows no-osx
+  $ env -u XDG_CACHE_HOME -u HOME HGRCPATH= hg config lfs --debug
+  abort: unknown lfs usercache location
+  (define XDG_CACHE_HOME or HOME in the environment, or set lfs.usercache)
+  [255]
+#endif
+
diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -92,16 +92,30 @@
     path = ui.configpath(name, b'usercache')
     if path:
         return path
+
+    hint = None
+
     if pycompat.iswindows:
         appdata = encoding.environ.get(
             b'LOCALAPPDATA', encoding.environ.get(b'APPDATA')
         )
         if appdata:
             return os.path.join(appdata, name)
+
+        hint = _(b"define %s or %s in the environment, or set %s.usercache") % 
(
+            b"LOCALAPPDATA",
+            b"APPDATA",
+            name,
+        )
     elif pycompat.isdarwin:
         home = encoding.environ.get(b'HOME')
         if home:
             return os.path.join(home, b'Library', b'Caches', name)
+
+        hint = _(b"define %s in the environment, or set %s.usercache") % (
+            b"HOME",
+            name,
+        )
     elif pycompat.isposix:
         path = encoding.environ.get(b'XDG_CACHE_HOME')
         if path:
@@ -109,11 +123,18 @@
         home = encoding.environ.get(b'HOME')
         if home:
             return os.path.join(home, b'.cache', name)
+
+        hint = _(b"define %s or %s in the environment, or set %s.usercache") % 
(
+            b"XDG_CACHE_HOME",
+            b"HOME",
+            name,
+        )
     else:
         raise error.Abort(
             _(b'unknown operating system: %s\n') % pycompat.osname
         )
-    raise error.Abort(_(b'unknown %s usercache location') % name)
+
+    raise error.Abort(_(b'unknown %s usercache location') % name, hint=hint)
 
 
 def inusercache(ui, hash):



To: mharbison72, #hg-reviewers
Cc: marmoute, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to