Pierre-Yves David avatar Pierre-Yves David committed 532d8e7 Draft

changed: only take unknown file in account in the summary case

Otherwise most commands breaks if repo contains unknown file. This were in
contradiction with Mercurial behavior.

Comments (0)

Files changed (3)

guestrepo/guestrepo.py

                 output.append('*' + currentbookmark)
 
             gr_changed = False
-            if changed(guestrepo):
+            if changed(guestrepo, unknown=True):
                 output.append('*')
                 gr_changed = True
 
     except KeyError:
         pass
 
-def changed(repo):
-    modified, added, removed, deleted, unknown = repo.status( unknown=True )[:5]
-    return modified + added + removed + deleted + unknown != []
+def changed(repo, unknown=False):
+    stop = 4 # first entry to ignore
+    if unknown:
+        stop += 1
+    for filelist in repo.status(unknown=unknown)[:stop]:
+        if filelist:
+            return True
+    return False
 
 # This method creates and destroys lots of repos, better for memory, worse
 # for speed

tests/test-dirtyupdate.t

   GR updating mygr1
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
+Test unknown does not prevent the update
+
+  $ hg -R mygr1 up -C null
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo Babar > mygr1/jungle
+  $ hg grupdate
+  GR updating mygr1
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
 Clone child
   $ hg up -C
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved

tests/test-summary.t

   $ hg grsummary --json
   [{"current_bookmark": "currentmark", "tags": "tip", "changed": true, "branch": "default", "path": "mygr", "bookmarks": "currentmark/mark", "remote_name": "mygr-name", "id": "*"}] (glob)
 
+Test summary with unknown file
+
+  $ hg -R mygr revert --all --no-backup
+  reverting mygr/f
+  $ echo 'Babar' > mygr/jungle
+  $ hg -R mygr status
+  ? jungle
+  $ hg grsummary
+  mygr (default) tip currentmark/mark *currentmark *
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.