def assertChangesEqual(self, file_id='fid', paths=('path', 'path'), content_change=False, versioned=(True, True), parent_id=('pid', 'pid'), name=('name', 'name'), kind=('file', 'file'), executable=(False, False), versioned_change='unchanged', renamed=False, modified='unchanged', exe_change=False): reporter = InstrumentedReporter() _mod_delta.report_changes([(file_id, paths, content_change, versioned, parent_id, name, kind, executable)], reporter) output = reporter.calls[0] self.assertEqual(file_id, output[0]) self.assertEqual(paths, output[1]) self.assertEqual(versioned_change, output[2]) self.assertEqual(renamed, output[3]) self.assertEqual(modified, output[4]) self.assertEqual(exe_change, output[5]) self.assertEqual(kind, output[6])
def get_status(repo, rev1=None, rev2=None, files=None, clean=None, ignored=None, renamed=False): if not files: files = None reverse = False if not rev1 and rev2: rev1, rev2 = rev2, rev1 reverse = True if rev1 or rev2: ignored = False old = repo.branch.repository.revision_tree(g_revid(repo, rev1)) if rev1 else repo.basis_tree() new = repo.branch.repository.revision_tree(g_revid(repo, rev2)) if rev2 else repo reporter = StatusReporter(repo, ignored, set(files) if files else ContainsEverything(), renamed) with ReadLock(repo), ReadLock(old), ReadLock(new): changes = new.iter_changes(old, clean, files, require_versioned=False, want_unversioned=True) report_changes(changes, reporter) r = reporter.status if renamed: if reverse: r['renames']=dict(((value, key) for key, value in reporter.renames.iteritems())) else: r['renames']=reporter.renames if reverse: r['deleted'], r['unknown'] = r['unknown'], r['deleted'] r['added'], r['removed'] = r['removed'], r['added'] return r
def report_changes(to_file, old, new, specific_files, show_short_reporter, show_long_callback, short=False, want_unchanged=False, want_unversioned=False, show_ids=False, classify=True): """Display summary of changes. This compares two trees with regards to a list of files, and delegates the display to underlying elements. For short output, it creates an iterator on all changes, and lets a given reporter display these changes. For stantard output, it creates a delta of the changes, and forwards it to a callback :param to_file: If set, write to this file (default stdout.) :param old: Start tree for the comparison :param end: End tree for the comparison :param specific_files: If set, a list of filenames whose status should be shown. It is an error to give a filename that is not in the working tree, or in the working inventory or in the basis inventory. :param show_short_reporter: Reporter in charge of display for short output :param show_long_callback: Callback in charge of display for normal output :param short: If True, gives short SVN-style status lines. :param want_unchanged: Deprecated parameter. If set, includes unchanged files. :param show_ids: If set, includes each file's id. :param want_unversioned: If False, only shows versioned files. :param classify: Add special symbols to indicate file kind. """ if short: changes = new.iter_changes(old, want_unchanged, specific_files, require_versioned=False, want_unversioned=want_unversioned) _mod_delta.report_changes(changes, show_short_reporter) else: delta = new.changes_from(old, want_unchanged=want_unchanged, specific_files=specific_files, want_unversioned=want_unversioned) # filter out unknown files. We may want a tree method for # this delta.unversioned = [unversioned for unversioned in delta.unversioned if not new.is_ignored(unversioned[0])] show_long_callback(to_file, delta, show_ids=show_ids, show_unchanged=want_unchanged, classify=classify)
else: new = wt old.lock_read() new.lock_read() try: _raise_if_nonexistent(specific_files, old, new) want_unversioned = not versioned if short: changes = new.iter_changes(old, show_unchanged, specific_files, require_versioned=False, want_unversioned=want_unversioned) reporter = _mod_delta._ChangeReporter( output_file=to_file, unversioned_filter=new.is_ignored) _mod_delta.report_changes(changes, reporter) else: delta = new.changes_from(old, want_unchanged=show_unchanged, specific_files=specific_files, want_unversioned=want_unversioned) # filter out unknown files. We may want a tree method for # this delta.unversioned = [ unversioned for unversioned in delta.unversioned if not new.is_ignored(unversioned[0]) ] delta.show(to_file, show_ids=show_ids, show_unchanged=show_unchanged, short_status=False)
def selected_changes(self, transform): """Report the changes that were selected.""" trace.note(gettext("Selected changes:")) changes = transform.iter_changes() delta.report_changes(changes, self.delta_reporter)
def report_changes(to_file, old, new, specific_files, show_short_reporter, show_long_callback, short=False, want_unchanged=False, want_unversioned=False, show_ids=False, classify=True): """Display summary of changes. This compares two trees with regards to a list of files, and delegates the display to underlying elements. For short output, it creates an iterator on all changes, and lets a given reporter display these changes. For stantard output, it creates a delta of the changes, and forwards it to a callback :param to_file: If set, write to this file (default stdout.) :param old: Start tree for the comparison :param end: End tree for the comparison :param specific_files: If set, a list of filenames whose status should be shown. It is an error to give a filename that is not in the working tree, or in the working inventory or in the basis inventory. :param show_short_reporter: Reporter in charge of display for short output :param show_long_callback: Callback in charge of display for normal output :param short: If True, gives short SVN-style status lines. :param want_unchanged: Deprecated parameter. If set, includes unchanged files. :param show_ids: If set, includes each file's id. :param want_unversioned: If False, only shows versioned files. :param classify: Add special symbols to indicate file kind. """ if short: changes = new.iter_changes(old, want_unchanged, specific_files, require_versioned=False, want_unversioned=want_unversioned) _mod_delta.report_changes(changes, show_short_reporter) else: delta = new.changes_from(old, want_unchanged=want_unchanged, specific_files=specific_files, want_unversioned=want_unversioned) # filter out unknown files. We may want a tree method for # this delta.unversioned = [ unversioned for unversioned in delta.unversioned if not new.is_ignored(unversioned[0]) ] show_long_callback(to_file, delta, show_ids=show_ids, show_unchanged=want_unchanged, classify=classify)
new_is_working_tree = False except errors.NoSuchRevision, e: raise errors.BzrCommandError(str(e)) else: new = wt old.lock_read() new.lock_read() try: _raise_if_nonexistent(specific_files, old, new) want_unversioned = not versioned if short: changes = new.iter_changes(old, show_unchanged, specific_files, require_versioned=False, want_unversioned=want_unversioned) reporter = _mod_delta._ChangeReporter(output_file=to_file, unversioned_filter=new.is_ignored) _mod_delta.report_changes(changes, reporter) else: delta = new.changes_from(old, want_unchanged=show_unchanged, specific_files=specific_files, want_unversioned=want_unversioned) # filter out unknown files. We may want a tree method for # this delta.unversioned = [unversioned for unversioned in delta.unversioned if not new.is_ignored(unversioned[0])] delta.show(to_file, show_ids=show_ids, show_unchanged=show_unchanged, short_status=False) # show the new conflicts only for now. XXX: get them from the # delta. conflicts = new.conflicts()