Skip to content
Snippets Groups Projects
Commit 427d672c authored by Angel Ezquerra's avatar Angel Ezquerra
Browse files

subrepo: make it possible to update to hidden subrepo revisions

When a subrepo revision was hidden it was considered missing and mercurial was
unable to update to the corresponding parent revision. Instead warn the user of
the problem and let it choose what to do (the default is to udpate anyway).
parent c5aef7a6
No related branches found
No related tags found
No related merge requests found
...@@ -702,7 +702,7 @@ ...@@ -702,7 +702,7 @@
def _get(self, state): def _get(self, state):
source, revision, kind = state source, revision, kind = state
if revision in self._repo.unfiltered(): if revision in self._repo.unfiltered():
return return True
self._repo._subsource = source self._repo._subsource = source
srcurl = _abssource(self._repo) srcurl = _abssource(self._repo)
other = hg.peer(self._repo, {}, srcurl) other = hg.peer(self._repo, {}, srcurl)
...@@ -728,6 +728,7 @@ ...@@ -728,6 +728,7 @@
if cleansub: if cleansub:
# keep the repo clean after pull # keep the repo clean after pull
self._cachestorehash(srcurl) self._cachestorehash(srcurl)
return False
@annotatesubrepoerror @annotatesubrepoerror
def get(self, state, overwrite=False): def get(self, state, overwrite=False):
...@@ -731,5 +732,5 @@ ...@@ -731,5 +732,5 @@
@annotatesubrepoerror @annotatesubrepoerror
def get(self, state, overwrite=False): def get(self, state, overwrite=False):
self._get(state) inrepo = self._get(state)
source, revision, kind = state source, revision, kind = state
...@@ -735,6 +736,15 @@ ...@@ -735,6 +736,15 @@
source, revision, kind = state source, revision, kind = state
self._repo.ui.debug("getting subrepo %s\n" % self._path) repo = self._repo
hg.updaterepo(self._repo, revision, overwrite) repo.ui.debug("getting subrepo %s\n" % self._path)
if inrepo:
urepo = repo.unfiltered()
ctx = urepo[revision]
if ctx.hidden():
urepo.ui.warn(
_('revision %s in subrepo %s is hidden\n') \
% (revision[0:12], self._path))
repo = urepo
hg.updaterepo(repo, revision, overwrite)
@annotatesubrepoerror @annotatesubrepoerror
def merge(self, state): def merge(self, state):
......
...@@ -68,4 +68,30 @@ ...@@ -68,4 +68,30 @@
$ ls subrepo $ ls subrepo
a a
Enable obsolete
$ cat > ${TESTTMP}/obs.py << EOF
> import mercurial.obsolete
> mercurial.obsolete._enabled = True
> EOF
$ cat >> $HGRCPATH << EOF
> [ui]
> logtemplate= {rev}:{node|short} {desc|firstline}
> [phases]
> publish=False
> [extensions]'
> obs=${TESTTMP}/obs.py
> EOF
check that we can update parent repo with missing (amended) subrepo revision
$ hg up --repository subrepo -r tip
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg ci -m "updated subrepo to tip"
created new head
$ cd subrepo
$ hg update -r tip
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo foo > a
$ hg commit --amend -m "addb (amended)"
$ cd .. $ cd ..
...@@ -71,1 +97,6 @@ ...@@ -71,1 +97,6 @@
$ cd .. $ cd ..
$ hg update --clean .
revision 102a90ea7b4a in subrepo subrepo is hidden
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd ..
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment