Fixing . in filenames

A couple of days ago, we had a problem with . in filenames. My solution was to manually amend the commit email. Today, I fixed the code after it happened again. This is a good thing.

Compare this screen shot with the real commit (may not be fixed in prod yes, but has been in dev).

The fix is straight forward, but perhaps not fool proof:

$ cvs di xml_munge.pm
Index: xml_munge.pm
===================================================================
RCS file: /home/repositories/freshports-1/scripts/xml_munge.pm,v
retrieving revision 1.12
diff -r1.12 xml_munge.pm
472a473,478
> 	# sometimes, we see . in pathnames.  e.g 201205262318.q4QNI7EZ020858@repoman.freebsd.org & 201205262318.q4QNI7EZ020858@repoman.freebsd.org
> 	# e,g ports/./devel/kdevelop-kde4/Makefile
> 	# this step reduces those pathnames to something we can use
> 	
> 	$FilePath =~ s#/./#/#;

NOTE: as crees correctly pointed out: you should still use s#/\./#/# in case we happen to introduce a one-letter category

Based on that, I made this change and retested it on one of the commits:

$ cvs di xml_munge.pm
Index: xml_munge.pm
===================================================================
RCS file: /home/repositories/freshports-1/scripts/xml_munge.pm,v
retrieving revision 1.13
diff -r1.13 xml_munge.pm
480c480
< 	$FilePath =~ s#/./#/#;
---
> 	$FilePath =~ s#/\./#/#;

Using the fix up method described in the previous article, I checked each level of the descendants from ‘.’ to see if they were used in any commits.

NOTE: you will see references to 248112 below. This was SQL used in the previous article (i.e. copy/paste) , and does not affect the result set of the SQL.

freshports.org=# select * from element where parent_id in (select id from element where name = '.' and id != 248112);
   id   | name  | parent_id | directory_file_flag | status 
--------+-------+-----------+---------------------+--------
 429213 | www   |    429183 | D                   | A
 429184 | devel |    429183 | D                   | A
(2 rows)

freshports.org=# select * from element where parent_id in (select id from element where parent_id in (select id from element where name = '.' and id != 248112));
   id   |       name        | parent_id | directory_file_flag | status 
--------+-------------------+-----------+---------------------+--------
 429214 | rekonq            |    429213 | D                   | A
 429205 | kdevplatform      |    429184 | D                   | A
 429201 | kdevelop-php      |    429184 | D                   | A
 429197 | kdevelop-php-docs |    429184 | D                   | A
 429191 | kdevelop-pg-qt    |    429184 | D                   | A
 429185 | kdevelop-kde4     |    429184 | D                   | A
(6 rows)

freshports.org=# select * from commit_log_elements where element_id in( select id from element where parent_id in (select id from element where parent_id in (select id from element where name = '.' and id != 248112)));
 id | commit_log_id | element_id | revision_name | change_type 
----+---------------+------------+---------------+-------------
(0 rows)

freshports.org=# select * from element where parent_id in (select id from element where parent_id in (select id from element where parent_id in (select id from element where name = '.' and id != 248112)));
   id   |   name    | parent_id | directory_file_flag | status 
--------+-----------+-----------+---------------------+--------
 429192 | Makefile  |    429191 | F                   | A
 429193 | distinfo  |    429191 | F                   | A
 429194 | files     |    429191 | D                   | A
 429196 | pkg-plist |    429191 | F                   | A
 429206 | Makefile  |    429205 | F                   | A
 429207 | distinfo  |    429205 | F                   | A
 429208 | files     |    429205 | D                   | A
 429212 | pkg-plist |    429205 | F                   | A
 429202 | Makefile  |    429201 | F                   | A
 429203 | distinfo  |    429201 | F                   | A
 429204 | pkg-plist |    429201 | F                   | A
 429215 | Makefile  |    429214 | F                   | A
 429216 | distinfo  |    429214 | F                   | A
 429217 | files     |    429214 | D                   | A
 429219 | pkg-plist |    429214 | F                   | A
 429198 | Makefile  |    429197 | F                   | A
 429199 | distinfo  |    429197 | F                   | A
 429200 | pkg-plist |    429197 | F                   | A
 429186 | Makefile  |    429185 | F                   | A
 429187 | distinfo  |    429185 | F                   | A
 429188 | files     |    429185 | D                   | A
 429190 | pkg-plist |    429185 | F                   | A
(22 rows)

freshports.org=# select * from commit_log_elements where element_id in ( select id from element where parent_id in ( select id from element where parent_id in (select id from element where parent_id in (select id from element where name = '.' and id != 248112))));
   id    | commit_log_id | element_id | revision_name | change_type 
---------+---------------+------------+---------------+-------------
 1854331 |        435665 |     429219 | 1.10          | M
 1854328 |        435665 |     429215 | 1.14          | M
 1854329 |        435665 |     429216 | 1.10          | M
(3 rows)

freshports.org=#

Oh damn. There are some elements used. Which commit was that?

freshports.org=# select * from commit_log where id = 435665;   id   |                   message_id                    |      message_date      |                      message_subject                       |          date_added           |      commit_date       | committer |   description    | system_id | encoding_losses 
--------+-------------------------------------------------+------------------------+------------------------------------------------------------+-------------------------------+------------------------+-----------+------------------+-----------+-----------------
 435665 | 201205262324.q4QNOLJF021342@repoman.freebsd.org | 2012-05-26 23:24:21+00 | cvs commit: ports/./www/rekonq Makefile distinfo pkg-plist | 2012-05-26 23:25:04.456674+00 | 2012-05-26 23:24:21+00 | rakuco    | Update to 0.9.2. |         1 | f
(1 row)

freshports.org=# 

Oh. This commit was also affected. I will run that through the system again.

freshports.org=# begin;
BEGIN
freshports.org=# delete from commit_log where message_id = '201205262324.q4QNOLJF021342@repoman.freebsd.org';DELETE 1
freshports.org=# select * from commit_log_elements where element_id in ( select id from element where parent_id in ( select id from element where parent_id in (select id from element where parent_id in (select id from element where name = '.' and id != 248112))));       
 id | commit_log_id | element_id | revision_name | change_type 
----+---------------+------------+---------------+-------------
(0 rows)

freshports.org=# commit;
COMMIT
freshports.org=# 

Then I reran that commit:

dan@ngaio:~/FreshPorts/freshports.org/msgs/FreeBSD/recent] $ grep -l 201205262324.q4QNOLJF021342@repoman.freebsd.org *
2012.05.26.23.25.00.81448.txt.loading
2012.05.26.23.25.00.81448.txt.raw
2012.05.26.23.25.00.81448.txt.xml
[dan@ngaio:~/FreshPorts/freshports.org/msgs/FreeBSD/recent] $ mv 2012.05.26.23.25.00.81448.txt.* BAD_PATHNAME/
[dan@ngaio:~/FreshPorts/freshports.org/msgs/FreeBSD/recent] $ cp BAD_PATHNAME/2012.05.26.23.25.00.81448.txt.raw ../incoming/2012.05.26.23.25.00.81448.txt
[dan@ngaio:~/FreshPorts/freshports.org/msgs/FreeBSD/recent] $ 

After that, with the patch in place, the commit was correctly processed.

Continuing with the checking of the tree for any commits that reference elements under the . node:

freshports.org=# begin;
BEGIN
freshports.org=# select * from element where parent_id in (select id from element where parent_id in (select id from element where parent_id in (select id from element where parent_id in (select id from element where name = '.' and id != 248112))));
   id   |                        name                        | parent_id | directory_file_flag | status 
--------+----------------------------------------------------+-----------+---------------------+--------
 429209 | patch-plugins__subversion__kdevsvncpp__context.cpp |    429208 | F                   | D
 429210 | patch-plugins__subversion__kdevsvncpp__path.cpp    |    429208 | F                   | D
 429211 | patch-util__dbus_socket_transformer__main.cpp      |    429208 | F                   | A
 429195 | patch-CMakeLists.txt                               |    429194 | F                   | A
 429189 | patch-git_6b95b83                                  |    429188 | F                   | A
 429218 | patch-src__main.cpp                                |    429217 | F                   | D
(6 rows)

freshports.org=# select * from commit_log_elements where element_id in (select id from element where parent_id in (select id from element where parent_id in (select id from element where parent_id in (select id from element where parent_id in (select id from element where name = '.' and id != 248112)))));
 id | commit_log_id | element_id | revision_name | change_type 
----+---------------+------------+---------------+-------------
(0 rows)

freshports.org=# 

OK, good. There are no elements under . which are referenced by any commit. We can delete.

freshports.org=# delete from element where name = '.';
DELETE 1
freshports.org=# commit;
COMMIT
freshports.org=# 

Done. I will be fixing up beta and www soon.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

2 thoughts on “Fixing . in filenames”

Leave a Comment

Scroll to Top