1. Nathan Durnan
  2. TimeStampMod
Issue #29 resolved

Not restoring timestamp when commas in filename

aikidoibiza
created an issue

If a file has a comma anywhere in the name, although the timestamp is correctly recorded in .hgtimestamp, when cloning the repository that timestamp is not restored, but instead the current system time is set for that file. A workaround is changing the filename to another one without commas, but I think this should be fixed.

Comments (19)

  1. Nathan Durnan repo owner
    • changed status to open
    • changed version to 0.1.5

    Thank you for the issue report! You're absolutely right. I never imagined a use-case needing to deal with a filename that had commas in it. As such, the timestamp file was a simple comma-separated format. Without even looking into the code, I can almost guarantee that it is trying to interpret the part of the filename after the comma as the timestamp value.

    I have some downtime right now, so I will try to get this addressed today if possible. The one problem I foresee is that I will need to use a different character as the separator character for the timestamp file. A simple "|" character that windows does not allow in filenames should do the trick. The problem comes up when trying to keep the extension compatible with both the old CSV formatted timestamp file AND the "|" method. I imagine I will need to add some kind of version indicator to the beginning of the timestamp file.

    Also, I imagine this change will make merges a little more of a pain when dealing with a v0.1.5 (or earlier) file and one after this fix. But that should be a short-term headache when updating to the new version. Once all branches have been worked on with the new version of the extension, this headache should fade away. I ran into a similar issue with the solutions for Issue #21 (merging fix for timestamp file). The transition between the v0.1.1 timestamp file and the v0.1.2 sorted format was a little rough, but worked itself out after a few manual merges.

    So, with all that said, I'll get to work on this!

  2. Nathan Durnan repo owner

    Create _save_TimestampsJSON method to save the timestamp file in JSON format. See Issue #29 at BitBucket. Using JSON should allow for any type of filename, Plus it will allow convenient storing of file version.

    45085c23ae16

  3. Nathan Durnan repo owner

    Added _read_TimestampJSONRecords to use to read new JSON format timestamp file. See Issue #29 at BitBucket. _read_TimestampJSONRecords will still call the original _read_TimestampRecords when trying to access a non-JSON formatted file committed with a previous version.

    3eb5238c87b2

  4. aikidoibiza reporter

    1) Now, when committing to the repository, after having added a new file, or renamed it in the following example ("test, timestamp, with, commas.doble.punto" renamed to "test, timestamp, with, commas.doble, x.punto") for testing purposes, I get the following in a separate window:

    % hg add --repository C:\xampp\EXTRA\Sites\aikidoibiza C:\xampp\EXTRA\Sites\aikidoibiza\test, timestamp, with, commas.doble, x.punto
    [command completed successfully Mon Apr 23 09:42:08 2012]
    % hg remove --repository C:\xampp\EXTRA\Sites\aikidoibiza C:\xampp\EXTRA\Sites\aikidoibiza\test, timestamp, with, commas.doble.punto
    [command completed successfully Mon Apr 23 09:42:08 2012]
    % hg commit --repository C:\xampp\EXTRA\Sites\aikidoibiza --verbose --user Admin@Acer-TM5520 --message=Probando timestamp_mod C:\xampp\EXTRA\Sites\aikidoibiza\test, timestamp, with, commas.doble.punto C:\xampp\EXTRA\Sites\aikidoibiza\test, timestamp, with, commas.doble, x.punto
    TimestampMod|Wrap_Commit accessed!
    Executing timestamp_mod function
    ______
    Saving timestamps to JSON file...
    ------
    descriptor 'lower' requires a 'str' object but received a 'unicode'
    [command returned code 255 Mon Apr 23 09:42:08 2012]
    

    If I try again for a second time, the command completes successfully without errors or warnings.

    2) The extension does not record the timestamp for the .hgtimestamp file, I don't know if this makes sense though.

    3) File dates are now restored successfully, even in the case of having commas in the filename.

    4) I know that Mercurial doesn't keep folder information, but the extension could anyway save and restore the timestamps for folders as well, couldn't it?

    Thanks for your good work.

    (edit: Nathan Durnan 2012-07-06 - added code brackets)

  5. Nathan Durnan repo owner
    • changed status to open

    aikidoibiza - Thanks for the quick test! I am able to reproduce the same error, so I should be able to address it today.

    As to your other points:

    2 . Not recording .hgtimestamp file modification time: This was very intentional. Its was originally tracked, but this quickly led to some very confusing behavior on merges, and almost every merge had to be done manually. Since the .hgtimestamp file is basically an "internal" file for the repository and not a direct part of the project being tracked, it was easier to exclude its own timestamp instead of coming up with a complex set of rules for managing the timestamp across merges. Believe me, it was much less confusing this way. Although, if you have a specific reason why you need the .hgtimestamp file's timestamp tracked and restored, please go ahead and open up a new issue describing the reason(s) and I will make every effort to revisit the issue. Otherwise, I will consider this point closed.

    4. Restoring timestamps on folders: I'm not sure of the benefit of this. Unless you have a compiler or synchronization program or some other application that is evaluating folder timestamps as well as file timestamps, I'm not sure this would be worth the effort it would take to implement. Since folder tracking is not specifically part of Mercurial (files are the real objects that are tracked), this aspect has been pretty much ignored. I don't recall the last time I really paid attention to the timestamp of a folder. But again, if you have a specific need for this, please open a new issue describing the need and I will attempt to include it in the next round of development.

    For now, I will work on addressing the error you reported today. I will keep an eye out for new issues addressing the other points on your list if you choose to create them. Thanks again for your feedback. It is greatly appreciated.

  6. aikidoibiza reporter

    I think that I really don't have any special interest in the .hgtimestamp file's timestamp. As for the folders' timestamps, well, maybe I'll lose some time on my side getting acquainted with Python and Mercurial (I'm new to both) and figuring out how to do it. In my case, I plan to use Mercurial not only as a versioning system, but also as a generic backup with versioning, and I don't want to lose the timestamps of anything (even folders) in the process.

    Thanks so much, anyway.

  7. aikidoibiza reporter

    Another quick one: When called on the command line with "hg timestamp_mod -s", the timestamps are still recorded in the old CSV format, not in JSON.

    Best regards.

    EDIT: Sorry, my mistake. I was again using version 0.1.5. Please ignore the above comment.

  8. aikidoibiza reporter

    OK, after reading documentation and examining your code, I came out with a couple of lines of code that will enhance TimestampMod to also manage folder timestamps. Just insert the following lines at line number 408 of TimestampMod.py (version 0.2.0 beta):

    		# **** Mod para incluir timestamps de carpetas
    		myFileName = os.path.dirname(myFileName)
    		while len(os.path.basename(myFileName))>0:
    			OUT_TimeStamp_dict[myFileName] = -1
    			myFileName = os.path.dirname(myFileName)
    		# **** End Mod
    

    Best regards.

  9. Nathan Durnan repo owner

    aikidoibiza - I've opened Issue #30 - "Save and Restore Folder timestamps" for further discussion on the topic. I'd like to continue the discussion about folder timestamps in that issue.

    I'm getting close to having a clean resolution for the error you reported earlier. Expect a new download link within the hour.

  10. Nathan Durnan repo owner

    Make sure to convert filenames explicitly as strings when importing JSON data. See Issue #29 at BitBucket. Also added global string variable for last placeholder text for JSON file and removed the placeholder from the incoming JSON data.

    5992c41ceea0

  11. Nathan Durnan repo owner

    aikidoibiza - Thanks again for the testing! I really appreciate feedback from users. Version 0.2.1 is now up for download thanks to your help. Issue #30 will be left open for further discussion of applying timestamps for Folders.

  12. Log in to comment