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
Argument
Description
Type
Required
Default
to
Object
Yes
to.url*
String
Yes
null
to.name*
String
Yes
null
to.username
String
No
null
to.password
String
No
null
to.path
String
No
Current Directory
pythonPath
Path of python 2.7 installation. This is used for the gitify function
String
No
'python'
Only one of these must be passed.
Returns
Description
HgRepo Instance
const Hg = require ( 'hg-plus' ) ( ) ;
let repo1 = await Hg . create ( { name : 'my-fancy-repo' } ) ;
let repo2 = await Hg . clone ( { url : 'http://hostname.com/my/repository/url' } ) ;
Inits the Hg repo instance.
Argument
Description
Type
Required
Default
done
Callback function
Function
No
Returns
Description
Promise <String>
Console output
const Hg = require ( 'hg-plus' ) ( ) ;
let repo = await Hg . create ( { name : 'my-fancy-repo' } ) ;
let output = await repo . init ( ) ;
console . log ( output ) ;
// OR
repo . init ( ( error , result ) => {
console . log ( result ) ;
} ) ;
Commits new changes in the the Hg repo instance.
Argument
Description
Type
Required
Default
message
Commit message
String
Yes
N/A
options
Object
No
N/A
options.add
Boolean
No
false
done
Callback function
Function
No
Returns
Description
Promise <String>
Console output
let output = repo . commit ( 'my commit message' ) ;
console . log ( output ) ;
// OR
repo . commit ( 'my commit message' , ( error , result ) => {
console . log ( result ) ;
} ) ;
Adds untracked files to the Hg repo instance.
Argument
Description
Type
Required
Default
options
Object
No
N/A
options.files
Array
No
All Files
options.include
String
No
null
options.exclude
String
No
null
options.subrepos
Boolean
No
false
options.dryRun
Boolean
No
false
done
Callback function
Function
No
Returns
Description
Promise <String>
Console output
let output = await repo . add ( ) ;
console . log ( output ) ;
// OR
repo . add ( [ 'file.txt' , 'file2.js' ] , ( error , result ) => {
console . log ( result ) ;
} ) ;
Gets the paths related to the specific Hg repo instance.
Argument
Description
Type
Required
Default
done
Callback function
Function
No
Returns
Description
Promise <Object>
Object represending the path name, and its correspinding path itself
let output = await repo . paths ( ) ;
console . log ( output ) ;
// OR
repo . push ( { force : true } , ( error , result ) => {
console . log ( result ) ;
} ) ;
Pushes untracked files to the Hg repo instance.
Argument
Description
Type
Required
Default
options
Object
No
N/A
options.force
Boolean
No
false
options.revision
String
No
null
options.bookmark
String
No
null
options.branch
String
No
null
options.ssh
String
No
null
options.insecure
Boolean
No
false
done
Callback function
Function
No
Returns
Description
Promise <String>
Console output
let output = await repo . push ( ) ;
console . log ( output ) ;
// OR
repo . push ( { force : true } , ( error , result ) => {
console . log ( result ) ;
} ) ;
Pulls files to the Hg repo instance.
Argument
Description
Type
Required
Default
source
String
No
this.url
options
Object
No
N/A
options.force
Boolean
No
false
options.update
Boolean
No
false
options.revision
String
No
null
options.bookmark
String
No
null
options.branch
String
No
null
options.ssh
String
No
null
options.insecure
Boolean
No
false
done
Callback function
Function
No
Returns
Description
Promise <String>
Console output
let output = await repo . pull ( ) ;
console . log ( output ) ;
// OR
repo . pull ( { source : 'my/repository/url/' , force : true } , ( error , result ) => {
console . log ( result ) ;
} ) ;
Update Hg repo instance.
Argument
Description
Type
Required
Default
options
Object
No
N/A
options.branchOrTag
A branch or tag name
String
No
null
options.clean
Boolean
No
false
options.check
Boolean
No
false
options.revision
String
No
null
options.tool
Boolean
No
false
done
Callback function
Function
No
Returns
Description
Promise <String>
Console output
let output = await repo . update ( ) ;
console . log ( output ) ;
// OR
repo . update ( { clean : true } , ( error , result ) => {
console . log ( result ) ;
} ) ;
Rename files to the Hg repo instance.
Argument
Description
Type
Required
Default
source
String
Yes
N/A
destination
String
Yes
N/A
options
Object
No
N/A
options.after
Boolean
No
false
options.force
Boolean
No
false
options.include
String
No
null
options.exclude
String
No
null
options.dryRun
Boolean
No
false
done
Callback function
Function
No
Returns
Description
Promise <String>
Console output
let output = await repo . rename ( 'one/path' , 'destination/path' ) ;
console . log ( output ) ;
// OR
repo . rename ( 'one/path' , 'destination/path' , { after : true } , ( error , result ) => {
console . log ( result ) ;
} ) ;
Rename files to the Hg repo instance.
Argument
Description
Type
Required
Default
options
Object
No
N/A
options.force
Boolean
No
false
options.preview
Boolean
No
false
options.revision
String
No
null
options.tool
String
No
null
done
Callback function
Function
No
Returns
Description
Promise <String>
Console output
let output = await repo . merge ( ) ;
console . log ( output ) ;
// OR
repo . merge ( { force : true } , ( error , result ) => {
console . log ( result ) ;
} ) ;
Convert repo from Hg to Git
Coverts Hg repo instance into a Git repo using the gitifyhg python package
Argument
Description
Type
Required
Default
options
Object
No
N/A
options.path
New git repository path
Boolean
No
Current base directory/current hg repo name-git
options.trackAll
Tells git to track all the branches
Boolean
No
False
options.remoteURL
Sets the remote URL of the new git repository
Boolean
No
null
options.clean
Will attempt to clean up the converted git branch, tag etc names
Boolean
No
False
done
Callback function
Function
No
null
Returns
Description
Promise
null
let output = await repo . gitify ( ) ;
console . log ( output ) ;
// OR
repo . gitify ( { path :'my/git/repo/path' } , ( error , result ) => {
console . log ( result ) ;
} ) ;