[PATCH 5 of 5 resync] subrepo: print paths relative to upper repo root for push/pull/commit
ed.gomez at free.fr
ed.gomez at free.fr
Sun Mar 14 03:08:10 CDT 2010
subrepo: print paths relative to upper repo root for push/pull/commit
This makes more sense when using multiple levels of
nesting.
This happens to help a lot in a case where 3 projects
of mine all use the same makefile helper project as a
sub. A fourth project use these first three projects
and current output made it very hard to figure
which makefile helper was committed. it looked more
like the project was committed/pushed/pulled three times
in a row than dealing on three different repos.
resynced because of a cosmetic change on crew
diff -r fe0307fbe349 mercurial/localrepo.py
--- a/mercurial/localrepo.py Sun Mar 14 08:50:37 2010 +0100
+++ b/mercurial/localrepo.py Sun Mar 14 08:51:42 2010 +0100
@@ -840,8 +840,10 @@
if subs or removedsubs:
state = wctx.substate.copy()
for s in subs:
- self.ui.status(_('committing subrepository %s\n') % s)
- sr = wctx.sub(s).commit(cctx._text, user, date)
+ sub = wctx.sub(s)
+ self.ui.status(_('committing subrepository %s\n') %
+ subrepo.relpath(sub))
+ sr = sub.commit(cctx._text, user, date)
state[s] = (state[s][0], sr)
subrepo.writestate(self, state)
diff -r fe0307fbe349 mercurial/subrepo.py
--- a/mercurial/subrepo.py Sun Mar 14 08:50:37 2010 +0100
+++ b/mercurial/subrepo.py Sun Mar 14 08:51:42 2010 +0100
@@ -126,6 +126,14 @@
# record merged .hgsubstate
writestate(repo, sm)
+def relpath(sub):
+ 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:]
+
def _abssource(repo, push=False):
if hasattr(repo, '_subparent'):
source = repo._subsource
@@ -211,7 +219,7 @@
return w.dirty() # working directory changed
def commit(self, text, user, date):
- self._repo.ui.debug("committing subrepo %s\n" % self._path)
+ self._repo.ui.debug("committing subrepo %s\n" % relpath(self))
n = self._repo.commit(text, user, date)
if not n:
return self._repo['.'].hex() # different version checked out
@@ -220,7 +228,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') % self._path)
+ self._repo.ui.note(_('removing subrepo %s\n') % relpath(self))
hg.clean(self._repo, node.nullid, False)
def _get(self, state):
@@ -231,7 +239,7 @@
self._repo._subsource = source
srcurl = _abssource(self._repo)
self._repo.ui.status(_('pulling subrepo %s from %s\n')
- % (self._path, srcurl))
+ % (relpath(self), srcurl))
other = hg.repository(self._repo.ui, srcurl)
self._repo.pull(other)
@@ -247,12 +255,12 @@
dst = self._repo[state[1]]
anc = dst.ancestor(cur)
if anc == cur:
- self._repo.ui.debug("updating subrepo %s\n" % self._path)
+ self._repo.ui.debug("updating subrepo %s\n" % relpath(self))
hg.update(self._repo, state[1])
elif anc == dst:
- self._repo.ui.debug("skipping subrepo %s\n" % self._path)
+ self._repo.ui.debug("skipping subrepo %s\n" % relpath(self))
else:
- self._repo.ui.debug("merging subrepo %s\n" % self._path)
+ self._repo.ui.debug("merging subrepo %s\n" % relpath(self))
hg.merge(self._repo, state[1], remind=False)
def push(self, force):
@@ -264,7 +272,7 @@
dsturl = _abssource(self._repo, True)
self._repo.ui.status(_('pushing subrepo %s to %s\n') %
- (self._path, dsturl))
+ (relpath(self), dsturl))
other = hg.repository(self._repo.ui, dsturl)
self._repo.push(other, force)
diff -r fe0307fbe349 tests/test-subrepo-deep-nested-change.out
--- a/tests/test-subrepo-deep-nested-change.out Sun Mar 14 08:50:37 2010 +0100
+++ b/tests/test-subrepo-deep-nested-change.out Sun Mar 14 08:51:42 2010 +0100
@@ -50,7 +50,7 @@
revision c57a0840e3badd667ef3c3ef65471609acb2ba3c
% Modifying deeply nested sub2
committing subrepository sub1
-committing subrepository sub2
+committing subrepository sub1/sub2
% Checking modified node ids
cloned ffe6649062fe tip
cloned/sub1 2ecb03bf44a9 tip
diff -r fe0307fbe349 tests/test-subrepo.out
--- a/tests/test-subrepo.out Sun Mar 14 08:50:37 2010 +0100
+++ b/tests/test-subrepo.out Sun Mar 14 08:51:42 2010 +0100
@@ -5,7 +5,7 @@
committing subrepository s
% add sub sub
committing subrepository s
-committing subrepository ss
+committing subrepository s/ss
% bump sub rev
committing subrepository s
% leave sub dirty
@@ -114,7 +114,7 @@
adding manifests
adding file changes
added 4 changesets with 5 changes to 3 files
-pulling subrepo ss from .../sub/t/s/ss
+pulling subrepo s/ss from .../sub/t/s/ss
requesting all changes
adding changesets
adding manifests
More information about the Mercurial-devel
mailing list