Jump to content


How to identify the version of a file which has a specific "String" in it's file-log


  • Please log in to reply
2 replies to this topic

#1 engr.vns

engr.vns

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 23 July 2020 - 02:53 PM

Assume that you hae a long list of versions on a file.
The user had inserted a specific "string" in it's changelog describing the change...

One method of identifying the version would be go through the filelog descriptions.
p4 filelog <file>
p4 describe <file>#N
....
Identify the string and version

But this is cumbersome...
Is there a better way of searching all the descriptions for this string to identify the file version.

Thanks in advance

#2 Miles O'Neal

Miles O'Neal

    Advanced Member

  • Members
  • PipPipPip
  • 204 posts
  • LocationAustin. Texas. Y'all.

Posted 23 July 2020 - 03:48 PM

p4 filelog -l <name>

This will print the full changelist description with each revision. Unfortunately it's not all one line, but the parsing is pretty basic. If you want to script this rather han piping it through less and eyeballing it, earch the file for the string, keeping track of the most recent version and/or changelist displayed. When you find the string, you also know the filerev/changelist.

#3 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1149 posts

Posted 23 July 2020 - 10:20 PM

Handling multi-line strings is a lot easier with the scripting APIs:


from P4 import P4
import sys

p4 = P4()
p4.connect()
[filelog] = p4.run_filelog("-l", sys.argv[1])
p4.disconnect()

print([f"#{r.rev}" for r in filelog.revisions if sys.argv[2] in r.desc])

% p4 filelog -l text.txt
//collaborators/main/python/text.txt
... #4 change 181 edit on 2020/07/23 by Samwise@Samwise-dvcs-1509687817 (text)

		multi line description
		keyword here
		blah blah blah

... #3 change 180 edit on 2020/07/23 by Samwise@Samwise-dvcs-1509687817 (text)

		blah blah blah blah

... #2 change 179 edit on 2020/07/23 by Samwise@Samwise-dvcs-1509687817 (text)

		blah blah blah test blah

... #1 change 178 add on 2020/07/23 by Samwise@Samwise-dvcs-1509687817 (text)

		blah blah blah blah

% python desc_grep.py text.txt keyword
['#4']

% python desc_grep.py text.txt test
['#2']

% python desc_grep.py text.txt blah
['#4', '#3', '#2', '#1']





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users