User to user discussion and support for UltraEdit, UEStudio, UltraCompare, and other IDM applications.

Help with setting up and configuring custom user tools in UltraEdit (based on command line input)
15 posts Page 1 of 1
Hello,

Although I'm not really a developper, I often do work on small programs/scripts, and so would need some source control so I can try different things while keeping a history of steps I tried.

A real SCM, even as light as Fossil, seems a pretty heavy solution, and saving a file manually through eg. File > Make Copy/Backup > make new name with date+time > Save is a bit annoying.

I was wondering if someone had built some add-on to UltraEdit so that I could simply hit a menu item, and the current file would be saved as a revision and let me go on while providing a history of the changes I made at each milepoint?

Thank you.
UltraEdit has built-in support for version backup. Once enabled every save results in creating a new backup with a new version number. See Advanced - Configuration - File Handling - Backup.
Thanks, I didn't know UE could do that.

However, is there a way to manually save a new version? I hit CTRL-S very often just in case XP crashes, but I don't want to create a new version every time.
fredtheman wrote: However, is there a way to manually save a new version?

Yes, with a VBS or BAT file executed as a user tool with "%f" on the command line and option Save active file enabled. The user tool can be added to the toolbar or executed by hotkey. The VBS or BAT file has to find out itself the next number for the file with the name passed to the VBS or BAT file to create a copy of it with a new number.

But you have to take into account that the VBS or BAT file creates a copy of the just saved file and not of the last saved file before saving the file as UltraEdit does with version backup. So the last version backup created by the VBS or BAT file is equal the saved file when you close UltraEdit after running the user tool to create a version backup manually.

BTW: UltraEdit can restore file content on crash of UltraEdit or Windows. So it is quite safe to not save a modified file for hours because the temporary file used in the background is updated on hard disk nevertheless often (more or less on every change). You could also use automatic save in regular intervals if you want your files often saved for safety. As you can see on the options of version backup, UltraEdit does by default not create a version backup on automatic save. It is necessary to additionally enable version backup on automatic save.
Thanks for the tip. I'll check it out.
fredtheman wrote: I was wondering if someone had built some add-on to UltraEdit so that I could simply hit a menu item, and the current file would be saved as a revision and let me go on while providing a history of the changes I made at each milepoint?

I'd use either Subversion or Git. It's not quite a drop-in solution; a little configuration would be required.
Both can be integrated into UE by creating user tools (under Advanced->Tool Configuration) to invoke the command-line programs for whatever functionality you want. (commit, revert, etc.)
Thanks for the idea. The problem is that even a very simple SCM like Fossil requires sending different commands:

  1. Make a connection to the repository (C:\fossil.exe open c:\repo)
  2. If this is a new file, add it from UE into the repository (C:\fossil.exe add c:\Ultra Edit\myfile.txt)
  3. Check in the file before making some changes (C:\fossil.exe commit), which requires adding a comment
How do you guys use an SCM with UE? Is there an easier way?
fredtheman wrote: How do you guys use an SCM with UE?

The only SCM I currently have integrated into UE is ClearCase. I have user tools for
  • checkout: cleartool checkout -nc "%f"
  • checkin: cleartool checkin "%f"
  • revert: cleartool uncheckout -rm "%f"
  • ...and a few others
I created a custom toolbar and added these user tools to it (the icons are cribbed from ClearQuest).
clearquest_toolbar.png
Custom toolbar for ClearQuest user tools
clearquest_toolbar.png (1.25 KiB) Viewed 8821 times

You could do something similar for SVN. You wouldn't need a "checkout" command, the checkin command would be svn commit "%f", etc. Note that SVN supports file:/// URLs for repositories. That means that your repo can be a local folder. You don't need a server process and don't need to connect to anywhere. You would need to create a repository up front and create a "checkout" of it in another folder (wherever you want to work from). After that you would just add files/commit changes.

Using a real SCM is far superior to numbered extensions or folders and only slightly harder to set up.

If you're willing to forgo UE integration Tortoise SVN is pretty nice. It integrates into Windows Explorer as a shell extension. You still have to create a repo and initial checkout, but it's more user-friendly than using command-line utilities. You would do all SVN actions in Explorer instead of UE. (Tortoise SVN doesn't have the command-line utilities necessary to support UE integration. You could install the base SVN utilities to do it but then you have to be careful to keep the versions of SVN and Tortoise in sync.)
Thanks much for the feedback.

After playing with Fossil, I think it could be good enough for what I need. I don't mind keeping all UE-editable files on a given partition, so I just need to create a new repository at the root of the partition, "open" it once, and from then on, I just need to add new files/commit existing files for Fossil to handle versioning.

Just one thing, though: Since adding a file that is already in the repository does nothing negative, I can simplify things in UE by simply calling the two commands one after the other, ie. Add, followed by Commit.
But is it possible to call two commands in the "Command Line" item in the Tool Configuration dialog? Something like "fossil.exe add "%f" ; fossil.exe commit -m "some comment"".

I suspect it's not possible, in which case I'll have to write a script and call it through the Advanced menu.

Thank you.
fredtheman wrote: But is it possible to call two commands in the "Command Line" item in the Tool Configuration dialog? Something like "fossil.exe" add "%f" ; fossil.exe commit -m "some comment".

It is not possible to run two commands from a command line in one user tool. But you can call a batch file which executes both commands.

Command line of user tool: "Path to batch file\AddAndCommit.bat" "%f"

Content of AddAndCommit.bat:

@echo off
fossil.exe add %1
fossil.exe commit -m "some comment"


%1 references the first parameter of the batch file which is the full file name in double quotes according to command line of the user tool.
Thanks, it worked fine without displaying the DOS box. I'll just add a second command to the UE menu so I can go back to the previous revision in case what I tried didn't work.

I have another question: I'd like to add a "Revert" item in UE, so the user can... discard the changes he made to the live file and revert to the last revision in the repository.

Problem is, Fossil requires passing the full path to the file, but without the drive name.

For instance, after adding "d:\some\where\myfile.txt" to the repository, its path in the repo is "some/where/myfile.txt", so if I want to retrieve the latest revision, I must type:

Code: Select all
c:\fossil.exe revert "some/where/myfile.txt"

According to the CHM help file, in the "Tool Configuration command (Advanced menu)", UE (15.10) doesn't provide the full path to a file without its prepented drive name.

Does the latest version of UE provide this, or must I write a second batch file to remove the drive name?

Thank you.
Again no problem with a batch file:

@echo off
set FileName=%~pnx1
set FileName=%FileName:~1%
set FileName=%FileName:\=/%
c:\fossil.exe revert "%FileName%"
set FileName=


First line converts first parameter string from "d:\some\where\myfile.txt" to \some\where\myfile.txt

Second line removes the first backslash. Third line replaces every backslash by a slash.

Because the string value of environment variable FileName does not contain anymore double quote characters around the UNIX file name with path without drive letter, it is necessary to use double quote characters in the call of fossil.exe in case the string contains a space anywhere inside.


Where to get the information to manipulate strings in a batch file?

Execute in UltraEdit Advanced - DOS Command with the command for /? to get help of DOS command for captured by UltraEdit into a text file and read that help to understand %~pnx1.

Execute in UltraEdit Advanced - DOS Command with the command set /? to get help of DOS command set captured by UltraEdit into a text file and read that help to understand %FileName:~1% and %FileName:\=/%.
Thanks a bunch. I can now successfully try something in a script file, and either commit or revert back to the previous revision :)
It would be nice if UE would detect then add Menu & toolbars for detected Version Controls. Like TortoiseSVN, TortoiseGit, TortoiseHg, TortoiseCVS.

I'm just getting started with playing with TortoiseGit...and well there are a lot of actions...and probably a godly amount of variations that I don't currently have accounted for.

Anyways to save others some effort here is a list of what I cobbled together...and well you'll have to pick and choose since I think you can only have like 29 or so User Tools, and I have 41 thus far. :(

Code: Select all
?Not sure of Use?
=================
:conflicteditor


Working Directory: "%p"


Add Files
TortoiseGitProc /command:add

Bisect
TortoiseGitProc /command:bisect /start

Blame
TortoiseGitProc /command:blame /path:"%f" /line:%line%

Branch
TortoiseGitProc /command:branch

Cat
TortoiseGitProc /command:cat /path:"%f" /savepath:"%pRevision\%n%e" /revision:%modify%

CleanUp
TortoiseGitProc /command:cleanup

Clone
TortoiseGitProc /command:clone

Commit
TortoiseGitProc /command:commit

Daemon
Command: TTortoiseGitProc.exe /command:daemon

Diff
TortoiseGitProc /command:diff /path:"%f"

Export
TortoiseGitProc /command:export

Fetch
TortoiseGitProc /command:fetch

Help
TortoiseGitProc /command:help

Ignore File
TortoiseGitProc /command:ignore /path:"%f"

Ignore Folder
TortoiseGitProc /command:ignore

Log
TortoiseGitProc /command:log

Merge
TortoiseGitProc /command:merge

Pull
TortoiseGitProc /command:pull

Push
TortoiseGitProc /command:push

Rebase
TortoiseGitProc /command:rebase

Reference Browse
TortoiseGitProc /command:refbrowse

Reference Log
TortoiseGitProc /command:reflog

Remove File
TortoiseGitProc /command:remove /path:"%f"

Remove Folder
TortoiseGitProc /command:remove

Rename File
TortoiseGitProc /command:rename /path:"%f"

Repo Browser
TortoiseGitProc /command:repobrowser

Repo Create
TortoiseGitProc /command:repocreate

Repo Status
TortoiseGitProc /command:repostatus

Resolve File
TortoiseGitProc /command:resolve /path:"%f"

Revert File
TortoiseGitProc /command:revert /path:"%f"

Revision Graph
TortoiseGitProc /command:revisiongraph

Settings General
TortoiseGitProc /command:settings

Settings Repo
TortoiseGitProc /command:settings

Show & Compare Differences
TortoiseGitProc /command:showcompare

Stash Apply
TortoiseGitProc /command:stashapply

Stash Pop
TortoiseGitProc /command:stashpop

Stash Save
TortoiseGitProc /command:stashsave

SubModule Add
TortoiseGitProc /command:subadd

SubModule Sync
TortoiseGitProc /command:subsync

SubModule Update
TortoiseGitProc /command:subupdate

Switch/Checkout
TortoiseGitProc /command:switch

Synchronize
TortoiseGitProc /command:sync

Check for Updates
TortoiseGitProc /command:updatecheck /visible


For some reason I haven't gotten /command:conflicteditor to work.

Anyways most of these will work with minor editing for the other Version Control app's I have listed at the top.

**Update**

TortoiseSVN entries.

Code: Select all
?Not sure of Use?
=================
:conflicteditor

Not using
=================
:rebuildiconcache
:showcompare


Working Directory: "%p"


Add Files
TortoiseProc /command:add /path:"%p"

Blame
TortoiseProc /command:blame /path:"%f" /line:%line%

Cat
TortoiseProc /command:cat /path:"%f" /savepath:"%pRevision\%n%e" /revision:%modify%

CheckOut
TortoiseProc /command:checkout /path:"%p"

CleanUp
TortoiseProc /command:cleanup /path:"%p"

Commit
TortoiseProc /command:commit /path:"%f"

Copy
TortoiseProc /command:copy /path:"%f"

Create Patch
TortoiseProc /command:createpatch /path:"%p"

Diff
TortoiseProc /command:diff /path:"%f"

Drop Export
TortoiseProc /command:dropexport /path:"%p" /droptarget:"%modify%" /overwrite

Drop Vendor
TortoiseProc /command:dropvendor /path:"%p" /droptarget:"%modify%"

Export
TortoiseProc /command:export /path:"%p"

Help
TortoiseProc /command:help

Ignore Files
TortoiseProc /command:ignore /path:"%f"

Import
TortoiseProc /command:import /path:"%p"

Lock File
TortoiseProc /command:lock /path:"%f"

Lock Files
TortoiseProc /command:lock /path:"%p"

Log
TortoiseProc /command:log /path:"%p"

Merge
TortoiseProc /command:merge /path:"%p"

Merge All
TortoiseProc /command:mergeall /path:"%p"

Properties
TortoiseProc /command:properties /path:"%p"

Relocate
TortoiseProc /command:relocate /path:"%p"

Remove
TortoiseProc /command:remove /path:"%p"

Rename
TortoiseProc /command:rename /path:"%f"

Repo Browser
TortoiseProc /command:repobrowser /path:"%p"

Repo Create
TortoiseProc /command:repocreate /path:"%p"

Repo Status
TortoiseProc /command:repostatus /path:"%p"

Resolve File
TortoiseProc /command:resolve /path:"%f"

Revert File
TortoiseProc /command:revert /path:"%f"

Revision Graph
TortoiseProc /command:revisiongraph /path:"%p"

Settings
TortoiseProc /command:settings

Switch
TortoiseProc /command:switch /path:"%p"

Unlock File
TortoiseProc /command:unlock /path:"%f"

Unlock Files
TortoiseProc /command:unlock /path:"%p"

Update to Revision...
TortoiseProc /command:update /path:"%p" /rev


**Update**

TortoiseHg Entries
Code: Select all
Not using
=================
about
shellconfig
thgstatus
version


Working Directory: "%p"


Add
thg add

Archive
thg archive

Backout
thg backout

Bisect
thg bisect

Blame
thg blame "%f" --line %line%

Bookmark
thg bookmark

Clone
thg clone

Commit
thg commit

Drag Copy
thg drag_copy "%f" "%modify%"

Drag Move
thg drag_move "%f" "%modify%"

Email
thg email

Forget
thg forget

Graft
thg graft -r %modify%

Search
thg search

Guess
thg guess

Ignore
thg ignore

Import
thg import

Repo Create
thg init

Log
thg log

Manifest
thg manifest

Merge
thg merge -r %modify%

Post Review
thg postreview -r %modify%

Purge
thg purge

Rebase
thg rebase -s %modify% -d %modify%

Reject File
thg rejects "%f"

Remove File
thg remove "%f"

Rename
thg rename

Repo Config
thg repoconfig

Resolve
thg resolve

Revision Details
thg revdetails

Revert File
thg revert "%f"

Repository Update
thg rupdate

Start Server
thg serve

Shelve
thg shelve

Sign
thg sign

Status
thg status

Strip
thg strip

Synchronize
thg sync

Tag
thg tag

Update
thg update

User Config
thg userconfig

Visual Diff
thg vdiff
I came across a post on StackOverFlow while looking for a way to execute multiple commands in a single line in DOS...which is for an AutoIt script I'm helping to design for making it easier to do VCS in UltraEdit.

Anyways point being is that one right now wouldn't need to use a batch script for a more or less short bit of code.

Using Mofi's excellent example..it could be written like so:
Code: Select all
set /p FileName=%~pnx1 & set /p FileName=%FileName:~1% & set /p FileName=%FileName:\=/% & c:\fossil.exe revert "%FileName%" & set /p FileName=


Well you should...actually haven't tested it. :p

Anyways food for thought.
15 posts Page 1 of 1
cron