I have pushed some files by mistake and it shows different heads in main repository. How can I delete that head?
You can enable the "mq" extension by editing your .hgrc file.
Make sure the following lines are present:
[extensions]
mq =
Afterwards you can "strip" a specific revision which deletes it so that you have only one head:
hg strip ...
I don't think that you actually want to delete the heads. If you do that, you will lose the work that was done in those branches.
You probably want to merge the heads back into one branch.
Say that you have a tree like this:
o 4 : Head 1
|
o 3 : Another commit
|
| o 2 : Head 2
| |
|/
o 1 : A commit
|
o 0 : Initial commit
To get rid of the additional head without losing the work contained within it you would merge the two heads (revisions 2 and 4 in this example) like this:
hg update 4
hg merge 2
hg commit -m "Merge"
That will create another commit which has all the changes in revisions 2, 3 and 4 in a single head like this:
o 5: Merge
|\
o | 4 : Head 1
| |
o | 3 : Another commit
| |
| o 2 : Head 2
| |
|/
o 1 : A commit
|
o 0 : Initial commit
This is standard procedure when multiple developers work on the same repository.
Related
I'm proficient with joining tables in mySQL, but I'm having trouble with joining results from the SAME table. I'm creating a folder structure in PHP where a folder has an ID, a parent ID, a random-string ID, and a label.
My DB looks like:
| id | parent_id | uniq | label
---------------------------------
| 1 | 0 | w2d4f6 | dir 1
| 2 | 1 | h9k3h7 | dir 2
The front end uses the uniq var to identify a folder. So In the DB you can see that if I am opening the folder dir 1, the folder dir 2 will be inside it, since dir 2 has dir 1's ID as its parent.
Still with me?
|- dir 1
| + dir 2
The folder dir 1 is identified by its uniq string, so w2d4f6. So what I'm wanting to do is:
Get the parent ID of the record that has uniq='w2d4f6'
The parent ID is 1
Look for records where parent_id=1
I know this is totally wrong, and I think I should be using JOIN but I tried the following without success.
SELECT folders.label,folders.parent_id FROM folders WHERE folders.uniq='w2d4f6' AND folders.id=folders.parent_id
To get the children of a folder:
select b.label, b.parent_id
from folders a, folders b
where a.uniq = 'w2d4f6' AND b.parent_id = a.id
This should work if you already have the parent data and just want to request the child data by the uniq value of the parent:
SELECT label, parent_id FROM folders WHERE parent_id IN (SELECT id FROM folders WHERE uniq='w2d4f6')
I'm trying to figure out a way to get an oddly-specific set of logs. This is input into a different program, where I'm parsing the logs and doing stuff with them, but ideally it would be great to do as much as possible with the hg commands to minimize my post-processing.
I want all commits marked with "O" and none of the "X" ones:
A5 O
|
|
|
A4 O X B4 X C2
|\ | |
| \ | |
| \| |
A3 O O B3 |
| | |
| | |
| | |
A2 O O B2 X C1
| | |
| | |
| | |
| O B1 |
| /| |
| / | |
|/ | |
A1 X X B0 X C0
|
|
|
A0 X
Given this chart, where A, B, and C are different branches, our users want a log of changes between A2 and A5. The issue is that they also want to know the rest of the history of any branches merged into A.
hg log -r A2:A5 will return:
A2,3,4,5
B2,3,4
C1,2
First off, I don't want C whatsoever. It isn't connected to anything here.
But what I do want is B1, or more generally all changes in B since it was last merged into A. Also I don't want B4. So if I have hanging tails that connect farther up, I need to find the rest. Annoyingly, they do not want A1.
My current plan is log A2:A5, then I create a tree structure from parsing the results. At the end I look for any hanging tails, and get the log of the common ancestor of that tail and A2, and A2, for just that branch. That's sort of convoluted and crazy.
Any ideas or suggestions to make this easy and reduce the work I have to do to post-process?
An improvement on your current approach will be hg log -r "A5 % parents(A2)". This is equivalent to A5 and all its ancestors, less A1 and any of its ancestors, so it returns:
A2,A3,A4, and A5
B0,B1,B2, and B3
Notably, the following will be excluded:
Any changeset in C
Changesets in B that hasn't been merged into A (e.g. B4)
There is only one undesired changeset in the resulting revset: B0. The criteria for removing that is a little unclear to me (It would probably help to see the ancestors A0, B0 and C0, as they will all stem from a common node at some point). I think a clarification of the stop conditions going backwards on branches that merge into A2::A5 is needed before a revset can be constructed.
However, that revset will probably be quite complicated, and it may be easier to postprocess the above revset instead.
Edit: Some further thoughts
You may be better off doing multiple different revsets:
hg log -r "A2::A5" returns the DAG from A2 to A5 (i.e. A2,A3,A4,A5)
hg log -r "(parents( A2::A5 & merge() ) - ( A2::A5 + parents(A2) ) )" will return any changeset that has been merged into the DAG from A2 to A5 (i.e. B3)
The first one will go directly to your final result set. The second one you can iterate (Imagine there's also a branch D with a D3 that's merged into the branch of interest) and traverse each branch towards the stop criteria, then add the relevant changesets into the final result set.
Iterating the merged branches to stop at the right time may be simpler than trying to prune a larger result set of the incorrectly included changesets
I want to retrieve commit order number, counting ONLY commits of specific branch (master).
As a branch "master" is the same on each machine/repo, then this will allow me to:
1. Have the same number regardless of the repository
2. Use this number in a version string.
So, is there any way to accomplish this?
hg log -b master --template "." | wc -m for example
Output current amount of changesets in branch
Your idea wont work, even though you limit yourself to a single named branch. As mentioned by Ry4an, the problem is that the order of changesets on that branch is determined by the order of hg push and hg pull. So you can easily end up with a situation where you have:
# branch: master, changeset: 5:f5b6808f2f04, summary: merge
|\
| o branch: master, changeset: 4:2b7bdcc98a88, summary: mmm
| |
o | branch: master, changeset: 3:6b60342a01a6, summary: mm
|/
o branch: master, changeset: 2:f39fa3fa1aaf, summary: m
|
o branch: master, changeset: 1:4dd5e8ae6481, summary: create master
|
o branch: default, changeset: 0:68b4eb1ca123, summary: a
in one repository, but
# branch: master, changeset: 5:f5b6808f2f04, summary: merge
|\
| o branch: master, changeset: 4:6b60342a01a6, summary: mm
| |
o | branch: master, changeset: 3:2b7bdcc98a88, summary: mmm
|/
o branch: master, changeset: 2:f39fa3fa1aaf, summary: m
|
o branch: master, changeset: 1:4dd5e8ae6481, summary: create master
|
o branch: default, changeset: 0:68b4eb1ca123, summary: a
in another. Note how the mm and mmm changesets are swapped in the two repositories.
It is only if the branch has the same heads in both repositories that you can talk about the "branch being the same" in each repository. If that is the case, then, as suggested by Lazy, a simple
hg log -b master --template "." | wc -m
will give the same count in both repositories.
I have a number of files on my website that are private and pushed through php. I keep track of the downloads using a mysql database. Currently I just use a column for each file and insert a new row for every day, which is fine because I don't have many files.
However, I am going to be starting to add and remove files fairly often, and the number of files will be getting very large. As I see it I have two options:
The first is to add and remove columns for each file as they are added and removed. This would quickly lead to the table having very many columns. I am self-taught so I'm not sure, but I think that's probably a very bad thing. Adding and removing columns once there are a lot of rows sounds like a very expensive operation.
I could also create a new database with a generic 'fileID' feild, and then can add a new row every day for each file, but this would lead to a lot of rows. Also, it would be a lot of row insert operations to create tracking for the next day.
Which would be better? Or is there a third solution that I'm missing? Should I be using something other than mysql? I want something that can be queried so I can display the stats as graphs on the site.
Thank you very much for your help, and for taking the time to read.
I could also create a new database with a generic 'fileID' feild, and then can add a new row every day for each file, but this would lead to a lot of rows.
Yes, this is what you need to do — but you mean "a new table", not "a new database".
Basically you'll want a file table, which might look like this:
id | name | created_date | [other fields ...]
----+-----------+--------------+--------------------
1 | foo.txt | 2012-01-26 | ...
2 | bar.txt | 2012-01-27 | ...
and your downloads_by_day table will refer to it:
id | file_id | `date` | download_count
----+---------+------------+----------------
1 | 1 | 2012-01-27 | 17
2 | 2 | 2012-01-27 | 23
3 | 1 | 2012-01-28 | 6
4 | 2 | 2012-01-28 | 195
I have two branches in mercurial..
default named
|r1
|r2
|r3 -------- named branch created here.
| |r4
| |r5
| r6 |
| |r7
| |
-----------> | r8 How do I achieve this catch-up?
| |
I want to update the named branch from default, but I'm not ready to merge the branches yet. How do I achieve this?
Edit:
Additionally, what would the operation be using the GUI?
Is it.. right-click r6, merge with..., r8,... then what? commit to named branch?
hg merge default from your named branch.