infocalypse
 
(Steve Dougherty)
2013-07-30: Fix clone truster resolution.

Fix clone truster resolution.

diff --git a/infocalypse/__init__.py b/infocalypse/__init__.py
--- a/infocalypse/__init__.py
+++ b/infocalypse/__init__.py
@@ -568,7 +568,7 @@ extensions.wrapfunction(discovery, 'find
 # wrap the commands
 
 
-def freenetpathtouri(ui, path, pull=True, repo=None):
+def freenetpathtouri(ui, path, repo=None, pull=True):
     """
     Return a usable request or insert URI. Expects a freenet:// or freenet:
     protocol to be specified.
@@ -613,7 +613,7 @@ def freenetpull(orig, *args, **opts):
     # only act differently, if the target is an infocalypse repo.
     if not isfreenetpath(path):
         return orig(*args, **opts)
-    uri = freenetpathtouri(ui, path)
+    uri = freenetpathtouri(ui, path, repo)
     opts["uri"] = uri
     opts["aggressive"] = True # always search for the latest revision.
     return infocalypse_pull(ui, repo, **opts)
@@ -650,7 +650,7 @@ def freenetpush(orig, *args, **opts):
     # only act differently, if the target is an infocalypse repo.
     if not isfreenetpath(path):
         return orig(*args, **opts)
-    uri = parse_repo_path(freenetpathtouri(ui, path, pull=False))
+    uri = parse_repo_path(freenetpathtouri(ui, path, repo, pull=False))
     if uri is None:
         return
     # if the uri is the short form (USK@/name/#), generate the key and preprocess the uri.
@@ -706,11 +706,10 @@ def freenetclone(orig, *args, **opts):
     # check whether to create, pull or copy
     pulluri, pushuri = None, None
     if isfreenetpath(source):
-        pulluri = parse_repo_path(freenetpathtouri(ui, source, repo=source))
+        pulluri = parse_repo_path(freenetpathtouri(ui, source))
 
     if isfreenetpath(dest):
-        pushuri = parse_repo_path(freenetpathtouri(ui, dest, pull=False,
-                                                   repo=source),
+        pushuri = parse_repo_path(freenetpathtouri(ui, dest, pull=False),
                                   assume_redundancy=True)
 
     # decide which infocalypse command to use.
diff --git a/infocalypse/commands.py b/infocalypse/commands.py
--- a/infocalypse/commands.py
+++ b/infocalypse/commands.py
@@ -512,12 +512,15 @@ def infocalypse_setupfreemail(ui, repo, 
     wot.execute_setup_freemail(ui, get_truster(ui, repo, opts['truster']))
 
 
-def get_truster(ui, repo, truster_identifier=None):
+def get_truster(ui, repo=None, truster_identifier=None):
     """
     Return a local WoT ID.
 
-    If truster_identifier is given, use that. Otherwise, either the identity
-    that published this repository, or if one is not set the default truster.
+    Search for a local identity from most to least specific:
+    1. truster_identifier (if given)
+    2. identity that published this respository (if repo is given and an
+                                                 identity is set)
+    3. default truster
 
     :rtype : Local_WoT_ID
     """
@@ -529,7 +532,11 @@ def get_truster(ui, repo, truster_identi
 
         # Value is identity ID, so '@' prefix makes it an identifier with an
         # empty nickname.
-        identity = cfg.get_wot_identity(cfg.get_request_uri(repo.root))
+        identity = None
+        if repo:
+            identity = cfg.get_wot_identity(cfg.get_request_uri(repo.root))
+
+        # Either repo is not given or there is no associated identity.
         if not identity:
             identity = cfg.defaults['DEFAULT_TRUSTER']