[PATCH 3 of 6] largefiles: rearrange how lfconvert detects non-local repos

Greg Ward greg-hg at gerg.ca
Sat Oct 22 14:43:18 CDT 2011


# HG changeset patch
# User Greg Ward <greg at gerg.ca>
# Date 1319307617 14400
# Branch stable
# Node ID 3a899da972a738d43e7eb81d3a7268b968522503
# Parent  49f3bb81d7ba631c8ea157c47ccdc4b0fe0656a2
largefiles: rearrange how lfconvert detects non-local repos

Mainly this is so we can test that code; it has the side benefit of not
requiring network I/O to reject non-local repo URLs.

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -43,14 +43,15 @@
     else:
         tolfile = True
         size = lfutil.getminsize(ui, True, opts.get('size'), default=None)
+
+    if not hg.islocal(src):
+        raise util.Abort(_('%s is not a local Mercurial repo') % src)
+    if not hg.islocal(dest):
+        raise util.Abort(_('%s is not a local Mercurial repo') % dest)
+
     rsrc = hg.repository(ui, src)
-    if not rsrc.local():
-        raise util.Abort(_('%s is not a local Mercurial repo') % src)
-
     ui.status(_('initializing destination %s\n') % dest)
     rdst = hg.repository(ui, dest, create=True)
-    if not rdst.local():
-        raise util.Abort(_('%s is not a local Mercurial repo') % dest)
 
     success = False
     try:
diff --git a/tests/test-lfconvert.t b/tests/test-lfconvert.t
--- a/tests/test-lfconvert.t
+++ b/tests/test-lfconvert.t
@@ -45,6 +45,12 @@
   $ cd ..
 
 "lfconvert" error cases
+  $ hg lfconvert http://localhost/foo foo
+  abort: http://localhost/foo is not a local Mercurial repo
+  [255]
+  $ hg lfconvert foo ssh://localhost/foo
+  abort: ssh://localhost/foo is not a local Mercurial repo
+  [255]
   $ hg lfconvert nosuchrepo foo
   abort: repository nosuchrepo not found!
   [255]


More information about the Mercurial-devel mailing list