hg log by default shows the commit timestamp in the timezone it was committed in. Is it possible to make it show the timestamp in a particular timezone?
Ideally a solution wouldn't require any external tools.
hg log --template "{date|localdate|rfc822date}\n"
So you take the date, convert it to local and format according to rfc822
Related
I am trying to use the git log pretty format command to input the log into a json file. Currently I am using this command to get the specific git attributes:
git log --pretty="format:{commit:%h,%n merge:%p,%n author:%an,%n title:%s,%n body:%b,%n}">git_log.json
The problem with this command is that it gets the logs of all the branches in the system and inputs into the json. I only want to use this command to input logs of a certain branch that I can input somehow.
I tried checking out the certain branch that I want to get the log off and then used that command but it did not work as it still showed logs of all the existing branches. This was my failed attemmpt in the cmd line:
git checkout robotics/ashish_c/infrastructure
git fetch
git log --pretty="format:{commit:%h,%n merge:%p,%n author:%an,%n title:%s,%n body:%b,%n}">git_log.json
But it gave me the log files of other branches as well.
How do I only get the pretty format log file of only the branch robotics/ashish_c/infrastructure ?
The problem with this command is that it gets the logs of all the branches in the system and inputs into the json.
That should not be so. git log gets the log of the currently checked out commit and its history. git log --all gets the logs of all branches.
Git history is not linear and it may look like you're getting the history of other branches which have been merged into the current commit. git log --graph --decorate will show you the true history.
How do I only get the pretty format log file of only the branch robotics/ashish_c/infrastructure ?
git log robotics/ashish_c/infrastructure
I am trying to use the git log pretty format command to input the log into a json file.
JSON keys and strings must be quoted. I've removed the newlines to simplify things, this isn't for human consumption. Instead try...
git log --format='{"commit":"%h", "merge": "%p", "author": "%an", "title": "%s", "body":"%b"},' > git_log.json
But that leaves you with no wrapping [] and a trailing ,.
I have been using the mercurial and Beyond Compare 4 tools together for about 2 weeks now and feel fairly confident in my usage, however I still seem to have a problem when comparing incoming changesets against my current local codebase. The problem is emphasized when I attempting a complicated merge.
Just to clarify, I am avoiding the use of tools such as TortoiseHg,
although I do have it installed. I am searching for feedback via cmd line operations only.
My current templated method to pull down the incoming changesets via the following ( as an [alias] )
hg in --verbose -T "\nchangeset: \t{rev}\nbranch: \t{branch}\nuser: \t\t{author}\ndate: \t\t{date(date,'%m-%d-%Y %I:%M%p')}\ndescription: \n\t{desc|fill76|tabindent}\n\n{files % ' \t{file}\n'}\n----------\n"
As an example, here is a simplified (and cleverly abstracted) block returned ::
changeset: 4685
branch: Feature-WI209825
user: Jack Handy <jhandy#anon.com>
date: 01-19-2015 10:19AM
description:
Display monkey swinging from vines while whistling dixie
Zoo/MonkeyCage/Resources/Localization.Designer.cs
Zoo/MonkeyCage/Resources/Localization.resx
Zoo/MonkeyCage/Utility/Extensions.cs
If I were to be comparing changes locally, I would simply use the following command ::
hg bcomp -r 4685 -r default <optional file name>
and then I would get an instance of Beyond Compare with a folder structure and files and I could just navigate accordingly to view the changes...however, when I attempt to do this with a changeset that has yet to be pulled into my local repository, I can't.
How do I diff incoming changesets with my local repository?
---- UPDATE --------------------------------
I pursued the idea of bundling the incoming changes and then trying to use BC4 to diff the bundle to any given branch/revision on my local repo.
hg in --bundle "C:\Sandboxes\Temp\temp.hg"
This creates a compressed file archive containing all the new changes.
Now I simply need to diff this bundle with my local, however am having difficulty optimizing this. Currently, I am using variations on the following command:
hg -R "C:\Sandboxes\Temp\temp.hg" bcomp -r default
Alas, I am still having difficulty perfecting this...any insight is appreciated.
I don't see how you can, since your local repository doesn't yet have that changeset, so mercurial can't create a local copy of the revision, as it doesn't have visibility of what the change actually is.
The -p flag to hg incoming will show you the patch for each revision, but that isn't what you want.
Why not just pull the remote changes anyway? It wont hurt unless you actually update. You can then do your diff in the normal way.
hg diff is a local operation.
But you can simply call hg incoming -p in order to obtain a diff view of what you're going to pull. See hg help incoming for more options and refinement (e.g. if you need to diff against a specific rev etc)
The hg history command shows me results in the following format:
changeset: 1:000000000000
user: somebody
date: Fri Jun 06 22:38:10 2014 +0000
summary: Do something clever.
The "date" seen above defaults to using the time the revision was committed to its original repository. Is there a parameter I can give it to get the time it was pushed to the upstream, or pulled to my local repository, instead? Both hg help history and Google ({hg history timestamps}, {hg config revision timestamps}, {hg revision timestamps local}, ...) are drawing a blank for me.
(Alternatively, is there any other way for me to quickly eyeball the history and see what revisions were done in a particular timeframe, when one of the committers has a computer clock which is always off but not consistently by the same amount?)
You can select changesets by users and date using revsets (see also hg help dates for how dates are formatted):
hg log -r "user(soandso) AND date('2014-05-21 to 2014-05-30')
The dates will still be the commit dates. I'm not sure if or where any other dates are stored.
Is it possible to know when a certain commit was pulled from a distant repository and the files updated with Mercurial ?
More precisely, I made a hg pull -u a few days ago, and now I'd like to know if this pull downloaded only the last commit, or if there were some commits that had not been pulled yet, making my last pull getting them as well.
hg log seems to give the dates of the commits, but nothing about the updates. Is this information anywhere ?
This information is not recorded by Mercurial. A Mercurial repository is just a container for changesets and Mercurial does not store how (or when) the changesets entered the repository.
You can setup hooks for this, though you would have to build the scripts yourself. A very rudimentary system would be
[hooks]
pre-pull = (date; hg root; hg tip) >> ~/.pull-log
post-pull = hg tip >> ~/.pull-log
This would record the current date, the current repository, and the current tip in ~/.pull-log just before every hg pull. After the pull the new tip is recorded. You could build scripts that parse the log file to extract information about what each pull did.
hg log seems to give the dates of the commits, but nothing about the updates
Yes, hg log is only concerned with the stored history (changesets) and working copy operations like updating is not part of recorded history.
Finally, let me mention that this is the first time I've seen someone ask for a "pull log". However, the opposite is quite common: there are scripts for maintaining a "push log" on a server to see who pushed what and when. This is done by Mozilla among others. See this README for some starting instructions.
If you want to log when and with which revision hg update was used to update the code, then use these hooks:
[hooks]
pre-update = (echo "---------------------------------"; date --rfc-3339=s; hg root; echo "pre-update:"; hg identify --id --branch) >> .hgupdates
post-update = (echo "post-update:"; hg identify --id --branch) >> .hgupdates
the above hooks produce a log entry like this for each time hg update is run:
2015-12-23 00:44:31+02:00
/var/www/my/project
pre-update:
802120d1d3a0 somebranch
post-update:
302720d1d3d2 otherbranch
This also works when hg update is run without a specific revision flag (-r) set
How does Mercurial tell a file was modified?
The reason I am asking is because when I run hg status its telling me several files are modified.
However, when I run hg diff there are no changes to report.
I have a theory as why this is happening: (but I am not positive)
I am using NetBeans which has Mercurial support built in. When I edit a file, it shows it as modified, although if I undo (rather than revert) those changes and save it, NetBeans tells me there are no local changes. So I am guessing NetBeans uses diffs to check for modifications while Mercurial is using something else like modification-date.
Is this correct or is something else the cause?
Mercurial does not use modification date to determine the status. This can be verified with a simple experiment:
hg init
echo "This is a test" > test.txt
hg commit -Am "commit"
touch test.txt
hg status
The code which performs the status check is in dirstate.py. If the dirstate is unsure about a file's status (e.g. because only the modification time differs, then it passes it up to localrepo.status for further analysis as seen here.
The hg help status text has some clues that may help:
status may appear to disagree with
diff if permissions have changed or a
merge has occurred. The standard diff
format does not report permission
changes and diff only reports changes
relative to one merge parent.
When you run hg diff, are you specifying any command-line options?
Is it possible the permissions of the file changed? Try hg diff --git which shows the git-style extended diffs that support permissions and binaries. By default hg diff shows only patch-friendly diffs, which don't show permissions changes.