On Tue, 2015-04-21 at 21:16:41 +0200, Daniel Dehennin wrote: > Yes, but to be sure, let me summarise, with your proposition I could > either: > > - pass an IO::Handle to the new constructor: > > #+begin_src perl > use Git::Repository; > my $repo = Git::Repository->new(work_tree => '/some/where'); > > my $control_ref = $self->dist_branch . ':debian/control'; > > my $control_fh = $repo->command(show => $control_ref)->stdout; > my $control = Dpkg::Control::Info->new($control_fh); > #+end_src > > - Pass “{filename => undef}” to the new constructor and then pass the > IO::Handle to “load()”: > > #+begin_src perl > use Git::Repository; > my $control = Dpkg::Control::Info->new({filename => undef}); > my $repo = Git::Repository->new(work_tree => '/some/where'); > > my $control_ref = $self->dist_branch . ':debian/control'; > > my $control_fh = $repo->command(show => $control_ref)->stdout; > $control->load($control_fh); > #+end_src > > Maybe it miss the “pass a filename string” to the constructor and > “load()” for compatibility, since this method automatically use > Dpkg::Compression::FileHandle?
Well, ideally Dpkg::Control::Info should not have ever done the loading in the constructor. But actually thinking about it, probably accepting IO::Handle does not make sense, because it removes the distinction between ->parse() and ->load() and would make it annoying to also pass a description of what the handle is to ->load() (so that error messages make sense). So even though I had already both basic options implemented, I'm thinking of only merging the one where you can declare filename => undef and avoid the load, and can then use ->parse() normally. Or perhaps, I'll add a load option as you suggested initially, and just deprecated loading at constructor time, will ponder about it. So, in essence, you will be able to do something like: ,--- my $control = Dpkg::Control::Info->new(filename => undef); $control->parse($control_fh, $control_ref); `--- which I think makes more sense. Thanks, Guillem -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org