D940: remotenames: add functions to read remotenames data from .hg/remotenames/

2017-11-29 Thread pulkit (Pulkit Goyal)
pulkit abandoned this revision.
pulkit added a comment.


  Updated the series with new differentials 
https://phab.mercurial-scm.org/D1547 to  https://phab.mercurial-scm.org/D1551.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D940

To: pulkit, #hg-reviewers, dlax
Cc: dlax, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D940: remotenames: add functions to read remotenames data from .hg/remotenames/

2017-11-10 Thread pulkit (Pulkit Goyal)
pulkit updated this revision to Diff 3395.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D940?vs=2437=3395

REVISION DETAIL
  https://phab.mercurial-scm.org/D940

AFFECTED FILES
  mercurial/remotenames.py

CHANGE DETAILS

diff --git a/mercurial/remotenames.py b/mercurial/remotenames.py
--- a/mercurial/remotenames.py
+++ b/mercurial/remotenames.py
@@ -17,6 +17,40 @@
 # directory name in .hg/ in which remotenames files will be present
 remotenamedir = 'remotenames'
 
+def readremotenamefile(repo, filename):
+"""
+reads a file from .hg/remotenames/ directory and yields it's content
+filename: the file to be read
+yield a tuple (node, remotepath, name)
+"""
+
+vfs = vfsmod.vfs(repo.vfs.join(remotenamedir))
+if not vfs.exists(filename):
+return
+f = vfs(filename)
+for line in f:
+line = line.strip()
+if not line:
+continue
+
+node, remote, rname = line.split()
+yield node, remote, rname
+
+f.close()
+
+def readremotenames(repo):
+"""
+read the details about the remotenames stored in .hg/remotenames/ and
+yields a tuple (node, remotepath, name). It does not yields information
+about whether an entry yielded is branch or bookmark. To get that
+information, call the respective functions.
+"""
+
+for bmentry in readremotenamefile(repo, 'bookmarks'):
+yield bmentry
+for branchentry in readremotenamefile(repo, 'branches'):
+yield branchentry
+
 def saveremotebookmarks(repo, remotepath, bookmarks):
 """
 save remote bookmarks in .hg/remotenames/bookmarks.



To: pulkit, #hg-reviewers, dlax
Cc: dlax, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D940: remotenames: add functions to read remotenames data from .hg/remotenames/

2017-10-17 Thread pulkit (Pulkit Goyal)
pulkit abandoned this revision.
pulkit added a comment.


  Will revisit after the freeze.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D940

To: pulkit, #hg-reviewers, dlax
Cc: dlax, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D940: remotenames: add functions to read remotenames data from .hg/remotenames/

2017-10-05 Thread dlax (Denis Laxalde)
dlax requested changes to this revision.
dlax added a comment.
This revision now requires changes to proceed.


  Overall, the series only introduces helper functions. So it's hard to tell if 
the implementation is meaningful without any use of the code...

INLINE COMMENTS

> remotenames.py:31
>  
> +def readremotenamefile(repo, vfs, filename):
> +""" reads a file from .hg/remotenames/ directory and yields it's content

`repo` not used

> remotenames.py:60
> +for bmentry in readremotenamefile(repo, vfs, 'bookmarks'):
> +yield bmentry
> +

Why only "bookmarks"? (and not "branches")

> remotenames.py:84
> +if bmentry[1] != remotepath:
> +yield bmentry
> +

As in previous patch, `readremotebookmarks` and `readremotebranches` functions 
only differ from the file name; this could be factored out as a function 
parameter.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D940

To: pulkit, #hg-reviewers, dlax
Cc: dlax, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D940: remotenames: add functions to read remotenames data from .hg/remotenames/

2017-10-04 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch functions which can be used to read remotenames data from
  .hg/remotenames/. The logic for the function which reads the remotenames file 
is
  taken from the remotenames extension.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D940

AFFECTED FILES
  mercurial/remotenames.py

CHANGE DETAILS

diff --git a/mercurial/remotenames.py b/mercurial/remotenames.py
--- a/mercurial/remotenames.py
+++ b/mercurial/remotenames.py
@@ -28,6 +28,61 @@
 remote += '/' + ref
 return remote
 
+def readremotenamefile(repo, vfs, filename):
+""" reads a file from .hg/remotenames/ directory and yields it's content
+
+filename: the file to be read
+
+yield a tuple (node, remotepath, name)
+"""
+
+f = vfs(filename)
+for line in f:
+line = line.strip()
+if not line:
+continue
+
+node, name = line.split()
+remote, rname = splitremotename(name)
+
+yield node, remote, rname
+
+def readremotenames(repo):
+""" read the details about the remotenames stored in .hg/remotenames/ and
+yields a tuple (node, remotepath, name). It does not yields information
+about whether an entry yielded is branch or bookmark. To get that
+information, call the respective functions.
+"""
+
+vfs = vfsmod.vfs(repo.vfs.join(remotenamedir))
+
+for bmentry in readremotenamefile(repo, vfs, 'bookmarks'):
+yield bmentry
+
+def readremotebookmarks(repo, remotepath=None):
+""" read the remotebookmarks stored in .hg/remotenames/bookmarks and yield 
a
+tuple of (node, remotepath, name)
+
+If remotepath is passed, the entries with the same remotepath are yielded
+only.
+"""
+vfs = vfsmod.vfs(repo.vfs.join(remotenamedir))
+for bmentry in readremotenamefile(repo, vfs, 'bookmarks'):
+if bmentry[1] != remotepath:
+yield bmentry
+
+def readremotebranches(repo, remotepath=None):
+""" read the remotebranches stored in .hg/remotenames/branches and yield a
+tuple of (node, remotepath, name)
+
+If remotepath is passed, the entries with the same remotepath are yielded
+only.
+"""
+vfs = vfsmod.vfs(repo.vfs.join(remotenamedir))
+for bmentry in readremotenamefile(repo, vfs, 'branches'):
+if bmentry[1] != remotepath:
+yield bmentry
+
 def saveremotebookmarks(repo, vfs, remotepath, bookmarks):
 """ save remote bookmarks in .hg/remotenames/bookmarks.
 The format of the data stored will be:



To: pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel