Mercurial - generate patch for both committed and uncommitted changes combined - mercurial

Sometimes in development it is useful for me to see a diff for both committed changes and uncommitted changes combined.
eg, as though they were either both uncommitted and I used hg diff,
or both uncommitted and I used hg diff -c REV.
Is there a way to do that? I have tried variants of diff, export and log.

For this toy-repo in such state
>hg st
M a.txt
>hg log --style compact
1[tip] 4d554db9595b 2016-08-05 23:56 +0500 lazybadger
Change 1
0 8bc9bcf8b736 2016-08-05 23:55 +0500 lazybadger
Initial state
combined diff for 4d554db9595b
>hg diff -c 1
diff -r 8bc9bcf8b736 -r 4d554db9595b a.txt
--- a/a.txt Fri Aug 05 23:55:46 2016 +0500
+++ b/a.txt Fri Aug 05 23:56:19 2016 +0500
## -1,1 +1,2 ##
Line 1
+Line 2
and workdir
>hg diff
diff -r 4d554db9595b a.txt
--- a/a.txt Fri Aug 05 23:56:19 2016 +0500
+++ b/a.txt Fri Aug 05 23:57:59 2016 +0500
## -1,2 +1,3 ##
Line 1
Line 2
+Line 3
will be, obviously
>hg diff -r "parents(1)"
diff -r 8bc9bcf8b736 a.txt
--- a/a.txt Fri Aug 05 23:55:46 2016 +0500
+++ b/a.txt Sat Aug 06 00:06:20 2016 +0500
## -1,1 +1,3 ##
Line 1
+Line 2
+Line 3
PS: Just some fast-reading of hg help diff, nothing more harder... use brain, at last!

Related

Running MySQL with on different directory

GOAL:
I am trying to run mysql on my work servers machines. But as admins did not install it in the usual default installation path, it fails. How can I make it works?
FACTS:
MySQL is installed under: /opt/mysql/10.1.16/
$> ls -1 /opt/mysql/10.1.16/
bin
COPYING
COPYING.LESSER
COPYING.thirdparty
CREDITS
data
EXCEPTIONS-CLIENT
include
INSTALL-BINARY
lib
man
mysql-test
README
README-wsrep
scripts
share
sql-bench
support-files
However, when I want to run mysql from a script, I do:
export LIBMYSQL_PLUGIN_DIR="/opt/mysql/10.1.16/lib/plugin"
export LD_LIBRARY_PATH="/opt/mysql/10.1.16/lib"
export LD_RUN_PATH="/opt/mysql/10.1.16/lib"
export PATH="/opt/mysql/10.1.16/bin:/home/xxxxxxxx/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib64/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin"
/opt/mysql/10.1.16/bin/mysql -C --no-beep --line-numbers --protocol=TCP --host="${DB_HOSTNAME}" --port="${DB_PORT}" --user="${DB_USER}" --database "${DB_SCHEMA}" -o --delimiter ','
With all my DB_xxxx corectly set, I get the following error:
ERROR 2059 (HY000): Authentication plugin 'dialog' cannot be loaded: /usr/local/mysql/lib/plugin/dialog.so: cannot open shared object file: No such file or directory
I checked the official documentation page:
https://dev.mysql.com/doc/refman/8.0/en/environment-variables.html and the only mention about plugin is to check if LIBMYSQL_PLUGIN_DIR, which seems good since:
$> echo "${LIBMYSQL_PLUGIN_DIR}"
/opt/mysql/10.1.16/lib/plugin
$> ls -la /opt/mysql/10.1.16/lib/plugin
-rwxr-xr-x 1 mysql dba 17382 Sep 13 2016 adt_null.so
-rwxr-xr-x 1 mysql dba 12462 Sep 13 2016 auth_0x0100.so
-rwxr-xr-x 1 mysql dba 33039 Sep 13 2016 auth_gssapi_client.so
-rwxr-xr-x 1 mysql dba 80774 Sep 13 2016 auth_gssapi.so
-rwxr-xr-x 1 mysql dba 18007 Sep 13 2016 auth_pam.so
-rwxr-xr-x 1 mysql dba 13028 Sep 13 2016 auth_socket.so
-rwxr-xr-x 1 mysql dba 23521 Sep 13 2016 auth_test_plugin.so
-rw-r--r-- 1 mysql dba 227 Sep 13 2016 daemon_example.ini
-rwxr-xr-x 1 mysql dba 15267 Sep 13 2016 debug_key_management.so
-rwxr-xr-x 1 mysql dba 14975 Sep 13 2016 dialog_examples.so
-rwxr-xr-x 1 mysql dba 39102 Sep 13 2016 dialog.so
-rwxr-xr-x 1 mysql dba 35337 Sep 13 2016 example_key_management.so
-rwxr-xr-x 1 mysql dba 67516 Sep 13 2016 file_key_management.so
-rwxr-xr-x 1 mysql dba 534847 Sep 13 2016 ha_archive.so
-rwxr-xr-x 1 mysql dba 326244 Sep 13 2016 ha_blackhole.so
-rwxr-xr-x 1 mysql dba 6315641 Sep 13 2016 ha_connect.so
-rwxr-xr-x 1 mysql dba 270829 Sep 13 2016 ha_example.so
-rwxr-xr-x 1 mysql dba 408688 Sep 13 2016 ha_federated.so
-rwxr-xr-x 1 mysql dba 658050 Sep 13 2016 ha_federatedx.so
-rwxr-xr-x 1 mysql dba 17067973 Sep 13 2016 ha_innodb.so
-rwxr-xr-x 1 mysql dba 13007344 Sep 13 2016 ha_mroonga.so
-rwxr-xr-x 1 mysql dba 1586135 Sep 13 2016 handlersocket.so
-rwxr-xr-x 1 mysql dba 1687004 Sep 13 2016 ha_oqgraph.so
-rwxr-xr-x 1 mysql dba 745005 Sep 13 2016 ha_sphinx.so
-rwxr-xr-x 1 mysql dba 5150095 Sep 13 2016 ha_spider.so
-rwxr-xr-x 1 mysql dba 226800 Sep 13 2016 ha_test_sql_discovery.so
-rwxr-xr-x 1 mysql dba 35898 Sep 13 2016 libdaemon_example.so
-rwxr-xr-x 1 mysql dba 131020 Sep 13 2016 locales.so
-rwxr-xr-x 1 mysql dba 221483 Sep 13 2016 metadata_lock_info.so
-rwxr-xr-x 1 mysql dba 18211 Sep 13 2016 mypluglib.so
-rwxr-xr-x 1 mysql dba 16382 Sep 13 2016 mysql_clear_password.so
-rwxr-xr-x 1 mysql dba 18751 Sep 13 2016 qa_auth_client.so
-rwxr-xr-x 1 mysql dba 24478 Sep 13 2016 qa_auth_interface.so
-rwxr-xr-x 1 mysql dba 13542 Sep 13 2016 qa_auth_server.so
-rwxr-xr-x 1 mysql dba 229059 Sep 13 2016 query_cache_info.so
-rwxr-xr-x 1 mysql dba 286720 Sep 13 2016 query_response_time.so
-rwxr-xr-x 1 mysql dba 534415 Sep 13 2016 semisync_master.so
-rwxr-xr-x 1 mysql dba 445144 Sep 13 2016 semisync_slave.so
-rwxr-xr-x 1 mysql dba 175928 Sep 13 2016 server_audit.so
-rwxr-xr-x 1 mysql dba 32295 Sep 13 2016 simple_password_check.so
-rwxr-xr-x 1 mysql dba 19846 Sep 13 2016 sql_errlog.so
-rwxr-xr-x 1 mysql dba 218688 Sep 13 2016 wsrep_info.so
All libraries have execution rights, they are all here BUT MYSQL is still trying to search in the default path /usr/local/mysql/lib/plugin/. And of course on our machine, this path does not exist.
QUESTION:
Is there another option/way to specifically ask mysql to load plugin for a specific directory?
NOTES:
I found some links about the error ERROR 2059 (HY000): Authentication plugin 'dialog' cannot be loaded: /usr/local/mysql/lib/plugin/dialog.so: cannot open shared object file: No such file or directory but solutions are all:
Uninstall mysql and install it again (which I can't)
Create the directory or symlink (I can't neither)
Use the --enable-cleartext-plugin option (it does nothing and I don't think it is related in my case)
So I think I understood why.
Setting LIBMYSQL_PLUGIN_DIR:
export LIBMYSQL_PLUGIN_DIR="/opt/mysql/10.1.16/lib/plugin"
is somehow not read or taken in account.
However, adding directly to the binary the option --plugin-dir="${LIBMYSQL_PLUGIN_DIR}" will make it work.
So correct answer is:
/opt/mysql/10.1.16/bin/mysql --plugin-dir="${LIBMYSQL_PLUGIN_DIR}" -C --no-beep --line-numbers --protocol=TCP --host="${DB_HOSTNAME}" --port="${DB_PORT}" --user="${DB_USER}" --database "${DB_SCHEMA}" -o --delimiter ','
Why the env varibale is not read, that is a mystery

SELECT /*!N SQL_NO_CACHE */ * FROM `table` - What is this?

I just enabled mysql slow query logging.
Now I see these queries being logged on different tables time to time:
SELECT /*!40001 SQL_NO_CACHE */ * FROM `paitents`;
# Time: 181128 6:38:50
# User#Host: my_testdatabase[my_testdatabase] # localhost []
# Query_time: 2.964142 Lock_time: 0.000081 Rows_sent: 3 Rows_examined: 1606915
I just searched and found out that it might be the database dump causing these queries.
But I want to make sure that its the mysql dump not some unauthorized access.
This is the latest log from that specific table in my logs right now:
SELECT /*!40001 SQL_NO_CACHE */ * FROM `paitents`;
# Time: 181128 6:38:50
# User#Host: my_testdatabase[my_testdatabase] # localhost []
# Query_time: 2.964142 Lock_time: 0.000081 Rows_sent: 3 Rows_examined: 1606915
And here is the logs of dumps that were created:
-rw-r--r-- 1 root root 381511206 Nov 23 23:21 my_testdatabase_2018-11-23.sql.tar.bz2
-rw-r--r-- 1 root root 381754145 Nov 24 23:21 my_testdatabase_2018-11-24.sql.tar.bz2
-rw-r--r-- 1 root root 381999764 Nov 25 23:21 my_testdatabase_2018-11-25.sql.tar.bz2
-rw-r--r-- 1 root root 382146325 Nov 26 23:22 my_testdatabase_2018-11-26.sql.tar.bz2
-rw-r--r-- 1 root root 382357755 Nov 27 23:23 my_testdatabase_2018-11-27.sql.tar.bz2
-rw-r--r-- 1 root root 382384209 Nov 28 06:29 my_testdatabase_2018-11-28.sql.tar.bz2
Now here I can see the difference in the latest query logged in slow query log and the latest dump created.
Latest query logged time: 181128 6:38:50
Latest dump created time: 2018-11-28 06:29
Why is there a difference?

How to view error logs generated by mariadb on CentOS 7

I am new to mariadb. Today, I was attempting to import a mysql database to mariadb and during the process the import stops when a warning is encountered as shown below.
Now, I said to myself that I should check a log file so I can see the error but I can't seem to fine any log file. I ran the query below with help from Get the error log of Mariadb:
As you can see there is no path to an error log file.
Next I checked /var/lib/mysql and below is the dir content:
-rw-rw----. 1 mysql mysql 16384 Jun 5 16:03 aria_log.00000001
-rw-rw----. 1 mysql mysql 52 Jun 5 16:03 aria_log_control
-rw-rw----. 1 mysql mysql 79691776 Jun 8 08:02 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Jun 8 08:02 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Jun 5 16:03 ib_logfile1
-rw-rw----. 1 mysql mysql 6 Jun 5 16:12 IMSPRO.pid
drwx------. 2 mysql mysql 4096 Jun 8 08:02 ecommence
-rw-rw----. 1 mysql mysql 0 Jun 5 16:12 multi-master.info
drwx--x--x. 2 mysql mysql 4096 Jun 5 16:03 mysql
srwxrwxrwx. 1 mysql mysql 0 Jun 5 16:12 mysql.sock
drwx------. 2 mysql mysql 20 Jun 5 16:03 performance_schema
-rw-rw----. 1 mysql mysql 24576 Jun 5 16:12 tc.log
No file in the above dir logs error.
Below is the content of my /etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
Below is the content of /etc/my.cnf.d
drwxr-xr-x. 2 root root 117 Jun 5 16:02 .
drwxr-xr-x. 91 root root 8192 Jun 7 01:14 ..
-rw-r--r--. 1 root root 295 May 29 16:48 client.cnf
-rw-r--r--. 1 root root 763 May 29 16:48 enable_encryption.preset
-rw-r--r--. 1 root root 232 May 29 16:48 mysql-clients.cnf
-rw-r--r--. 1 root root 1080 May 29 16:48 server.cnf
-rw-r--r--. 1 root root 285 May 29 16:48 tokudb.cnf
What can I do to get error log?
The way to see the warnings is to type this immediately after receiving that "Warnings: 1":
SHOW WARNINGS;
(As soon as the next other command is run, the warnings are cleared.)
In mariadb version 10.3.29,
#show variables like 'log-error';
is showing "Empty set" output
Instead, the following command is working
show global variables like 'log_error';
In my case, I edited /etc/my.cnf and added the line log_error after [mysqld]:
[mysqld]
...
log_error
After that, the query show variables like 'log_error'; displays the following (before the change, the Value column was empty):
+---------------+--------------------------+
| Variable_name | Value |
+---------------+--------------------------+
| log_error | /var/lib/mysql/host.err |
+---------------+--------------------------+
Now the error log is being written to the above file.
The exact name of the file will vary from server to server and will take the name of the current host, so expect it to be different in your particular case.

how to access a database files via the command line mysql?

I just installed mysql for the first time and created a databse with create database foo;
I think I have found where mysql stores the databases (/var/lib/mysql). When I try to cd to the foo directory I get permission denied. When I try with sudo nothing happens.
output of ls -l
-rw-rw----. 1 mysql mysql 16384 Feb 21 17:44 aria_log.00000001
-rw-rw----. 1 mysql mysql 52 Feb 21 17:44 aria_log_control
drwx------. 2 mysql mysql 4096 Mar 1 22:08 foo
-rw-rw----. 1 mysql mysql 18874368 Feb 21 17:44 ibdata1
-rw-rw----. 1 mysql mysql 5242880 Mar 1 16:05 ib_logfile0
-rw-rw----. 1 mysql mysql 5242880 Feb 21 17:34 ib_logfile1
drwx------. 2 mysql mysql 4096 Feb 21 17:34 mysql
srwxrwxrwx. 1 mysql mysql 0 Mar 1 16:05 mysql.sock
drwx------. 2 mysql mysql 4096 Feb 21 17:34 performance_schema
I know your meant to view the databases and stuff through that application on the command line but I am interested as to why I can't view the foo directory when i am root.
You can't view the foo directory because of the permissions:
owner - mysql - read, write, execute
group - mysql - no access
other - no access
First connect to mysql from command prompt using
[root#host]# mysql -u root -p
Enter password:******
Now select the database using
mysql> USE DB_Name
You can use belo command to have the list of databases
mysql> SHOW DATABASES;
To get the directory details you can use
mysql -uUSER -p -e 'SHOW VARIABLES WHERE Variable_Name = "dir_name"

How to get mercurial commit sequence number in a branch

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.