Menu

#81 tkdiff -r option not working for Perforce

V5.2.1
closed
Perforce (2)
2
2021-12-07
2021-12-03
No

The -r options are not working for Perforce (Version control system).
I am getting these errors:

$ tkdiff -r3 -r4 include/file.h
Error: fatal: Invalid object name '3'.


Error: Insufficeint usable input
TkDiff Aborted
 $ 

if i run "tkdiff" with no argument and Select Perforce in window - then it works fine.

With tkdiff version 4.1.4 the command "tkdiff -r3 -r4 include/file.h " was working fine for Perforce repository.

Is there a way that i can set the Perforce mode from the command line ?

if i run it
Thanks
Deepak

Discussion

  • Deepak Yadav

    Deepak Yadav - 2021-12-03

    it would be better to have options -perforce | -git to force a specific Source Control.

     
  • michael-m

    michael-m - 2021-12-03
    • assigned_to: michael-m
     
  • michael-m

    michael-m - 2021-12-03

    Oddly enough, a second user issued a ticket(#82) regarding using Perforce not one hour after yours(#81). They appear to have identified and suggested a apparent fix that I am only too happy to make. I simply need to verify it fits your description of failing from the command line but NOT from the interactive panel (which sounds a bit unusual).
    Please standby while I research this, and I will let you know the results (either way).

     
  • Deepak Yadav

    Deepak Yadav - 2021-12-04

    Tcket #82 is also filed by a member of our company.
    There are 2 issues - #82 is related to Perforce only and #81 is realted to git and Perforce.

    My home directory has git enabled. There is a dir "$HOME/Perforce/repo" which is a Perforce reporsitory. "$HOME/Perforce/repo" is not added to git.

    if i execute " cd /tmp ; tkdiff -r3 -r4 //misc/proj1/dev/main/src/include/file.h" then it work fine.

     

    Last edit: Deepak Yadav 2021-12-04
  • michael-m

    michael-m - 2021-12-04

    OK. That clears things up a bit.
    Ticket #82 is a clear problem for ANY use of Perforce (commandline OR interactive); its just plain wrong and your co-workers suggestion for the fix is completely correct. We will make THAT fix - although if you dont want to wait, you can fix your copy of TkDiff yourself.

    As to YOUR problem, TkDiff does have a solution, just not directly from the command line.

    Tkdiff determines the choice of Source Code Management (SCM) based on "availability". It looks for the telltale signs of access to approximately a dozen individual systems. MOST people tend to use a single system, so generally this results in a definitive answer. It would appear however you are set up to access Perforce AND Git.
    When you changed your WORKING DIRECTORY to "/tmp" you altered which SCMs were perceived as "available" and thus changed the outcome of what SCM was chosen. Sadly, when it chose Perforce, it hit your co-workers identified issue. When it WORKED, I strongly suspect it
    used Git.

    The default action of TkDiff is to use whichever SCM appears first in line, based on a long standing (ie. historical) ordering that was formerly hard-coded. TkDiff has since added a "voting" process to address situations like yours. The reason V4.1.4 worked (besides the bug not having been introduced yet) was because Git never existed at that time, thus Perforce was the ONLY choice. But getting back to this "voting" thing, you CAN specify which SCM you would prefer to use by editting your TkDiff Preferences. However, your vote is only VALID if TkDiff agrees that the designated SCM is considered "available" - otherwise you get the default selection.

    The rules for detecting any given SCM are wildly varying and are dictated by each SCM individually; we dont get to tell them how their system should operate: some have utility commands (such as Git), others use the presence of environment variables (Perforce) and still others use various file naming conventions and/or adjunct file structures derived from the target file being Diff'ed. Even your choice of working directory can play a role for some. Its not enough to just REQUEST any given SCM, by name (eg. from the command line) and be assured that it is even possible. Hence the "voting" approach to at least try to differentiate when multiple SCMs appear to be valid.

    When using the interactive panel, the VALID choices are presented in a choice box allowing you to select a different SCM if alternates are present (only valid ones are). From the command line, it is based on a pre-selected preference value, which you change by modifying your personal preferences file (typically $HOME/.tkdiffrc but it can be overridden via the TKDIFFRC environment variable). You can modify this file directly, but it is generally safer to make edits from within Tkdiff itself from the "Edit Preferences" menu pulldown. I suppose you could have TWO preference files, and switch by passing the environment variable setting ON the command line if it really is imperative to have command line control (although doing so is a "Unix-y Shell" kind of thing).

    The point is, you CAN operate with TkDiff even when the choice of SCM appears ambiguous,
    but only when those choices are considered valid at the time (and place) you run TkDiff.

    Let me know if this explanation (which is in the builtin online Help) solves your issue. Your co-workers issue WILL be addressed and part of the next release, but as indicated, you can just go ahead and make his recommended fix right now, and not have to wait.

     
  • Deepak Yadav

    Deepak Yadav - 2021-12-06

    I used the below prefernce and command line worked. You can close this ticket.

    define scmPrefer {Perforce Auto}

     

    Last edit: Deepak Yadav 2021-12-06
  • michael-m

    michael-m - 2021-12-07

    Glad it helped you.
    Be advised that based on your original problem description, you MIGHT want to amend your edit to set BOTH values to "Perforce" instead of just the first. You had originally asked for a diff among TWO different revisions of a named file. This shows up in TkDiff as a "Left" and "Right" representation that REFLECTS the ordering of the TWO original revision arguments, eg. -r3 (Left) and -r4 (Right). However, your settings do NOT say that you prefer "Perforce" as the SCM in the Right-hand window, and instead will let TkDiff choose, as per the default method described earlier for all files presented on that SIDE of the comparison that require an SCM!
    This "duality" allows one to, for example, compare a given file between DIFFERENT SCM instances.
    As someone who actually HAS multiple SCMs (Perforce, Git) in active use, this distinction could be important, as the default precedence of SCM Systems places Git AHEAD of Perforce. In any event, the labels above the Left/Right windows should always tell you what you are looking at.

     
  • michael-m

    michael-m - 2021-12-07
    • status: open --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.