Switch to side-by-side view

--- a/ForgeHg/forgehg/hg_main.py
+++ b/ForgeHg/forgehg/hg_main.py
@@ -51,7 +51,8 @@
     installable=False
     permissions = [ 'read', 'write', 'create', 'admin', 'configure' ]
     config_options = Application.config_options + [
-        ConfigOption('cloned_from', ObjectId, None)
+        ConfigOption('cloned_from_project_id', ObjectId, None),
+        ConfigOption('cloned_from_repo_id', ObjectId, None)
         ]
     tool_label='Hg'
     default_mount_label='Hg'
@@ -122,9 +123,11 @@
             tool='hg',
             status='initing')
         ThreadLocalORMSession.flush_all()
-        cloned_from_id = self.config.options.get('cloned_from')
-        if cloned_from_id is not None:
-            cloned_from = model.HgRepository.query.get(_id=cloned_from_id)
+        cloned_from_project_id = self.config.options.get('cloned_from_project_id')
+        cloned_from_repo_id = self.config.options.get('cloned_from_repo_id')
+        if cloned_from_project_id is not None:
+            with h.push_config(c, project=Project.query.get(_id=cloned_from_project_id)):
+                cloned_from = model.HgRepository.query.get(_id=cloned_from_repo_id)
             g.publish('audit', 'scm.hg.clone',
                       dict(repo_name=repo.name, repo_path=repo.fs_path, cloned_from=cloned_from.full_fs_path))
         else:
@@ -193,6 +196,7 @@
         to_project_name = 'u/' + c.user.username
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
+        from_project = c.project
         to_project = Project.query.get(shortname=to_project_name)
         with h.push_config(c, project=to_project):
             require(has_project_access('tool', to_project))
@@ -205,7 +209,10 @@
                             in_use=in_use,
                             to_name=to_name or '')
             else:
-                to_project.install_app('Hg', to_name, cloned_from=from_repo._id)
+                to_project.install_app(
+                    'Hg', to_name,
+                    cloned_from_project_id=from_project._id,
+                    cloned_from_repo_id=from_repo._id)
                 redirect('/'+to_project_name+'/'+to_name+'/')
 
 class Refs(object):