Issue #2405 resolved

piping filenames to `thg log` with `--listfile -` does not work

__russ__
created an issue

How to replicate:

  1. update the TortoiseHg stable branch to fcea9c8d41f0
  2. cd to the repository root
  3. echo INSTALL.txt | ./thg log --listfile -
  4. This should open the "Hg file log viewer" view of thg, but instead, it opens the full repo/workbench view
  5. Now disable forking with the 'nofork' option, and it works as expected

I did nofork with a brutal hack to portable_fork as follows, but I'm sure there's a proper way:

def portable_fork(ui, opts):
    opts["nofork"] = True  #hack!!!
    #(rest of function untouched)

This issue with --listfile - has a direct impact on the nautilus integration which uses log --listfile - for the "File History" context menu.

ie: "File History" nautilus integration does not work due to this issue.

I do not know what the impact is of disabling the fork (nor what the reason for the fork is to begin with).

Comments (7)

  1. __russ__ reporter

    FWIW, setting "Fork GUI" to False in the global settings for TortoiseHg is the proper workaround for this problem, rather than hacking up the portable_fork code.

  2. Franco Bugnano

    I have the same problem on Fedora 20 x86_64 and the nautilus-python extension. The --listfile option seems always broken, not only for the log command, but for everything (add, revert, etc...), and it is broken even when configuring the gui to No Fork, and even when patching the nautilus extension, as suggested by Yuya Nishira, in order to use "--listfile - --nofork" in the run_dialog function. As it is now, the nautilus extension is completely unusable. Is there a reason why the nautilus extension uses a list of files in the stdin instead of using them directly in the command line?

  3. Yuya Nishihara

    --listfile option seems always broken,

    Can you show the full command-line string and the data sent to stdin? It worked fine from the console.

    % cat | thg log --listfile - --nofork
    setup.py
    

    Is there a reason why the nautilus extension uses a list of files in the stdin instead of using them directly in the command line?

    d4c301397992 says to "avoid shell command line limitations." It's still valid I think.

  4. Franco Bugnano

    For test purposes, I have created a new repository in the directory

    /home/fri/prova

    Inside that repository I have created a subdirectory named dir1 and a new file named file1.txt

    Then, I have used the nautilus extension with right click on the file->Add file..., and TortoiseHG returns a file not found error.

    I have added a couple of print statements in the run_dialog function of the nautilus extension, other than adding the --nofork option, and the output is as follows:

    DEBUG: run_dialog: cmdopts: ['/usr/bin/python', '/usr/bin/thg', 'add', '--listfile', '-', '--nofork']

    DEBUG: run_dialog: stdin: '/home/fri/prova/dir1/file1.txt'

    dir1/file1.txt: No such file or directory

    The same problem exists if I try the following commands:

    echo '/home/fri/prova/dir1/file1.txt' | thg add --listfile - --nofork

    but the command fails also if I try to add the file directly from the command line with the command:

    thg add /home/fri/prova/dir1/file1.txt

    so it seems that the problem is not with the --listfile option, but any time a filename is passed to the thg command, be it on the command line or stdin.

    I am using TortoiseHG version 2.11 with Mercurial version 2.8.1 as they are in the Fedora 20 repositories.

  5. Yuya Nishihara

    Inside that repository I have created a subdirectory

    Thanks, this is the key point to reproduce the problem. Can you file a new issue? It isn't related to --listfile -.

    I guess quickop dialog, open by thg add|forget|remove|revert, still relies on cwd = repo.root, but os.chdir() hack was removed at 89fa569323e3.

  6. Log in to comment