diff options
author | Laurent Bachelier <laurent@bachelier.name> | 2011-10-25 23:33:32 +0200 |
---|---|---|
committer | Laurent Bachelier <laurent@bachelier.name> | 2011-10-25 23:33:32 +0200 |
commit | a090960af95d89022e5ada64fabca201fd6fcb63 (patch) | |
tree | 79db223ac5c101ef5c3f7fece1a86e4303274db1 | |
parent | PEP8 fixes (diff) | |
download | confman-a090960af95d89022e5ada64fabca201fd6fcb63.tar.xz |
Print friendly message to help resolving conflicts
This happens often after updating portage for instance,
symbolic links are replaced by files with the contents
of the target.
An evolution would be to automatically replace the file if the contents
are the same.
-rw-r--r-- | confman.py | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -35,12 +35,16 @@ class ConfmanException(Exception): class ActionException(ConfmanException): - def __init__(self, action, value): + def __init__(self, action, value, resolve=None): self.action = action + self.resolve = resolve ConfmanException.__init__(self, value) def __str__(self): - return "%s (%s)" % (ConfmanException.__str__(self), repr(self.action)) + s = "%s (%s)" % (ConfmanException.__str__(self), repr(self.action)) + if self.resolve: + s += "\nResolve the issue with:\n%s" % self.resolve + return s class Action(object): @@ -97,8 +101,10 @@ class SymlinkAction(Action): dest = self.dest_path() if osp.lexists(dest): if not osp.islink(dest): + resolve = "diff %s %s\nrm -vi %s" % (osp.abspath(source), osp.abspath(dest), osp.abspath(dest)) raise ActionException(self, - "Destination exists and is not a link") + "Destination exists and is not a link", + resolve=resolve) def sync(self): source = self.source_path() |