Skip to content

fix crash in diff command on commits with inherited files

Richard Hansen requested to merge rhansen/reposurgeon:fix-diff into master

Before, when running the diff command on a commit whose files are at least partially inherited from its parent, the following exception would be raised:

Traceback (most recent call last):
  File "../reposurgeon", line 11286, in <module>
    main()
  File "../reposurgeon", line 11276, in main
    cmd.Cmd.onecmd(interpreter, interpreter.precmd(arg))
  File "/usr/lib/python2.7/cmd.py", line 221, in onecmd
    return func(arg)
  File "../reposurgeon", line 8129, in do_script
    self.onecmd(self.precmd(scriptline))
  File "../reposurgeon", line 7083, in onecmd
    cmd.Cmd.onecmd(self, line)
  File "/usr/lib/python2.7/cmd.py", line 221, in onecmd
    return func(arg)
  File "../reposurgeon", line 10875, in do_diff
    lines1 = totext.split('\n')
AttributeError: 'bool' object has no attribute 'split'

This was caused by Commit.blob_by_name() only searching its own file operations for an M operation matching the given name. It did not search ancestor commits as appropriate.

Now Commit.blob_by_name() gets the blob's mark from its manifest, which effectively falls back to ancestors as needed in case the commit doesn't modify the named file.

Merge request reports