On 4 May 2010 15:19, Harry Putnam <rea...@newsguy.com> wrote: > Philip Potter <philip.g.pot...@gmail.com> writes: >> haven't explained *why* you are doing this comparison in this thread. >> [You might have done elsewhere, but I don't read every thread.] > Uri actually did (most of) it for me at one point in a recent post on > this thread. Message-ID: <87mxwgbvyo....@quad.sysarch.com> on > gmane.comp.lang.perl.beginners > > This is probably overly verbose... as I am not very good at explain > the full project simply. > > Project: Merge two directory structures that contain: > > Many files in one and not the other > But different thing have to happen in each structures case. > > 1) > A larger structure has many files not contained in a smaller > structure. Those files need to disappear. > > 2) > The smaller structure has many files not present in the larger > structure. Those files need to remain. > > NOTE: Those two chores are in hand... due to excellent examples > supplied here. > > 3) Of the remaining files: > Many of them have the same final (end name) but different > paths... besides the obvious difference of root path. > > b1/some/path/file (from larger hierarch) > b2/path/file (from smaller hierarch) > > But also there are many cases where the end name is the same but > the files themselves are different. (Those are handled through a > dispatch table of functions. One being to check the files size > and another supplies command line to diff the files.). In fact > usually the size is enough to make a choice. > > So, if they are the same file then the file from the larger > structure will be moved to new base and over the path of the > smaller structure.. That sounds too confusing but illustration will > show is not really: > > b1/some/path/file > b2/path/file > > b1 file will be moved to > b3/path/file > > Overwriting the file from b2. > > The final confusion is that all this is not really being done, but is > generating a list of cmds that will do the complete job. > > What will happen in the end is all of b2 will be left and all > identical files from b1 will overwrite there twin by being move to > the twins address. Whatever is in b1 that isn't in b2 at all will be > deleted.
Thank you harry for writing this. Can I ask some questions? You have path P1 and path P2. P1 has more files than P2, but P2 may contain files that P1 doesn't. You want to create P3, which is a merge of P1 and P2. But if a file is in P1 and not P2, that file gets ignored. Doesn't this mean P3 is identical to P2? If two files are identical, you want to copy the P1 version over the P2 version. If the files are identical, what effect will this copy have? > In step 1. rm (b1) [ files not in b2] remove from b1 those files which are in b1 but not in b2. ok. > step 2) add (b2) [ files not in b1 ] add to b2 those files which are in b2 but not in b1. --> Aren't they already in b2? > step 3) mv matching b1 over there twin in b2 move identical files from b1 over their twins in b2. --> If they are identical, why bother moving them? > The equivalent cmds will be carried out inside a Distributed > Versioning System called `git'. > > I'm not familiar yet with git. At least not much, but can generate a > list of cmds to be carrried out by that program. "git merge" probably does what you want in one command. Phil -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/