Skip to content

jdalrymple/node-hg-plus

Repository files navigation

Coverage Status Build Status Dependency Status devDependency StatusCode ClimateLicense: MIT Greenkeeper badge

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

# Install from npm

npm install -S hg-plus

To use the gitify function, you must also have python2.7.x, git as well as the shipped gitifyhg python addon installed.

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

// Initialize with default python path ('python')
const Hg = require('hg-plus')();

// Clone a repo using only the url string
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'
})

Hg to Git conversion caveats

This functionality is still in development. There are a few issues that arise if for example, there are conflicting branches during the clean processing. Before merging repositories, ensure that the branch names(besides default) do not conflict. If it errors out for you, try running the conversion without the clean option.

Tests

Ensure to install the gitifyhg library as outlined at the beginning of this README then 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.2.3 (2018-4-29)

  • Updating library dependencies

1.2.2 (2017-10-29)

  • Added Checkout alias for hg update
  • Added branch specification for hg update
  • Updating library dependencies

1.2.1 (2017-10-29)

  • Updating error messages for the creation of hg repositories
  • Updating Hg.getRepo to return the correct remote url in the HgRepo instance
  • Added HgRepo.paths()

1.2.0 (2017-10-03)

1.1.0 (2017-08-29)

  • Renamed the Hg.gitify function gitRepoPath parameter to be just path
  • Made HgRepo objects gitify function take in an object with a output path, path, a remoteURL option, an option to track all of the git branches after the conversion, and an option to clean the git branch names during conversion
  • Major updates the the gitifyhg library

1.0.2 (2017-07-30)

1.0.1 (2017-07-26)

  • Removed the .hgtags and hg folders from the gitified repo
  • Rename .hgignore to be .gitignore and removing 'syntax*' line from the .gitignore file

1.0.0 (2017-07-25)

  • Cleaned up old promise logic and replaced with async/await
  • Removed useless 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 dependencies 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')()