changeset 12752:18b5b6392fcf

subrepo: rename relpath to subrelpath and introduce reporelpath
author Mads Kiilerich <mads@kiilerich.com>
date Tue, 19 Oct 2010 03:55:28 +0200
parents 8eb758ea738c
children ef5eaf53f4f7
files mercurial/localrepo.py mercurial/subrepo.py
diffstat 2 files changed, 19 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Tue Oct 19 03:55:06 2010 +0200
+++ b/mercurial/localrepo.py	Tue Oct 19 03:55:28 2010 +0200
@@ -938,7 +938,7 @@
                 for s in sorted(subs):
                     sub = wctx.sub(s)
                     self.ui.status(_('committing subrepository %s\n') %
-                        subrepo.relpath(sub))
+                        subrepo.subrelpath(sub))
                     sr = sub.commit(cctx._text, user, date)
                     state[s] = (state[s][0], sr)
                 subrepo.writestate(self, state)
--- a/mercurial/subrepo.py	Tue Oct 19 03:55:06 2010 +0200
+++ b/mercurial/subrepo.py	Tue Oct 19 03:55:28 2010 +0200
@@ -154,14 +154,18 @@
     # record merged .hgsubstate
     writestate(repo, sm)
 
-def relpath(sub):
+def reporelpath(repo):
+    """return path to this (sub)repo as seen from outermost repo"""
+    parent = repo
+    while hasattr(parent, '_subparent'):
+        parent = parent._subparent
+    return repo.root[len(parent.root)+1:]
+
+def subrelpath(sub):
     """return path to this subrepo as seen from outermost repo"""
     if not hasattr(sub, '_repo'):
         return sub._path
-    parent = sub._repo
-    while hasattr(parent, '_subparent'):
-        parent = parent._subparent
-    return sub._repo.root[len(parent.root)+1:]
+    return reporelpath(sub._repo)
 
 def _abssource(repo, push=False):
     """return pull/push path of repo - either based on parent repo
@@ -332,7 +336,7 @@
             return self._repo.status(ctx1, ctx2, **opts)
         except error.RepoLookupError, inst:
             self._repo.ui.warn(_('warning: error "%s" in subrepository "%s"\n')
-                               % (inst, relpath(self)))
+                               % (inst, subrelpath(self)))
             return [], [], [], [], [], [], []
 
     def diff(self, diffopts, node2, match, prefix, **opts):
@@ -348,7 +352,7 @@
                                    listsubrepos=True, **opts)
         except error.RepoLookupError, inst:
             self._repo.ui.warn(_('warning: error "%s" in subrepository "%s"\n')
-                               % (inst, relpath(self)))
+                               % (inst, subrelpath(self)))
 
     def archive(self, archiver, prefix):
         abstractsubrepo.archive(self, archiver, prefix)
@@ -372,7 +376,7 @@
         return self._repo._checknested(self._repo.wjoin(path))
 
     def commit(self, text, user, date):
-        self._repo.ui.debug("committing subrepo %s\n" % relpath(self))
+        self._repo.ui.debug("committing subrepo %s\n" % subrelpath(self))
         n = self._repo.commit(text, user, date)
         if not n:
             return self._repo['.'].hex() # different version checked out
@@ -381,7 +385,7 @@
     def remove(self):
         # we can't fully delete the repository as it may contain
         # local-only history
-        self._repo.ui.note(_('removing subrepo %s\n') % relpath(self))
+        self._repo.ui.note(_('removing subrepo %s\n') % subrelpath(self))
         hg.clean(self._repo, node.nullid, False)
 
     def _get(self, state):
@@ -392,7 +396,7 @@
             self._repo._subsource = source
             srcurl = _abssource(self._repo)
             self._repo.ui.status(_('pulling subrepo %s from %s\n')
-                                 % (relpath(self), srcurl))
+                                 % (subrelpath(self), srcurl))
             other = hg.repository(self._repo.ui, srcurl)
             self._repo.pull(other)
 
@@ -408,12 +412,12 @@
         dst = self._repo[state[1]]
         anc = dst.ancestor(cur)
         if anc == cur:
-            self._repo.ui.debug("updating subrepo %s\n" % relpath(self))
+            self._repo.ui.debug("updating subrepo %s\n" % subrelpath(self))
             hg.update(self._repo, state[1])
         elif anc == dst:
-            self._repo.ui.debug("skipping subrepo %s\n" % relpath(self))
+            self._repo.ui.debug("skipping subrepo %s\n" % subrelpath(self))
         else:
-            self._repo.ui.debug("merging subrepo %s\n" % relpath(self))
+            self._repo.ui.debug("merging subrepo %s\n" % subrelpath(self))
             hg.merge(self._repo, state[1], remind=False)
 
     def push(self, force):
@@ -426,7 +430,7 @@
 
         dsturl = _abssource(self._repo, True)
         self._repo.ui.status(_('pushing subrepo %s to %s\n') %
-            (relpath(self), dsturl))
+            (subrelpath(self), dsturl))
         other = hg.repository(self._repo.ui, dsturl)
         return self._repo.push(other, force)