New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hg-plus

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hg-plus

A Mercurial client for Node

  • 0.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-20%
Maintainers
1
Weekly downloads
 
Created
Source

Coverage Status Build Status Dependency Status devDependency Status

node-hg-plus

=======

A node js client for Mercurial.

Supported node version => 6.0.0

Installation

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 = Hg.clone('my/repository/url');

repo.add()
.then(() => repo.commit('my example commit'))
.then(() => repo.push({password: 'myPassword',username:'username'}))

Pushing repository

const Hg = require('hg-plus');

let repo = Hg.create(let to = {url: 'my/repository/url', username: 'user', password: 'pass', path: 'path'});

repo.push()

Cloning from multiple repositories into a new one

const Hg = require('hg-plus');

let combinedRepo = Hg.clone(['my/repository/url1', 'my/repository/url2', 'my/repository/url3']);

combinedRepo.commit('I just created a repository from three other repositories!'))
.then(() => repo.push({password: 'myPassword',username:'username'}))

API

Supports both Promises and Standard callbacks following this structure

Promise
.then(()=>{
	
})
.catch((error)=>{
	
});

Callback((error, output)=>{
	
})

Hg

ReturnsDescription
Hg Instance

Example

const Hg = require('hg-plus');

Hg.setPythonPath(path)

ArgumentDescriptionTypeRequiredDefault
pathPath of python 2.7 installation. This is used for the gitify functionStringNo'python'

Example

const Hg = require('hg-plus');

Hg.setPythonPath('python');

Hg.clone(from, [to], [done])

Clones a Mercurial repository.

ArgumentDescriptionTypeRequiredDefault
fromStringYes
toObjectNo
to.urlStringNonull
to.usernameStringNonull
to.passwordStringNonull
to.pathStringNoCurrent Directory
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

const Hg = require('hg-plus');

let from = 'my/repository/url';
Hg.clone(from);

let to = {url:'another/url',username:'user2',password:'pass2',path:'path2'};
Hg.clone(from, to);

Hg.clone(from, null, (error, results) => {
	console.log(results);
});

Hg.create([to], [done = undefined])

Creates and initialized a Mercurial repository

ArgumentDescriptionTypeRequiredDefault
toObjectNo
to.urlStringNonull
to.usernameStringNonull
to.passwordStringNonull
to.pathStringNoCurrent Directory
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

const Hg = require('hg-plus');

Hg.create()
	.then((results) => {
		console.log(results);
	});

let to = {url: 'my/repository/url', username: 'user', password: 'pass', path: 'path'};
Hg.create(to);

let to = {url: 'someurl', username: 'user', password: 'pass', path: 'path'};
Hg.create(to,(error, results) => {
	console.log(results);
});

Hg.gitify([options], [done])

Create a git copy of this repository using the gitifyhg python package

ArgumentDescriptionTypeRequiredDefault
optionsObjectNo
options.gitRepoPathStringNoBase Directory / Current Hg repo name-git
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

const Hg = require('hg-plus');

Hg.gitify()
	.then((results) => {
		console.log(results);
	});

Hg.gitify({gitRepoPath: 'some/path/here'}, (error, results) => {
	console.log(results);
});

Hg.version([done])

Gets the version of the installed mercurial package

ArgumentDescriptionTypeRequiredDefault
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

const Hg = require('hg-plus');

Hg.version()
	.then((version) => {
		console.log(version);
	});

Hg.version((error, results) => {
	console.log(results);
});

HgRepo

HgRepo([options],[pythonPath]) {

HgRepo instance.

Mercurial repository wrapper to handle all the sub functions for mecurial repositories such as: init,commit,add,push,pull,rename and merge

Note: These are only created through Hg.clone or Hg.create

ArgumentDescriptionTypeRequiredDefault
toObjectNo
to.urlStringNonull
to.usernameStringNonull
to.passwordStringNonull
to.pathStringNoCurrent Directory
pythonPathPath of python 2.7 installation. This is used for the gitify functionStringNo'python'
ReturnsDescription
HgRepo Instance

Example:

const Hg = require('hg-plus');

let repo = Hg.create();

let repo2 = Hg.clone('my/repository/url');

HgRepo.init([done]) {

Inits the Hg repo instance.

ArgumentDescriptionTypeRequiredDefault
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

const Hg = require('hg-plus');

let repo = Hg.create();

repo.init()
	.then((result) => {
		console.log(result);
	});

repo.init((error, result) => {
	console.log(result);
});

HgRepo.commit(message, [options], [done]) {

Commits new changes in the the Hg repo instance.

ArgumentDescriptionTypeRequiredDefault
messageCommit messageStringYesN/A
optionsObjectNoN/A
options.addBooleanNofalse
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

repo.commit('my commit message')
	.then((result) => {
		console.log(result);
	});

repo.commit('my commit message', (error, result) => {
	console.log(result);
});

HgRepo.add([options], [done]) {

Adds untracked files to the Hg repo instance.

ArgumentDescriptionTypeRequiredDefault
optionsObjectNoN/A
options.filesArrayNoAll Files
options.includeStringNonull
options.excludeStringNonull
options.subreposBooleanNofalse
options.dryRunBooleanNofalse
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

repo.add()
	.then((result) => {
		console.log(result);
	});

repo.add(['file.txt','file2.js'], (error, result) => {
	console.log(result);
});

HgRepo.push([options], [done]) {

Pushes untracked files to the Hg repo instance.

ArgumentDescriptionTypeRequiredDefault
optionsObjectNoN/A
options.forceBooleanNofalse
options.revisionStringNonull
options.bookmarkStringNonull
options.branchStringNonull
options.sshStringNonull
options.insecureBooleanNofalse
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

repo.push()
	.then((result) => {
		console.log(result);
	});

repo.push({force: true}, (error, result) => {
	console.log(result);
});

HgRepo.pull([options], [done]) {

Pulls files to the Hg repo instance.

ArgumentDescriptionTypeRequiredDefault
sourceStringNothis.url
optionsObjectNoN/A
options.forceBooleanNofalse
options.updateBooleanNofalse
options.revisionStringNonull
options.bookmarkStringNonull
options.branchStringNonull
options.sshStringNonull
options.insecureBooleanNofalse
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

repo.pull()
	.then((result) => {
		console.log(result);
	});

repo.pull({source: 'my/repository/url/', force: true}, (error, result) => {
	console.log(result);
});

HgRepo.update([options], [done]) {

Update Hg repo instance.

ArgumentDescriptionTypeRequiredDefault
optionsObjectNoN/A
options.cleanBooleanNofalse
options.checkBooleanNofalse
options.revisionStringNonull
options.toolBooleanNofalse
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

repo.update()
	.then((result) => {
		console.log(result);
	});

repo.update({clean: true}, (error, result) => {
	console.log(result);
});

HgRepo.gitify([{gitRepoPath}], [done]) {

Coverts Hg repo instance into a Git repo using the gitifyhg python package

ArgumentDescriptionTypeRequiredDefault
optionsObjectNoN/A
options.gitRepoPathNew git repository pathBooleanNoCurrent base directory/current hg repo name-git
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

repo.gitify()
	.then((result) => {
		console.log(result);
	});

HgRepo.rename([options], [done]) {

Rename files to the Hg repo instance.

ArgumentDescriptionTypeRequiredDefault
sourceStringYesN/A
destinationStringYesN/A
optionsObjectNoN/A
options.afterBooleanNofalse
options.forceBooleanNofalse
options.includeStringNonull
options.excludeStringNonull
options.dryRunBooleanNofalse
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

repo.rename('one/path','destination/path')
	.then((result) => {
		console.log(result);
	});

repo.rename('one/path','destination/path',{after: true}, (error, result) => {
	console.log(result);
});

HgRepo.merge([options], [done]) {

Rename files to the Hg repo instance.

ArgumentDescriptionTypeRequiredDefault
optionsObjectNoN/A
options.forceBooleanNofalse
options.previewBooleanNofalse
options.revisionStringNonull
options.toolStringNonull
doneCallback functionFunctionNonull
ReturnsDescription
Promise <String>Console output

Example:

repo.merge()
	.then((result) => {
		console.log(result);
	});

repo.merge({force: true}, (error, result) => {
	console.log(result);
});

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

Release Notes

TODO

  1. Add tests for credentials handling

LICENSE

MIT, No Attribution Required, Copyright 2016 Justin Dalrymple

Keywords

FAQs

Package last updated on 30 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc