changing description of list of changelist's in perforce - perforce

I would like to put a common description among a list of change list's , so far i tried this
p4 changelist -o >changelist.txt
notepad changelist.txt
put the desired description in changelist.txt
p4 changelist -i to append the description from changelist.txt
but it will only append the text from chnagelist.txt to a single change list , what i would like to do is append the same description to a list of change list any ideas how to do that .

Put your 'changelist -i' command into a 'for' loop in your favorite scripting language, iterating over all the changelist numbers you wish to update.

Related

Concatenate multiple yaml files with seperator

I need to concat multiple k8s deployment yaml files into one deployment script, and in doing so create a specific separator --- between each file. I know the specific depth at which the files will live as well as the filename, however I don't know how many there will be at a given time, so I've used the find statement below to
recursively search for the yaml file
concat each
piped in the tail command as a seperator
find . -type f -name 'deployment.yml' -exec cat {} + | tail -n +1 * > finalDeployment.yml
However, this creates broken yaml syntax by inserting the ==> <== delimeter:
I could simply have another task run a find/replace using the above as prefix/suffix tokens, however I'd like something more succinct within the above statement.
Is it possible to pipe in a specific character/set of characters a delimeter within a cat command, or is there another method to accomplish this?
What you want to do is not guaranteed to work. For example, you have these two YAML files:
foo: bar
and:
%YAML 1.2
---
baz
As you can see, the second file contains a directive. It also shows that --- in YAML is not a separator, but a directives end marker. It is optional if you don't have any directives like in the first document. If you concatenate both documents in the way you want to do it, you will get a document with two --- and %YAML 1.2 will be interpreted as content because it occurs after a directives end marker.
So what you actually want to do is to mark the end of each document with ..., the document end marker. After that marker, the parser is reset to its initial state, which guarantees that the second document is parsed exactly as it would have been when it was in a separate file.
Also, no harm is done by adding ... to the last document since it does not start another document implicitly. So your command could look like this (I depend on your statement that you know the depth at which the files lie here and as example, expect a depth of 3 directories):
echo -n > finalDeplayment.yml
for f in */*/*/deployment.yml; do
cat $f >> finalDeployment.yml; echo "..." >> finalDeployment.yml
done

adding many dictionaries to aspell

I have a tex document spanning several files that I want to check with aspell.
The command I use is:
cat $f | aspell list --extra-dicts="./names.spl" --mode=tex -l en |sort -u
for every file name f.
Some files that concern pronunciation have "words" like aj and oo inside them, which aspell counts as spelling mistakes. I want to filter them out without putting them into the names.spl dictionary. (first because they are not names, second because they shouldn't be ignored in other files)
the aspell documentation states that the "extra-dicts" argument can receive a list, but I can't seem to delimit it properly. I tried , : and plain spaces to no avail. They are either treated as a long file path or get entirely separated from the extra-dicts keywords.
I also tried to use the option twice, but the second time just overrides the first.
Am I missing something trivial about how lists are provided as command line arguments in the terminal?
According to the texinfo manual (info aspell), aspell uses a list option format that is different from other GNU programs, in which the base option name is prefixed with add- or rem- to respectively add or remove items from a list:
4.1.1.3 List options ....................
To add a value to the list, prefix the option name with an 'add-' and
then specify the value to add. For example, to add the URL filter use
'--add-filter url'. To remove a value from a list option, prefix the
option name with a 'rem-' and then specify the value to remove. For
example, to remove the URL filter use '--rem-filter url'. To remove
all items from a list prefix the option name with a 'clear-' without
specify any value. For example, to remove all filters use
'--clear-filter'.
Following this pattern for the --extra-dicts option, you would add multiple extra dictionaries as
--add-extra-dicts dict1 --add-extra-dicts dict2
The documentation for Aspell 0.60.7-20110707 also mentions a (possibly newer) more direct delimited list format, using a third prefix lset:
A list option can also be set directly, in which case it will be
set to a single value. To directly set a list option to multiple
values prefix the option name with a 'lset-' and separate each value
with a ':'. For example, to use the URL and TeX filter use
'--lset-filter url:tex'.
Following this format, your option would become
--lset-extra-dicts dict1:dict2

Tcsh completion in the format of ls -l

When setting autolist in tcsh.rc, and pressing Tab to complete a filename i get a list of available completions in the format of a "regular" ls command.
is there any way to set tcsh in a way that pressing tab will show a list of available completions in the format of "ls -l"?
or if not, then just sort the "regular" list by date?
pressing tab will show a list of available completions in the format of "ls -l"?
No, this is not possible.
Completion in tcsh works by getting a list of words (ie. my trousers are on fire), checking if one of the word matches, and then insert that word in the commandline.
There is no functionality which says "display this to the user, but insert something else in the commandline". So while you could complete commands with ls -l, this would be fairly useless, since you'll get the entire line in your commandline.
just sort the "regular" list by date?
This is also not possible, since tcsh sorts the completions. You can't disable this ...
Sorry :-( I believe that at least zsh is able to do this, but I'm not sure. Maybe bash can do this as well (but again, not sure).
(This information derived from a careful reading of the manpage, and tw.parse.c in the source code.)

How to find which changelists will be copied?

I want to be able to do a 'p4 describe' on all the changelists that will be copied upon a 'p4 copy' command. How can this be done?
I could do something like:
p4 copy -n from-branch/... to-branch/... | sed -e 's|.* ||' | xargs -n 1 p4 filelog
to find the list of changes per file and truncate the list at the point of the last branch or integrate action into to-branch (if there is one). But this could potentially take a long time. Is there a better way?
Try p4 interchanges. I like the -l and -f flags, which print the whole changelist description and list the files changed:
p4 interchanges -lf from-branch/... to-branch/...
I haven't actually used this command with p4 copy, though, so the results might be slightly different. If you're doing especially fancy integrations (cherry-picking revisions) Perforce might show a changelist as needing to be integrated even when it's already been integrated.
I think the easiest thing to do would be to create a label and tag from-branch/... at the last CL that was copied to to-branch from from-branch. Then finding out the list of CLs not copied is as easy as:
p4 changes 'from-branch/...#>copied-up-to' # where copied-up-to is the name of the dynamic label
If everything under from-branch is all tagged at the same CL, I could use a dynamic label whose Revision spec would be the last CL that was copied to to-branch from from-branch.
A script is probably the right way to go. I'd use the perl, python, or ruby API to make it more efficient and easier to maintain.
The basic outline would be:
Run p4 copy -n to get the list of candidate files
Parse out the source revisions that are being copied. For instance, each line of output has something like "branch/sync from //depot/foo.c#1,#3". For that file you'd want to know how revisions 1-3 were created.
Run p4 changes to get the changelists that affected each file (e.g. p4 changes -l //depot/foo.c#1,#3
Again, doing this using an API will be much more efficient, as you can use a single connection for all the command calls.

How do you search the text of changelist descriptions in Perforce?

On occasion, I find myself wanting to search the text of changelist descriptions in Perforce. There doesn't appear to be a way to do this in P4V. I can do it by redirecting the output of the changes command to a file...
p4 changes -l > p4changes.txt
...(the -l switch tells it to dump the full text of the changelist descriptions) and then searching the file, but this is rather cumbersome. Has anyone found a better way?
When the submitted changelist pane has focus, a CTRL+F lets you do an arbitrary text search, which includes changelist descriptions.
The only limitation is that it searches just those changelists that have been fetched from the server, so you may need to up the number retrieved. This is done via the "Number of changelists, jobs, branch mappings or labels to fetch at a time" setting which can be found by navigating to Edit->Preferences->Server Data.
p4 changes -L | grep -B 3 searchstring
-B 3 means show 3 lines before the matched string, should be enough to show the change id with 2 line comments but you can change it as necessary.
I use p4sql and run a query on the "changes" database. Here's the perforce database schema
The query looks something like this (untested)
select change from changes where description like '%text%' and p4options = 'longdesc'
edit: added the p4options to return more than 31 characters in the description.
Here is a Powershell version of Paul's "grep" answer. Again, it searches for the specified string within the change description and returns the 3 lines before it, to include the change id:
p4 changes -L | select-string "search string" -Context (3,0)
Why redirect to a file when you can pipe the output through less and use less's search?
p4 changes -l | less
And then press / to prompt for a search string. Afterward, n will jump to the next match, and Shift+n will jump to the previous one.
An implementation of less for Windows is available as part of UnxUtils.
Using p4sql is really the only way to effectively do what you want. I am not aware of any other way. The benefit of course is that you can use the select statements to limit the range of changelist values (via date, user, etc). Your method will work but will get cumbersome very quickly as you generate more changelists. You can limit the scope of the changes command, but you won't get the flexibility of p4sql.
Eddie on Games posted his Perforce Changelist Search 0.1 at http://www.eddiescholtz.com/blog/archives/130
But, I do like using my favorite text editor with the simple:
p4 changes -s submitted //prog/stuff/main/... >temp.txt
If you still love your command line, you can write a small perl script that:
changes the record separator $/ to
double newline "\n\n" so it filters
the input into full records of the
ztagged p4 output.
scans
the '/^... desc/..//' part with
regular expressions from the args.
usage would be something like 'p4 -ztag changes -l | yourperlfilter.pl searchterm1 searchterm2'
if that worked ok, you could integrate it into the p4win tools menu.

Resources