On Wed, February 27, 2008 9:22 am, Lan Barnes wrote:
>
> On Wed, February 27, 2008 1:21 am, Andrew Lentvorski wrote:
>> Lan Barnes wrote:
>>> I have two file trees (source code). I want to know the differences in
>>> file names in those trees. I don't care if the files themselves differ
>>> internally (I'm searching for new and deleted files between the two
>>> trees).
>>>
>>> I'm in Linux and have available all the usual utilities as well as p4.
>>> Also anything I can download.
>>>
>>> Closest I've come on my own so far is
>>>
>>> dir -Rx1 .
>>>
>>> Done in both trees, and diffed. But the output is complex.
>>
>> diff -cr dir1 dir2
>>
>> will give you the diffs, but also outputs lines like
>> "only in dir1: file.c"
>>
>> So:
>> diff -cr dir1 dir2 | grep -i only
>>
>>
>> Alternatvely:
>>
>> rsync -n dir1/ dir2/
>> rsync --dry-run dir1/ dir2/
>>
>> might also do something useful.
>>
>> -a
>
> Thanks.
>
> A working script is done, The "<" and ">" were quite adequate markers.
>
> Perforce does the syncing for us. As it is, we're much more interested in
> what p4 puts in the dirs than what rsync could.
>
> Script attached.
>
OK, even in-line text apparently gets stripped when attached.
Try this:
# a tcl proc that can diff two dirs and say what's new, deleted
set NewFiles [list ""]
set DeletedFiles [list ""]
proc diffDirs {dir1 dir2} {
global NewFiles DeletedFiles
cd $dir1
set cmd "find . -type f > /tmp/scmdir1.diff"
eval exec $cmd
cd $dir2
set cmd "find . -type f > /tmp/scmdir2.diff"
eval exec $cmd
catch {exec diff /tmp/scmdir1.diff /tmp/scmdir2.diff >
/tmp/scmfile.diff}
set DIFF [open /tmp/scmfile.diff r]
set LineList [split [read $DIFF] \n]
foreach Line $LineList {
regexp {^\s*(\S)\s+(\S+)} $Line match FirstChar FileName
if {![info exists match]} {
continue
}
if {$FirstChar == "\<"} {
lappend DeletedFiles $FileName
}
if {$FirstChar == "\>"} {
lappend NewFiles $FileName
}
}
set NewFiles [lrange $NewFiles 1 end]
set DeletedFiles [lrange $DeletedFiles 1 end]
}
Please note the complete lack of comments 8-))
Oh, and Darren will probably see lots of places to simplify. For example,
$FirstChar == "\>"
would almost certainly work just as well as
$FirstChar == >
--
Lan Barnes
SCM Analyst Linux Guy
Tcl/Tk Enthusiast Biodiesel Brewer
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list