[cig-commits] commit: use hg.repository() directly instead of a wrapper

Mercurial hg at geodynamics.org
Mon Nov 24 11:27:01 PST 2008


changeset:   39:62227d7f2d23
user:        Robin Farine <robin.farine at terminus.org>
date:        Fri Dec 22 22:01:50 2006 +0100
files:       forest.py
description:
use hg.repository() directly instead of a wrapper

The wrapper is not needed because:

  o symbolic links to repositories do not work since enumerate_repos()
    rely util.walkrepos()

  o localrepo.__init__() dreferences symbolic links


diff -r b29f327bdc10 -r 62227d7f2d23 forest.py
--- a/forest.py	Fri Dec 22 02:14:02 2006 +0100
+++ b/forest.py	Fri Dec 22 22:01:50 2006 +0100
@@ -101,15 +101,6 @@ def mq_patches_applied(rpath):
     return False
 
 
-def repository(ui, rpath):
-    while os.path.islink(rpath):
-        path = os.readlink(rpath)
-        if not os.path.isabs(path):
-            path = os.path.join(os.path.dirname(rpath), path)
-        rpath = path
-    return hg.repository(ui, rpath)
-
-
 class ForestSnapshot(object):
 
     class Tree(object):
@@ -174,8 +165,8 @@ class ForestSnapshot(object):
                 repo = toprepo
             else:
                 try:
-                    repo = repository(ui,
-                                      os.path.join(pfx, util.localpath(root)))
+                    rpath = os.path.join(pfx, util.localpath(root))
+                    repo = hg.repository(ui, rpath)
                 except RepoError:
                     ui.write(_("skipped, no valid repo found\n\n"))
                     continue
@@ -202,7 +193,7 @@ class ForestSnapshot(object):
             if root == '':
                 root = '.'
             else:
-                repo = repository(ui, rpath)
+                repo = hg.repository(ui, rpath)
             if mq_fatal and mq_patches_applied(rpath):
                 raise util.Abort(_("'%s' has mq patches applied") % root)
             if tip:
@@ -245,7 +236,7 @@ def clone(ui, source, dest, **opts):
         commands.clone(ui, repo.root, destpath, **opts)
 
     snapshot = ForestSnapshot()
-    repo = repository(ui, source)
+    repo = hg.repository(ui, source)
     snapshot.update(ui, repo, True)
     snapshot(ui, repo, doit, mq_check=False)
 
@@ -326,7 +317,7 @@ def seed(ui, snapshot, pathalias='defaul
         if not opts['tip']:
             rev = cfg.get(section, 'revision')
             if rev and rev != 'tip' and rev != node.nullid:
-                repo = repository(ui, dest)
+                repo = hg.repository(ui, dest)
                 commands.update(repo.ui, repo, node=rev)
         ui.write("\n")
 



More information about the CIG-COMMITS mailing list