time for hg log --date - mercurial

I generate hg logs for some repositories (on the remote server where all local repos push their changes to) using this command:
hg log -R "path-to-repo" -b somebranch --date "$YESTERDAY to $TODAY"
where :
YESTERDAY=$(date +%Y-%m-%d -d "yesterday")
TODAY=$(date +%Y-%m-%d)
As an example this could be:
hg log -R "path-to-repo" -b somebranch --date "2012-11-27 to 2012-11-28"
But at what time: hour:minutes:seconds does the generated log start when specifying --date? End would be the time when the command is executed.
The reason I ask is that the log was empty when I ran the above at 10:00 but when I ran it 11:10 it found changes.

You forgot about local timezone: date without TZ for mercurial is some predefined timezone (probably GMT)
BTW, "from yesterday" (without TZ-related headache) for hg log is static line --date "-1"
Example of log, when committer isn't from my local TZ
hg log --date "2012-11-04" --template "{date|date}\n"
Sat Nov 03 22:36:13 2012 -0400
Sat Nov 03 22:22:43 2012 -0400
Sat Nov 03 19:25:13 2012 -0400
Sat Nov 03 19:20:52 2012 -0400
Sat Nov 03 19:20:39 2012 -0400
Sat Nov 03 19:14:17 2012 -0400
Sat Nov 03 19:12:08 2012 -0400
Sat Nov 03 19:11:50 2012 -0400

Related

Mecurial hg push error

I'm new to Mercurial and I was hoping that you guys could help. I made and committed some changes on the default and dev branch on my local system. When I ran the "hg push" command, I got the following error. Do you know what I have to do to fix it? Thank you.
searching for changes
abort: push creates new remote head 6a3192edc4aa!
(merge or see "hg help push" for details about pushing new heads)
==========
Output of hg log:
changeset: 6583:6a3192edc4aa
tag: tip
parent: 6581:049cddc21e42
parent: 6582:ae83c2445264
user: user1
date: Thu Aug 14 15:35:08 2014 -0400
summary: Merged with dev.
changeset: 6582:ae83c2445264
branch: dev
parent: 6579:dd7c0641e5cf
parent: 6581:049cddc21e42
user: user1
date: Thu Aug 14 09:53:09 2014 -0400
summary: Merged with default.
changeset: 6581:049cddc21e42
parent: 6577:df050be5e368
user: deploy
date: Fri Aug 08 21:07:14 2014 +0000
summary: Added tag 0.3.343 for changeset df050be5e368
changeset: 6580:f28967065103
parent: 6577:df050be5e368
user: user1
date: Thu Aug 14 09:27:44 2014 -0400
summary: Fixed a timeout bug.
changeset: 6579:dd7c0641e5cf
branch: dev
user: user1
date: Wed Aug 13 09:29:58 2014 -0400
summary: Fixed a few typos.
Changesets 6580 and 6583 are both on default branch, but are both heads. Issue a hg merge and you should be good to push.

Mecurial trying to merge file with identical DAGs

I have two repositories A and B.
I have pulled B into A.
For a given file on A hg log returns
changeset: 40967:d7f84148b444
parent: 40966:afbd3f7ddeea
parent: 40730:8658f8a70bd5
user: anon
date: Tue Nov 05 11:52:13 2013 +0000
summary: merge from B
changeset: 40894:7f667abe8948
user: anon
date: Wed Oct 16 11:53:13 2013 +0100
summary: Refactored some code
and on B hg log return
changeset: 40570:d7f84148b444
parent: 40402:afbd3f7ddeea
parent: 40569:8658f8a70bd5
user: anon
date: Tue Nov 05 11:52:13 2013 +0000
summary: merge from B
changeset: 39676:7f667abe8948
user: anon
date: Wed Oct 16 11:53:13 2013 +0100
summary: Refactored some code
The two graphs appear identical and there are no commits in A for the file that aren't in B and vice versa.
However merging the two heads in A requires a conflict to be resolved for this file.
I guess I'm missing something. What cases could cause Mercurial to think it needs to merge these two graphs?
Is there someway I can determine why Mercurial is trying to merge the file?

How to get previous changeset id of a specific file

I would like to get the previous revision for a specific file, no matter if it was changed in the tip or not.
For example, I have a repo that has a tip at changeset 226
$:~/sandbox$ hg log -r -3::.
changeset: 224:591c7a48b15f
user: blah <blah.com>
date: Tue May 28 09:07:25 2013 -0700
summary: TEST: test
changeset: 225:8c3689dedfa8
user: blah <blah.com>
date: Tue May 28 09:07:53 2013 -0700
summary: TEST: test2
changeset: 226:88f5ee46f99b
tag: tip
user: blah <blah.com>
date: Tue May 28 09:42:46 2013 -0700
summary: TEST:test
Inside that repo is a file called doit that was changed a while ago, at changeset 158:
$:~/projects/sandbox$ hg log doit
changeset: 158:8536d2b52f24
user: blah <blah.com>
date: Thu May 03 18:56:50 2012 -0700
summary: TEST: clean up buiild
changeset: 121:82313616d631
user: blah <blah.com>
date: Wed Apr 06 14:04:55 2011 -0700
summary: scr3: created program to test UI tests in Hudson
changeset: 116:c668d2a9c2b2
user: blah <blah.com>
date: Tue Feb 15 11:31:31 2011 -0800
summary: TEST: add another line
changeset: 115:9affabd80774
user: blah <blah.com>
date: Tue Feb 15 11:21:01 2011 -0800
summary: TEST: modify doit
changeset: 114:4097920e7edb
user: blah <blah.com>
date: Tue Feb 15 11:18:58 2011 -0800
summary: TEST: add doit
And I can dump the contents of the file using hg cat:
$:~/projects/sandbox$ hg cat -r 158 doit
#! /bin/sh
echo doit for the sandbox hudson test job...
echo add another line out
echo add yet another line...
#ant clean build
So far so good. The question is how do I specify the previous revision of the file (doit) without explicitly specifying "158". (I'd have to search the hg log output for it for example).
I've tried:
hg log -r -2 doit
hg log -r "ancestor(.)" doit
hg log -r "ancestor(file(doit))"
hg log -r "limit(file(doit))"
hg log -r "limit(file(doit)~0)"
(etc.)
I finally tried this one which seems to work:
$:~/sandbox$ hg log -r "last(file(doit))"
changeset: 158:8536d2b52f24
But when I tried it against another repo and file:
$:~/projects/otherrepo$ hg log -r "last(file(file-version))"
hg: parse error: file requires a pattern
It seems the dash "-" is causing a syntax issue. I tried escaping it:
$:~/projects/otherrepo$ hg log -r "last(file(uic\-version))"
hg: parse error at 13: syntax error
Any ideas on what to try next?
You can use different type of escaping:
hg log -r 'last(file("uic-version"))'

I have one repository with multiple projects how do I give each project it’s on repository with the existing history?

When I started with Mercurial about a year ago I created one repository called SandBox to put all my projects in it, now about a year later I realize that wasn’t very smart choice I have 19 project in it some of them are big. I would like to give each project its own repository also keeping the history. Is there an easy way I accomplish this?
Well, consider a project with the following structure (in bitbucket):
$ find hgmultiproject
hgmultiproject
hgmultiproject/proj2
hgmultiproject/proj2/mysndfile
hgmultiproject/proj1
hgmultiproject/proj1/myfirstfile
hgmultiproject/proj3
hgmultiproject/proj3/mythirdfile
This project has this log:
revision: 7:6bbc26c1a34d
tag: tip
user: Adam Victor Nazareth Brandizzi <brandizzi#gmail.com>
date: Wed Aug 08 11:49:22 2012 -0300
summary: correcting
revision: 6:32c312e7072e
user: Adam Victor Nazareth Brandizzi <brandizzi#gmail.com>
date: Wed Aug 08 11:48:55 2012 -0300
summary: Adding period
revision: 5:f332e0ecee4d
user: Adam Victor Nazareth Brandizzi <brandizzi#gmail.com>
date: Wed Aug 08 11:48:39 2012 -0300
summary: Moving to correct name
revision: 4:5850a93d80dd
user: Adam Victor Nazareth Brandizzi <brandizzi#gmail.com>
date: Wed Aug 08 11:48:05 2012 -0300
summary: More content on second file
revision: 3:0098ebd2cea5
user: Adam Victor Nazareth Brandizzi <brandizzi#gmail.com>
date: Wed Aug 08 11:47:41 2012 -0300
summary: A third file
revision: 2:096c984a8f2a
user: Adam Victor Nazareth Brandizzi <brandizzi#gmail.com>
date: Wed Aug 08 11:47:09 2012 -0300
summary: More content on 1st file
revision: 1:b9491918efcc
user: Adam Victor Nazareth Brandizzi <brandizzi#gmail.com>
date: Wed Aug 08 11:46:52 2012 -0300
summary: My second file
revision: 0:4e429ac2fee9
user: Adam Victor Nazareth Brandizzi <brandizzi#gmail.com>
date: Wed Aug 08 11:46:23 2012 -0300
summary: My first file
You can extract the projects using the Convert extension with the --filemap option.
How to do it? First, you should create a filemap file. In this case, the content should be:
rename proj1 .
exclude proj2
exclude proj3
The first line will move everything inside the proj1 dir to the root of the new repository. The second line will remove the proj2 dir from the new repository, and the third line will remove the proj3.
To use it, just call this way:
$ hg convert --filemap proj1filemap hgmultiproject/ extracted-proj1
Now, enter the new repo:
$ cd extracted-proj1/
It has no working copy...
extracted-proj1 $ ls
y but you just need to update:
extracted-proj1 $ hg update
1 updated files, 0 merged files, 0 deleted files, 0 nonresolved files
extracted-proj1 $ ls
myfirstfile
And the new log is...
extracted-proj1 $ hg log
revision: 2:eb31727c0df8
tag: tip
user: Adam Victor Nazareth Brandizzi <brandizzi#gmail.com>
date: Wed Aug 08 11:48:55 2012 -0300
summary: Adding period
revision: 1:e701f0ad5335
user: Adam Victor Nazareth Brandizzi <brandizzi#gmail.com>
date: Wed Aug 08 11:47:09 2012 -0300
summary: More content on 1st file
revision: 0:c0b6ad18ff22
user: Adam Victor Nazareth Brandizzi <brandizzi#gmail.com>
date: Wed Aug 08 11:46:23 2012 -0300
summary: My first file
You should follow these steps for each project of your repository.
Take a look at the Convert extension: https://www.mercurial-scm.org/wiki/ConvertExtension
What you actually need is --filemap: https://www.mercurial-scm.org/wiki/ConvertExtension#A--filemap

How to get rid of older mercurial heads?

Hi I hope you can from my i/o tell how to proceed to merge everything to the latest update without losing my changes:
$ hg merge
avbryter: grenen 'default' har 4 huvuden - sammanfoga med en specifik rev
(kör 'hg heads .' för att se huvuden)
ubuntu#ubuntu:/media/Lexar/montao$ hg heads
ändring: 192:e571b17295e9
märke: tip
förälder: 175:f50d4c4461e5
användare: tekniklas
datum: Sat Jan 08 04:45:07 2011 +0000
kortfattat: twitter support added
ändring: 191:9e419ce3e7e1
användare: tekniklas
datum: Wed Mar 09 12:56:27 2011 +0000
kortfattat: adsense maps
ändring: 159:f8d974793b12
förälder: 157:ef1d955b9236
användare: tekniklas
datum: Sat Dec 18 17:05:45 2010 +0000
kortfattat: remove
ändring: 89:008a2ac46b4f
användare: tekniklas
datum: Sun Aug 01 07:10:40 2010 +0000
kortfattat: classifiedsmarket/market/market_ad_preview.html
ubuntu#ubuntu:/media/Lexar/montao$
The latest version is good and I want to "lose" the older heads.
UPDATE. After proceeding with the tip this is the latest output from hg heads:
$ LC_ALL=C hg heads
changeset: 195:fa7d0ec3760d
tag: tip
user: tekniklas
date: Fri Mar 11 06:04:17 2011 +0000
summary: searchbox
changeset: 192:e571b17295e9
parent: 175:f50d4c4461e5
user: tekniklas
date: Sat Jan 08 04:45:07 2011 +0000
summary: twitter support added
changeset: 159:f8d974793b12
parent: 157:ef1d955b9236
user: tekniklas
date: Sat Dec 18 17:05:45 2010 +0000
summary: remove
changeset: 89:008a2ac46b4f
user: tekniklas
date: Sun Aug 01 07:10:40 2010 +0000
summary: classifiedsmarket/market/market_ad_preview.html
EDIT, current issue status is:
$ LC_ALL=C hg heads
changeset: 195:fa7d0ec3760d
tag: tip
user: tekniklas
date: Fri Mar 11 06:04:17 2011 +0000
summary: searchbox
changeset: 192:e571b17295e9
parent: 175:f50d4c4461e5
user: tekniklas
date: Sat Jan 08 04:45:07 2011 +0000
summary: twitter support added
changeset: 159:f8d974793b12
parent: 157:ef1d955b9236
user: tekniklas
date: Sat Dec 18 17:05:45 2010 +0000
summary: remove
changeset: 89:008a2ac46b4f
user: tekniklas
date: Sun Aug 01 07:10:40 2010 +0000
summary: classifiedsmarket/market/market_ad_preview.html
ubuntu#ubuntu:/media/Lexar/montao$ LC_ALL=C hg --config ui.merge=internal:local merge 195
abort: merging with a working directory ancestor has no effect
Mercurial is about building a permanent history of your work, so none of its normal usage modes include "getting rid" of old heads.
The most Mercurial-like way to do this is to merge that head in selecting nothing from it.
hg update tip
hg --config ui.merge=internal:local merge 191 # keep my files
Found here.
That will eliminate that head, selecting nothing from it.
Other options that actually remove it from history include just doing:
hg clone -r tip myrepo mynewrepo
Which gets you a new clone that has only your newest head and its ancestors (not its sibling heads) which you can replace your old repo with if you like the result.
That's generally inferior if you buy into the keep-everything-forever model (I do) and doesn't work at all if other people already have clones fo your repo.
Nowadays you can close your branches (anonymous or not) with:
hg commit --close-branch -m "Closing branch."
You need to be in the branch you want to close before doing it.
I think that closing branches is better than merging it discarding changes because have a better meaning. When closing you said "This changes aren't useful any more", when merging you said "I like the changes but they are already included manually" (but maybe is what you wanted).
You can see this related question Mercurial: beheading a head or this one if you don't want/can't update Can you close a Mercurial branch without updating to it first?.
You can close your old branches. See article from official wiki.
Try to merge with lastest remote head and then push your commit
hg merge
hg commit -m 'merge'
hg push