node-hg-plus
A node js client for Mercurial. Supports both Async/Await/Promises and Standard callbacks.
Supported node version => 7.6.0
Table of Contents
Install
npm install -S hg-plus
To use the gitify function, you must also have python2.7.x installed as well as the shipped gitifyhg python addon.
To install the addon simply run:
cd node_modules/hg-plus/utils/gitifyhg/
python2.7 setup.py install
Note this feature currently has mixed results on windows. Working on fixing that functionality for the next release.
Usage
Basic
const Hg = require('hg-plus')();
let repo = await Hg.clone('http://hostname.com/my/repository/url')
await repo.add()
await repo.commit('my example commit')
await repo.push({ password: 'myPassword', username: 'username' })
Create and push a repository
const Hg = require('hg-plus')();
let to = {
url: 'http://hostname.com/my/repository/url',
username: 'me@host.com',
password: 'secret'
}
let repo = await Hg.create(to);
await repo.push()
Cloning from multiple repositories into a new one
const Hg = require('hg-plus')();
let to = {
url: 'http://hostname.com/my/repository/url'
}
let from = [
'http://hostname.com/my/repository/url1',
'http://hostname.com/my/repository/url2',
'http://hostname.com/my/repository/url3'
]
let repo = await Hg.clone(from, to);
await repo.commit('I just created a repository from three other repositories!')
await repo.push({
username: 'me@host.com',
password: 'secret'
})
Tests
First make sure to change the global variable in tests/HgRepo called pythonPath to be a valid
path to your python2.7.x installation. Then run:
npm test
LICENSE
MIT, No Attribution Required, Copyright 2016 Justin Dalrymple
Changelog
1.0.0 (2017-07-20)
- Cleaned up old promise logic and replaced with async/await
- Removed usless rest param arguments from many of the Hg functions for clarity
- Added Object input to the Hg.Clone function (See API Docs above)
- Cleaned up folder structure
- Fixed the setting of the default url if none is passed in by the user
- Fixed cloning from urls instead of local paths
- Added various callback tests to ensure the callback backwards compatibility is maintained
- Added default state tests for the HgRepo Object
- Removed old dependancies now that Promises are more widely supported
- Standardized the callback support to return in the form callback(error, results) always
NOTE: Upgrading from 0.8.0 to 1.0 will break your project. Ensure to add the function call to your require statement - require('hg-plus')()