[cig-commits] commit: symbolic links as nested tree roots

Mercurial hg at geodynamics.org
Mon Nov 24 11:26:47 PST 2008

changeset:   5:7648fb26fde9
user:        Robin Farine <robin.farine at terminus.org>
date:        Sat Jul 22 01:08:39 2006 +0200
files:       forest.py
symbolic links as nested tree roots

For each nested tree represented by a symbolic link, record the path
to the link in snapshots but follow the link to apply Mercurial
commands to the actual repository.

The 'fclone' or 'fseed' commands do not preserve symbolic links, they
create a directory instead. One consequence of this is that if a
forest contains more than one path to the same repository, a clone of
this forest or a forest populated based on a snapshot of it will
contain more than one copy of the original repository.

Thanks to "Eric Bloodworth" <ergosys at gmail.com> for reporting this.

diff -r 5b9d129c02f2 -r 7648fb26fde9 forest.py
--- a/forest.py	Sat Jul 22 00:14:46 2006 +0200
+++ b/forest.py	Sat Jul 22 01:08:39 2006 +0200
@@ -31,13 +31,12 @@ import sys
 import sys
 import mercurial.node
-from mercurial import commands, util
+from mercurial import commands, hg, util
 try: # 'find' renamed as 'findcmd' after Mercurial 0.9
     from mercurial.commands import findcmd
     from mercurial.commands import find as findcmd
-from mercurial.hg import repository
 from mercurial.i18n import gettext as _
 from mercurial.repo import RepoError
@@ -85,6 +84,14 @@ def mq_patches_applied(rootpath):
             if s.st_size > 0:
                 return True
     return False
+def repository(ui, root):
+    while os.path.islink(root):
+        path = os.readlink(root)
+        if not os.path.isabs(path):
+            path = os.path.join(os.path.dirname(root), path)
+        root = path
+    return hg.repository(ui, root)
 class ForestSnapshot(object):

More information about the CIG-COMMITS mailing list