Showing posts with label version-control. Show all posts
Showing posts with label version-control. Show all posts

Thursday, June 21, 2018

Take Snapshot of Webpage and Compare To Source

Leave a Comment

EDITED BETTER VERSION OF MY QUESTION:

1) I want to be able to take a screenshot of a URL at two different times, compare the images, and highlight the differences, if any. Has to be done via a PHP-based web app.

2) I also want a user to be able to submit a URL, which then takes a screenshot, and then using a drawing tool, highlight the section of the URL that they wish to be monitored - much like VisualPing.io.

ORIGINAL QUESTION: I want to be able to monitor just a specific section of a web page (rather than entire page). So essentially, this is what what I want a user to be able to do in an app I'm creating:

1) Enter the URL of any web page in a form field and submit. 2) A snapshot of that URL is taken and image is shown on page. 3) They can then highlight just a section of that screenshot using an overlay (the part that they wish to monitor 4) System then stores that, then using cron, pings that URL, downloads source, compares ONLY the code of the section that user highlighted, then emails user if there's a change in that specific section.

Now, the parts that I'm not sure of, is...

a) How to let someone draw on an image on the website b) Then store that section and somehow connect it back to the source of the page, so that... c) later when a file_get_contents or curl of that URL is done and source is retrieved, then same section of source is compared to highlighted part of image.

See VisualPing.io - they already do this. I want similar functionality. There are already a couple of websites like VisualPing that do this, and I need to implement that for my project.

Sorry about the complex requirement. And this has to be done in PHP.

Thanks!

2 Answers

Answers 1

I do not think that you will find a ready solution to your problem.

But I can suggest what you should do.

Parse web pages via CLI. I usually used PhantomJS, but project development is stopped now. I used this solution in my pet project. So, you can install PhantomJS, implement .js script and call it from your PHP script. Then you can use output image as you wish. For example, you can compare this with a reference picture pixel by pixel.

Answers 2

It seems like you already found the solution at VisualPing.io.

I'm guessing you're looking for a free option and that's why you don't want to use VisualPing.

Wachete does the same thing. You can have them monitor up to 5 web pages on the free plan. And yes, you can select specific parts to of the page to watch for. Some other honorbale mentions if you will are (https://changetower.com/ and https://versionista.com/).

Read More

Friday, May 26, 2017

What's the difference between a 'delete' and 'unversion' in SVN?

Leave a Comment

I have a file that had been under revision control in SVN (I use tortoiseSVN). This file has become obsolete, thus I no longer want it to be in a working copy of my repo. However, it would probably be good to retain the history of that file.

I essentially want to 'delete' this file such that it is no longer tracked or 'versioned'. I have the option to either 'delete' this file, or 'unversion' this file.

What is the difference between 'delete' and 'unversion'. What the use cases for each command?

1 Answers

Answers 1

Removing a file from svn, does not delete its revision history.
Apparently deleting the history is possible [SO]: Delete file with all history from svn repository.

To make things easier let's consider the following analogy.
From svn's PoV, just like:

  • a (source) file consists of:
    • a sequence of items: lines (of code)

Same way:

  • a folder consists of:
    • a sequence of items: its children:
      • (sub)folders
      • files

Let's say that we have an svn file:

  • In revision M, a line of code (let's make it the last one to better illustrate the example) in that file was modified
  • In revision N (> M), that line was deleted

The situation is as follows:

  1. For file revisions greater than N, the line won't be present
  2. For file revisions between M and N, the line will have its last content
  3. For file revisions lower than M, the line will have its old content
  4. ....

Same thing would happen if removing a file (from its parent folder perspective).

Now, back to your question: on my TortoiseSVN (v1.9.5):

  • I have a Delete option
  • I don't have an Unversion option, but
  • I do have a Delete (keep local) option - which is (a better name maybe for) Unversion. In terms of command line, this is equivalent to svn delete --keep-local

After performing one of the actions on a file, that file will no longer be tracked by svn, but as opposed to Delete (where the file is also removed from the Working Copy/disk), Unversion will leave it on the disk just like the user would have manually copied it there (a subsequent svn st will "see" the file as not under version control: the first column will be a question mark (?) as described on [SVNBook]: svn status).

[TortoiseSVN]: Deleting, Moving and Renaming contains very little official info.

Personally, I see no use of keeping the local file except when fixing an error, e.g. removing previously committed items that don't belong in the repository (user specific) like:

  • Eclipse: .classpath, .project
  • PyCharm: .idea
  • VStudio: .vcxproj.user

Quote from [SVNBook]: svn delete:

Use the --keep-local option to override the default svn delete behavior of also removing the target file that was scheduled for versioned deletion. This is helpful when you realize that you've accidentally committed the addition of a file that you need to keep around in your working copy, but which shouldn't have been added to version control.

Read More

Monday, October 3, 2016

How can I manage my projects versions using Visual Studio 2012 Professional

Leave a Comment

I am working on developing an asp.net mvc web application , using visual studio 2012 professional. now when I want to update my project, for example by adding new features, I do the following steps:-

  • I copy the project folder.
  • past it inside a "versioning" folder.
  • work on the original project , were I add the new features and code.
  • now if I want to revert my project back before the new features, I can open the folder inside the "Versioning" folder. and so on...

now my current approach is some how sufficient.. but I am trying to find a more automated approach where I can for example revert certain file let say a certain .cs file to its previous version , or revert back my whole project to certain point.

so can anyone advice how Visual studio 2012 can help me in managing my versioning ? Thanks in advance for any help.

Regards

3 Answers

Answers 1

You'll want to use a version control system like Team Foundation Server (TFS), Git, Mercurial, Subversion, etc. I personally recommend Git. Many of them have a means of integration with Visual Studio 2012 (for example, see How to Connect Visual Studio 2012 with git (github)?). Version control software supports features such as tracking file changes, creating code branches, merging code from different commits/users back together, etc.

Here's what a very simple workflow might look like with version control (see https://guides.github.com/introduction/flow/ for an example of the GitHub flow):

  1. You're ready to add a new feature/start a new version. For simplicity we'll assume you're working on a single branch (e.g. Git "master" branch).
  2. As you program, you make incremental changes to you source code and commit those changes regularly. Each commit gives you a snapshot of the work you've done and you can go back to any commit at any point and compare the changes between commits. The VCS you choose will influence how you synchronize those changes with a central/remote repository. You can even check revision history and look at previous versions of specific files and your code is typically backed up on another server for you without much additional work.
  3. When you're ready to release, you could tag a specific revision (or merge features branches into master, or ... etc.). Whatever the case, you can keep track of all the cumulative changes you've made for each release and be able to revert back to any point.

There are a few other steps you may consider for versioning such as updating the assembly information. In the AssemblyInfo.cs file there is assembly metadata specifying the assembly version, file version (or informational version, which I prefer). See What is AssemblyInfo.cs used for?. You can configure Visual Studio to auto-increment the version numbers.

Team Foundation Server should be available by default with VS 2012, although I'm vague on the details of setting up a TFS server to host your repositories. Visual Studio added direct support for Git (open source, very popular) starting in VS 2013, however there is an extension available for 2012 (https://visualstudiogallery.msdn.microsoft.com/abafc7d6-dcaa-40f4-8a5e-d6724bdb980c). The extension allows you to perform some of the most used Git functions such as committing, branching, and pushing.

Here are some links to get you started:

Why should I use version control?

Using Git with Visual Studio

https://git-scm.com/download/win

https://tortoisegit.org/

https://www.visualstudio.com/en-us/products/tfs-overview-vs.aspx

Answers 2

I use VSTS and it is fantastic. You can use GIT or TFS version control. Both are hosted by Microsoft. I prefer Microsoft due to the idea of long term support and reliability. You can see they are supporting VS 2008 to current.

https://www.visualstudio.com/team-services/pricing/

It is also free for up to 5 users.

From the link posted below. It has full support for many versions of Visual Studio

Q: Which versions of Visual Studio can I use with Visual Studio Team Services?

A: You can use:

  • Visual Studio "15"
  • Visual Studio 2015
  • Visual Studio 2013
  • Visual Studio 2012
  • Visual Studio 2010, requires Service Pack 1 and KB2662296
  • Visual Studio 2008 SP1, requires GDR update To connect to Team Services with
  • Visual Studio 2008 through 2012

Start Visual Studio. From the Team menu or Team Explorer, go to Connect to Team Foundation Server > Select Team Projects > Servers. Add your Team Services account ({youraccount}.visualstudio.com). Select your team project, and finish connecting. If you get connection errors, try choosing HTTPS as your protocol.

https://www.visualstudio.com/en-us/docs/setup-admin/team-services/connect-to-visual-studio-team-services

GIT Vs TFS Version Control - https://www.visualstudio.com/en-us/docs/tfvc/comparison-git-tfvc

One thing to look into is how you visualize editing and checking in code. I personally find that TFS version control follows a very simple and linear model. I prefer it to git. But its really Apples vs Oranges and usually people like what they are used to. I will say that Git currently is in active development and is not as feature rich as TFS-VC. Not to mention VSTS hooks into their entire ecosystem of plugins, build systems, test infrastructure and all of their cloud platform "Azure"

Answers 3

If you dont need to be sharing your version controlled stuff, I like TurtleSVN. Its simple and I like the UI it has for displaying modifications between versions. It adds a choice on the right-click menu of any file or folder in windows explorer for "TurtleSVN" and then all of the operations can be handled from there.

Read More

Sunday, June 19, 2016

Notify about / check for SCM poll failure in Jenkins

Leave a Comment

I would like to check for or get notifications about SCM poll failures in Jenkins (for example, when the repository URL had changed, or branch got deleted). I thought about these:

a) A Jenkins console script, which would list such faulty jobs

b) Configuring/installing plugin for Jenkins to notify me somehow about that fact (e-mail, anything)

c) External script/executable (bash, python, ...), which would list builds which failed in last X hours due to SCM poll failure

0 Answers

Read More

Tuesday, April 19, 2016

Undoing the merge in Git so that no commits from the other branch exist

Leave a Comment

I've two branches: development, and bug_fixes, and I accidentally merged development branch in bug_fixes two to three weeks ago, and have been working on bug_fixes since then, and I've pushed the changes in bug_fixes.

Now, I need to un-merge the development branch. I want a pure bug_fixes branch with no commits form development branch. By googling, I've come up with the following scenarios:

1) Revert the commit that merged development branch in bug_fixes branch, but it partially did the job. The commits from development branch can still be seen in bug_fixes branch, something that isn't required.

2) Rebase, and delete the commit that did the merging, but it still has the same issue described in point 1. bug_fixes branch still contains the commits from development branch.

Is there a way I can delete the merging commit, and all those commits that came in bug_fixes branch form development branch, would be deleted as well? Or, it isn't possible?

4 Answers

Answers 1

IF you know which commits are coming from the development branch (in addition of the merge commit), you can do a git rebase -i (interactive rebase) from the last good commit of bug fixes:

 b--b--(B)--M--d--b--d--b--b (bugfix)            /     d--d--d  (devel)  git checkout bugfix git rebase -i (B) # drop M, d, and d   b--b--(B)--b'--b'--b' (bugfix)      d--d--d  (devel) 

The more complex alternative would be a git filter-branch, but hopefully, the interactive rebase is enough.

Answers 2

I would try the following approach:

First of all, make a list of the commits in both branches:

git checkout development git log --oneline > log-devel.txt  git checkout bug_fixing git log --oneline > log-bugfixing.txt 

Second, identify in each branch the id of the last commit before executing the merge. Let's name these commits devel-0 and bugfixing-0 Then, take your branches to the status they were before the accidental merge:

git checkout development git reset --hard <devel-0-hash>  git checkout bug_fixing git reset --hard <bugfixin-0-hash> 

At this point you have two clean but outdated git branches. Now, you should take from log-devel.txt and log-bugfixing.txt all the commits that are not included in the current branches, and add them to the corresponding branch. In order to add a commit with id abc0123 to your branch development you can use cherry pick:

git checkout development git cherry-pick `abc0123` 

Take into account that the commits should better be added to the clean branches in the same order they were added to the bug fixing branch, in order to minimize the number of conflicts appearing.

Answers 3

you need to know your latest commit message for bug_fixes before merge, if you know the sha hash then evne better.

now first you need to find the sha hash using the command

$ git reflog

the output is something like

1fb5738 HEAD@{10}: commit...

4d47df6 HEAD@{11}: commit...

5f32c4b HEAD@{12}: merge...

428f91d HEAD@{13}: checkout...

5f32c4b HEAD@{14}: checkout...

the first part is the sha hash. In this case the state before merge has hash value 428f91d

so now, in bug_fixes branch we reset to this hash value

git reset --hard 428f91d

now it is undone

Answers 4

Let me describe the scenario with an example below

Bug Fix branch: Revision 10

Merged Dev Branch: Revision 11

Multiple changes after merge: Revision 12 - Revision 15

-

Now there are 2 steps that needs to be done(Easy method Without git native commands)

  1. Go back to Revision 10

    Clone Latest code to a folder called "latest"

    Clone Revision 10 to a folder called "rev10"

    Remove all the content(except .git folder) from latest folder

    Copy all the content(except .git folder) from rev10 folder to latest folder

    Checking the latest folder content

Now the Bug fix branch will be having the content equal to Revision 10 without any developer branch changes

  1. Optional - Merging Revision 12 - Revision 15 to bug_fix branch

    As we have revert back to the old revision the latest commits to bugfix branch is also gone This revisions needs to be manually merged one by one back to bug fix branch

Read More

Friday, April 8, 2016

Is there a way to make git automatically retry commands if index.lock exists?

Leave a Comment

I use some of Xcode's source control features, specifically the blame feature in the main editor, but use git on the command line for all of my actual version control. This means that, fairly often, git commands on the command line fail with the message:

fatal: Unable to create '/path/to/repo/.git/index.lock': File exists. 

Xcode is creating this file to lock the repo as it runs its own git commands. I've already turned off all the unnecessary source control options in Preferences (Refresh local status automatically, Refresh server status automatically, and Add and remove files automatically.)

My current strategy is just to retry the command until it works, which rarely takes more than one attempt.

Is there a way to make Xcode any less aggressive with how often it creates index.lock?

Or, is there a way I can make git automatically retry commands until they succeed if they fail in this way?

5 Answers

Answers 1

I can make git automatically retry commands until they succeed if they fail in this way?

Not with native git: you would need to script a git command wrapper which will loop and essentially wait for index.lock to disappear (which is similar to the wait strategy described in the answers of "Git - fatal: Unable to create '/path/my_project/.git/index.lock': File exists")

That wrapper could:

  • include a timeout in order to not wait indefinitely,
  • try and search for a git process when the timeout and try and kill it, in order to finally free that lock.

That is what, for instance, an IDE like SublimeText does

root = git_root(self.get_working_dir()) if wait_for_lock and root and os.path.exists(os.path.join(root, '.git', 'index.lock')):     print("waiting for index.lock", command)     do_when(lambda: not os.path.exists(os.path.join(root, '.git', 'index.lock')),         self.run_command, command, callback=callback, show_status=show_status, filter_empty_args=filter_empty_args, no_save=no_save, wait_for_lock=wait_for_lock, **kwargs) 

Answers 2

Since this file is created and removed by git itself.
If you wish to remove it when its created you will need to set some "watch" on the file and when you see it to remove it.

A simple solution is to install some "watch" plugin which will "capture" when the file is created.

There are plenty of libraries and tools for this task.


Here is a list of few:

inotify-tools

inotify-tools is a C library and a set of command-line programs for Linux providing a simple interface to inotify. These programs can be used to monitor and act upon filesystem events


fswatch

fswatch is a file change monitor that receives notifications when the contents of the specified files or directories are modified.

Usage example:

fswatch -o ~/path/to/watch | xargs -n1 ~/script/to/run/when/files/change.sh 

watchdog

Python API and shell utilities to monitor file system events.

You can use the shell-command subcommand to execute shell commands in response to events:

watchmedo shell-command \     --patterns="*.lock" \     --recursive \     --command='rm index.lock' \     . 


You are a mac user but windows user can install any of the following programs which will monitor when file is created

https://www.raymond.cc/blog/3-portable-tools-monitor-files-folders-changes/

Answers 3

Like others said there is nothing native to git but the Chromium devs did a python script called git-retry that is called by a shell wrapper.

Instead of typing for example:

git commit you would type git-retry commit

You can get the tool from their tools repository by cloning it:

https://chromium.googlesource.com/chromium/tools/depot_tools.git

Answers 4

Here's my hacky patchy for this: a few lines of bash which waits till the lock file disappears and then runs your git commands. Race conditions are certainly possible, this isn't bullet proof but would work most of the time.

function retry {     while [ 1 == 1 ]; do         if test -f /path/to/repo/.git/index.lock; then             echo -n ".";             sleep 0.5;         else             "$@";             return;         fi       done } 

You could throw this into your ~/.bashrc for example then to use it:

retry git commit -m "ohhh yeaaaa" 

Cheers!

Answers 5

I used to use Xcode's git client, and it was consistently causing errors including this one, so I've stopped using Xcode to setup my workspaces or make commits. To enable this setup, I installed the git support from the Command Line Tools for Xcode X.x, and refer to an external git GUI for any commands that result in a change to my local or remote copy, including switching branches.

Since I've started using an external client, I've had no problems with an index.lock file. When performing rare operations, like resetting a remote branch, or renaming a branch, I use the terminal. There are a few high-quality git clients out there that are free, including SourceTree.

If you want to use an external git client with a new project in Xcode, simply do not opt-in to the git workspace option, if it is displayed. Instead, use your external git client to 'Add' an additional git workspace, and choose the root directory of the Xcode project.

As a side note, when I do this, I usually have a root directory for a lot of related miscellaneous files, and that is also the home of my Xcode project directory which is the root of my git workspace. This allows me to have notes, and other files that I don't want to be version-controlled.

Here's a typical setup:

     + Project Directory     ---+ Xcode project directory (git root)     ---- Other project files (not under source control) 

Hope that helps!

Read More