Can't add files in perforce - perforce

As far as I can tell, my client is setup correctly:
$ p4 client -o
# A Perforce Client Specification.
# ...
Client: stephen-dev1-stephen
Update: 2014/06/26 17:41:14
Access: 2014/06/26 17:45:47
Owner: StephenRasku
Host: stephen-dev1
Description:
Created by StephenRasku.
Root: /home/stephen/Code
Options: noallwrite noclobber nocompress unlocked nomodtime rmdir
SubmitOptions: submitunchanged
LineEnd: local
View:
//depot/labs/products/component/SpamView-URI/... //stephen-dev1-stephen/SpamView-URI/...
//version/... //stephen-dev1-stephen/version/...
//thirdparty/... //stephen-dev1-stephen/thirdparty/...
//starteam/... //stephen-dev1-stephen/starteam/...
//specs/... //stephen-dev1-stephen/specs/...
//release/... //stephen-dev1-stephen/release/...
//projects/... //stephen-dev1-stephen/projects/...
//main/... //stephen-dev1-stephen/main/...
//features/... //stephen-dev1-stephen/features/...
//dev/... //stephen-dev1-stephen/dev/...
//depot/... //stephen-dev1-stephen/depot/...
The files exist:
$ pwd
/home/stephen/Code/SpamView-URI
$ ls mainline/EBUILD_VERSION mainline/package.sh mainline/ebuild
mainline/ebuild mainline/EBUILD_VERSION mainline/package.sh
But it complains when I try and add them:
$ p4 add mainline/EBUILD_VERSION mainline/package.sh mainline/ebuild
mainline/EBUILD_VERSION - file(s) not in client view.
mainline/package.sh - file(s) not in client view.
mainline/ebuild - file(s) not in client view.
What's the problem? I checked out the file using git p4 clone if that makes a difference.

Check the "View" lines in the client workspace specification to confirm
that the file specification used in your Perforce command (or appearing in the error message)
falls within your workspace view. If you see an error attempting to add a file,
for example, you might want to check your mapping to confirm that the
file resides in a directory that is within your client view.
See the section under 'Client Workspace View':
http://answers.perforce.com/articles/KB_Article/Common-Permissions-and-File-Access-Problems
Are the files under this exact directory structure below?
/home/stephen/Code/SpamView-URI/mainline/EBUILD_VERSION
/home/stephen/Code/SpamView-URI/mainline/package.sh
/home/stephen/Code/SpamView-URI/mainline/ebuild
Judging by the first View mapping line of:
//depot/labs/products/component/SpamView-URI/... //stephen-dev1-stephen/SpamView-URI/...
I would guess that is the path they should be under.
If you 'cd' into the '/home/stephen/Code/SpamView-URI/mainline'
directory are you able to add these files?

Your client spec isn't right, as you noticed. With these 2 lines,
//depot/labs/products/component/SpamView-URI/... //stephen-dev1-stephen/SpamView-URI/...
//depot/... //stephen-dev1-stephen/depot/...
Your trying to map the files under //depot/labs/products/component/SpamView-URI/... to both //stephen-dev1-stephen/SpamView-URI/... and //stephen-dev1-stephen/depot/labs/products/component/SpamView-URI/... Since perforce reads top to bottom, it will overwrite your first mapping with the second mapping, basically removing the second mapping. \
Move your //depot/labs/products/component/SpamView-URI/... //stephen-dev1-stephen/SpamView-URI/... to the last line, and you should be ok.

Related

diff showing only the diff color without change code

I have changed line of a sql file file. But the diff only shows the diff colour without any change code.
the line is: #enabled=0, before the change we had 1 instead of 0.
without the gitattribute
*.sql text diff
I get the error message that file suppressed by a .gitattributes entry or the file's encoding is unsupported.
[this is the link of the image of my git diff] (https://i.stack.imgur.com/bgMvv.png)
You need to check your git status (assuming the #enabled=0 was done on your workstation)
Check if:
the file is indeed Test/Scripts/ScriptsIgnoredOnImport.sql
there is any local commit which would not have been pushed yet.
The file on GitHub can also tell you more, by typing b (which triggers the file "blame" view on GitHub).
As shown here, you can then "View blame prior to this change" and see if your #enabled= was visible then.
As noted by torek, you could have a difference in encoding as well.
As I mentioned in "How do I determine file encoding?", you can (even in a simple CMD on Windows), check the encoding of your current file with:
git show :your/file.sql | file -
# compare it with the previous version
git show #~your/file.sql | file -

p4python create and submit a new file

How to create and submit a new file using p4python?
create_and_submit_file(full_path_in_depot, new_file_text_content):
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
p4 = get_p4() # implemented
try: # Catch exceptions with try/except
connect_and_login_p4(p4) # implemented
# .. implementation here .. p4.some_call()
LOGGER.info('done')
except P4Exception:
for e in p4.errors: # Display errors
LOGGER.error(e)
If the file already exists on the local filesystem within a workspace, all you need to do is p4.run_add(file) and p4.run_submit('-d', 'this is my awesome file').
If the file doesn't exist, you need to create it, and if you don't have a workspace, you need to create that too. For the sake of brevity, here's how you'd do that from the command line completely from scratch (this maps pretty directly to P4Python but I don't know enough about your environment to give you code that'll work out of the box so I won't attempt the translation):
echo "my awesome file content" > my_awesome_file
p4 set P4CLIENT=my_awesome_client
p4 --field "View=//depot/... //my_awesome_client/..." client -o | p4 client -i
p4 add my_awesome_file
p4 submit -d "this is my awesome file"
Check out the example for p4.save_client to see a simple example of how you can create/modify a client spec with P4Python and modify the fields to suit your environment (similar to how I used the --field flag to set the View such that the root of my_awesome_client corresponds to //depot/...):
https://www.perforce.com/perforce/r14.2/manuals/p4script/python.p4.html#python.p4.save_spectype

How to find (grep) text for files in a perforce changelist?

How to grep/find for a particular text in all files within a pending changelist?
My use case:
I have a debug_flag in my code and would want to make sure I do not check-in any code with the debug_flag which will cause a compiler error for all others. (Not for me since I have the debug_flag declared locally)
p4 describe changelist# gives you the list of the files in a changelist, but it has some extra information, and the paths are with respect to the depo. Example:
p4 describe 12334
output:
Change 12334 by me on 2014/01/04 00:57:08 pending
Some test changelist
Affected files ...
... //depot/path/to/my/files/file1#15 edit
... //depot/path/to/my/files/file2#12 edit
With a few search/replace or a simple perls script, you can change this text output to a list of files with actual path and then run grep on them:
xargs grep "debug_flag" < file_list.txt

How to revert a subversion ignore?

I've run the following command via commandline:
svn propset svn:ignore "*.classpath" .
I wanted to only ignore the .classpath file.
However, this seems to have messed things up and now a lot of directories seem to be ignored.
How do I revert this and start over?
svn propedit svn:ignore . should bring up your editor, where you can remove the offending ignores one at a time.
Note
For this svn:ignore you effectively said "ignore in the currect directory only files with extension classpath": patterns for filenames in Subversion uses only OS-specific glob-pattern, not regexps
Fixes for syntax of DaFunix
List all svn-properties and their values in somepath: svn proplist -v <PATH>|<URL>. For your case
svn proplist -v .
Sample output for my URL
>svn proplist -v http://mayorat.ursinecorner.ru:8088/svn/Hello/trunk/
Properties on 'http://mayorat.ursinecorner.ru:8088/svn/Hello/trunk':
bugtraq:logregex
([Ff][Ss])\s#
(\d+)
svn:mergeinfo
/branches/Greetings:3-12
/branches/i18n:18-20
List single svn:property value (with known name): svn propget <PROPERTY> <PATH>|<URL>. For your case
svn propget svn:ignore .
Sample output for my URL (same as before for proplist)
>svn propget bugtraq:logregex http://mayorat.ursinecorner.ru:8088/svn/Hello/trunk/
([Ff][Ss])\s#
(\d+)
Both proplist and propget operations are RO, will change nothing
In order to fix bad definition of property you can
or
Delete bad property and re-create it in correct form:
svn propdel svn:ignore . & svn propset svn:ignore "classpath" . (maybe use propset with -R option to define ignore resursively for the whole subtree)
or (as suggested by John Brodie) edit and fix current definition
svn propedit svn:ignore . and in editor window "*.classpath" change to "classpath", save
PS Don't forget:
commit correct form of added property
remove from versioned code previously (possibly) added classpath files: svn:ignore affect only unversioned new files, already added to repo files with current ignore-pattern must be unversioned by hand

How to update all the files under the current directory in Ubuntu with some comments at the start of the files

I have an issue where in, I am trying to add copyrights message in all our files in the project. Since it will affect many directories and files, our team has split the task.
so each on of us will be updating the files manually. Can I automate it.
I tried with:
find -exec sed -i "1i # x CONFIDENTIAL\n# _____________________\n#\n# 1997 - 2012 x Incorporated\n# All Rights Reserved.\n#\n# NOTICE: All information contained herein is, and remains\n# the property of x Incorporated and its suppliers,\n# if any. The intellectual and technical concepts contained\n# herein are proprietary to x Incorporated\n# and its suppliers and may be covered by U.S. and Foreign Patents,\n# patents in process, and are protected by trade secret or copyright law.\n# Dissemination of this information or reproduction of this material\n# is strictly forbidden unless prior written permission is obtained\n# from x Incorporated.\n" -- {} \;
It just stops, as soon as it encounters the . folder and any folder under the current directory.
Can we control the command to affect some of the files in the directory by specifying the complete/partial name of the file?
You can do so by executing the following commands for each file:
cp file temp
cat copy_right_notice temp > file
Note that > overwrites file (while >> appends to file, which is not what you want (referring to your comment))

Resources