Re: Linking of a derived file that was a project file

Peter Miller <[email protected]>
Newsgroups gmane.comp.version-control.aegis.user
Message-ID <[email protected]>
On Wed, 2012-04-11 at 15:19 +1000, Richard Walker wrote: 
> Any word on whether this defect I reported last July was fixed?
> (Or if it wasn't, will it be?)

Does the attached patch fix the problem?
Can you supply a test script?


-- 
Regards
Peter Miller <[email protected]>
/\/\*        http://miller.emu.id.au/pmiller/

PGP public key ID: 1024D/D0EDB64D
fingerprint = AD0A C5DF C426 4F03 5D53  2BDB 18D8 A4E2 D0ED B64D
See http://www.keyserver.net or any PGP keyserver for public key.

"Projects promoting programming in 'natural language' are intrinsically
doomed to fail." -- Edsger Dijkstra

_______________________________________________
Aegis-users mailing list
[email protected]
http://lists.auug.org.au/listinfo/aegis-users
patch.txt (text/plain, 5.8 KB)
MIME-Version: 1.0
Content-Type: application/aegis-patch
Subject: aegis.4.25 - aedb vs aeb vs removed file
Content-Name: aegis.4.25.C670.patch
Content-Disposition: attachment; filename=aegis.4.25.C670.patch
X-Aegis-Project-Name: aegis.4.25
X-Aegis-Change-Number: 670

#
#	Summary:
#	aedb vs aeb vs removed file
#
#	Description:
#	This change set fixes a problem where aedb and aeb do not treat
#	symbolic links to (restored) derived files in the same way.
#	My thanks to Richard Walker <[email protected]> for reporting
#	this problem, and diagnosing the problem.
#
# Aegis-Change-Set-Begin
# QlpoMzFBWSZTWXDayIMAAGdfgAAQUGf+70ACFI6//9/qMAFgxQaJPSYRqaeSNGQmJtCaDI9I
# 2pjAADQABk0AAAaAaaQCU8ZBDUMg0PUAAHlNedmYDEyLYaAdfu/j2HMjPAp0wM06Qelc60UG
# 756Fv6JQcFBbcfmo2BFlAMws26kqQCP+zg3h1SNXelT7+XKriwQZfzudetsmJ1MPtMXSSbQQ
# LNhymWatmpT9NtNCA2Nsaon60uwqxd+KUtw7kHUwoW3Sszp73lkyzfXGeho2s0Twa0JEbZp6
# w8tO70mFFNQVFyo5slq9AUuCrh4KyK21jtuxCINpW1sEZqlq6U33sfBoe5DJmxMa92dG5FLs
# BsMSI/jF2iZBHTos7xphWW1M5knDGQUFFiNw55MjVEXJe8pxQ9vRjPfAMAbZm0arB4D0l+rT
# hIOAIJNUY4i6KWTtcBKtsaxndGGQpieJkXZEI9epwl4lKQcMpG55K31KK9aLOxwWbI0WjwCV
# zrRkIYRAZxlkagL7OQXNEiA5L5myVZWq2IdooYjTq7KsSH+LuSKcKEg4bWRBgA==
# Aegis-Change-Set-End
#
Index: libaegis/change/build/symlinks.cc
--- libaegis/change/build/symlinks.cc
+++ libaegis/change/build/symlinks.cc
@@ -1,6 +1,6 @@
 //
 // aegis - project change supervisor
-// Copyright (C) 1999, 2001-2008, 2011 Peter Miller
+// Copyright (C) 1999, 2001-2008, 2011, 2012 Peter Miller
 // Copyright (C) 2007-2009 Walter Franzini
 //
 // This program is free software; you can redistribute it and/or modify
@@ -239,7 +239,7 @@
     switch (errno_old)
     {
     case EPERM:
-        // The filesystem containing the desitination does not support
+        // The filesystem containing the destination does not support
         // the creation of symbolic links.
     case ENOSYS:
         // This operating doesn't grok symlinks.
@@ -505,9 +505,62 @@
 
     case dir_stack_walk_file:
         trace(("dir_stack_walk_file\n"));
+        bool file_restored = false;
+        if
+        (
+            (
+                sip->style->derived_file_link
+            ||
+                sip->style->derived_file_symlink
+            ||
+                sip->style->derived_file_copy
+            )
+        &&
+            p_src
+        &&
+            (p_src->action == file_action_remove)
+        )
+        {
+            //
+            // Ralph Smith: If the visible file is shallower than the
+            // removal, then it has presumably been restored as a
+            // derived file.  If it is stale, the user gets to deal with
+            // it.
+            //
+            // Can't use project_file_path() for a removed file.
+            // Is there a simpler way to do this?
+            //
+            int rem_depth = 1;
+            project *ptmp;
+            fstate_src_ty *tmp_src;
+            for
+            (
+                ptmp = pp->is_a_trunk() ? 0 : pp->parent_get();
+                ptmp;
+                ptmp = (ptmp->is_a_trunk() ? 0 : ptmp->parent_get())
+            )
+            {
+                sip->up->become_end();
+                tmp_src = ptmp->file_find(path_rel, view_path_simple);
+                sip->up->become_begin();
+
+                if (tmp_src && tmp_src->action == file_action_remove)
+                    rem_depth++;
+                else
+                    break;
+            }
+            trace(("rem_depth: %d\n",rem_depth));
+            if (rem_depth >= depth)
+                file_restored = true;
+        }
         if (top_level_symlink)
         {
             trace(("top level symlink\n"));
+            if (file_restored)
+            {
+                trace(("symlink to a restored derived file"));
+                goto done;
+            }
             if (c_src)
             {
                 switch (c_src->action)
@@ -853,55 +906,6 @@
             }
             goto done;
         }
-        bool file_restored = false;
-        if
-        (
-            (
-                sip->style->derived_file_link
-            ||
-                sip->style->derived_file_symlink
-            ||
-                sip->style->derived_file_copy
-            )
-        &&
-            p_src
-        &&
-            (p_src->action == file_action_remove)
-        )
-        {
-            //
-            // Ralph Smith: If the visible file is shallower than the
-            // removal, then it has presumably been restored as a
-            // derived file.  If it is stale, the user gets to deal with
-            // it.
-            //
-            // Can't use project_file_path() for a removed file.
-            // Is there a simpler way to do this?
-            //
-            int rem_depth = 1;
-            bool looking = true;
-            project *ptmp;
-            fstate_src_ty *tmp_src;
-            for
-            (
-                ptmp = pp->is_a_trunk() ? 0 : pp->parent_get();
-                ptmp && looking;
-                ptmp = (ptmp->is_a_trunk() ? 0 : ptmp->parent_get())
-            )
-            {
-                sip->up->become_end();
-                tmp_src = ptmp->file_find(path_rel, view_path_simple);
-                sip->up->become_begin();
-
-                if (tmp_src && tmp_src->action == file_action_remove)
-                    rem_depth++;
-                else
-                    looking = false;
-            }
-            trace(("rem_depth: %d\n",rem_depth));
-            if (rem_depth >= depth)
-                file_restored = true;
-        }
 
         if (p_src && !file_restored)
         {
@@ -1289,3 +1293,6 @@
     derived_symlinks = NULL;
     trace(("}\n"));
 }
+
+
+// vim: set ts=8 sw=4 et :
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.