Get creation and last modification date with branch - python-2.7

I am trying to use pysvn to get creation and last modification revisions (and above all dates) of files in a svn system...
The typical file history I'm struggling with looks like that :
I'm using pysvn but I can't understand the documentation very well. So far, either I manage to get branching date/revision or last modification on root... What I would like, is to get real creation date (regardless of if it's in root or branch), and last modification date, excluding branching if there has been no modification in branch since branch creation.
Thanks in advance if someone can provide me help on that, I don't want to spend to much time on this specific part of my script... :)
Manu
(BTW, i'm using an existing simple algo that tries to find creation date using dichotomia, given min and max revisions to check, that checks if file can be found in given revision recursively until the earliest... sorry for that not-very-English explanation!)
(EDIT : of course, for now, branch and root are not merging yet ^^ else I would probably not struggle with the branch revisions and just take merge revision as last modification for instance)

pysvn.Client().log() will return information on commits that you can then analyse.
Of interest to you is the optional changed_paths information, make sure you set discover_changed_paths=True to have this information returned.
That will show you when a file was added to the repo, this is your creation date event. And when a file was modified which is your modified date.
You may also have to figure out that a file was renamed, which looks like a commit with a delete of the original file and the adding of another.
You can also figure out the branch relationship by looking at the value of the copyfrom_path and copyfrom_revision.

Related

Cycling through URLs to download csv files

I have a list of URLs which will access a webservice. The webservice downloads .csv files. I want to be able to cycle through them using a date field which is in a specific format in the url itself, thereby downloading the data day-by-day. The access seems fairly slow as even a manual url entry can take a couple of minutes to complete, and I suspect the issue is at the webservice' end.
The URL is in the format:
http://web.service.com/ws/XYZ/data/?key=mysecretkeyf&field1=X&start=YYYY-MM-DD 00:00&end= YYYY-MM-DD 00:00&field=Y&format=csv
So the way I envision it (and I am keen to take advice) is using a variable for the start year, month and day fields cycling onto the next URL as the previous .csv is downloaded, with the code ending when the current date is accessed.
Any ideas most welcome.
The coding is really straightforward which makes me wonder if you are looking to code this yourself or asking if there is a service out there that would help do this. If you are coding, I'd choose a language that works well for you. #Vivek mentioned Python which is what I would choose as well.
If you do not want to go the coding approach, you could check out DownThemAll. I have used this utility for batch downloading where you have to increment numbers in parts of the URL. Check it out, it may be a good non-programming solution: DownThemAll

Batch file date check from multiple folders

I'm looking (if possible) for a check and copy batch script that I can run remotely to check multiple directories and copy the newest modified date.
To clarify: On the remote machine I'm looking at a potential five folders (that may or may not be there). I need the script to check the last modified date of two sub-folders (Desktop and Internet Favorites) of a user's potential 5 profiles, then pick the most recent modified date and copy the folders to another location
So pathway looks like:
"\\%asset%\c$\documents and settings\%username%\Desktop"
"\\%asset%\c$\documents and settings\%username%\Favorites"
To check the date and compare it with (potentially)
"\\%asset%\c$\documents and settings\%username%.temp\Desktop"
"\\%asset%\c$\documents and settings\%username%.temp\Favorites"
Or
"\\%asset%\c$\documents and settings\%username%.temp001\Desktop"
"\\%asset%\c$\documents and settings\%username%.temp001\Favorites"
Once it has found the sub-folders with the most recent modified date to copy (only the most recent) to:
"\\%asset%\c$\documents and settings\Backup"
I know I can get the check done on one location, but I don't know how to ask batch to run multiple checks and then to pick the most recent.
Is that actually possible or am I trying this in the wrong language? I've gotten every thing but the check written out and that's where I'm getting stuck...
Any help would be appreciated!
As I said in my comment, I think Powershell would be better suited to the task. But I did think of one approach that may work in batch without having to resort to textual date comparisons (which are difficult).
You may be able to use robocopy with its /copy:t option which copies timestamps. Imagine copying all three directories to one location, then doing a dir /b /od to list out this temporary directory sorted by date to find the most recent one, and copy that to your target.
I don't have time to test this theory out or give you real code, but hopefully it gives you an approach to try. Or convinces you to take a look at Powershell. :-)

sketch flow -- how do we rename .xaml and .cs files without breaking sketchflow map?

how do we rename .xaml and .cs files?
would like to be able to keep development in synch with the original sketchflow. i.e. sketchflow has features such as the ability to collect client feedback on a per screen basis, etc.
... I kind of answered my own question here, so I'll post it as a follow up. Asked the original question 9 hours ago on the MS site without response... still trying to work out where the best place is to talk to the community, so sorry for the duplicate.
THE ANSWER (IS THERE A BETTER ONE?)
Context: Sketchflow is a prototyping tool. In large teams possibly you want to keep the prototype seperate from the finished version, or there's a large prototyping phase.
My view is that I really like Sketchflow. It's one of the coolest things I've seen for a while (well done Microsoft).
... so for me, I want the prototype to become a the finished product. I want the designers to step in and make transitions whenever they want. I want the designers to kick the process off, and the developers to put in the detail. I'd like our customers to be able to post feedback at any time during the build process. btw: get your developers to check out MVVM. It's very cool.
My bet is that the feedback could get lost if you make a breaking change (a file rename) -- so just beware of that. That wont be a problem for us. We'll get our file names to make sense and then mostly leave it alone. Of course MS could fix this this by creating a globally unique id (Guid) for each screen that is created. Perhaps they've done this already. If someone from MS reads this, please put this on your requested features list.
THE ANSWER:
So here is the answer that works for me:
don't try to hand-edit the xaml / cs, as all the cross referencing that you might be doing with behaviors will break if you aren't really careful. Typical files that need to be modified: .csproj, Sketch.Flow, xxxx.xaml, and xxxx.cs.
To auto do it, download a tool like Ultraedit. Alternatively, you might be able to just use VS 2010 (untested).
Steps with ultraedit:
(BACKUP YOUR PROJECT FIRST)
Search/Replace In Files...
Find in files... "Screen_1_19"
Replace with... "Welcome"
In Files/Types... "."
Directory...
Match Whole Word Only
Hit "Start"
follow the prompts
rename the files (.xaml & .cs) to be Welcome.???? (where ???? is .xaml or .cs) . Since I use SVN, this step gets done for me in one step (no big deal).
If using VS2010 for steps 1 through 8, be careful do longer string replacements first e.g. Screen_1_19 before Screen_1. I think VS treats _ as a word break. On ultraedit you'll be fine.
If there's interest, in the spare time that I don't currently have, I could release a quick tool to do this on codeplex.
** note: because we are working with XML and XML is very particular about being correct, I close expression blend down, and then reopen it again after the replace/rename to see if I was successful + my screen map still has all the flow lines still drawn in.
answer is above in the body of the question.

Scan for changed files

I'm looking for a good efficient method for scanning a directory structure for changed files in Windows XP+. Something like how git does it is exactly what I'm looking for, when running a git status it displays all modified files, all new (untracked) files and deleted files very quickly which is exactly what I would like to do.
I have a basic model up and running which performs an initial scan and stores all filenames, size, dates and attributes.
On a subsequent scan it checks if the size, attributes or date have changed and marks as a changed file.
My issue now comes in detecting moved and deleted files. Is there a tried and tested method for this sort of thing? I'm struggling to come up with a good method.
I should mention that it will eventually use ReadDirectoryChangesW to monitor files and alert the user when something changes so a full scan is really a last resort after the initial scan.
Thanks,
J
EDIT: I think I may have described the problem badly. The issue I'm facing is not so much detecting the changes - I have ReadDirectoryChangesW() using IOCP on multiple threads to detected when a change happens, the issue is more what to do with the information. For example, a moved file is reported as a delete followed by a create and a rename comes in 2 parts, old name, followed by new name. So what I'm asking is how to differentiate between the delete as part of a move and an actual delete. I'm guessing buffering the changes and processing batches would be an option but feels messy.
In native code FileSystemWatcher is replaced by ReadDirectoryChangesW. Using this properly is not simple, there is a good baseline to build off here.
I have used this code in a previous job and it worked pretty well. The Win32 API itself (and FileSystemWatcher) are prone to problems that are described in the docs and also discussed in various places online, but impact of those will depending on your use cases.
EDIT: the exact change is indicated in the FILE_NOTIFY_INFORMATION structure that you get back - adds, removals, rename data including old and new name.
I voted Liviu M. up. However, another option if you don't want to use the .NET framework for some reason, would be to use the basic Win32 API call FindFirstChangeNotification.
You can use USN journaling if you are up to it, that is pretty low level (NTFS level) stuff.
Here you can find detailed information and source code included. It is written in C# but most of it is PInvoking C/C++ functions.

Do you add information to the top of each .hpp/.cpp file? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
When creating a new C++ header/source file, what information do you add to the top? For example, do you add the date, your name, a description of the file, etc.? Do you use a structured format for this information?
e.g.
// Foo.cpp - Implementation of the Foo class
// Date: 2008-25-11
// Created by: John Smith
One team I know embeds CVS commit messages to the foot of each file, but I'm not sure I want to go this far...
Information about who created a file and when and who edited it and when is all in source control. If your team has good practices around check-in comments, then you'll know the reasons for each change too. No need for comments for that stuff.
I think it's 100% legit - wise, even - to put a comment block, as long as is necessary, explaining the purpose of the class/module. When the next person goes to change it, they'll have a better idea of the overall vision and whether this file is the appropriate place for their change.
Some shops put copyright notices and other legal folderol in source file comments. This strikes me as just silly - if your (non-OSS) source code has made it onto someone else's servers without your knowledge or permission, a copyright notice is probably not going to deter them from doing anything with it. IANAL, YMMV.
Don't. Most of the stuff can be retrieved from the versioning system when needed so it's redundant to add. That would leave you with the description of the content of the file but that's part of the class documentation most of the time (or at least the documentation of the specific type).
I don't do any of those, but then again, I don't like the cruft.
We're required to put copyright information at the top of each file. I think dates, authors, and the name of the file is a waste of time.
We also have our source control system append check-in comments at the bottom of each file. I initially hated the change log, but over time I learned to like it. It really helps when merging changes.
I include the file name, a brief description of the file's purpose, and a $Id$ tag for CVS or Subversion purposes. File creator and date of creation can be found by checking the repository, so it's not needed.
File name is included because depending on what you're using to edit the file, that might not be entirely apparent when you're editing it. The description can be used to determine if a bit of code belongs in the file, or if it should be moved to another. And of course, $Id$ gives you last change time, and last editor.
Embedding check-in messages is only useful when the message is useful, and only if the file is updated once and a while. Including every message will simply bloat the file to the point where there's more comments describing changes than there is actual code. Best to leave that to the repository as well; often it's only a short command line to get the file's check-in log.
If you're stuck with a revision control system that can't keep history for moves and copies, in that case just reference the original file and its version number. Of course, if you're using a system that was created sometime in this century and not the last, that shouldn't be an issue.
I used to like putting version control keywords in the header of file. But recovered from that affliction. :) For two reasons:
Nobody put comments in that are of any use. You always wind up looking at the diffs reported by the version control system.
It creates a nightmare in trying to diff large filesets because the keywords create differences that are the only difference in the file.
Originally answered here, but since deleted: 134249
I would only put two things:
licensing/copyright information
comments required by documentation-generating tools (i.e., the comments have to be in the header to work - otherwise, they should go in the definition files)
Anything else is unnecessary fluff that won't be maintained, and will eventually become worse than nothing at all.
At the time I worked for a large defense company, and we had draconian coding standards. If you followed them to the letter (and most people don't), most of your headers would be composed mostly of that meaningless fluff. Doubly worse is that the exact same fluff is required to be placed in source files as well, which means two copies of the fluff gets out of date and becomes misleading.
I don't embed the date because it's redundant. If someone wants to know the date a file was created don't trust the author, trust your source control system. It should be the defintive answer for the date of creation.
I'm definately not against embedding check in messages though. Those are pretty useful.
We use our RCS to automatically stamp the following on the file:
Copyright,
RCS file name,
Date modified,
Author of last change,
RCS revision number
I think this is very convenient. I really like having the file name automatically populated in each file, because it makes searching the solution for files very quick.
This is what i normaly put at the top of files:
///////////// Copyright © 2008 DesuraNET. All rights reserved. /////////////
//
// Project : [project name]
// File : [file name]
// Description :
// [TODO: Write the purpose of ... ]
//
// Created On: 11/12/2008 2:24:07 PM
// Created By: [name] <mailto:[email]>
////////////////////////////////////////////////////////////////////////////
and i set up a macro in vis to do add it in and fill in default info when i make a new file
If you're using CVS, check out it's keyword substitutions. They will help automate embedding that information.
Personally I stick this at the top of all of my source files:
// $Id$
Other informative comments I embed to be parsed with doxygen, if they relate to something specific (the file, the class, a type, etc).
i generally only add any "comment info" when...
i don't think i'll remember or its not obvious what something is doing
or
when i release the source code and i actually want others to be able to use/learn from it.
I usually include a description of the purpose of the code found in that file. Everything else seems to be handled elsewhere: dates and comments in source control, etc.
Everyone is saying that your source control will have the date and programmer info, but that isn't always true. I worked in a shop that used Source Safe, and it was fine until someone decided to move a file to a different location. At that point, it essentially became a new file according to SS, and no previous history existed.
Perhaps because of that, the programmer name and date were automatically added to the comment section at the top of the file. When there got to be more than about 10 entries, we'd strip out all of the middle ones, leaving only the original date and author, and the current information.
A copyright statement for my client ;-)
We use MSVC & VSS and have a plugin that adds any comment you specifiy at check-in to the file that's being checked in as a comment. It's very convinient to look at the top of the CPP file to find out the bug-tracking ticket number that a change was made for.
I use Subversion.
Here's what I like to put near to the top.
$Id$
$HeadURL$
That substitutes the revision, last editor, and then the location of the file in the repository. Although I always work from working copies, this lets me print/email a file and look at it later to know exactly where it came from. $HeadURL$ especially is nice because it tells what project and branch the file is in and how to get to it (nice with larger nested subpackages and the like).
Agreed on the uselessness of big manual comment blocks — although docstrings/Javadocs are recommended — and on automatically appending the commit log.
It sounds like some of you are using terrible VCSes, if you are getting diffs or merge conflicts generated by the keywords themselves. Subversion handles it well.