I have a problem on a repository. I use phabricator as the front-gui of my repository. Recently I found I am not able to open and view a few directories in one repository in phabricator while other directories are fine. Phabricator reports 'hg locate' command output is empty like this:
Command failed with error #1!
COMMAND
hg locate --print0 --rev ''\''d8f8fd40c58bf883ec88bd037f96b962ec16f48e'\''' -I './/OA'
STDOUT
(empty)
STDERR
(empty)
I tried the same command in the repository on the server and I did get no output. So I just simply tried the command 'hg locate' without any parameter. That command is supposed to list all the files in the repo but I found the output was still empty!
I then cloned the repo to another directory on the server and tried the same 'hg locate' command and found it was find and I got the file list in the repo.
What is the problem with my original repo? Is there any setting to prevent the 'hg locate' command to output anything?
Related
When I click on Annotate, I often get this message in PyCharm 2018.2.5 (running on Ubuntu 18.04):
Number of lines annotated by Mercurial is not equal to number of lines
in the file. Check file econding and line separators
It looks like a Mercurial error, but in command line, the following command on the same file is succesful:
# hg annotate -ud <file>
Line enconding is LF, File encoding is UTF-8
EDIT
Mercurial version:
# hg --version
Mercurial Distributed SCM (version 4.5.3)
The file I'm try to annotate is in a subrepository, and checking the logs I discovered
PyCharm is trying to annotate using the father's repo.
If I execute the command in father's directory, I get an empty result.
So the error is misleading, and apparently I don't know how to set up PyCharm in this case.
Is there a way to fix this?
I got it. I think it makes sense answering my own question.
The structure of my project is the following:
Project root (no VCS)
RepoDir (hg repository)
SubRepoDir (hg subrepository)
In this configuration something confuses PyCharm, and subrepositories at third level
won't be recognized.
The following works pretty well:
RepoDir as Project root (hg repository)
SubRepoDir (hg subrepository)
If other directories are needed, one can add them as content root.
I'm trying to use mercurial file sets to add all the files in a directory tree, excluding very large files and any binary files. Cribbing from the mercurial documentation, this command should do it:
hg init
hg add 'set: size("<1M") and not binary()'
However this returns a status code of 0, and hasn't added anything to my new, empty repo. I've tried just 'set: not binary()' and that didn't work either.
The frustrating thing is that although I can google for mercurial file sets, and find lots of examples, I can't find anything to help troubleshoot when it doesn't work!
I don't have a .hgignore file, and it's a fresh empty repo. Mercurial 4.2.2.
The directory where I'm testing this has a couple of artificially created files for the purpose of testing. In my real use case, I inherit a multi-gigbyte tarball of assorted sources and binaries from a client, and I want to get all the sources into mercurial before I start hacking to fix their problems, hence the need to exclude the binaries and large files that otherwise choke mercurial.
Here's my little test script:
#!/bin/sh -ex
dd if=/dev/urandom of=binary_1k bs=1 count=1024
dd if=/dev/urandom of=binary_2M bs=1 count=2097152
echo "This. Is, a SMALL text file." > text_small
hexdump binary_1k > text_1k
hexdump binary_2M > text_2M
ls -lh
file binary_1k
file binary_2M
file text_1k
file text_2M
hg init
hg add 'set: size("<1M") and not binary()'
hg status -a
hg add 'set: not binary()'
hg status -a
hg add 'set: size("<1M")'
hg status -a
At the end of this, each status command reports no files in the repo, and the add commands report no errors.
The problem is that file sets do a query of Mercurial's repository data base, which knows only about files that are part of the repository or have been added.
One solution is to add all, and then to get rid of the files that you don't like, e.g.:
hg forget 'set:size(">1M") or binary()'
This works, because the query also requires recently added files, even if they haven't been committed yet.
I'm having some difficulty cloning my mercurial repository over ssh.
Here's what I have tried:
hg clone ssh://username#username.webfactional.com/path/to/projectname projectname
It's giving me this error:
remote: bash: hg: command not found
abort: no suitable response from remote hg!
hg is installed on the server, however.
I was trying to follow the instructions on this website.
You need a double // after hostname i.e.:
hg clone ssh://username#username.webfactional.com//path/to/projectname projectname
Sounds like hg is not on your path. The Mercurial FAQ mentions possible fixes for this issue: FAQ/CommonProblems.
Add the remotecmd value to your Mercurial configuration by opening ~/.hgrc (or Mercurial.ini on Windows) on your client machine and adding the following:
[ui]
remotecmd = /path/to/hg
where /path/to/hg is the path to the hg command on the remote server.
If you're having problems with your Mercurial configuration, you can use the hg showconfig --debug command to obtain a full list of your Mercurial settings along with the path and line number of the configuration file that defines each configuration value.
Looks like mercurial isn't in your user's PATH on the remote server.
On webfactional I had to add:
export PATH=$PATH:/home/<user>/bin
to .bashrc to get it to work.
(also followed the remotecmd advice above)
You can use Sourcetree, TortoiseHg, Mercurial from the terminal, or any client you like to clone your Mercurial repository. These instructions show you how to clone your repository using Mercurial from the terminal.
From the repository, click + in the global sidebar and select Clone
this repository under Get to work.
Copy the clone command (either the SSH format or the HTTPS).
If you are using the SSH protocol, ensure your public key is in Bitbucket and loaded on the local system to which you are cloning.
From a terminal window, change to the local directory where you want to clone your repository.
Paste the command you copied from Bitbucket, for example:
CLONE OVER HTTPS:
$ hg clone https://username#bitbucket.org/teamsinspace/hg-documentation-tests
CLONE OVER SSH:
$ hg clone ssh://hg#bitbucket.org/teamsinspace/hg-documentation-tests
If the clone was successful, a new sub-directory appears on your local drive.
This directory has the same name as the Bitbucket repository that you cloned.
The clone contains the files and metadata that Mercurial requires to maintain the changes you make to the source files.
On the server, type: nano ~/.bashrc end edit the file by adding:
# User specific aliases and functions
export PATH=$PATH:$HOME/packages/mercurial
Under the assumption that ~/packages is the folder where mercurial was installed.
After editing, finish off with source ~/.bashrc and try again.
Pretty helpful to me was the following elaborate guide to install mercurial on a Bluehost hosting server.
I'm trying to convert a CVS repository to mercurial but can't get it to work.
I start with a clean checkout:
cvs -d :sspi;username=xxx;hostname=yyy.local:/cvsrepos checkout repo
Which works fine
I then do:
hg convert .
But it fails with:
assuming destination .-hg
initializing destination .-hg repository
connecting to :sspi;username=xxx;hostname=yyy.local:/cvsrepos
abort: unexpected response from CVS server (expected "Valid-requests", but got 'E cvs [server aborted]: Root :sspi;username=xxx;hostname=yyy.local:/cvsrepos must be an absolute pathname\n')
I'm running cvsnt on windows 7
Edit:
Investigated this a bit more and it seems like mercurial starts a local server cvs server and then communicates with that instance instead of the remote server.
I base this on the following observations:
I created a cvs.bat file that sends the command line arguments to a file. The file shows the argument "server".
process monitor shows that hg.exe tries to open the file
C:\cvstest\:sspi;username=xxx;hostname=yyy.local:\cvsrepos which of course fails.
Can it be that hg does not understand the sspi connection string?
Edit 2:
Not a solution but I found a workaround: Copy the complete remote repository to my machine and:
cvs -d :local:\localcopyofrepo checkout repo
hg convert repo
Everything worked fine
Looks like the error message is telling you to use an absolute pathname to the repository, try using
hg convert <full_path_including_drive>
rather than the . path on a checked out sandbox of your CVS repository. You could also try specifying the repository type in the convert command by adding -s cvs to the command, the result would look something like this:
hg convert -s cvs C:\sandbox\cvsrepos
It looks like you are using ConvertExtension. Can you try hg convert from the parent folder and specify the folder name, instead of . and see if it works?
I know about hgtk log command but it is working for directory not for a file.
If I execute something like this
hgtk log -R D:\bmutilities\big_repo\chrome\content\br_editor.js
It throws an error saying---directory not found
But if run hgtk command in D:\bmutilities\big_repo\chrome\content\ directory
hgtk log -R br_editor.js
it works fine...
Suggestions please ????
You use the --repository or -R option to specify the path to the repository. After that, the filenames are relative to that directory. In this sense, hgtk -R works like hg --cwd meaning that it actually changes the current working directory.
Mercurial also has a --repository (-R) command like switch, but this does not change the current working directory of the process.
UPDATE
I understand your question better now. You mean that you cannot view the history of a file from the command line if you are not in a folder under the .hg root folder.
That appears to be a design decision by mercurial.
I just make sure I cd to a folder inside the repo before I do hgtk log on a specific file.