def show(self, snapshot, compact=False): """ show details pertaining to given snapshot """ snapshot = Snapshot(snapshot) if snapshot.name == "@": parent, changes = self._get_status() else: parent, changes = snapshot.parent, snapshot.changes fca = snapshots.first_common_ancestor("@", snapshot) mainline = (fca == snapshot) and 'Is' or "Isn't" mainline = "%s an ancestor of @" % mainline pretty_history = self._prettify_changes(changes) if parent == None: parent = "unknown" else: parent = parent.name if not compact: title = "Snapshot %s" % snapshot.name print(title) if snapshot.name != "@": print(mainline) print("Parent: %s" % parent) if parent == "unknown" and snapshot.name == "@": print("dpkg history shown for the last 30 days") print("dpkg history:") else: print("dpkg history for %s" % snapshot.name) print("\n".join(pretty_history)) return True
def _sort_key(self, snapshot): """ key for sorting the to_print list in order to assure that the different branches are printed coherently """ if snapshot.name == "@" or len(self.junctions) == 0: return snapshot.date junctions = self.junctions.keys() junctions.sort(key = lambda x: x.date) oldest = junctions[0] newest = junctions[-1] fca = snapshots.first_common_ancestor(newest, snapshot) if fca == None or oldest.date < fca.date: return snapshot.date return fca.date