"Error: Not a branch" when trying to revert a symlink

Bug #236149 reported by Daniel Hahler on 2008-05-30
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

I cannot revert a symlink change, which causes trouble as seen in bug 183831.

I've changed "blogs/media" to be a symlink, but cannot revert it:

daniel@base { ~/www/hahler_de.bzr }
$ bzr st | grep "kind changed" -A1
kind changed:
  blogs/media (directory => symlink)
daniel@base { ~/www/hahler_de.bzr }
$ bzr revert blogs/media
bzr: ERROR: Not a branch: "/home/daniel/www/hahler_live/web/media/".

This appears to be caused by some realpath related change, which is probably the reason for a lot of other (symlink) related errors.
It is maybe a dupe of bug 124859 - but after all just another error caused by incorrect symlink handling somewhere.

This is with bzr 1.3.1 on Ubuntu Hardy.

Daniel Hahler (blueyed) on 2008-05-30
description: updated
John A Meinel (jameinel) wrote :

This is because we are dereferencing the symlink, trying to find the branch you are working on.

If you did:

bzr revert blogs

It would recursively revert everything underneath, which will naturally revert that file.

Or you could

rm blogs/media
ln foo blogs/media
bzr revert blogs/media

Certainly this is still a bug, but it is the same bug as bug #128562. Just that we dereference symlinks when trying to open a branch. (Note that we need to dereference some symlinks, since /foo/bar/baz we should presumably dereference foo and bar, but not baz.

Changed in bzr:
importance: Undecided → Low
status: New → Triaged
Daniel Hahler (blueyed) wrote :
Download full text (3.2 KiB)

Somehow I could solve the above, original situation.

But I've just ran into something similar again and wanted to note that reverting does not appear to help, but fails with an error on its own:

bzr: ERROR: bzrlib.errors.PathNotChild: Path "/home/daniel/dev/simpletest/docs" is not a child of path "/home/daniel/src/b2evo/dev.local"

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 846, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 797, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 499, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 3201, in run
    self._revert_tree_to_revision(tree, revision, file_list, no_backup)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 3215, in _revert_tree_to_revision
    not no_backup, pb, report_changes=True)
  File "/usr/lib/python2.5/site-packages/bzrlib/mutabletree.py", line 52, in tree_write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree.py", line 1943, in revert
  File "/usr/lib/python2.5/site-packages/bzrlib/transform.py", line 1895, in revert
    lambda t, c: conflict_pass(t, c, target_tree))
  File "/usr/lib/python2.5/site-packages/bzrlib/transform.py", line 2016, in resolve_conflicts
    conflicts = tt.find_conflicts()
  File "/usr/lib/python2.5/site-packages/bzrlib/transform.py", line 580, in find_conflicts
  File "/usr/lib/python2.5/site-packages/bzrlib/transform.py", line 611, in _add_tree_children
  File "/usr/lib/python2.5/site-packages/bzrlib/transform.py", line 630, in iter_tree_children
    yield self.trans_id_tree_path(childpath)
  File "/usr/lib/python2.5/site-packages/bzrlib/transform.py", line 293, in trans_id_tree_path
    path = self.canonical_path(path)
  File "/usr/lib/python2.5/site-packages/bzrlib/transform.py", line 287, in canonical_path
    relpath = self._tree.relpath(abs)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree.py", line 416, in relpath
    return osutils.relpath(self.basedir, path)
  File "/usr/lib/python2.5/site-packages/bzrlib/osutils.py", line 884, in relpath
    raise errors.PathNotChild(rp, base)
PathNotChild: Path "/home/daniel/dev/simpletest/docs" is not a child of path "/home/daniel/src/b2evo/dev.local"

bzr 1.5 on python 2.5.2 (linux2)
arguments: ['/usr/bin/bzr', 'revert', '.']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'de_DE.UTF-8'
  builddeb /usr/lib/python2.5/site-packages/bzrlib/plugins/builddeb [0.92.0dev0]
  bzrtools /usr/lib/python2.5/site-packages/bzrlib/plugins/bzrtools [1.5.0]
  gtk /usr/lib/python2.5/site-packages/bzrlib/plugins/gtk [0.94.0]
  launchpad /usr/lib/python2.5/site-packages/bzrlib/plugins/launchpad [unknown]
  qbzr /usr/lib/python2.5/site-packages/bzrlib/plugins/qbzr [0.9.0]
  rebase /usr/lib/python2.5/site-packages/...


Daniel Clemente (n142857) wrote :

A way to reproduce this easily is:

mkdir bzr236149; cd bzr236149; bzr init; ln -s /etc/ etec; bzr add etec; bzr remove --keep etec

On 1.6b2 it fails with:
bzr: ERROR: Not a branch: "/etc/".

Running into the same issue.

Also, the same happens if you want to commit only a newly added symlink, and leave other changed files alone.

Using the example from the previous comment:
mkdir bzr236149; cd bzr236149; bzr init; bzr ci -m "initial"; ln -s /etc/ etec; bzr add etec; bzr ci -m "added symlink" etec

On 1.6b2 it fails with:
bzr: ERROR: Not a branch: "/etc/".

Is there a workaround? Especially for the revert?

Forgot to mention, using bzr 1.3.1 on Hardy (and not 1.6b2 as the message above implies):

$ bzr --version
Bazaar (bzr) 1.3.1
  Python interpreter: /usr/bin/python 2.5.2.final.0
  Python standard library: /usr/lib/python2.5
  bzrlib: /usr/lib/python2.5/site-packages/bzrlib
  Bazaar configuration: /home/me/.bazaar
  Bazaar log file: /home/me/.bzr.log

Martin Pool (mbp) on 2010-03-19
Changed in bzr:
status: Triaged → Confirmed
Jelmer Vernooij (jelmer) on 2011-02-02
tags: added: revert symlink
Jelmer Vernooij (jelmer) on 2017-11-09
tags: added: check-for-breezy
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers